mirror of
https://github.com/wekan/wekan.git
synced 2025-12-17 07:50:12 +01:00
ifttt: card actions: simplify the logic for setting the color
Jade allows a simpler approach than my initial manual update. Just declare the correct ReactiveVar and accessor, and done.
This commit is contained in:
parent
1a64a88d3d
commit
850b34ce33
2 changed files with 17 additions and 13 deletions
|
|
@ -39,8 +39,10 @@ template(name="cardActions")
|
||||||
div.trigger-content
|
div.trigger-content
|
||||||
div.trigger-text
|
div.trigger-text
|
||||||
| {{{_'r-set-color'}}}
|
| {{{_'r-set-color'}}}
|
||||||
button.trigger-button.trigger-button-color.card-details-green.js-show-color-palette(id="color-action")
|
button.trigger-button.trigger-button-color.js-show-color-palette(
|
||||||
| {{{_'color-green'}}}
|
id="color-action"
|
||||||
|
class="card-details-{{cardColorButton}}")
|
||||||
|
| {{{_ cardColorButtonText }}}
|
||||||
div.trigger-button.js-set-color-action.js-goto-rules
|
div.trigger-button.js-set-color-action.js-goto-rules
|
||||||
i.fa.fa-plus
|
i.fa.fa-plus
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,15 @@ Meteor.startup(() => {
|
||||||
BlazeComponent.extendComponent({
|
BlazeComponent.extendComponent({
|
||||||
onCreated() {
|
onCreated() {
|
||||||
this.subscribe('allRules');
|
this.subscribe('allRules');
|
||||||
|
this.cardColorButtonValue = new ReactiveVar('green');
|
||||||
|
},
|
||||||
|
|
||||||
|
cardColorButton() {
|
||||||
|
return this.cardColorButtonValue.get();
|
||||||
|
},
|
||||||
|
|
||||||
|
cardColorButtonText() {
|
||||||
|
return `color-${ this.cardColorButtonValue.get() }`;
|
||||||
},
|
},
|
||||||
|
|
||||||
labels() {
|
labels() {
|
||||||
|
|
@ -128,11 +137,7 @@ BlazeComponent.extendComponent({
|
||||||
'click .js-set-color-action' (event) {
|
'click .js-set-color-action' (event) {
|
||||||
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 colorButton = this.find('#color-action');
|
const selectedColor = this.cardColorButtonValue.get();
|
||||||
if (colorButton.value === '') {
|
|
||||||
colorButton.value = 'green';
|
|
||||||
}
|
|
||||||
const selectedColor = colorButton.value;
|
|
||||||
const boardId = Session.get('currentBoard');
|
const boardId = Session.get('currentBoard');
|
||||||
const desc = Utils.getTriggerActionDesc(event, this);
|
const desc = Utils.getTriggerActionDesc(event, this);
|
||||||
const triggerId = Triggers.insert(trigger);
|
const triggerId = Triggers.insert(trigger);
|
||||||
|
|
@ -157,8 +162,8 @@ BlazeComponent.extendComponent({
|
||||||
BlazeComponent.extendComponent({
|
BlazeComponent.extendComponent({
|
||||||
onCreated() {
|
onCreated() {
|
||||||
this.currentAction = this.currentData();
|
this.currentAction = this.currentData();
|
||||||
this.colorButton = Popup.getOpenerComponent().find('#color-action');
|
this.colorButtonValue = Popup.getOpenerComponent().cardColorButtonValue;
|
||||||
this.currentColor = new ReactiveVar(this.colorButton.value);
|
this.currentColor = new ReactiveVar(this.colorButtonValue.get());
|
||||||
},
|
},
|
||||||
|
|
||||||
colors() {
|
colors() {
|
||||||
|
|
@ -175,10 +180,7 @@ BlazeComponent.extendComponent({
|
||||||
this.currentColor.set(this.currentData().color);
|
this.currentColor.set(this.currentData().color);
|
||||||
},
|
},
|
||||||
'click .js-submit' () {
|
'click .js-submit' () {
|
||||||
this.colorButton.classList.remove(`card-details-${ this.colorButton.value }`);
|
this.colorButtonValue.set(this.currentColor.get());
|
||||||
this.colorButton.value = this.currentColor.get();
|
|
||||||
this.colorButton.innerText = `${TAPi18n.__(`color-${ this.currentColor.get() }`)}`;
|
|
||||||
this.colorButton.classList.add(`card-details-${ this.colorButton.value }`);
|
|
||||||
Popup.close();
|
Popup.close();
|
||||||
},
|
},
|
||||||
}];
|
}];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue