Avoid links on a template-board

Allow creation of template boards with a linked card
Avoid changing the name of the template-container swimlanes
This commit is contained in:
Andrés Manelli 2019-02-23 12:14:37 +01:00
parent cdf070189e
commit 1e72177991
7 changed files with 54 additions and 30 deletions

View file

@ -46,6 +46,7 @@ template(name="addCardForm")
button.primary.confirm(type="submit") {{_ 'add'}} button.primary.confirm(type="submit") {{_ 'add'}}
unless isSandstorm unless isSandstorm
unless currentBoard.isTemplatesBoard unless currentBoard.isTemplatesBoard
unless currentBoard.isTemplateBoard
span.quiet span.quiet
| {{_ 'or'}} | {{_ 'or'}}
a.js-link {{_ 'link'}} a.js-link {{_ 'link'}}

View file

@ -67,29 +67,47 @@ BlazeComponent.extendComponent({
const labelIds = formComponent.labels.get(); const labelIds = formComponent.labels.get();
const customFields = formComponent.customFields.get(); const customFields = formComponent.customFields.get();
const boardId = this.data().board(); const board = this.data().board();
let linkedId = '';
let swimlaneId = ''; let swimlaneId = '';
const boardView = Meteor.user().profile.boardView; const boardView = Meteor.user().profile.boardView;
let cardType = 'cardType-card'; let cardType = 'cardType-card';
if (this.data().board().isTemplatesBoard()) { if (title) {
if (board.isTemplatesBoard()) {
swimlaneId = this.parentComponent().parentComponent().data()._id; // Always swimlanes view swimlaneId = this.parentComponent().parentComponent().data()._id; // Always swimlanes view
cardType = (Swimlanes.findOne(swimlaneId).isCardTemplatesSwimlane())?'template-card':'cardType-card'; const swimlane = Swimlanes.findOne(swimlaneId);
// If this is the card templates swimlane, insert a card template
if (swimlane.isCardTemplatesSwimlane())
cardType = 'template-card';
// If this is the board templates swimlane, insert a board template and a linked card
else if (swimlane.isBoardTemplatesSwimlane()) {
linkedId = Boards.insert({
title,
permission: 'private',
type: 'template-board',
});
Swimlanes.insert({
title: TAPi18n.__('default'),
boardId: linkedId,
});
cardType = 'cardType-linkedBoard';
}
} else if (boardView === 'board-view-swimlanes') } else if (boardView === 'board-view-swimlanes')
swimlaneId = this.parentComponent().parentComponent().data()._id; swimlaneId = this.parentComponent().parentComponent().data()._id;
else if ((boardView === 'board-view-lists') || (boardView === 'board-view-cal')) else if ((boardView === 'board-view-lists') || (boardView === 'board-view-cal'))
swimlaneId = boardId.getDefaultSwimline()._id; swimlaneId = board.getDefaultSwimline()._id;
if (title) {
const _id = Cards.insert({ const _id = Cards.insert({
title, title,
members, members,
labelIds, labelIds,
customFields, customFields,
listId: this.data()._id, listId: this.data()._id,
boardId: boardId._id, boardId: board._id,
sort: sortIndex, sort: sortIndex,
swimlaneId, swimlaneId,
type: cardType, type: cardType,
linkedId,
}); });
// if the displayed card count is less than the total cards in the list, // if the displayed card count is less than the total cards in the list,

View file

@ -1,8 +1,14 @@
template(name="swimlaneHeader") template(name="swimlaneHeader")
.swimlane-header-wrap.js-swimlane-header(class='{{#if colorClass}}swimlane-{{colorClass}}{{/if}}') .swimlane-header-wrap.js-swimlane-header(class='{{#if colorClass}}swimlane-{{colorClass}}{{/if}}')
if this.isTemplateContainer
+swimlaneFixedHeader(this)
else
+inlinedForm +inlinedForm
+editSwimlaneTitleForm +editSwimlaneTitleForm
else else
+swimlaneFixedHeader(this)
template(name="swimlaneFixedHeader")
.swimlane-header( .swimlane-header(
class="{{#if currentUser.isBoardMember}}js-open-inlined-form is-editable{{/if}}") class="{{#if currentUser.isBoardMember}}js-open-inlined-form is-editable{{/if}}")
= title = title

View file

@ -168,8 +168,8 @@ BlazeComponent.extendComponent({
evt.preventDefault(); evt.preventDefault();
const titleInput = this.find('.list-name-input'); const titleInput = this.find('.list-name-input');
const title = titleInput.value.trim(); const title = titleInput.value.trim();
const listType = (this.currentSwimlane.isListTemplatesSwimlane())?'template-list':'list';
if (title) { if (title) {
const listType = (this.currentSwimlane.isListTemplatesSwimlane())?'template-list':'list';
Lists.insert({ Lists.insert({
title, title,
boardId: Session.get('currentBoard'), boardId: Session.get('currentBoard'),

View file

@ -455,7 +455,6 @@
"welcome-swimlane": "Milestone 1", "welcome-swimlane": "Milestone 1",
"welcome-list1": "Basics", "welcome-list1": "Basics",
"welcome-list2": "Advanced", "welcome-list2": "Advanced",
"templates-board": "Templates Board",
"card-templates-swimlane": "Card Templates", "card-templates-swimlane": "Card Templates",
"list-templates-swimlane": "List Templates", "list-templates-swimlane": "List Templates",
"board-templates-swimlane": "Board Templates", "board-templates-swimlane": "Board Templates",

View file

@ -149,7 +149,7 @@ Swimlanes.helpers({
isBoardTemplatesSwimlane() { isBoardTemplatesSwimlane() {
const user = Users.findOne(Meteor.userId()); const user = Users.findOne(Meteor.userId());
return user.profile.boardsTemplatesSwimlaneId === this._id; return user.profile.boardTemplatesSwimlaneId === this._id;
}, },
}); });

View file

@ -739,7 +739,7 @@ if (Meteor.isServer) {
}); });
Boards.insert({ Boards.insert({
title: TAPi18n.__('templates-board'), title: TAPi18n.__('templates'),
permission: 'private', permission: 'private',
type: 'template-container' type: 'template-container'
}, fakeUser, (err, boardId) => { }, fakeUser, (err, boardId) => {