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

120 lines
3.7 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 = {};
},
setNameFilter(name){
this.cardTitleFilters[this.currentPopupTriggerId] = name;
2018-08-15 18:47:09 +02:00
},
events() {
2018-09-14 17:39:37 +02:00
return [{
2019-01-02 14:45:45 +01:00
'click .js-open-card-title-popup'(event){
2019-01-02 22:51:00 +01:00
const funct = Popup.open('boardCardTitle');
const divId = $(event.currentTarget.parentNode.parentNode).attr('id');
2019-01-04 11:00:33 +02:00
//console.log('current popup');
//console.log(this.currentPopupTriggerId);
2019-01-02 14:45:45 +01:00
this.currentPopupTriggerId = divId;
2019-01-02 22:51:00 +01:00
funct.call(this, event);
2018-09-14 17:39:37 +02:00
},
'click .js-add-create-trigger' (event) {
const desc = Utils.getTriggerActionDesc(event, this);
2018-09-16 01:50:36 +03:00
const datas = this.data();
2018-09-14 17:39:37 +02:00
const listName = this.find('#create-list-name').value;
2018-12-30 22:08:34 +01:00
const swimlaneName = this.find('#create-swimlane-name').value;
2018-09-16 01:50:36 +03:00
const boardId = Session.get('currentBoard');
2019-01-02 22:51:00 +01:00
const divId = $(event.currentTarget.parentNode).attr('id');
2019-01-02 14:45:45 +01:00
const cardTitle = this.cardTitleFilters[divId];
// move to generic funciont
2018-12-30 22:08:34 +01:00
datas.triggerVar.set({
2019-01-02 22:51:00 +01:00
activityType: 'createCard',
boardId,
cardTitle,
swimlaneName,
listName,
desc,
});
2018-09-14 17:39:37 +02:00
},
'click .js-add-moved-trigger' (event) {
2018-09-16 01:50:36 +03:00
const datas = this.data();
2018-09-14 17:39:37 +02:00
const desc = Utils.getTriggerActionDesc(event, this);
2019-02-12 23:40:12 +01:00
const swimlaneName = this.find('#create-swimlane-name-2').value;
2018-09-14 17:39:37 +02:00
const actionSelected = this.find('#move-action').value;
const listName = this.find('#move-list-name').value;
2018-09-16 01:50:36 +03:00
const boardId = Session.get('currentBoard');
2019-02-12 23:40:12 +01:00
const divId = $(event.currentTarget.parentNode).attr('id');
const cardTitle = this.cardTitleFilters[divId];
2018-09-16 01:50:36 +03:00
if (actionSelected === 'moved-to') {
2018-09-14 17:39:37 +02:00
datas.triggerVar.set({
2018-09-16 01:50:36 +03:00
activityType: 'moveCard',
boardId,
listName,
2019-02-12 23:40:12 +01:00
cardTitle,
2018-12-30 22:08:34 +01:00
swimlaneName,
2018-09-16 01:50:36 +03:00
'oldListName': '*',
desc,
2018-09-14 17:39:37 +02:00
});
}
2018-09-16 01:50:36 +03:00
if (actionSelected === 'moved-from') {
2018-09-14 17:39:37 +02:00
datas.triggerVar.set({
2018-09-16 01:50:36 +03:00
activityType: 'moveCard',
boardId,
2019-02-12 23:40:12 +01:00
cardTitle,
2018-12-30 22:08:34 +01:00
swimlaneName,
2018-09-16 01:50:36 +03:00
'listName': '*',
'oldListName': listName,
desc,
2018-09-14 17:39:37 +02:00
});
}
},
2018-09-21 17:20:45 +02:00
'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 20:19:47 +02:00
datas.triggerVar.set({
2019-01-02 14:45:45 +01:00
'activityType': 'moveCard',
2018-09-21 20:19:47 +02:00
boardId,
2019-01-02 14:45:45 +01:00
'swimlaneName': '*',
2018-09-21 20:19:47 +02:00
'listName':'*',
'oldListName': '*',
desc,
});
2018-09-21 17:20:45 +02:00
},
2018-09-14 17:39:37 +02:00
'click .js-add-arc-trigger' (event) {
2018-09-16 01:50:36 +03:00
const datas = this.data();
2018-09-14 17:39:37 +02:00
const desc = Utils.getTriggerActionDesc(event, this);
const actionSelected = this.find('#arch-action').value;
2018-09-16 01:50:36 +03:00
const boardId = Session.get('currentBoard');
if (actionSelected === 'archived') {
2018-09-14 17:39:37 +02:00
datas.triggerVar.set({
2018-09-16 01:50:36 +03:00
activityType: 'archivedCard',
boardId,
desc,
2018-09-14 17:39:37 +02:00
});
}
2018-09-16 01:50:36 +03:00
if (actionSelected === 'unarchived') {
2018-09-14 17:39:37 +02:00
datas.triggerVar.set({
2018-09-16 01:50:36 +03:00
activityType: 'restoredCard',
boardId,
desc,
2018-09-14 17:39:37 +02:00
});
}
2018-09-16 01:50:36 +03:00
},
2018-08-16 16:54:29 +02: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({
submit(evt, tpl) {
const title = tpl.$('.js-card-filter-name').val().trim();
Popup.getOpenerComponent().setNameFilter(title);
evt.preventDefault();
Popup.close();
},
});