mirror of
https://github.com/wekan/wekan.git
synced 2025-04-22 04:57:07 -04:00
Merge branch 'kuleuven-feature-action-move-other-board'
This commit is contained in:
commit
79223b0b8c
3 changed files with 102 additions and 39 deletions
|
@ -1,29 +1,42 @@
|
|||
template(name="boardActions")
|
||||
div.trigger-item
|
||||
div.trigger-content
|
||||
div.trigger-text
|
||||
div.trigger-text
|
||||
| {{_'r-move-card-to'}}
|
||||
div.trigger-dropdown
|
||||
select(id="move-gen-action")
|
||||
option(value="top") {{_'r-top-of'}}
|
||||
option(value="bottom") {{_'r-bottom-of'}}
|
||||
div.trigger-text
|
||||
div.trigger-text
|
||||
| {{_'r-its-list'}}
|
||||
div.trigger-button.js-add-gen-move-action.js-goto-rules
|
||||
i.fa.fa-plus
|
||||
|
||||
div.trigger-item
|
||||
div.trigger-content
|
||||
div.trigger-text
|
||||
div.trigger-text
|
||||
| {{_'r-move-card-to'}}
|
||||
div.trigger-dropdown
|
||||
select(id="move-spec-action")
|
||||
option(value="top") {{_'r-top-of'}}
|
||||
option(value="bottom") {{_'r-bottom-of'}}
|
||||
div.trigger-text
|
||||
| {{_'r-list'}}
|
||||
div.trigger-text
|
||||
| {{_'r-the-board'}}
|
||||
div.trigger-dropdown
|
||||
select(id="board-id")
|
||||
each boards
|
||||
if $eq _id currentBoard._id
|
||||
option(value="{{_id}}" selected) {{_ 'current'}}
|
||||
else
|
||||
option(value="{{_id}}") {{title}}
|
||||
div.trigger-text
|
||||
| {{_'r-in-list'}}
|
||||
div.trigger-dropdown
|
||||
input(id="listName",type=text,placeholder="{{_'r-name'}}")
|
||||
div.trigger-text
|
||||
| {{_'r-in-swimlane'}}
|
||||
div.trigger-dropdown
|
||||
input(id="swimlaneName",type=text,placeholder="{{_'r-name'}}")
|
||||
div.trigger-button.js-add-spec-move-action.js-goto-rules
|
||||
i.fa.fa-plus
|
||||
|
||||
|
@ -33,14 +46,14 @@ template(name="boardActions")
|
|||
select(id="arch-action")
|
||||
option(value="archive") {{_'r-archive'}}
|
||||
option(value="unarchive") {{_'r-unarchive'}}
|
||||
div.trigger-text
|
||||
div.trigger-text
|
||||
| {{_'r-card'}}
|
||||
div.trigger-button.js-add-arch-action.js-goto-rules
|
||||
i.fa.fa-plus
|
||||
|
||||
div.trigger-item
|
||||
div.trigger-content
|
||||
div.trigger-text
|
||||
div.trigger-text
|
||||
| {{_'r-add-swimlane'}}
|
||||
div.trigger-dropdown
|
||||
input(id="swimlane-name",type=text,placeholder="{{_'r-name'}}")
|
||||
|
@ -49,15 +62,15 @@ template(name="boardActions")
|
|||
|
||||
div.trigger-item
|
||||
div.trigger-content
|
||||
div.trigger-text
|
||||
div.trigger-text
|
||||
| {{_'r-create-card'}}
|
||||
div.trigger-dropdown
|
||||
input(id="card-name",type=text,placeholder="{{_'r-name'}}")
|
||||
div.trigger-text
|
||||
div.trigger-text
|
||||
| {{_'r-in-list'}}
|
||||
div.trigger-dropdown
|
||||
input(id="list-name",type=text,placeholder="{{_'r-name'}}")
|
||||
div.trigger-text
|
||||
div.trigger-text
|
||||
| {{_'r-in-swimlane'}}
|
||||
div.trigger-dropdown
|
||||
input(id="swimlane-name2",type=text,placeholder="{{_'r-name'}}")
|
||||
|
@ -65,8 +78,8 @@ template(name="boardActions")
|
|||
i.fa.fa-plus
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,22 @@
|
|||
BlazeComponent.extendComponent({
|
||||
onCreated() {},
|
||||
|
||||
boards() {
|
||||
const boards = Boards.find(
|
||||
{
|
||||
archived: false,
|
||||
'members.userId': Meteor.userId(),
|
||||
_id: {
|
||||
$ne: Meteor.user().getTemplatesBoardId(),
|
||||
},
|
||||
},
|
||||
{
|
||||
sort: ['title'],
|
||||
},
|
||||
);
|
||||
return boards;
|
||||
},
|
||||
|
||||
events() {
|
||||
return [
|
||||
{
|
||||
|
@ -52,15 +68,18 @@ BlazeComponent.extendComponent({
|
|||
const ruleName = this.data().ruleName.get();
|
||||
const trigger = this.data().triggerVar.get();
|
||||
const actionSelected = this.find('#move-spec-action').value;
|
||||
const listTitle = this.find('#listName').value;
|
||||
const swimlaneName = this.find('#swimlaneName').value;
|
||||
const listName = this.find('#listName').value;
|
||||
const boardId = Session.get('currentBoard');
|
||||
const destBoardId = this.find('#board-id').value;
|
||||
const desc = Utils.getTriggerActionDesc(event, this);
|
||||
if (actionSelected === 'top') {
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({
|
||||
actionType: 'moveCardToTop',
|
||||
listTitle,
|
||||
boardId,
|
||||
listName,
|
||||
swimlaneName,
|
||||
boardId: destBoardId,
|
||||
desc,
|
||||
});
|
||||
Rules.insert({
|
||||
|
@ -74,8 +93,9 @@ BlazeComponent.extendComponent({
|
|||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({
|
||||
actionType: 'moveCardToBottom',
|
||||
listTitle,
|
||||
boardId,
|
||||
listName,
|
||||
swimlaneName,
|
||||
boardId: destBoardId,
|
||||
desc,
|
||||
});
|
||||
Rules.insert({
|
||||
|
|
|
@ -42,35 +42,65 @@ RulesHelper = {
|
|||
performAction(activity, action) {
|
||||
const card = Cards.findOne({ _id: activity.cardId });
|
||||
const boardId = activity.boardId;
|
||||
if (action.actionType === 'moveCardToTop') {
|
||||
let listId;
|
||||
if (
|
||||
action.actionType === 'moveCardToTop' ||
|
||||
action.actionType === 'moveCardToBottom'
|
||||
) {
|
||||
let list;
|
||||
if (action.listTitle === '*') {
|
||||
listId = card.listId;
|
||||
let listId;
|
||||
if (action.listName === '*') {
|
||||
list = card.list();
|
||||
if (boardId !== action.boardId) {
|
||||
list = Lists.findOne({ title: list.title, boardId: action.boardId });
|
||||
}
|
||||
} else {
|
||||
list = Lists.findOne({
|
||||
title: action.listName,
|
||||
boardId: action.boardId,
|
||||
});
|
||||
}
|
||||
if (list === undefined) {
|
||||
listId = '';
|
||||
} else {
|
||||
list = Lists.findOne({ title: action.listTitle, boardId });
|
||||
listId = list._id;
|
||||
}
|
||||
const minOrder = _.min(
|
||||
list.cardsUnfiltered(card.swimlaneId).map(c => c.sort),
|
||||
);
|
||||
card.move(boardId, card.swimlaneId, listId, minOrder - 1);
|
||||
}
|
||||
if (action.actionType === 'moveCardToBottom') {
|
||||
let listId;
|
||||
let list;
|
||||
if (action.listTitle === '*') {
|
||||
listId = card.listId;
|
||||
list = card.list();
|
||||
|
||||
let swimlane;
|
||||
let swimlaneId;
|
||||
if (action.swimlaneName === '*') {
|
||||
swimlane = Swimlanes.findOne(card.swimlaneId);
|
||||
if (boardId !== action.boardId) {
|
||||
swimlane = Swimlanes.findOne({
|
||||
title: swimlane.title,
|
||||
boardId: action.boardId,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
list = Lists.findOne({ title: action.listTitle, boardId });
|
||||
listId = list._id;
|
||||
swimlane = Swimlanes.findOne({
|
||||
title: action.swimlaneName,
|
||||
boardId: action.boardId,
|
||||
});
|
||||
}
|
||||
if (swimlane === undefined) {
|
||||
swimlaneId = Swimlanes.findOne({
|
||||
title: 'Default',
|
||||
boardId: action.boardId,
|
||||
})._id;
|
||||
} else {
|
||||
swimlaneId = swimlane._id;
|
||||
}
|
||||
|
||||
if (action.actionType === 'moveCardToTop') {
|
||||
const minOrder = _.min(
|
||||
list.cardsUnfiltered(swimlaneId).map(c => c.sort),
|
||||
);
|
||||
card.move(action.boardId, swimlaneId, listId, minOrder - 1);
|
||||
} else {
|
||||
const maxOrder = _.max(
|
||||
list.cardsUnfiltered(swimlaneId).map(c => c.sort),
|
||||
);
|
||||
card.move(action.boardId, swimlaneId, listId, maxOrder + 1);
|
||||
}
|
||||
const maxOrder = _.max(
|
||||
list.cardsUnfiltered(card.swimlaneId).map(c => c.sort),
|
||||
);
|
||||
card.move(boardId, card.swimlaneId, listId, maxOrder + 1);
|
||||
}
|
||||
if (action.actionType === 'sendEmail') {
|
||||
const to = action.emailTo;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue