mirror of
https://github.com/wekan/wekan.git
synced 2026-02-04 15:41:52 +01:00
Refactoring rules description
This commit is contained in:
parent
e649c79bb7
commit
fc73dc5bbc
15 changed files with 270 additions and 69 deletions
|
|
@ -17,7 +17,6 @@ BlazeComponent.extendComponent({
|
|||
if(actionSelected == "top"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "moveCardToTop","listTitle":listTitle,"boardId":boardId});
|
||||
console.log("Action inserted");
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
}
|
||||
if(actionSelected == "bottom"){
|
||||
|
|
@ -49,12 +48,12 @@ BlazeComponent.extendComponent({
|
|||
const actionSelected = this.find('#arch-action').value;
|
||||
if(actionSelected == "archive"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "archive"});
|
||||
const actionId = Actions.insert({actionType: "archive","boardId":boardId});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
}
|
||||
if(actionSelected == "unarchive"){
|
||||
const triggerId = Triggers.insert(trigger);
|
||||
const actionId = Actions.insert({actionType: "unarchive"});
|
||||
const actionId = Actions.insert({actionType: "unarchive","boardId":boardId});
|
||||
Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ BlazeComponent.extendComponent({
|
|||
|
||||
labels(){
|
||||
const labels = Boards.findOne(Session.get('currentBoard')).labels;
|
||||
console.log(labels);
|
||||
for(let i = 0;i<labels.length;i++){
|
||||
if(labels[i].name == "" || labels[i].name == undefined){
|
||||
labels[i].name = labels[i].color.toUpperCase();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,5 @@ template(name="ruleDetails")
|
|||
h2
|
||||
i.fa.fa-magic
|
||||
| {{{_ 'r-rule-details' }}}
|
||||
|
||||
| trigger
|
||||
| action
|
||||
= trigger
|
||||
= action
|
||||
|
|
@ -1,15 +1,24 @@
|
|||
BlazeComponent.extendComponent({
|
||||
onCreated() {
|
||||
this.subscribe('allRules');
|
||||
this.subscribe('allTriggers');
|
||||
this.subscribe('allActions');
|
||||
|
||||
},
|
||||
|
||||
trigger(){
|
||||
const rule = Rules.findOne({_id:ruleId});
|
||||
return Triggers.findOne({_id:rule.triggerId});
|
||||
const ruleId = this.data().ruleId;
|
||||
const rule = Rules.findOne({_id: ruleId.get()});
|
||||
const trigger = Triggers.findOne({_id:rule.triggerId});
|
||||
console.log(trigger);
|
||||
return trigger.description();
|
||||
},
|
||||
action(){
|
||||
const rule = Rules.findOne({_id:ruleId});
|
||||
return Triggers.findOne({_id:rule.actionId});
|
||||
const ruleId = this.data().ruleId;
|
||||
const rule = Rules.findOne({_id: ruleId.get()});
|
||||
const action = Actions.findOne({_id:rule.actionId});
|
||||
console.log(action);
|
||||
return action.description();
|
||||
},
|
||||
|
||||
events() {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ template(name="rulesList")
|
|||
p
|
||||
= title
|
||||
div.rules-btns-group
|
||||
button
|
||||
button.js-goto-details
|
||||
i.fa.fa-eye
|
||||
| {{{_ 'r-view-rule'}}}
|
||||
if currentUser.isAdmin
|
||||
|
|
|
|||
|
|
@ -4,4 +4,6 @@ template(name="rulesMain")
|
|||
if($eq rulesCurrentTab.get 'trigger')
|
||||
+rulesTriggers(ruleName=ruleName triggerVar=triggerVar)
|
||||
if($eq rulesCurrentTab.get 'action')
|
||||
+rulesActions(ruleName=ruleName triggerVar=triggerVar)
|
||||
+rulesActions(ruleName=ruleName triggerVar=triggerVar)
|
||||
if($eq rulesCurrentTab.get 'ruleDetails')
|
||||
+ruleDetails(ruleId=ruleId)
|
||||
|
|
@ -46,6 +46,8 @@ BlazeComponent.extendComponent({
|
|||
},
|
||||
'click .js-goto-details'(event) {
|
||||
event.preventDefault();
|
||||
const rule = this.currentData();
|
||||
this.ruleId.set(rule._id)
|
||||
this.setRuleDetails();
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ template(name="boardTriggers")
|
|||
div.trigger-dropdown
|
||||
select(id="gen-action")
|
||||
option(value="created") {{{_'r-added-to'}}}
|
||||
option(value="removed") {{{_'r-added-to'}}}
|
||||
option(value="removed") {{{_'r-removed-from'}}}
|
||||
div.trigger-text
|
||||
| {{{_'r-the-board'}}}
|
||||
div.trigger-button.js-add-gen-trigger.js-goto-action
|
||||
|
|
@ -19,7 +19,7 @@ template(name="boardTriggers")
|
|||
div.trigger-dropdown
|
||||
select(id="create-action")
|
||||
option(value="created") {{{_'r-added-to'}}}
|
||||
option(value="removed") {{{_'r-added-to'}}}
|
||||
option(value="removed") {{{_'r-removed-from'}}}
|
||||
div.trigger-text
|
||||
| {{{_'r-list'}}}
|
||||
div.trigger-dropdown
|
||||
|
|
|
|||
|
|
@ -6,51 +6,56 @@ BlazeComponent.extendComponent({
|
|||
events() {
|
||||
return [
|
||||
{'click .js-add-gen-trigger'(event) {
|
||||
|
||||
const desc = Utils.getTriggerActionDesc(event,this);
|
||||
let datas = this.data();
|
||||
const actionSelected = this.find('#gen-action').value;
|
||||
const boardId = Session.get('currentBoard')
|
||||
if(actionSelected == "created"){
|
||||
datas.triggerVar.set({activityType: "createCard","boardId":boardId,"listName":"*"});
|
||||
datas.triggerVar.set({activityType: "createCard","boardId":boardId,"listName":"*","desc":desc});
|
||||
}
|
||||
if(actionSelected == "removed"){
|
||||
datas.triggerVar.set({activityType: "removeCard","boardId":boardId});
|
||||
datas.triggerVar.set({activityType: "removeCard","boardId":boardId,"desc":desc});
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
'click .js-add-create-trigger'(event) {
|
||||
|
||||
const desc = Utils.getTriggerActionDesc(event,this);
|
||||
let datas = this.data();
|
||||
const actionSelected = this.find('#create-action').value;
|
||||
const listName = this.find('#create-list-name').value;
|
||||
const boardId = Session.get('currentBoard')
|
||||
if(actionSelected == "created"){
|
||||
datas.triggerVar.set({activityType: "createCard","boardId":boardId,"listName":listName});
|
||||
datas.triggerVar.set({activityType: "createCard","boardId":boardId,"listName":listName,"desc":desc});
|
||||
}
|
||||
if(actionSelected == "removed"){
|
||||
datas.triggerVar.set({activityType: "removeCard","boardId":boardId,"listName":listName});
|
||||
datas.triggerVar.set({activityType: "removeCard","boardId":boardId,"listName":listName,"desc":desc});
|
||||
}
|
||||
},
|
||||
'click .js-add-moved-trigger'(event) {
|
||||
let datas = this.data();
|
||||
const desc = Utils.getTriggerActionDesc(event,this);
|
||||
|
||||
const actionSelected = this.find('#move-action').value;
|
||||
const listName = this.find('#move-list-name').value;
|
||||
const boardId = Session.get('currentBoard')
|
||||
if(actionSelected == "moved-to"){
|
||||
datas.triggerVar.set({activityType: "moveCard","boardId":boardId,"listName":listName,"oldListName":"*"});
|
||||
datas.triggerVar.set({activityType: "moveCard","boardId":boardId,"listName":listName,"oldListName":"*","desc":desc});
|
||||
}
|
||||
if(actionSelected == "moved-from"){
|
||||
datas.triggerVar.set({activityType: "moveCard","boardId":boardId,"listName":"*","oldListName":listName});
|
||||
datas.triggerVar.set({activityType: "moveCard","boardId":boardId,"listName":"*","oldListName":listName,"desc":desc});
|
||||
}
|
||||
},
|
||||
'click .js-add-arc-trigger'(event) {
|
||||
let 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":boardId});
|
||||
datas.triggerVar.set({activityType: "archivedCard","boardId":boardId,"desc":desc});
|
||||
}
|
||||
if(actionSelected == "unarchived"){
|
||||
datas.triggerVar.set({activityType: "restoredCard","boardId":boardId});
|
||||
datas.triggerVar.set({activityType: "restoredCard","boardId":boardId,"desc":desc});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ template(name="cardTriggers")
|
|||
option(value="#{_id}")
|
||||
= name
|
||||
div.trigger-text
|
||||
| is
|
||||
| {{{_'r-is'}}}
|
||||
div.trigger-dropdown
|
||||
select(id="spec-label-action")
|
||||
option(value="added") {{{_'r-added-to'}}}
|
||||
|
|
|
|||
|
|
@ -40,14 +40,14 @@ Utils = {
|
|||
base = 0;
|
||||
increment = 1;
|
||||
// If we drop the card in the first position
|
||||
} else if (!prevData) {
|
||||
base = nextData.sort - 1;
|
||||
increment = -1;
|
||||
} else if (!prevData) {
|
||||
base = nextData.sort - 1;
|
||||
increment = -1;
|
||||
// If we drop the card in the last position
|
||||
} else if (!nextData) {
|
||||
base = prevData.sort + 1;
|
||||
increment = 1;
|
||||
}
|
||||
} else if (!nextData) {
|
||||
base = prevData.sort + 1;
|
||||
increment = 1;
|
||||
}
|
||||
// In the general case take the average of the previous and next element
|
||||
// sort indexes.
|
||||
else {
|
||||
|
|
@ -72,14 +72,14 @@ Utils = {
|
|||
base = 0;
|
||||
increment = 1;
|
||||
// If we drop the card in the first position
|
||||
} else if (!prevCardDomElement) {
|
||||
base = Blaze.getData(nextCardDomElement).sort - 1;
|
||||
increment = -1;
|
||||
} else if (!prevCardDomElement) {
|
||||
base = Blaze.getData(nextCardDomElement).sort - 1;
|
||||
increment = -1;
|
||||
// If we drop the card in the last position
|
||||
} else if (!nextCardDomElement) {
|
||||
base = Blaze.getData(prevCardDomElement).sort + 1;
|
||||
increment = 1;
|
||||
}
|
||||
} else if (!nextCardDomElement) {
|
||||
base = Blaze.getData(prevCardDomElement).sort + 1;
|
||||
increment = 1;
|
||||
}
|
||||
// In the general case take the average of the previous and next element
|
||||
// sort indexes.
|
||||
else {
|
||||
|
|
@ -121,7 +121,7 @@ Utils = {
|
|||
return Math.sqrt(
|
||||
Math.pow(touchA.screenX - touchB.screenX, 2) +
|
||||
Math.pow(touchA.screenY - touchB.screenY, 2)
|
||||
);
|
||||
);
|
||||
},
|
||||
|
||||
enableClickOnTouch(selector) {
|
||||
|
|
@ -144,6 +144,27 @@ Utils = {
|
|||
}
|
||||
});
|
||||
},
|
||||
|
||||
getTriggerActionDesc(event,tempInstance){
|
||||
const jqueryEl = tempInstance.$(event.currentTarget.parentNode);
|
||||
const triggerEls = jqueryEl.find(".trigger-content").children();
|
||||
let finalString = "";
|
||||
for(let i = 0;i< triggerEls.length;i++){
|
||||
const element = tempInstance.$(triggerEls[i]);
|
||||
if(element.hasClass("trigger-text")){
|
||||
finalString += element.text();
|
||||
}else if(element.find("select").length > 0){
|
||||
finalString += element.find("select option:selected").text();
|
||||
}else if(element.find("input").length > 0){
|
||||
finalString += element.find("input").val();
|
||||
}
|
||||
// Add space
|
||||
if(i != length - 1){
|
||||
finalString += " ";
|
||||
}
|
||||
}
|
||||
return finalString.toLowerCase();
|
||||
},
|
||||
};
|
||||
|
||||
// A simple tracker dependency that we invalidate every time the window is
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue