summaryrefslogtreecommitdiffstats
path: root/client/components/cards/cardDetails.js
diff options
context:
space:
mode:
authorMaxime Quandalle <maxime@quandalle.com>2015-09-08 20:19:42 +0200
committerMaxime Quandalle <maxime@quandalle.com>2015-09-08 20:19:42 +0200
commit45b662a1ddb46a0f17fab7b2383c82aa1e1620ef (patch)
treecc7be215c7e7ebffd2597df70cf271b3dd435e1a /client/components/cards/cardDetails.js
parentc04341f1ea5efe082bf7318cf9eb0e99b9b8374a (diff)
downloadwekan-45b662a1ddb46a0f17fab7b2383c82aa1e1620ef.tar.gz
wekan-45b662a1ddb46a0f17fab7b2383c82aa1e1620ef.tar.bz2
wekan-45b662a1ddb46a0f17fab7b2383c82aa1e1620ef.zip
Centralize all mutations at the model level
This commit uses a new package that I need to document. It tries to solve the long-standing debate in the Meteor community about allow/deny rules versus methods (RPC). This approach gives us both the centralized security rules of allow/deny and the white-list of allowed mutations similarly to Meteor methods. The idea to have static mutation descriptions is also inspired by Facebook's Relay/GraphQL. This will allow the development of a REST API using the high-level methods instead of the MongoDB queries to do the mapping between the HTTP requests and our collections.
Diffstat (limited to 'client/components/cards/cardDetails.js')
-rw-r--r--client/components/cards/cardDetails.js25
1 files changed, 5 insertions, 20 deletions
diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js
index 69e0cfdd..a493d938 100644
--- a/client/components/cards/cardDetails.js
+++ b/client/components/cards/cardDetails.js
@@ -55,12 +55,6 @@ BlazeComponent.extendComponent({
this.componentParent().showOverlay.set(false);
},
- updateCard(modifier) {
- Cards.update(this.data()._id, {
- $set: modifier,
- });
- },
-
events() {
const events = {
[`${CSSEvents.animationend} .js-card-details`]() {
@@ -76,13 +70,13 @@ BlazeComponent.extendComponent({
'submit .js-card-description'(evt) {
evt.preventDefault();
const description = this.currentComponent().getValue();
- this.updateCard({ description });
+ this.data().setDescription(description);
},
'submit .js-card-details-title'(evt) {
evt.preventDefault();
const title = this.currentComponent().getValue();
if ($.trim(title)) {
- this.updateCard({ title });
+ this.data().setTitle(title);
}
},
'click .js-member': Popup.open('cardMember'),
@@ -135,14 +129,9 @@ Template.cardDetailsActionsPopup.events({
'click .js-labels': Popup.open('cardLabels'),
'click .js-attachments': Popup.open('cardAttachments'),
'click .js-move-card': Popup.open('moveCard'),
- // 'click .js-copy': Popup.open(),
'click .js-archive'(evt) {
evt.preventDefault();
- Cards.update(this._id, {
- $set: {
- archived: true,
- },
- });
+ this.archive();
Popup.close();
},
'click .js-more': Popup.open('cardMore'),
@@ -152,13 +141,9 @@ Template.moveCardPopup.events({
'click .js-select-list'() {
// XXX We should *not* get the currentCard from the global state, but
// instead from a “component” state.
- const cardId = Session.get('currentCard');
+ const card = Cards.findOne(Session.get('currentCard'));
const newListId = this._id;
- Cards.update(cardId, {
- $set: {
- listId: newListId,
- },
- });
+ card.move(newListId);
Popup.close();
},
});