Sfoglia il codice sorgente

Allow card creation from template

Andrés Manelli 6 anni fa
parent
commit
044126188d
1 ha cambiato i file con 18 aggiunte e 17 eliminazioni
  1. 18 17
      client/components/lists/listBody.js

+ 18 - 17
client/components/lists/listBody.js

@@ -593,26 +593,27 @@ BlazeComponent.extendComponent({
         this.term.set(evt.target.searchTerm.value);
         this.term.set(evt.target.searchTerm.value);
       },
       },
       'click .js-minicard'(evt) {
       'click .js-minicard'(evt) {
-        // LINK CARD
-        const card = Blaze.getData(evt.currentTarget);
-        const _id = Cards.insert({
-          title: card.title, //dummy
-          listId: this.listId,
-          swimlaneId: this.swimlaneId,
-          boardId: this.boardId,
-          sort: Lists.findOne(this.listId).cards().count(),
-          type: 'cardType-linkedCard',
-          linkedId: card.linkedId || card._id,
-        });
+        let card = Blaze.getData(evt.currentTarget);
+        let _id = '';
+        // Common
+        card.listId = this.listId;
+        card.swimlaneId = this.swimlaneId;
+        card.boardId = this.boardId;
+        card.sort = Lists.findOne(this.listId).cards().count();
+        // From template
+        if (this.isTemplateSearch) {
+            card.type = 'cardType-card';
+            card.linkedId = '';
+            _id = card.copy();
+        } else { // Linked
+            card._id = null;
+            card.type = 'cardType-linkedCard';
+            card.linkedId = card.linkedId || card._id;
+            _id = Cards.insert(card);
+        }
         Filter.addException(_id);
         Filter.addException(_id);
         Popup.close();
         Popup.close();
       },
       },
     }];
     }];
   },
   },
 }).register('searchCardPopup');
 }).register('searchCardPopup');
-
-Template.searchCardPopup.helpers({
-    isTemplateSearch() {
-        return $(Popup._getTopStack().openerElement).hasClass('js-search-template');
-    },
-});