Trigger event on property change (#979)

* Add _triggerScanInputsChanged function

* Trigger event when inputs are changed
This commit is contained in:
toasted-nutbread 2020-10-31 17:13:24 -04:00 committed by GitHub
parent 11c5dbac64
commit 94620f4f22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,9 +64,12 @@ class ScanInputsController {
return true; return true;
} }
setProperty(index, property, value) { async setProperty(index, property, value, event) {
const path = `scanning.inputs[${index}].${property}`; const path = `scanning.inputs[${index}].${property}`;
return this._settingsController.setProfileSetting(path, value); await this._settingsController.setProfileSetting(path, value);
if (event) {
this._triggerScanInputsChanged();
}
} }
instantiateTemplate(name) { instantiateTemplate(name) {
@ -131,6 +134,10 @@ class ScanInputsController {
async _modifyProfileSettings(targets) { async _modifyProfileSettings(targets) {
await this._settingsController.modifyProfileSettings(targets); await this._settingsController.modifyProfileSettings(targets);
this._triggerScanInputsChanged();
}
_triggerScanInputsChanged() {
this._settingsController.trigger('scanInputsChanged', {source: this}); this._settingsController.trigger('scanInputsChanged', {source: this});
} }
@ -224,11 +231,11 @@ class ScanInputField {
// Private // Private
_onIncludeValueChange({value}) { _onIncludeValueChange({value}) {
this._parent.setProperty(this._index, 'include', value); this._parent.setProperty(this._index, 'include', value, true);
} }
_onExcludeValueChange({value}) { _onExcludeValueChange({value}) {
this._parent.setProperty(this._index, 'exclude', value); this._parent.setProperty(this._index, 'exclude', value, true);
} }
_onRemoveClick(e) { _onRemoveClick(e) {
@ -287,6 +294,6 @@ class ScanInputField {
_setAdvancedOptionsVisible(showAdvanced) { _setAdvancedOptionsVisible(showAdvanced) {
showAdvanced = !!showAdvanced; showAdvanced = !!showAdvanced;
this._node.dataset.showAdvanced = `${showAdvanced}`; this._node.dataset.showAdvanced = `${showAdvanced}`;
this._parent.setProperty(this._index, 'options.showAdvanced', showAdvanced); this._parent.setProperty(this._index, 'options.showAdvanced', showAdvanced, false);
} }
} }