diff --git a/client/components/boards/boardHeader.jade b/client/components/boards/boardHeader.jade index d448ead91..cca0b97e7 100644 --- a/client/components/boards/boardHeader.jade +++ b/client/components/boards/boardHeader.jade @@ -232,6 +232,11 @@ template(name="createBoard") span.quiet | / a.js-board-template {{_ 'template'}} + br + br + span.quiet.right + | / + a.js-board-template-container {{_ 'add-template-container'}} //template(name="listsortPopup") // h2 diff --git a/client/components/boards/boardHeader.js b/client/components/boards/boardHeader.js index 7bf32a05d..3055247c5 100644 --- a/client/components/boards/boardHeader.js +++ b/client/components/boards/boardHeader.js @@ -229,6 +229,97 @@ const CreateBoard = BlazeComponent.extendComponent({ Utils.goBoardId(this.boardId.get()); }, + addBoardTemplateContainer(event) { + event.preventDefault(); + const title = this.find('.js-new-board-title').value; + + // Insert Template Container + const Future = require('fibers/future'); + const future1 = new Future(); + const future2 = new Future(); + const future3 = new Future(); + Boards.insert( + { + title: title || TAPi18n.__('templates'), + permission: 'private', + type: 'template-container', + }, + fakeUser, + (err, boardId) => { + // Insert the reference to our templates board + Users.update(fakeUserId.get(), { + $set: { + 'profile.templatesBoardId': boardId, + }, + }); + + // Insert the card templates swimlane + Swimlanes.insert( + { + title: TAPi18n.__('card-templates-swimlane'), + boardId, + sort: 1, + type: 'template-container', + }, + fakeUser, + (err, swimlaneId) => { + // Insert the reference to out card templates swimlane + Users.update(fakeUserId.get(), { + $set: { + 'profile.cardTemplatesSwimlaneId': swimlaneId, + }, + }); + future1.return(); + }, + ); + + // Insert the list templates swimlane + Swimlanes.insert( + { + title: TAPi18n.__('list-templates-swimlane'), + boardId, + sort: 2, + type: 'template-container', + }, + fakeUser, + (err, swimlaneId) => { + // Insert the reference to out list templates swimlane + Users.update(fakeUserId.get(), { + $set: { + 'profile.listTemplatesSwimlaneId': swimlaneId, + }, + }); + future2.return(); + }, + ); + + // Insert the board templates swimlane + Swimlanes.insert( + { + title: TAPi18n.__('board-templates-swimlane'), + boardId, + sort: 3, + type: 'template-container', + }, + fakeUser, + (err, swimlaneId) => { + // Insert the reference to out board templates swimlane + Users.update(fakeUserId.get(), { + $set: { + 'profile.boardTemplatesSwimlaneId': swimlaneId, + }, + }); + future3.return(); + }, + ); + }, + ); + // HACK + future1.wait(); + future2.wait(); + future3.wait(); + }, + events() { return [ { @@ -240,6 +331,7 @@ const CreateBoard = BlazeComponent.extendComponent({ submit: this.onSubmit, 'click .js-import-board': Popup.open('chooseBoardSource'), 'click .js-board-template': Popup.open('searchElement'), + 'click .js-board-template-container': this.addBoardTemplateContainer, }, ]; }, diff --git a/client/components/boards/boardsList.jade b/client/components/boards/boardsList.jade index da9047581..dae1221dc 100644 --- a/client/components/boards/boardsList.jade +++ b/client/components/boards/boardsList.jade @@ -17,47 +17,90 @@ template(name="boardList") button.js-accept-invite.primary {{_ 'accept'}} button.js-decline-invite {{_ 'decline'}} else - a.js-open-board.board-list-item(href="{{pathFor 'board' id=_id slug=slug}}") - span.details - span.board-list-item-name(title="{{_ 'board-drag-drop-reorder-or-click-open'}}") - +viewer - = title - i.fa.js-star-board( - class="fa-star{{#if isStarred}} is-star-active{{else}}-o{{/if}}" - title="{{_ 'star-board-title'}}") - p.board-list-item-desc - +viewer - = description - if hasSpentTimeCards - i.fa.js-has-spenttime-cards( - class="fa-circle{{#if hasOvertimeCards}} has-overtime-card-active{{else}} no-overtime-card-active{{/if}}" - title="{{#if hasOvertimeCards}}{{_ 'has-overtime-cards'}}{{else}}{{_ 'has-spenttime-cards'}}{{/if}}") - if isMiniScreen - i.fa.board-handle( - class="fa-arrows" - title="{{_ 'Drag board'}}") - unless isMiniScreen - if isSandstorm - i.fa.js-clone-board( - class="fa-clone" - title="{{_ 'duplicate-board'}}") - i.fa.js-archive-board( - class="fa-archive" - title="{{_ 'archive-board'}}") - else if isAdministrable - i.fa.js-clone-board( - class="fa-clone" - title="{{_ 'duplicate-board'}}") - i.fa.js-archive-board( - class="fa-archive" - title="{{_ 'archive-board'}}") - else if currentUser.isAdmin - i.fa.js-clone-board( - class="fa-clone" - title="{{_ 'duplicate-board'}}") - i.fa.js-archive-board( - class="fa-archive" - title="{{_ 'archive-board'}}") + if $eq type "template-container" + a.js-open-board.template-container.board-list-item(href="{{pathFor 'board' id=_id slug=slug}}") + span.details + span.board-list-item-name(title="{{_ 'template-container'}}") + +viewer + = title + i.fa.js-star-board( + class="fa-star{{#if isStarred}} is-star-active{{else}}-o{{/if}}" + title="{{_ 'star-board-title'}}") + p.board-list-item-desc + +viewer + = description + if hasSpentTimeCards + i.fa.js-has-spenttime-cards( + class="fa-circle{{#if hasOvertimeCards}} has-overtime-card-active{{else}} no-overtime-card-active{{/if}}" + title="{{#if hasOvertimeCards}}{{_ 'has-overtime-cards'}}{{else}}{{_ 'has-spenttime-cards'}}{{/if}}") + if isMiniScreen + i.fa.board-handle( + class="fa-arrows" + title="{{_ 'Drag board'}}") + unless isMiniScreen + if isSandstorm + i.fa.js-clone-board( + class="fa-clone" + title="{{_ 'duplicate-board'}}") + i.fa.js-archive-board( + class="fa-archive" + title="{{_ 'archive-board'}}") + else if isAdministrable + i.fa.js-clone-board( + class="fa-clone" + title="{{_ 'duplicate-board'}}") + i.fa.js-archive-board( + class="fa-archive" + title="{{_ 'archive-board'}}") + else if currentUser.isAdmin + i.fa.js-clone-board( + class="fa-clone" + title="{{_ 'duplicate-board'}}") + i.fa.js-archive-board( + class="fa-archive" + title="{{_ 'archive-board'}}") + else + a.js-open-board.board-list-item(href="{{pathFor 'board' id=_id slug=slug}}") + span.details + span.board-list-item-name(title="{{_ 'board-drag-drop-reorder-or-click-open'}}") + +viewer + = title + i.fa.js-star-board( + class="fa-star{{#if isStarred}} is-star-active{{else}}-o{{/if}}" + title="{{_ 'star-board-title'}}") + p.board-list-item-desc + +viewer + = description + if hasSpentTimeCards + i.fa.js-has-spenttime-cards( + class="fa-circle{{#if hasOvertimeCards}} has-overtime-card-active{{else}} no-overtime-card-active{{/if}}" + title="{{#if hasOvertimeCards}}{{_ 'has-overtime-cards'}}{{else}}{{_ 'has-spenttime-cards'}}{{/if}}") + if isMiniScreen + i.fa.board-handle( + class="fa-arrows" + title="{{_ 'Drag board'}}") + unless isMiniScreen + if isSandstorm + i.fa.js-clone-board( + class="fa-clone" + title="{{_ 'duplicate-board'}}") + i.fa.js-archive-board( + class="fa-archive" + title="{{_ 'archive-board'}}") + else if isAdministrable + i.fa.js-clone-board( + class="fa-clone" + title="{{_ 'duplicate-board'}}") + i.fa.js-archive-board( + class="fa-archive" + title="{{_ 'archive-board'}}") + else if currentUser.isAdmin + i.fa.js-clone-board( + class="fa-clone" + title="{{_ 'duplicate-board'}}") + i.fa.js-archive-board( + class="fa-archive" + title="{{_ 'archive-board'}}") template(name="boardListHeaderBar") h1 {{_ title }} diff --git a/client/components/boards/boardsList.js b/client/components/boards/boardsList.js index b13687bef..ee65a1921 100644 --- a/client/components/boards/boardsList.js +++ b/client/components/boards/boardsList.js @@ -88,7 +88,7 @@ BlazeComponent.extendComponent({ boards() { const query = { archived: false, - type: 'board', + type: { $in: ['board','template-container'] }, }; if (FlowRouter.getRouteName() === 'home') query['members.userId'] = Meteor.userId(); diff --git a/client/components/boards/boardsList.styl b/client/components/boards/boardsList.styl index 067a21bcd..635138f3d 100644 --- a/client/components/boards/boardsList.styl +++ b/client/components/boards/boardsList.styl @@ -45,6 +45,9 @@ $spaceBetweenTiles = 16px text-decoration: none word-wrap: break-word + &.template-container + border: 4px solid #fff + &.tile background-size: auto background-repeat: repeat diff --git a/client/components/lists/listBody.js b/client/components/lists/listBody.js index 6073f3900..f56ba6ba1 100644 --- a/client/components/lists/listBody.js +++ b/client/components/lists/listBody.js @@ -552,7 +552,7 @@ BlazeComponent.extendComponent({ board = Boards.findOne((Meteor.user().profile || {}).templatesBoardId); } else { // Prefetch first non-current board id - board = Boards.findOne({ + board = Boards.find({ archived: false, 'members.userId': Meteor.userId(), _id: { diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index c03e97bba..c1ae6f911 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -81,6 +81,7 @@ "activity-endDate": "edited end date to %s of %s", "add-attachment": "Add Attachment", "add-board": "Add Board", + "add-template": "Add Template", "add-card": "Add Card", "add-card-to-top-of-list": "Add Card to Top of List", "add-card-to-bottom-of-list": "Add Card to Bottom of List", @@ -119,6 +120,8 @@ "archives": "Archive", "template": "Template", "templates": "Templates", + "template-container": "Template Container", + "add-template-container": "Add Template Container", "assign-member": "Assign member", "attached": "attached", "attachment": "Attachment",