mirror of
https://github.com/wekan/wekan.git
synced 2025-12-19 17:00:13 +01:00
parent
70f5326099
commit
4b56bbfe6d
3 changed files with 102 additions and 39 deletions
|
|
@ -21,9 +21,22 @@ template(name="boardActions")
|
||||||
option(value="top") {{_'r-top-of'}}
|
option(value="top") {{_'r-top-of'}}
|
||||||
option(value="bottom") {{_'r-bottom-of'}}
|
option(value="bottom") {{_'r-bottom-of'}}
|
||||||
div.trigger-text
|
div.trigger-text
|
||||||
| {{_'r-list'}}
|
| {{_'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
|
div.trigger-dropdown
|
||||||
input(id="listName",type=text,placeholder="{{_'r-name'}}")
|
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
|
div.trigger-button.js-add-spec-move-action.js-goto-rules
|
||||||
i.fa.fa-plus
|
i.fa.fa-plus
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,22 @@
|
||||||
BlazeComponent.extendComponent({
|
BlazeComponent.extendComponent({
|
||||||
onCreated() {},
|
onCreated() {},
|
||||||
|
|
||||||
|
boards() {
|
||||||
|
const boards = Boards.find(
|
||||||
|
{
|
||||||
|
archived: false,
|
||||||
|
'members.userId': Meteor.userId(),
|
||||||
|
_id: {
|
||||||
|
$ne: Meteor.user().getTemplatesBoardId(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sort: ['title'],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return boards;
|
||||||
|
},
|
||||||
|
|
||||||
events() {
|
events() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
|
@ -52,15 +68,18 @@ BlazeComponent.extendComponent({
|
||||||
const ruleName = this.data().ruleName.get();
|
const ruleName = this.data().ruleName.get();
|
||||||
const trigger = this.data().triggerVar.get();
|
const trigger = this.data().triggerVar.get();
|
||||||
const actionSelected = this.find('#move-spec-action').value;
|
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 boardId = Session.get('currentBoard');
|
||||||
|
const destBoardId = this.find('#board-id').value;
|
||||||
const desc = Utils.getTriggerActionDesc(event, this);
|
const desc = Utils.getTriggerActionDesc(event, this);
|
||||||
if (actionSelected === 'top') {
|
if (actionSelected === 'top') {
|
||||||
const triggerId = Triggers.insert(trigger);
|
const triggerId = Triggers.insert(trigger);
|
||||||
const actionId = Actions.insert({
|
const actionId = Actions.insert({
|
||||||
actionType: 'moveCardToTop',
|
actionType: 'moveCardToTop',
|
||||||
listTitle,
|
listName,
|
||||||
boardId,
|
swimlaneName,
|
||||||
|
boardId: destBoardId,
|
||||||
desc,
|
desc,
|
||||||
});
|
});
|
||||||
Rules.insert({
|
Rules.insert({
|
||||||
|
|
@ -74,8 +93,9 @@ BlazeComponent.extendComponent({
|
||||||
const triggerId = Triggers.insert(trigger);
|
const triggerId = Triggers.insert(trigger);
|
||||||
const actionId = Actions.insert({
|
const actionId = Actions.insert({
|
||||||
actionType: 'moveCardToBottom',
|
actionType: 'moveCardToBottom',
|
||||||
listTitle,
|
listName,
|
||||||
boardId,
|
swimlaneName,
|
||||||
|
boardId: destBoardId,
|
||||||
desc,
|
desc,
|
||||||
});
|
});
|
||||||
Rules.insert({
|
Rules.insert({
|
||||||
|
|
|
||||||
|
|
@ -42,35 +42,65 @@ RulesHelper = {
|
||||||
performAction(activity, action) {
|
performAction(activity, action) {
|
||||||
const card = Cards.findOne({ _id: activity.cardId });
|
const card = Cards.findOne({ _id: activity.cardId });
|
||||||
const boardId = activity.boardId;
|
const boardId = activity.boardId;
|
||||||
|
if (
|
||||||
|
action.actionType === 'moveCardToTop' ||
|
||||||
|
action.actionType === 'moveCardToBottom'
|
||||||
|
) {
|
||||||
|
let list;
|
||||||
|
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 {
|
||||||
|
listId = list._id;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
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') {
|
if (action.actionType === 'moveCardToTop') {
|
||||||
let listId;
|
|
||||||
let list;
|
|
||||||
if (action.listTitle === '*') {
|
|
||||||
listId = card.listId;
|
|
||||||
list = card.list();
|
|
||||||
} else {
|
|
||||||
list = Lists.findOne({ title: action.listTitle, boardId });
|
|
||||||
listId = list._id;
|
|
||||||
}
|
|
||||||
const minOrder = _.min(
|
const minOrder = _.min(
|
||||||
list.cardsUnfiltered(card.swimlaneId).map(c => c.sort),
|
list.cardsUnfiltered(swimlaneId).map(c => c.sort),
|
||||||
);
|
);
|
||||||
card.move(boardId, card.swimlaneId, listId, minOrder - 1);
|
card.move(action.boardId, swimlaneId, listId, minOrder - 1);
|
||||||
}
|
|
||||||
if (action.actionType === 'moveCardToBottom') {
|
|
||||||
let listId;
|
|
||||||
let list;
|
|
||||||
if (action.listTitle === '*') {
|
|
||||||
listId = card.listId;
|
|
||||||
list = card.list();
|
|
||||||
} else {
|
} else {
|
||||||
list = Lists.findOne({ title: action.listTitle, boardId });
|
|
||||||
listId = list._id;
|
|
||||||
}
|
|
||||||
const maxOrder = _.max(
|
const maxOrder = _.max(
|
||||||
list.cardsUnfiltered(card.swimlaneId).map(c => c.sort),
|
list.cardsUnfiltered(swimlaneId).map(c => c.sort),
|
||||||
);
|
);
|
||||||
card.move(boardId, card.swimlaneId, listId, maxOrder + 1);
|
card.move(action.boardId, swimlaneId, listId, maxOrder + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (action.actionType === 'sendEmail') {
|
if (action.actionType === 'sendEmail') {
|
||||||
const to = action.emailTo;
|
const to = action.emailTo;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue