Handle changes via callbacks instead of observers
Dieser Commit ist enthalten in:
Ursprung
e2b1c9e69f
Commit
2844a75f30
8 geänderte Dateien mit 63 neuen und 31 gelöschten Zeilen
|
@ -25,8 +25,10 @@ export default Component.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@observes('connector')
|
actions: {
|
||||||
updated() {
|
changeConnector(value) {
|
||||||
this.onUpdate('connector');
|
this.set('connector', value);
|
||||||
|
this.onUpdate('connector', this.connectorType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
|
@ -24,10 +24,14 @@ export default Component.extend({
|
||||||
this.send('addPair');
|
this.send('addPair');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasOutput && !this.input.outputConnector) {
|
if (this.hasOutput) {
|
||||||
const options = this.options;
|
this.set('input.output', null);
|
||||||
this.set('input.output_type', defaultSelectionType('output', options));
|
|
||||||
this.set('input.output_connector', defaultConnector('output', this.inputType, options));
|
if (!this.input.outputConnector) {
|
||||||
|
const options = this.options;
|
||||||
|
this.set('input.output_type', defaultSelectionType('output', options));
|
||||||
|
this.set('input.output_connector', defaultConnector('output', this.inputType, options));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -72,16 +72,6 @@ export default Component.extend({
|
||||||
return type ? I18n.t(`admin.wizard.selector.label.${snakeCase(type)}`) : null;
|
return type ? I18n.t(`admin.wizard.selector.label.${snakeCase(type)}`) : null;
|
||||||
},
|
},
|
||||||
|
|
||||||
@observes('inputType')
|
|
||||||
resetActiveType() {
|
|
||||||
this.set('activeType', defaultSelectionType(this.selectorType, this.options));
|
|
||||||
},
|
|
||||||
|
|
||||||
@observes('activeType')
|
|
||||||
clearValue() {
|
|
||||||
this.set('value', null);
|
|
||||||
},
|
|
||||||
|
|
||||||
@discourseComputed('activeType')
|
@discourseComputed('activeType')
|
||||||
comboBoxContent(activeType) {
|
comboBoxContent(activeType) {
|
||||||
const controller = getOwner(this).lookup('controller:admin-wizards-wizard-show');
|
const controller = getOwner(this).lookup('controller:admin-wizards-wizard-show');
|
||||||
|
@ -167,19 +157,38 @@ export default Component.extend({
|
||||||
return this.activeType === type && this[`${type}Enabled`];
|
return this.activeType === type && this[`${type}Enabled`];
|
||||||
},
|
},
|
||||||
|
|
||||||
@observes('activeType', 'value')
|
changeValue(value) {
|
||||||
updated() {
|
this.set('value', value);
|
||||||
this.onUpdate('selector');
|
this.onUpdate('selector', this.activeType);
|
||||||
|
},
|
||||||
|
|
||||||
|
@observes('inputType')
|
||||||
|
resetActiveType() {
|
||||||
|
this.set('activeType', defaultSelectionType(this.selectorType, this.options));
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
toggleType(type) {
|
toggleType(type) {
|
||||||
this.set('activeType', type);
|
this.set('activeType', type);
|
||||||
this.set('showTypes', false);
|
this.set('showTypes', false);
|
||||||
|
this.set('value', null);
|
||||||
|
this.onUpdate('selector');
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleTypes() {
|
toggleTypes() {
|
||||||
this.toggleProperty('showTypes');
|
this.toggleProperty('showTypes');
|
||||||
|
},
|
||||||
|
|
||||||
|
changeValue(value) {
|
||||||
|
this.changeValue(value);
|
||||||
|
},
|
||||||
|
|
||||||
|
changeInputValue(event) {
|
||||||
|
this.changeValue(event.target.value);
|
||||||
|
},
|
||||||
|
|
||||||
|
changeUserValue(previousValue, value) {
|
||||||
|
this.changeValue(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
|
@ -77,8 +77,8 @@ export default Component.extend({
|
||||||
this.onUpdate(this.property, 'input');
|
this.onUpdate(this.property, 'input');
|
||||||
},
|
},
|
||||||
|
|
||||||
inputUpdated(type) {
|
inputUpdated(component, type) {
|
||||||
this.onUpdate(this.property, type);
|
this.onUpdate(this.property, component, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
12
assets/javascripts/discourse/components/wizard-value-list.js.es6
Normale Datei
12
assets/javascripts/discourse/components/wizard-value-list.js.es6
Normale Datei
|
@ -0,0 +1,12 @@
|
||||||
|
import ValueList from 'admin/components/value-list';
|
||||||
|
|
||||||
|
export default ValueList.extend({
|
||||||
|
_saveValues() {
|
||||||
|
if (this.inputType === "array") {
|
||||||
|
this.onChange(this.collection);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.onChange(this.collection.join(this.inputDelimiter || "\n"));
|
||||||
|
}
|
||||||
|
})
|
|
@ -117,8 +117,9 @@ export default Mixin.create({
|
||||||
this.setupObservers(type);
|
this.setupObservers(type);
|
||||||
},
|
},
|
||||||
|
|
||||||
mappedFieldUpdated(property, type) {
|
mappedFieldUpdated(property, mappedComponent, type) {
|
||||||
this.get(this.componentType).notifyPropertyChange(property);
|
const obj = this.get(this.componentType);
|
||||||
|
obj.notifyPropertyChange(property);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
|
@ -2,7 +2,7 @@
|
||||||
{{combo-box
|
{{combo-box
|
||||||
value=connector
|
value=connector
|
||||||
content=connectors
|
content=connectors
|
||||||
onChange=(action (mut connector))}}
|
onChange=(action "changeConnector")}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#if connector}}
|
{{#if connector}}
|
||||||
<span class="connector-single">
|
<span class="connector-single">
|
||||||
|
|
|
@ -24,14 +24,15 @@
|
||||||
{{input
|
{{input
|
||||||
type="text"
|
type="text"
|
||||||
value=value
|
value=value
|
||||||
placeholder=(i18n placeholderKey)}}
|
placeholder=(i18n placeholderKey)
|
||||||
|
change=(action "changeInputValue")}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if showComboBox}}
|
{{#if showComboBox}}
|
||||||
{{combo-box
|
{{combo-box
|
||||||
value=value
|
value=value
|
||||||
content=comboBoxContent
|
content=comboBoxContent
|
||||||
onChange=(action (mut value))
|
onChange=(action "changeValue")
|
||||||
options=(hash
|
options=(hash
|
||||||
none=placeholderKey
|
none=placeholderKey
|
||||||
)}}
|
)}}
|
||||||
|
@ -41,19 +42,21 @@
|
||||||
{{multi-select
|
{{multi-select
|
||||||
content=multiSelectContent
|
content=multiSelectContent
|
||||||
value=value
|
value=value
|
||||||
onChange=(action (mut value))
|
onChange=(action "changeValue")
|
||||||
options=multiSelectOptions}}
|
options=multiSelectOptions}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if showList}}
|
{{#if showList}}
|
||||||
{{value-list
|
{{wizard-value-list
|
||||||
values=value
|
values=value
|
||||||
addKey=placeholderKey}}
|
addKey=placeholderKey
|
||||||
|
onChange=(action "changeValue")}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if showTag}}
|
{{#if showTag}}
|
||||||
{{tag-chooser
|
{{tag-chooser
|
||||||
tags=value
|
tags=value
|
||||||
|
onChange=(action "changeValue")
|
||||||
options=(hash
|
options=(hash
|
||||||
none=placeholderKey
|
none=placeholderKey
|
||||||
filterable=true
|
filterable=true
|
||||||
|
@ -65,6 +68,7 @@
|
||||||
includeMessageableGroups='true'
|
includeMessageableGroups='true'
|
||||||
placeholderKey=placeholderKey
|
placeholderKey=placeholderKey
|
||||||
usernames=value
|
usernames=value
|
||||||
autocomplete="discourse"}}
|
autocomplete="discourse"
|
||||||
|
onChangeCallback=(action "changeUserValue")}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
Laden …
In neuem Issue referenzieren