@iapps/ng-dhis2-ui 1.2.161 → 1.2.163

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8781,6 +8781,7 @@ class BaseFormFieldComponent extends ReactWrapperModule {
8781
8781
  this.field = input.required(...(ngDevMode ? [{ debugName: "field" }] : []));
8782
8782
  this.fieldError = input(...(ngDevMode ? [undefined, { debugName: "fieldError" }] : []));
8783
8783
  this.fieldConfig = input(new FieldConfig(), ...(ngDevMode ? [{ debugName: "fieldConfig" }] : []));
8784
+ this.programRuleOptions = input(...(ngDevMode ? [undefined, { debugName: "programRuleOptions" }] : []));
8784
8785
  this.form = model.required(...(ngDevMode ? [{ debugName: "form" }] : []));
8785
8786
  // kept for compatibility (even if not used directly here)
8786
8787
  this.isValid = input(...(ngDevMode ? [undefined, { debugName: "isValid" }] : []));
@@ -8798,6 +8799,7 @@ class BaseFormFieldComponent extends ReactWrapperModule {
8798
8799
  this.value$ = toObservable(this.value);
8799
8800
  this.isValueAssigned$ = toObservable(this.isValueAssigned);
8800
8801
  this.fieldError$ = toObservable(this.fieldError);
8802
+ this.programRuleOptions$ = toObservable(this.programRuleOptions);
8801
8803
  this.label = computed(() => {
8802
8804
  const cfg = this.fieldConfig();
8803
8805
  const f = this.field();
@@ -8952,6 +8954,34 @@ class BaseFormFieldComponent extends ReactWrapperModule {
8952
8954
  const [initialError, setInitialError] = useState();
8953
8955
  const [recordExistError, setRecordExistError] = useState();
8954
8956
  const [checkingUniqueness, setCheckingUniqueness] = useState(false);
8957
+ useEffect(() => {
8958
+ const sub = this.programRuleOptions$.subscribe((options) => {
8959
+ if (!options)
8960
+ return;
8961
+ if (field.controlType !== 'dropdown' &&
8962
+ field.controlType !== 'multi-dropdown') {
8963
+ return;
8964
+ }
8965
+ const cascade = this.#resolveCascadeForCurrentField();
8966
+ if (cascade?.kind === 'OPTIONS_PATH')
8967
+ return;
8968
+ const nextOptions = options;
8969
+ setFilteredOptions(nextOptions);
8970
+ const currentCtrl = this.#getCurrentFieldControl(fg);
8971
+ const currentValue = String(currentCtrl?.value ?? '').trim();
8972
+ if (!currentValue)
8973
+ return;
8974
+ const stillValid = nextOptions.some((option) => {
8975
+ const optionValue = String(option?.value ?? option?.id ?? option?.code ?? option?.key ?? '');
8976
+ return optionValue === currentValue;
8977
+ });
8978
+ if (!stillValid) {
8979
+ currentCtrl?.setValue(null, { emitEvent: true });
8980
+ setValue('');
8981
+ }
8982
+ });
8983
+ return () => sub.unsubscribe();
8984
+ }, []);
8955
8985
  // Keep refs synced
8956
8986
  useEffect(() => {
8957
8987
  valueRef.current = value;
@@ -9311,7 +9341,7 @@ class BaseFormFieldComponent extends ReactWrapperModule {
9311
9341
  }
9312
9342
  }
9313
9343
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: BaseFormFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
9314
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.1.3", type: BaseFormFieldComponent, isStandalone: true, inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: true, transformFunction: null }, fieldError: { classPropertyName: "fieldError", publicName: "fieldError", isSignal: true, isRequired: false, transformFunction: null }, fieldConfig: { classPropertyName: "fieldConfig", publicName: "fieldConfig", isSignal: true, isRequired: false, transformFunction: null }, form: { classPropertyName: "form", publicName: "form", isSignal: true, isRequired: true, transformFunction: null }, isValid: { classPropertyName: "isValid", publicName: "isValid", isSignal: true, isRequired: false, transformFunction: null }, isValueAssigned: { classPropertyName: "isValueAssigned", publicName: "isValueAssigned", isSignal: true, isRequired: false, transformFunction: null }, dataId: { classPropertyName: "dataId", publicName: "dataId", isSignal: true, isRequired: false, transformFunction: null }, customOrgUnitRoots: { classPropertyName: "customOrgUnitRoots", publicName: "customOrgUnitRoots", isSignal: true, isRequired: false, transformFunction: null }, optionCascadeConfigs: { classPropertyName: "optionCascadeConfigs", publicName: "optionCascadeConfigs", isSignal: true, isRequired: false, transformFunction: null }, optionCascadeConfigMap: { classPropertyName: "optionCascadeConfigMap", publicName: "optionCascadeConfigMap", isSignal: true, isRequired: false, transformFunction: null }, coordinatePickerGeoConfig: { classPropertyName: "coordinatePickerGeoConfig", publicName: "coordinatePickerGeoConfig", isSignal: true, isRequired: false, transformFunction: null }, fieldControlKeyById: { classPropertyName: "fieldControlKeyById", publicName: "fieldControlKeyById", isSignal: true, isRequired: false, transformFunction: null }, program: { classPropertyName: "program", publicName: "program", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { form: "formChange", value: "valueChange", update: "update", immediateUpdate: "immediateUpdate" }, usesInheritance: true, ngImport: i0 }); }
9344
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.1.3", type: BaseFormFieldComponent, isStandalone: true, inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: true, transformFunction: null }, fieldError: { classPropertyName: "fieldError", publicName: "fieldError", isSignal: true, isRequired: false, transformFunction: null }, fieldConfig: { classPropertyName: "fieldConfig", publicName: "fieldConfig", isSignal: true, isRequired: false, transformFunction: null }, programRuleOptions: { classPropertyName: "programRuleOptions", publicName: "programRuleOptions", isSignal: true, isRequired: false, transformFunction: null }, form: { classPropertyName: "form", publicName: "form", isSignal: true, isRequired: true, transformFunction: null }, isValid: { classPropertyName: "isValid", publicName: "isValid", isSignal: true, isRequired: false, transformFunction: null }, isValueAssigned: { classPropertyName: "isValueAssigned", publicName: "isValueAssigned", isSignal: true, isRequired: false, transformFunction: null }, dataId: { classPropertyName: "dataId", publicName: "dataId", isSignal: true, isRequired: false, transformFunction: null }, customOrgUnitRoots: { classPropertyName: "customOrgUnitRoots", publicName: "customOrgUnitRoots", isSignal: true, isRequired: false, transformFunction: null }, optionCascadeConfigs: { classPropertyName: "optionCascadeConfigs", publicName: "optionCascadeConfigs", isSignal: true, isRequired: false, transformFunction: null }, optionCascadeConfigMap: { classPropertyName: "optionCascadeConfigMap", publicName: "optionCascadeConfigMap", isSignal: true, isRequired: false, transformFunction: null }, coordinatePickerGeoConfig: { classPropertyName: "coordinatePickerGeoConfig", publicName: "coordinatePickerGeoConfig", isSignal: true, isRequired: false, transformFunction: null }, fieldControlKeyById: { classPropertyName: "fieldControlKeyById", publicName: "fieldControlKeyById", isSignal: true, isRequired: false, transformFunction: null }, program: { classPropertyName: "program", publicName: "program", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { form: "formChange", value: "valueChange", update: "update", immediateUpdate: "immediateUpdate" }, usesInheritance: true, ngImport: i0 }); }
9315
9345
  }
9316
9346
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: BaseFormFieldComponent, decorators: [{
9317
9347
  type: Directive
@@ -9358,6 +9388,7 @@ class FormFieldComponent {
9358
9388
  this.runtimeOptionChange = new EventEmitter();
9359
9389
  this.value = signal('', ...(ngDevMode ? [{ debugName: "value" }] : []));
9360
9390
  this.runtimeError = signal(undefined, ...(ngDevMode ? [{ debugName: "runtimeError" }] : []));
9391
+ this.programRuleOptions = signal(undefined, ...(ngDevMode ? [{ debugName: "programRuleOptions" }] : []));
9361
9392
  this._runtimeOptions = [];
9362
9393
  this.runtimeOptions = [];
9363
9394
  this.fieldFilterControl = new FormControl();
@@ -9394,6 +9425,7 @@ class FormFieldComponent {
9394
9425
  const fieldRuleActions = ruleActions.filter((ruleAction) => ruleAction.field === this.field().id);
9395
9426
  let runtimeError;
9396
9427
  let isValueAssigned = false;
9428
+ let hasProgramRuleOptions = false;
9397
9429
  fieldRuleActions.forEach((ruleAction) => {
9398
9430
  switch (ruleAction.actionType) {
9399
9431
  case 'ASSIGN': {
@@ -9417,10 +9449,18 @@ class FormFieldComponent {
9417
9449
  });
9418
9450
  break;
9419
9451
  }
9452
+ case 'SHOWOPTIONGROUP': {
9453
+ hasProgramRuleOptions = true;
9454
+ this.programRuleOptions.set(this.getProgramRuleOptions(ruleAction.options || []));
9455
+ break;
9456
+ }
9420
9457
  default:
9421
9458
  break;
9422
9459
  }
9423
9460
  });
9461
+ if (!hasProgramRuleOptions) {
9462
+ this.programRuleOptions.set(undefined);
9463
+ }
9424
9464
  this.runtimeError.set(runtimeError);
9425
9465
  this.isValueAssigned.set(isValueAssigned);
9426
9466
  }
@@ -9526,15 +9566,32 @@ class FormFieldComponent {
9526
9566
  }
9527
9567
  this.fieldUpdate.emit(this.form);
9528
9568
  }
9569
+ getDisplayField(field) {
9570
+ const options = this.programRuleOptions();
9571
+ return options ? { ...field, options } : field;
9572
+ }
9573
+ getProgramRuleOptions(ruleOptions) {
9574
+ const ruleOptionIds = new Set((ruleOptions || [])
9575
+ .map((option) => option?.id ?? option?.key)
9576
+ .filter(Boolean));
9577
+ const fieldOptions = this.field().options || [];
9578
+ if (ruleOptionIds.size === 0)
9579
+ return [];
9580
+ const optionsFromField = fieldOptions.filter((option) => ruleOptionIds.has(option?.key ?? option?.id));
9581
+ if (optionsFromField.length > 0) {
9582
+ return optionsFromField;
9583
+ }
9584
+ return [...ruleOptions].sort((a, b) => (a?.sortOrder ?? a?.order ?? 0) - (b?.sortOrder ?? b?.order ?? 0));
9585
+ }
9529
9586
  onUpdateRuntimeOptions(options) {
9530
9587
  this._runtimeOptions = [...options];
9531
9588
  }
9532
9589
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: FormFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
9533
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.3", type: FormFieldComponent, isStandalone: false, selector: "ng-dhis2-ui-form-field", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: true, transformFunction: null }, fieldConfig: { classPropertyName: "fieldConfig", publicName: "fieldConfig", isSignal: true, isRequired: true, transformFunction: null }, form: { classPropertyName: "form", publicName: "form", isSignal: false, isRequired: false, transformFunction: null }, isCheckBoxButton: { classPropertyName: "isCheckBoxButton", publicName: "isCheckBoxButton", isSignal: true, isRequired: false, transformFunction: null }, fieldClass: { classPropertyName: "fieldClass", publicName: "fieldClass", isSignal: true, isRequired: false, transformFunction: null }, programRuleActions: { classPropertyName: "programRuleActions", publicName: "programRuleActions", isSignal: true, isRequired: false, transformFunction: null }, dataEntities: { classPropertyName: "dataEntities", publicName: "dataEntities", isSignal: true, isRequired: false, transformFunction: null }, minDate: { classPropertyName: "minDate", publicName: "minDate", isSignal: true, isRequired: false, transformFunction: null }, maxDate: { classPropertyName: "maxDate", publicName: "maxDate", isSignal: true, isRequired: false, transformFunction: null }, dataId: { classPropertyName: "dataId", publicName: "dataId", isSignal: true, isRequired: false, transformFunction: null }, customOrgUnitRoots: { classPropertyName: "customOrgUnitRoots", publicName: "customOrgUnitRoots", isSignal: true, isRequired: false, transformFunction: null }, program: { classPropertyName: "program", publicName: "program", isSignal: true, isRequired: false, transformFunction: null }, optionCascadeConfigs: { classPropertyName: "optionCascadeConfigs", publicName: "optionCascadeConfigs", isSignal: true, isRequired: false, transformFunction: null }, optionCascadeConfigMap: { classPropertyName: "optionCascadeConfigMap", publicName: "optionCascadeConfigMap", isSignal: true, isRequired: false, transformFunction: null }, coordinatePickerGeoConfig: { classPropertyName: "coordinatePickerGeoConfig", publicName: "coordinatePickerGeoConfig", isSignal: true, isRequired: false, transformFunction: null }, fieldControlKeyById: { classPropertyName: "fieldControlKeyById", publicName: "fieldControlKeyById", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { fieldUpdate: "fieldUpdate", immediateFieldUpdate: "immediateFieldUpdate", runtimeOptionChange: "runtimeOptionChange" }, usesOnChanges: true, ngImport: i0, template: "@if (field(); as formField) {\n @let fieldError = runtimeError();\n @let isAssigned = isValueAssigned();\n @let fieldConfigValue = fieldConfig();\n @let cascadeConfigs = optionCascadeConfigs();\n @let entryFormCoordinatePickerGeoConfig = coordinatePickerGeoConfig();\n\n <div class=\"form-field-item\">\n <ng-dhis2-ui-form-field-item\n [field]=\"formField\"\n [fieldError]=\"fieldError\"\n [isValueAssigned]=\"isAssigned\"\n [fieldConfig]=\"fieldConfigValue\"\n [(form)]=\"form\"\n [dataId]=\"dataId()\"\n [customOrgUnitRoots]=\"customOrgUnitRoots()\"\n [optionCascadeConfigs]=\"cascadeConfigs\"\n [optionCascadeConfigMap]=\"optionCascadeConfigMap()\"\n [fieldControlKeyById]=\"fieldControlKeyById()\"\n [coordinatePickerGeoConfig]=\"entryFormCoordinatePickerGeoConfig\"\n [program]=\"program()\"\n [value]=\"value()\"\n (update)=\"onValueChange()\"\n (immediateUpdate)=\"onImmediateChange($event)\"\n />\n </div>\n}\n", styles: [".form-field-item{margin-bottom:16px}\n"], dependencies: [{ kind: "component", type: FormFieldItemComponent, selector: "ng-dhis2-ui-form-field-item" }] }); }
9590
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.3", type: FormFieldComponent, isStandalone: false, selector: "ng-dhis2-ui-form-field", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: true, transformFunction: null }, fieldConfig: { classPropertyName: "fieldConfig", publicName: "fieldConfig", isSignal: true, isRequired: true, transformFunction: null }, form: { classPropertyName: "form", publicName: "form", isSignal: false, isRequired: false, transformFunction: null }, isCheckBoxButton: { classPropertyName: "isCheckBoxButton", publicName: "isCheckBoxButton", isSignal: true, isRequired: false, transformFunction: null }, fieldClass: { classPropertyName: "fieldClass", publicName: "fieldClass", isSignal: true, isRequired: false, transformFunction: null }, programRuleActions: { classPropertyName: "programRuleActions", publicName: "programRuleActions", isSignal: true, isRequired: false, transformFunction: null }, dataEntities: { classPropertyName: "dataEntities", publicName: "dataEntities", isSignal: true, isRequired: false, transformFunction: null }, minDate: { classPropertyName: "minDate", publicName: "minDate", isSignal: true, isRequired: false, transformFunction: null }, maxDate: { classPropertyName: "maxDate", publicName: "maxDate", isSignal: true, isRequired: false, transformFunction: null }, dataId: { classPropertyName: "dataId", publicName: "dataId", isSignal: true, isRequired: false, transformFunction: null }, customOrgUnitRoots: { classPropertyName: "customOrgUnitRoots", publicName: "customOrgUnitRoots", isSignal: true, isRequired: false, transformFunction: null }, program: { classPropertyName: "program", publicName: "program", isSignal: true, isRequired: false, transformFunction: null }, optionCascadeConfigs: { classPropertyName: "optionCascadeConfigs", publicName: "optionCascadeConfigs", isSignal: true, isRequired: false, transformFunction: null }, optionCascadeConfigMap: { classPropertyName: "optionCascadeConfigMap", publicName: "optionCascadeConfigMap", isSignal: true, isRequired: false, transformFunction: null }, coordinatePickerGeoConfig: { classPropertyName: "coordinatePickerGeoConfig", publicName: "coordinatePickerGeoConfig", isSignal: true, isRequired: false, transformFunction: null }, fieldControlKeyById: { classPropertyName: "fieldControlKeyById", publicName: "fieldControlKeyById", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { fieldUpdate: "fieldUpdate", immediateFieldUpdate: "immediateFieldUpdate", runtimeOptionChange: "runtimeOptionChange" }, usesOnChanges: true, ngImport: i0, template: "@if (field(); as formField) {\n @let fieldError = runtimeError();\n @let isAssigned = isValueAssigned();\n @let fieldConfigValue = fieldConfig();\n @let cascadeConfigs = optionCascadeConfigs();\n @let entryFormCoordinatePickerGeoConfig = coordinatePickerGeoConfig();\n\n <div class=\"form-field-item\">\n <ng-dhis2-ui-form-field-item\n [field]=\"getDisplayField(formField)\"\n [fieldError]=\"fieldError\"\n [isValueAssigned]=\"isAssigned\"\n [fieldConfig]=\"fieldConfigValue\"\n [(form)]=\"form\"\n [programRuleOptions]=\"programRuleOptions()\"\n [dataId]=\"dataId()\"\n [customOrgUnitRoots]=\"customOrgUnitRoots()\"\n [optionCascadeConfigs]=\"cascadeConfigs\"\n [optionCascadeConfigMap]=\"optionCascadeConfigMap()\"\n [fieldControlKeyById]=\"fieldControlKeyById()\"\n [coordinatePickerGeoConfig]=\"entryFormCoordinatePickerGeoConfig\"\n [program]=\"program()\"\n [value]=\"value()\"\n (update)=\"onValueChange()\"\n (immediateUpdate)=\"onImmediateChange($event)\"\n />\n </div>\n}\n", styles: [".form-field-item{margin-bottom:16px}\n"], dependencies: [{ kind: "component", type: FormFieldItemComponent, selector: "ng-dhis2-ui-form-field-item" }] }); }
9534
9591
  }
9535
9592
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: FormFieldComponent, decorators: [{
9536
9593
  type: Component,
9537
- args: [{ selector: 'ng-dhis2-ui-form-field', standalone: false, template: "@if (field(); as formField) {\n @let fieldError = runtimeError();\n @let isAssigned = isValueAssigned();\n @let fieldConfigValue = fieldConfig();\n @let cascadeConfigs = optionCascadeConfigs();\n @let entryFormCoordinatePickerGeoConfig = coordinatePickerGeoConfig();\n\n <div class=\"form-field-item\">\n <ng-dhis2-ui-form-field-item\n [field]=\"formField\"\n [fieldError]=\"fieldError\"\n [isValueAssigned]=\"isAssigned\"\n [fieldConfig]=\"fieldConfigValue\"\n [(form)]=\"form\"\n [dataId]=\"dataId()\"\n [customOrgUnitRoots]=\"customOrgUnitRoots()\"\n [optionCascadeConfigs]=\"cascadeConfigs\"\n [optionCascadeConfigMap]=\"optionCascadeConfigMap()\"\n [fieldControlKeyById]=\"fieldControlKeyById()\"\n [coordinatePickerGeoConfig]=\"entryFormCoordinatePickerGeoConfig\"\n [program]=\"program()\"\n [value]=\"value()\"\n (update)=\"onValueChange()\"\n (immediateUpdate)=\"onImmediateChange($event)\"\n />\n </div>\n}\n", styles: [".form-field-item{margin-bottom:16px}\n"] }]
9594
+ args: [{ selector: 'ng-dhis2-ui-form-field', standalone: false, template: "@if (field(); as formField) {\n @let fieldError = runtimeError();\n @let isAssigned = isValueAssigned();\n @let fieldConfigValue = fieldConfig();\n @let cascadeConfigs = optionCascadeConfigs();\n @let entryFormCoordinatePickerGeoConfig = coordinatePickerGeoConfig();\n\n <div class=\"form-field-item\">\n <ng-dhis2-ui-form-field-item\n [field]=\"getDisplayField(formField)\"\n [fieldError]=\"fieldError\"\n [isValueAssigned]=\"isAssigned\"\n [fieldConfig]=\"fieldConfigValue\"\n [(form)]=\"form\"\n [programRuleOptions]=\"programRuleOptions()\"\n [dataId]=\"dataId()\"\n [customOrgUnitRoots]=\"customOrgUnitRoots()\"\n [optionCascadeConfigs]=\"cascadeConfigs\"\n [optionCascadeConfigMap]=\"optionCascadeConfigMap()\"\n [fieldControlKeyById]=\"fieldControlKeyById()\"\n [coordinatePickerGeoConfig]=\"entryFormCoordinatePickerGeoConfig\"\n [program]=\"program()\"\n [value]=\"value()\"\n (update)=\"onValueChange()\"\n (immediateUpdate)=\"onImmediateChange($event)\"\n />\n </div>\n}\n", styles: [".form-field-item{margin-bottom:16px}\n"] }]
9538
9595
  }], ctorParameters: () => [], propDecorators: { form: [{
9539
9596
  type: Input
9540
9597
  }], fieldUpdate: [{