Skip to content

Commit

Permalink
Contacts: adds pendingOrgs display
Browse files Browse the repository at this point in the history
 * Adds computation of OrgClass class, so that 'pending' is different.
 * Adds a conditional Commit button.
  • Loading branch information
bernhardreiter committed Feb 14, 2017
1 parent 438ec57 commit 27a27a9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
22 changes: 19 additions & 3 deletions src/components/dash/Contacts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@
v-on:click="newOrg"><i class="fa fa-plus-square-o" style="margin-right:.2em"></i>New
</button>

<org-card v-for="(org, index) of pendingOrgs" class="col-md-6 col-sm-6"
v-bind:org="org" status="pending"
v-on:clone="cloneOrg(index, $event)"></org-card>

<button v-if="pendingOrgIDs.length !== 0"
class="btn btn-danger btn-lg btn-block"
v-on:click="commitPendingOrgs"
><i class="fa fa-pencil-square-o"
style="margin-right:.2em"></i>Commit
</button>

</div> <!-- .col... -->
</div> <!-- /.row -->
</section>
Expand All @@ -127,8 +138,8 @@ module.exports = {
manualOrgs: [],
autoOrgIDs: [], // list of ids of auto entries we currently show
autoOrgs: [],
pendingOrgIDs: [], // entries we currently edit
pendingOrgs: []
pendingOrgIDs: [], // entries we currently edit, null when needing new id
pendingOrgs: [] // objects, potentially changed, to be written back
}
},
components: {
Expand Down Expand Up @@ -246,14 +257,19 @@ module.exports = {
},
newOrg: function () {
console.log('newOrg() called')
// TODO get a template
// push it to pendingOrgs
},
cloneOrg: function (index, event) {
console.log('cloneOrg() called with index: ' + index +
' and argument: ' + JSON.stringify(event))
// deep-copy the org we want to edit
var newOrg = JSON.parse(JSON.stringify(this.autoOrgs[index]))
this.pendingOrgs.push(newOrg)
this.pendingOrgIDs.push(newOrg['id'])
this.pendingOrgIDs.push(null)
},
commitPendingOrgs () {
console.log('commitPendingOrgs() called')
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/components/dash/OrgCard.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="panel panel-primary">
<div class="panel" v-bind:class="computedPanelClass">
<div class="panel-heading">
<h3 class="panel-title">
<i class="fa fa-address-book-o rme"></i>
Expand Down Expand Up @@ -54,6 +54,12 @@ module.exports = {
}
}
return newOrg
},
computedPanelClass: function () {
return {
'panel-primary': this.status !== 'pending',
'panel-danger': this.status === 'pending'
}
}
},
methods: {
Expand Down

0 comments on commit 27a27a9

Please sign in to comment.