wekan/client/components/rules/triggers/boardTriggers.js

122 lines
3.9 KiB
JavaScript
Raw Normal View History

2018-08-15 18:47:09 +02:00
BlazeComponent.extendComponent({
onCreated() {
2019-01-02 14:45:45 +01:00
this.provaVar = new ReactiveVar('');
2019-01-02 22:51:00 +01:00
this.currentPopupTriggerId = 'def';
2019-01-02 14:45:45 +01:00
this.cardTitleFilters = {};
},
2019-06-28 12:52:09 -05:00
setNameFilter(name) {
this.cardTitleFilters[this.currentPopupTriggerId] = name;
2018-08-15 18:47:09 +02:00
},
events() {
2019-06-28 12:52:09 -05:00
return [
{
'click .js-open-card-title-popup'(event) {
const funct = Popup.open('boardCardTitle');
const divId = $(event.currentTarget.parentNode.parentNode).attr('id');
//console.log('current popup');
//console.log(this.currentPopupTriggerId);
this.currentPopupTriggerId = divId;
funct.call(this, event);
},
'click .js-add-create-trigger'(event) {
const desc = Utils.getTriggerActionDesc(event, this);
const datas = this.data();
const listName = this.find('#create-list-name').value;
const swimlaneName = this.find('#create-swimlane-name').value;
const boardId = Session.get('currentBoard');
const divId = $(event.currentTarget.parentNode).attr('id');
const cardTitle = this.cardTitleFilters[divId];
// move to generic funciont
2018-09-14 17:39:37 +02:00
datas.triggerVar.set({
2019-06-28 12:52:09 -05:00
activityType: 'createCard',
2018-09-16 01:50:36 +03:00
boardId,
2019-02-12 23:40:12 +01:00
cardTitle,
2018-12-30 22:08:34 +01:00
swimlaneName,
2019-06-28 12:52:09 -05:00
listName,
2018-09-16 01:50:36 +03:00
desc,
2018-09-14 17:39:37 +02:00
});
2019-06-28 12:52:09 -05:00
},
'click .js-add-moved-trigger'(event) {
const datas = this.data();
const desc = Utils.getTriggerActionDesc(event, this);
const swimlaneName = this.find('#create-swimlane-name-2').value;
const actionSelected = this.find('#move-action').value;
const listName = this.find('#move-list-name').value;
const boardId = Session.get('currentBoard');
const divId = $(event.currentTarget.parentNode).attr('id');
const cardTitle = this.cardTitleFilters[divId];
if (actionSelected === 'moved-to') {
datas.triggerVar.set({
activityType: 'moveCard',
boardId,
listName,
cardTitle,
swimlaneName,
oldListName: '*',
desc,
});
}
if (actionSelected === 'moved-from') {
datas.triggerVar.set({
activityType: 'moveCard',
boardId,
cardTitle,
swimlaneName,
listName: '*',
oldListName: listName,
desc,
});
}
},
'click .js-add-gen-moved-trigger'(event) {
const datas = this.data();
const desc = Utils.getTriggerActionDesc(event, this);
const boardId = Session.get('currentBoard');
2018-09-21 17:20:45 +02:00
2018-09-14 17:39:37 +02:00
datas.triggerVar.set({
2019-06-28 12:52:09 -05:00
activityType: 'moveCard',
2018-09-16 01:50:36 +03:00
boardId,
2019-06-28 12:52:09 -05:00
swimlaneName: '*',
listName: '*',
oldListName: '*',
2018-09-16 01:50:36 +03:00
desc,
2018-09-14 17:39:37 +02:00
});
2019-06-28 12:52:09 -05:00
},
'click .js-add-arc-trigger'(event) {
const datas = this.data();
const desc = Utils.getTriggerActionDesc(event, this);
const actionSelected = this.find('#arch-action').value;
const boardId = Session.get('currentBoard');
if (actionSelected === 'archived') {
datas.triggerVar.set({
activityType: 'archivedCard',
boardId,
desc,
});
}
if (actionSelected === 'unarchived') {
datas.triggerVar.set({
activityType: 'restoredCard',
boardId,
desc,
});
}
},
2018-09-16 01:50:36 +03:00
},
2019-06-28 12:52:09 -05:00
];
2018-08-15 18:47:09 +02:00
},
2018-09-16 01:50:36 +03:00
}).register('boardTriggers');
2019-01-02 14:45:45 +01:00
Template.boardCardTitlePopup.events({
2019-06-28 12:52:09 -05:00
submit(event, templateInstance) {
const title = templateInstance
.$('.js-card-filter-name')
.val()
.trim();
2019-01-02 14:45:45 +01:00
Popup.getOpenerComponent().setNameFilter(title);
2019-06-28 12:52:09 -05:00
event.preventDefault();
Popup.back();
2019-01-02 14:45:45 +01:00
},
});