From adb622f2aeeb0387ced08e645cb27fbd317ac0ed Mon Sep 17 00:00:00 2001 From: andrewbrazzatti Date: Thu, 19 May 2022 14:28:14 +0930 Subject: [PATCH] Added extra event emitting functions to allow more control in subscribe blocks (#1080) --- angular/shared/form/field-base.ts | 83 +++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/angular/shared/form/field-base.ts b/angular/shared/form/field-base.ts index c0cafa5874..69f4407b2a 100644 --- a/angular/shared/form/field-base.ts +++ b/angular/shared/form/field-base.ts @@ -513,10 +513,93 @@ export class FieldBase { return _.isUndefined(_.get(this.appConfig, name)) ? defValue : _.get(this.appConfig, name); } + + /** + * + * Emits the current form value as a value loaded event. + * + * To be used in subscribe blocks + * e.g. to emit the form value when the form loads + * + * 'form': { + * onFormLoaded: [{ + * action: 'publishValueLoaded' + * }] + * } + * + */ public publishValueLoaded() { this.onValueLoaded.emit(this.value); } + /** + * + * Emits the value passed ot it as a value loaded event. + * + * To be used in subscribe blocks as part of the processing chain to emit the current processed value. + * e.g. + * + * 'rdmpGetter': { + * onValueUpdate: [ + * { + * action: 'utilityService.getPropertyFromObject', + * field: 'some-value-on-object' + * }, + * { + * action: 'publishProcessedValueUpdated' + * } + * ] + * } + * + */ + public publishProcessedValueLoaded(curValue) { + this.onValueLoaded.emit(curValue); + } + + /** + * + * Emits the field's current value as a value loaded event. + * + * To be used in subscribe blocks as part of the processing chain to emit the current processed value. + * e.g. + * + * 'some-property': { + * onValueUpdate: [ + * { + * action: 'publishValueUpdated' + * } + * ] + * } + * + */ + public publishValueUpdated() { + this.onValueUpdate.emit(this.value); + } + + /** + * + * Emits the value passed to it as a value updated event. + * + * To be used in subscribe blocks as part of the processing chain to emit the current processed value. + * e.g. + * + * 'rdmpGetter': { + * onValueUpdate: [ + * { + * action: 'utilityService.getPropertyFromObject', + * field: 'some-value-on-object' + * }, + * { + * action: 'publishProcessedValueUpdated' + * } + * ] + * } + * + */ + public publishProcessedValueUpdated(curValue) { + this.onValueUpdate.emit(curValue); + } + setRequiredAndClearValueOnFalse(flag) { this.required = flag; if (flag) {