2
0
Эх сурвалжийг харах

New component for use in header-bar

Joel Louzado 8 жил өмнө
parent
commit
ac07646749

+ 1 - 1
client/components/boards/boardHeader.jade

@@ -170,7 +170,7 @@ template(name="boardChangeColorPopup")
           if isSelected
           if isSelected
             i.fa.fa-check
             i.fa.fa-check
 
 
-template(name="createBoardPopup")
+template(name="createBoard")
   form
   form
     label
     label
       | {{_ 'title'}}
       | {{_ 'title'}}

+ 15 - 5
client/components/boards/boardHeader.js

@@ -119,10 +119,15 @@ BlazeComponent.extendComponent({
   },
   },
 }).register('boardChangeColorPopup');
 }).register('boardChangeColorPopup');
 
 
-BlazeComponent.extendComponent({
+const CreateBoard = BlazeComponent.extendComponent({
+  template() {
+    return 'createBoard';
+  },
+
   onCreated() {
   onCreated() {
     this.visibilityMenuIsOpen = new ReactiveVar(false);
     this.visibilityMenuIsOpen = new ReactiveVar(false);
     this.visibility = new ReactiveVar('private');
     this.visibility = new ReactiveVar('private');
+    const boardId = '';
   },
   },
 
 
   visibilityCheck() {
   visibilityCheck() {
@@ -143,15 +148,12 @@ BlazeComponent.extendComponent({
     const title = this.find('.js-new-board-title').value;
     const title = this.find('.js-new-board-title').value;
     const visibility = this.visibility.get();
     const visibility = this.visibility.get();
 
 
-    const boardId = Boards.insert({
+    boardId = Boards.insert({
       title,
       title,
       permission: visibility,
       permission: visibility,
     });
     });
 
 
     Utils.goBoardId(boardId);
     Utils.goBoardId(boardId);
-
-    // Immediately star boards crated with the headerbar popup.
-    Meteor.user().toggleBoardStar(boardId);
   },
   },
 
 
   events() {
   events() {
@@ -166,6 +168,14 @@ BlazeComponent.extendComponent({
   },
   },
 }).register('createBoardPopup');
 }).register('createBoardPopup');
 
 
+(class HeaderBarCreateBoard extends CreateBoard {
+  onSubmit(evt) {
+    super.onSubmit(evt);
+    // Immediately star boards crated with the headerbar popup.
+    Meteor.user().toggleBoardStar(boardId);
+  }
+}).register('headerBarCreateBoardPopup')
+
 BlazeComponent.extendComponent({
 BlazeComponent.extendComponent({
   visibilityCheck() {
   visibilityCheck() {
     const currentBoard = Boards.findOne(Session.get('currentBoard'));
     const currentBoard = Boards.findOne(Session.get('currentBoard'));