mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +01:00
Allow list creation from template
This commit is contained in:
parent
044126188d
commit
f888cfd565
8 changed files with 121 additions and 26 deletions
|
|
@ -57,7 +57,7 @@ template(name="addCardForm")
|
||||||
span.quiet
|
span.quiet
|
||||||
|
|
|
|
||||||
| /
|
| /
|
||||||
a.js-search-template {{_ 'template'}}
|
a.js-card-template {{_ 'template'}}
|
||||||
|
|
||||||
template(name="autocompleteLabelLine")
|
template(name="autocompleteLabelLine")
|
||||||
.minicard-label(class="card-label-{{colorName}}" title=labelName)
|
.minicard-label(class="card-label-{{colorName}}" title=labelName)
|
||||||
|
|
@ -104,5 +104,12 @@ template(name="searchCardPopup")
|
||||||
.list-body.js-perfect-scrollbar.search-card-results
|
.list-body.js-perfect-scrollbar.search-card-results
|
||||||
.minicards.clearfix.js-minicards
|
.minicards.clearfix.js-minicards
|
||||||
each results
|
each results
|
||||||
a.minicard-wrapper.js-minicard
|
if isListTemplateSearch
|
||||||
+minicard(this)
|
a.minicard-wrapper.js-minicard
|
||||||
|
+minilist(this)
|
||||||
|
if isSwimlaneTemplateSearch
|
||||||
|
a.minicard-wrapper.js-minicard
|
||||||
|
+miniswimlane(this)
|
||||||
|
unless isTemplateSearch
|
||||||
|
a.minicard-wrapper.js-minicard
|
||||||
|
+minicard(this)
|
||||||
|
|
|
||||||
|
|
@ -524,7 +524,10 @@ BlazeComponent.extendComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
onCreated() {
|
onCreated() {
|
||||||
this.isTemplateSearch = $(Popup._getTopStack().openerElement).hasClass('js-search-template');
|
this.isCardTemplateSearch = $(Popup._getTopStack().openerElement).hasClass('js-card-template');
|
||||||
|
this.isListTemplateSearch = $(Popup._getTopStack().openerElement).hasClass('js-list-template');
|
||||||
|
this.isSwimlaneTemplateSearch = $(Popup._getTopStack().openerElement).hasClass('js-swimlane-template');
|
||||||
|
this.isTemplateSearch = this.isCardTemplateSearch || this.isListTemplateSearch || this.isSwimlaneTemplateSearch;
|
||||||
let board = {};
|
let board = {};
|
||||||
if (this.isTemplateSearch) {
|
if (this.isTemplateSearch) {
|
||||||
board = Boards.findOne(Meteor.user().profile.templatesBoardId);
|
board = Boards.findOne(Meteor.user().profile.templatesBoardId);
|
||||||
|
|
@ -579,7 +582,15 @@ BlazeComponent.extendComponent({
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const board = Boards.findOne(this.selectedBoardId.get());
|
const board = Boards.findOne(this.selectedBoardId.get());
|
||||||
return board.searchCards(this.term.get(), false);
|
if (!this.isTemplateSearch || this.isCardTemplateSearch) {
|
||||||
|
return board.searchCards(this.term.get(), false);
|
||||||
|
} else if (this.isListTemplateSearch) {
|
||||||
|
return board.searchLists(this.term.get());
|
||||||
|
} else if (this.isSwimlaneTemplateSearch) {
|
||||||
|
return board.searchSwimlanes(this.term.get());
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
events() {
|
events() {
|
||||||
|
|
@ -593,25 +604,38 @@ BlazeComponent.extendComponent({
|
||||||
this.term.set(evt.target.searchTerm.value);
|
this.term.set(evt.target.searchTerm.value);
|
||||||
},
|
},
|
||||||
'click .js-minicard'(evt) {
|
'click .js-minicard'(evt) {
|
||||||
let card = Blaze.getData(evt.currentTarget);
|
// 0. Common
|
||||||
|
let element = Blaze.getData(evt.currentTarget);
|
||||||
|
console.log(element);
|
||||||
|
element.boardId = this.boardId;
|
||||||
let _id = '';
|
let _id = '';
|
||||||
// Common
|
if (!this.isTemplateSearch || this.isCardTemplateSearch) {
|
||||||
card.listId = this.listId;
|
// Card insertion
|
||||||
card.swimlaneId = this.swimlaneId;
|
// 1. Common
|
||||||
card.boardId = this.boardId;
|
element.listId = this.listId;
|
||||||
card.sort = Lists.findOne(this.listId).cards().count();
|
element.swimlaneId = this.swimlaneId;
|
||||||
// From template
|
element.sort = Lists.findOne(this.listId).cards().count();
|
||||||
if (this.isTemplateSearch) {
|
// 1.A From template
|
||||||
card.type = 'cardType-card';
|
if (this.isTemplateSearch) {
|
||||||
card.linkedId = '';
|
element.type = 'cardType-card';
|
||||||
_id = card.copy();
|
element.linkedId = '';
|
||||||
} else { // Linked
|
_id = element.copy();
|
||||||
card._id = null;
|
// 1.B Linked card
|
||||||
card.type = 'cardType-linkedCard';
|
} else {
|
||||||
card.linkedId = card.linkedId || card._id;
|
element._id = null;
|
||||||
_id = Cards.insert(card);
|
element.type = 'cardType-linkedCard';
|
||||||
|
element.linkedId = element.linkedId || element._id;
|
||||||
|
_id = Cards.insert(element);
|
||||||
|
}
|
||||||
|
Filter.addException(_id);
|
||||||
|
// List insertion
|
||||||
|
} else if (this.isListTemplateSearch) {
|
||||||
|
element.swimlaneId = '';
|
||||||
|
element.sort = Swimlanes.findOne(this.swimlaneId).lists().count();
|
||||||
|
element.type = 'list';
|
||||||
|
element.swimlaneId = this.swimlaneId;
|
||||||
|
_id = element.copy();
|
||||||
}
|
}
|
||||||
Filter.addException(_id);
|
|
||||||
Popup.close();
|
Popup.close();
|
||||||
},
|
},
|
||||||
}];
|
}];
|
||||||
|
|
|
||||||
8
client/components/lists/minilist.jade
Normal file
8
client/components/lists/minilist.jade
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
template(name="minilist")
|
||||||
|
.minicard(
|
||||||
|
class="minicard-{{colorClass}}")
|
||||||
|
.minicard-title
|
||||||
|
.handle
|
||||||
|
.fa.fa-arrows
|
||||||
|
+viewer
|
||||||
|
= title
|
||||||
8
client/components/swimlanes/miniswimlane.jade
Normal file
8
client/components/swimlanes/miniswimlane.jade
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
template(name="miniswimlane")
|
||||||
|
.minicard(
|
||||||
|
class="minicard-{{colorClass}}")
|
||||||
|
.minicard-title
|
||||||
|
.handle
|
||||||
|
.fa.fa-arrows
|
||||||
|
+viewer
|
||||||
|
= title
|
||||||
|
|
@ -51,7 +51,11 @@ template(name="addListForm")
|
||||||
autocomplete="off" autofocus)
|
autocomplete="off" autofocus)
|
||||||
.edit-controls.clearfix
|
.edit-controls.clearfix
|
||||||
button.primary.confirm(type="submit") {{_ 'save'}}
|
button.primary.confirm(type="submit") {{_ 'save'}}
|
||||||
a.fa.fa-times-thin.js-close-inlined-form
|
unless currentBoard.isTemplatesBoard
|
||||||
|
unless currentBoard.isTemplateBoard
|
||||||
|
span.quiet
|
||||||
|
| {{_ 'or'}}
|
||||||
|
a.js-list-template {{_ 'template'}}
|
||||||
else
|
else
|
||||||
a.open-list-composer.js-open-inlined-form
|
a.open-list-composer.js-open-inlined-form
|
||||||
i.fa.fa-plus
|
i.fa.fa-plus
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,8 @@ BlazeComponent.extendComponent({
|
||||||
|
|
||||||
BlazeComponent.extendComponent({
|
BlazeComponent.extendComponent({
|
||||||
onCreated() {
|
onCreated() {
|
||||||
|
currentBoard = Boards.findOne(Session.get('currentBoard'));
|
||||||
|
this.isListTemplatesSwimlane = currentBoard.isTemplatesBoard() && this.currentData().isListTemplatesSwimlane();
|
||||||
this.currentSwimlane = this.currentData();
|
this.currentSwimlane = this.currentData();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -169,19 +171,19 @@ BlazeComponent.extendComponent({
|
||||||
const titleInput = this.find('.list-name-input');
|
const titleInput = this.find('.list-name-input');
|
||||||
const title = titleInput.value.trim();
|
const title = titleInput.value.trim();
|
||||||
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'),
|
||||||
sort: $('.list').length,
|
sort: $('.list').length,
|
||||||
type: listType,
|
type: (this.isListTemplatesSwimlane)?'template-list':'list',
|
||||||
swimlaneId: this.currentSwimlane._id,
|
swimlaneId: (this.isListTemplatesSwimlane)?this.currentSwimlane._id:'',
|
||||||
});
|
});
|
||||||
|
|
||||||
titleInput.value = '';
|
titleInput.value = '';
|
||||||
titleInput.focus();
|
titleInput.focus();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'click .js-list-template': Popup.open('searchCard'),
|
||||||
}];
|
}];
|
||||||
},
|
},
|
||||||
}).register('addListForm');
|
}).register('addListForm');
|
||||||
|
|
|
||||||
|
|
@ -463,6 +463,30 @@ Boards.helpers({
|
||||||
return _id;
|
return _id;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
searchLists(term) {
|
||||||
|
check(term, Match.OneOf(String, null, undefined));
|
||||||
|
|
||||||
|
const query = { boardId: this._id };
|
||||||
|
if (this.isTemplatesBoard()) {
|
||||||
|
query.type = 'template-list';
|
||||||
|
query.archived = false;
|
||||||
|
} else {
|
||||||
|
query.type = {$nin: ['template-list']};
|
||||||
|
}
|
||||||
|
const projection = { limit: 10, sort: { createdAt: -1 } };
|
||||||
|
|
||||||
|
if (term) {
|
||||||
|
const regex = new RegExp(term, 'i');
|
||||||
|
|
||||||
|
query.$or = [
|
||||||
|
{ title: regex },
|
||||||
|
{ description: regex },
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return Lists.find(query, projection);
|
||||||
|
},
|
||||||
|
|
||||||
searchCards(term, excludeLinked) {
|
searchCards(term, excludeLinked) {
|
||||||
check(term, Match.OneOf(String, null, undefined));
|
check(term, Match.OneOf(String, null, undefined));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,24 @@ Lists.allow({
|
||||||
});
|
});
|
||||||
|
|
||||||
Lists.helpers({
|
Lists.helpers({
|
||||||
|
copy() {
|
||||||
|
const oldId = this._id;
|
||||||
|
this._id = null;
|
||||||
|
const _id = Lists.insert(this);
|
||||||
|
|
||||||
|
// Copy all cards in list
|
||||||
|
Cards.find({
|
||||||
|
listId: oldId,
|
||||||
|
archived: false,
|
||||||
|
}).forEach((card) => {
|
||||||
|
card.type = 'cardType-card';
|
||||||
|
card.listId = _id;
|
||||||
|
card.boardId = this.boardId;
|
||||||
|
card.swimlaneId = this.swimlaneId;
|
||||||
|
card.copy();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
cards(swimlaneId) {
|
cards(swimlaneId) {
|
||||||
const selector = {
|
const selector = {
|
||||||
listId: this._id,
|
listId: this._id,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue