@iapps/ng-dhis2-ui 1.3.2 → 1.3.4
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.
|
@@ -11317,7 +11317,6 @@ class BaseFormWrapperComponent {
|
|
|
11317
11317
|
this.formValidityUpdate.emit(isFormValid);
|
|
11318
11318
|
}
|
|
11319
11319
|
executeRules() {
|
|
11320
|
-
console.log(this.#updatedDataValues());
|
|
11321
11320
|
this.ruleActions.set(new ProgramRuleEngine()
|
|
11322
11321
|
.setRules(this.rules())
|
|
11323
11322
|
.setDataValues(this.#updatedDataValues())
|
|
@@ -11353,10 +11352,10 @@ class FlatFormComponent extends BaseFormWrapperComponent {
|
|
|
11353
11352
|
}
|
|
11354
11353
|
ngOnInit() {
|
|
11355
11354
|
this.formGroup = FormUtil.getFormGroup(this.fields(), this.dataValues());
|
|
11356
|
-
this.onFormUpdate();
|
|
11355
|
+
this.onFormUpdate(this.dataValues());
|
|
11357
11356
|
}
|
|
11358
|
-
onFormUpdate() {
|
|
11359
|
-
this.updateDataValues(this.formGroup.getRawValue());
|
|
11357
|
+
onFormUpdate(dataValues) {
|
|
11358
|
+
this.updateDataValues(dataValues ?? this.formGroup.getRawValue());
|
|
11360
11359
|
this.updateFormValidity(this.formGroup.valid);
|
|
11361
11360
|
}
|
|
11362
11361
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: FlatFormComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
@@ -12208,7 +12207,7 @@ class ProgramEntryFormFieldUtil {
|
|
|
12208
12207
|
return [...this.reportFields, ...fields];
|
|
12209
12208
|
}
|
|
12210
12209
|
#getDisabledStatus(field) {
|
|
12211
|
-
if (field?.generated) {
|
|
12210
|
+
if (field?.generated || this.config.disableForm) {
|
|
12212
12211
|
return true;
|
|
12213
12212
|
}
|
|
12214
12213
|
if (this.config.autoAssignedValues &&
|
|
@@ -12225,192 +12224,6 @@ class ProgramEntryFormFieldUtil {
|
|
|
12225
12224
|
}
|
|
12226
12225
|
}
|
|
12227
12226
|
|
|
12228
|
-
// Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
|
|
12229
|
-
// Use of this source code is governed by a BSD-style
|
|
12230
|
-
// license that can be found in the LICENSE file.
|
|
12231
|
-
class ProgramStageEntryFormSection {
|
|
12232
|
-
constructor(props) {
|
|
12233
|
-
this.formFields = [];
|
|
12234
|
-
this.orientation = 'HORIZONTAL';
|
|
12235
|
-
Object.assign(this, props);
|
|
12236
|
-
}
|
|
12237
|
-
}
|
|
12238
|
-
|
|
12239
|
-
class ProgramStageEntryFormSectionUtil {
|
|
12240
|
-
#sortedCanonicalStageFieldsCache = null;
|
|
12241
|
-
constructor(program, config) {
|
|
12242
|
-
this.program = program;
|
|
12243
|
-
this.config = config;
|
|
12244
|
-
this.fieldUtil = new ProgramEntryFormFieldUtil(program, config);
|
|
12245
|
-
}
|
|
12246
|
-
get programStageEntryFormSections() {
|
|
12247
|
-
const programStageId = this.#getStageIdFromConfig();
|
|
12248
|
-
if (!programStageId)
|
|
12249
|
-
return [];
|
|
12250
|
-
const programStage = this.#findStageById(programStageId);
|
|
12251
|
-
if (!programStage)
|
|
12252
|
-
return [];
|
|
12253
|
-
const sections = [];
|
|
12254
|
-
const basicDetailsFields = this.fieldUtil.eventReportFields;
|
|
12255
|
-
if (basicDetailsFields?.length) {
|
|
12256
|
-
sections.push(new ProgramStageEntryFormSection({
|
|
12257
|
-
id: `${programStage.id}_basic_information`,
|
|
12258
|
-
name: 'Basic Information',
|
|
12259
|
-
description: programStage.description ?? '',
|
|
12260
|
-
formFields: basicDetailsFields,
|
|
12261
|
-
orientation: 'VERTICAL',
|
|
12262
|
-
}));
|
|
12263
|
-
}
|
|
12264
|
-
const canonicalFieldsByDataElementId = this.#buildCanonicalStageFieldsByDataElementId(programStage);
|
|
12265
|
-
const programStageSections = programStage.programStageSections ?? [];
|
|
12266
|
-
for (const programStageSection of programStageSections) {
|
|
12267
|
-
const sectionFields = this.#mapStageSectionToFields(programStageSection, canonicalFieldsByDataElementId);
|
|
12268
|
-
if (!sectionFields.length)
|
|
12269
|
-
continue;
|
|
12270
|
-
sections.push(new ProgramStageEntryFormSection({
|
|
12271
|
-
id: programStageSection.id,
|
|
12272
|
-
name: programStageSection.displayName ?? programStageSection.name ?? '',
|
|
12273
|
-
description: programStageSection.description ?? '',
|
|
12274
|
-
formFields: sectionFields,
|
|
12275
|
-
orientation: 'HORIZONTAL',
|
|
12276
|
-
}));
|
|
12277
|
-
}
|
|
12278
|
-
return sections;
|
|
12279
|
-
}
|
|
12280
|
-
// ---------------------------
|
|
12281
|
-
// Canonical stage fields
|
|
12282
|
-
// ---------------------------
|
|
12283
|
-
#buildCanonicalStageFieldsByDataElementId(programStage) {
|
|
12284
|
-
const programStageDataElements = programStage.programStageDataElements ?? [];
|
|
12285
|
-
const fieldsByDataElementId = new Map();
|
|
12286
|
-
for (let i = 0; i < programStageDataElements.length; i++) {
|
|
12287
|
-
const programStageDataElement = programStageDataElements[i];
|
|
12288
|
-
const canonicalField = this.#mapProgramStageDataElementToField(programStageDataElement, programStage.id);
|
|
12289
|
-
if (!canonicalField?.id)
|
|
12290
|
-
continue;
|
|
12291
|
-
fieldsByDataElementId.set(canonicalField.id, canonicalField);
|
|
12292
|
-
}
|
|
12293
|
-
this.#sortedCanonicalStageFieldsCache = null;
|
|
12294
|
-
return fieldsByDataElementId;
|
|
12295
|
-
}
|
|
12296
|
-
// ---------------------------
|
|
12297
|
-
// Map a stage section using canonical fields (like program sections)
|
|
12298
|
-
// ---------------------------
|
|
12299
|
-
#mapStageSectionToFields(programStageSection, canonicalFieldsByDataElementId) {
|
|
12300
|
-
const sectionDataElements = programStageSection.dataElements;
|
|
12301
|
-
const sectionDataElementIdsFromAlt = programStageSection?.dataElementsIds ??
|
|
12302
|
-
undefined;
|
|
12303
|
-
const sectionDataElementIds = (sectionDataElements?.length
|
|
12304
|
-
? sectionDataElements.map((d) => d?.id).filter(Boolean)
|
|
12305
|
-
: sectionDataElementIdsFromAlt?.filter(Boolean)) ?? [];
|
|
12306
|
-
if (sectionDataElementIds.length > 0) {
|
|
12307
|
-
const sectionFields = [];
|
|
12308
|
-
for (let index = 0; index < sectionDataElementIds.length; index++) {
|
|
12309
|
-
const dataElementId = sectionDataElementIds[index];
|
|
12310
|
-
const canonicalField = canonicalFieldsByDataElementId.get(dataElementId);
|
|
12311
|
-
if (!canonicalField)
|
|
12312
|
-
continue;
|
|
12313
|
-
sectionFields.push({
|
|
12314
|
-
...canonicalField,
|
|
12315
|
-
order: index + 1,
|
|
12316
|
-
});
|
|
12317
|
-
}
|
|
12318
|
-
return sectionFields;
|
|
12319
|
-
}
|
|
12320
|
-
return this.#getSortedCanonicalStageFields(canonicalFieldsByDataElementId);
|
|
12321
|
-
}
|
|
12322
|
-
#getSortedCanonicalStageFields(canonicalFieldsByDataElementId) {
|
|
12323
|
-
const cache = this.#sortedCanonicalStageFieldsCache;
|
|
12324
|
-
if (cache?.sourceMap === canonicalFieldsByDataElementId) {
|
|
12325
|
-
return cache.sortedFields;
|
|
12326
|
-
}
|
|
12327
|
-
const sortedFields = Array.from(canonicalFieldsByDataElementId.values());
|
|
12328
|
-
sortedFields.sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
12329
|
-
this.#sortedCanonicalStageFieldsCache = {
|
|
12330
|
-
sourceMap: canonicalFieldsByDataElementId,
|
|
12331
|
-
sortedFields,
|
|
12332
|
-
};
|
|
12333
|
-
return sortedFields;
|
|
12334
|
-
}
|
|
12335
|
-
// ---------------------------
|
|
12336
|
-
// Map a programStageDataElement => canonical form field
|
|
12337
|
-
// ---------------------------
|
|
12338
|
-
#mapProgramStageDataElementToField(programStageDataElement, programStageId) {
|
|
12339
|
-
const dataElementDefinition = programStageDataElement?.dataElement;
|
|
12340
|
-
if (!dataElementDefinition?.id)
|
|
12341
|
-
return null;
|
|
12342
|
-
const fieldBaseConfig = {
|
|
12343
|
-
id: dataElementDefinition.id,
|
|
12344
|
-
code: dataElementDefinition.code,
|
|
12345
|
-
formName: dataElementDefinition.formName,
|
|
12346
|
-
name: dataElementDefinition.displayName ?? dataElementDefinition.name ?? '',
|
|
12347
|
-
description: dataElementDefinition.description,
|
|
12348
|
-
mandatory: !!programStageDataElement.compulsory,
|
|
12349
|
-
valueType: dataElementDefinition.valueType,
|
|
12350
|
-
sortOrder: programStageDataElement.sortOrder,
|
|
12351
|
-
stepId: programStageId,
|
|
12352
|
-
allowFutureDate: programStageDataElement.allowFutureDate,
|
|
12353
|
-
optionSet: dataElementDefinition.optionSet,
|
|
12354
|
-
};
|
|
12355
|
-
const dropdownOptions = FieldDropdown.getDropdownOptions(fieldBaseConfig);
|
|
12356
|
-
const hasSelectableOptions = (dropdownOptions?.length ?? 0) > 0;
|
|
12357
|
-
const fieldExtension = this.config.formFieldExtensions?.find((extension) => extension?.id === fieldBaseConfig.id);
|
|
12358
|
-
const autoAssignedValue = this.#getAutoAssignedValue(fieldBaseConfig);
|
|
12359
|
-
if (!isUndefined(autoAssignedValue) &&
|
|
12360
|
-
this.config.hideCustomAssignedFields) {
|
|
12361
|
-
return null;
|
|
12362
|
-
}
|
|
12363
|
-
return new FormField({
|
|
12364
|
-
...fieldBaseConfig,
|
|
12365
|
-
label: fieldBaseConfig.formName || fieldBaseConfig.name,
|
|
12366
|
-
key: fieldBaseConfig.code
|
|
12367
|
-
? camelCase(fieldBaseConfig.code)
|
|
12368
|
-
: fieldBaseConfig.id,
|
|
12369
|
-
required: fieldBaseConfig.mandatory,
|
|
12370
|
-
type: FieldUtil.getFieldType(fieldBaseConfig.valueType),
|
|
12371
|
-
options: dropdownOptions,
|
|
12372
|
-
disabled: this.#getDisabledStatus(fieldBaseConfig),
|
|
12373
|
-
order: fieldBaseConfig.sortOrder,
|
|
12374
|
-
hasOptions: hasSelectableOptions,
|
|
12375
|
-
controlType: FieldUtil.getFieldControlType(fieldBaseConfig.valueType, hasSelectableOptions),
|
|
12376
|
-
extension: fieldExtension,
|
|
12377
|
-
});
|
|
12378
|
-
}
|
|
12379
|
-
// ---------------------------
|
|
12380
|
-
// Stage selection helpers
|
|
12381
|
-
// ---------------------------
|
|
12382
|
-
#getStageIdFromConfig() {
|
|
12383
|
-
const programStageRef = this.config?.programStage;
|
|
12384
|
-
if (!programStageRef)
|
|
12385
|
-
return null;
|
|
12386
|
-
if (typeof programStageRef === 'string' && programStageRef.trim()) {
|
|
12387
|
-
return programStageRef.trim();
|
|
12388
|
-
}
|
|
12389
|
-
const candidateId = programStageRef.id ??
|
|
12390
|
-
programStageRef.stageId ??
|
|
12391
|
-
programStageRef.programStageId ??
|
|
12392
|
-
programStageRef.value?.id ??
|
|
12393
|
-
null;
|
|
12394
|
-
return typeof candidateId === 'string' && candidateId.trim()
|
|
12395
|
-
? candidateId.trim()
|
|
12396
|
-
: null;
|
|
12397
|
-
}
|
|
12398
|
-
#findStageById(programStageId) {
|
|
12399
|
-
return ((this.program.programStages ?? []).find((stage) => stage?.id === programStageId) ?? null);
|
|
12400
|
-
}
|
|
12401
|
-
// ---------------------------
|
|
12402
|
-
// Extension hooks
|
|
12403
|
-
// ---------------------------
|
|
12404
|
-
#getAutoAssignedValue(field) {
|
|
12405
|
-
const impl = this?.['#getAutoAssignedValue'];
|
|
12406
|
-
return typeof impl === 'function' ? impl.call(this, field) : undefined;
|
|
12407
|
-
}
|
|
12408
|
-
#getDisabledStatus(field) {
|
|
12409
|
-
const impl = this?.['#getDisabledStatus'];
|
|
12410
|
-
return typeof impl === 'function' ? impl.call(this, field) : false;
|
|
12411
|
-
}
|
|
12412
|
-
}
|
|
12413
|
-
|
|
12414
12227
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
12415
12228
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
12416
12229
|
// Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
|
|
@@ -12725,6 +12538,195 @@ class ProgramEntryFormSectionUtil {
|
|
|
12725
12538
|
}
|
|
12726
12539
|
}
|
|
12727
12540
|
|
|
12541
|
+
// Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
|
|
12542
|
+
// Use of this source code is governed by a BSD-style
|
|
12543
|
+
// license that can be found in the LICENSE file.
|
|
12544
|
+
class ProgramStageEntryFormSection {
|
|
12545
|
+
constructor(props) {
|
|
12546
|
+
this.formFields = [];
|
|
12547
|
+
this.orientation = 'HORIZONTAL';
|
|
12548
|
+
Object.assign(this, props);
|
|
12549
|
+
}
|
|
12550
|
+
}
|
|
12551
|
+
|
|
12552
|
+
class ProgramStageEntryFormSectionUtil {
|
|
12553
|
+
#sortedCanonicalStageFieldsCache = null;
|
|
12554
|
+
constructor(program, config) {
|
|
12555
|
+
this.program = program;
|
|
12556
|
+
this.config = config;
|
|
12557
|
+
this.fieldUtil = new ProgramEntryFormFieldUtil(program, config);
|
|
12558
|
+
}
|
|
12559
|
+
get programStageEntryFormSections() {
|
|
12560
|
+
const programStageId = this.#getStageIdFromConfig();
|
|
12561
|
+
if (!programStageId)
|
|
12562
|
+
return [];
|
|
12563
|
+
const programStage = this.#findStageById(programStageId);
|
|
12564
|
+
if (!programStage)
|
|
12565
|
+
return [];
|
|
12566
|
+
const sections = [];
|
|
12567
|
+
const basicDetailsFields = this.fieldUtil.eventReportFields;
|
|
12568
|
+
if (basicDetailsFields?.length) {
|
|
12569
|
+
sections.push(new ProgramStageEntryFormSection({
|
|
12570
|
+
id: `${programStage.id}_basic_information`,
|
|
12571
|
+
name: 'Basic Information',
|
|
12572
|
+
description: programStage.description ?? '',
|
|
12573
|
+
formFields: basicDetailsFields,
|
|
12574
|
+
orientation: 'VERTICAL',
|
|
12575
|
+
}));
|
|
12576
|
+
}
|
|
12577
|
+
const canonicalFieldsByDataElementId = this.#buildCanonicalStageFieldsByDataElementId(programStage);
|
|
12578
|
+
const programStageSections = programStage.programStageSections ?? [];
|
|
12579
|
+
for (const programStageSection of programStageSections) {
|
|
12580
|
+
const sectionFields = this.#mapStageSectionToFields(programStageSection, canonicalFieldsByDataElementId);
|
|
12581
|
+
if (!sectionFields.length)
|
|
12582
|
+
continue;
|
|
12583
|
+
sections.push(new ProgramStageEntryFormSection({
|
|
12584
|
+
id: programStageSection.id,
|
|
12585
|
+
name: programStageSection.displayName ?? programStageSection.name ?? '',
|
|
12586
|
+
description: programStageSection.description ?? '',
|
|
12587
|
+
formFields: sectionFields,
|
|
12588
|
+
orientation: 'HORIZONTAL',
|
|
12589
|
+
}));
|
|
12590
|
+
}
|
|
12591
|
+
return sections;
|
|
12592
|
+
}
|
|
12593
|
+
// ---------------------------
|
|
12594
|
+
// Canonical stage fields
|
|
12595
|
+
// ---------------------------
|
|
12596
|
+
#buildCanonicalStageFieldsByDataElementId(programStage) {
|
|
12597
|
+
const programStageDataElements = programStage.programStageDataElements ?? [];
|
|
12598
|
+
const fieldsByDataElementId = new Map();
|
|
12599
|
+
for (let i = 0; i < programStageDataElements.length; i++) {
|
|
12600
|
+
const programStageDataElement = programStageDataElements[i];
|
|
12601
|
+
const canonicalField = this.#mapProgramStageDataElementToField(programStageDataElement, programStage.id);
|
|
12602
|
+
if (!canonicalField?.id)
|
|
12603
|
+
continue;
|
|
12604
|
+
fieldsByDataElementId.set(canonicalField.id, canonicalField);
|
|
12605
|
+
}
|
|
12606
|
+
this.#sortedCanonicalStageFieldsCache = null;
|
|
12607
|
+
return fieldsByDataElementId;
|
|
12608
|
+
}
|
|
12609
|
+
// ---------------------------
|
|
12610
|
+
// Map a stage section using canonical fields (like program sections)
|
|
12611
|
+
// ---------------------------
|
|
12612
|
+
#mapStageSectionToFields(programStageSection, canonicalFieldsByDataElementId) {
|
|
12613
|
+
const sectionDataElements = programStageSection.dataElements;
|
|
12614
|
+
const sectionDataElementIdsFromAlt = programStageSection?.dataElementsIds ??
|
|
12615
|
+
undefined;
|
|
12616
|
+
const sectionDataElementIds = (sectionDataElements?.length
|
|
12617
|
+
? sectionDataElements.map((d) => d?.id).filter(Boolean)
|
|
12618
|
+
: sectionDataElementIdsFromAlt?.filter(Boolean)) ?? [];
|
|
12619
|
+
if (sectionDataElementIds.length > 0) {
|
|
12620
|
+
const sectionFields = [];
|
|
12621
|
+
for (let index = 0; index < sectionDataElementIds.length; index++) {
|
|
12622
|
+
const dataElementId = sectionDataElementIds[index];
|
|
12623
|
+
const canonicalField = canonicalFieldsByDataElementId.get(dataElementId);
|
|
12624
|
+
if (!canonicalField)
|
|
12625
|
+
continue;
|
|
12626
|
+
sectionFields.push({
|
|
12627
|
+
...canonicalField,
|
|
12628
|
+
order: index + 1,
|
|
12629
|
+
});
|
|
12630
|
+
}
|
|
12631
|
+
return sectionFields;
|
|
12632
|
+
}
|
|
12633
|
+
return this.#getSortedCanonicalStageFields(canonicalFieldsByDataElementId);
|
|
12634
|
+
}
|
|
12635
|
+
#getSortedCanonicalStageFields(canonicalFieldsByDataElementId) {
|
|
12636
|
+
const cache = this.#sortedCanonicalStageFieldsCache;
|
|
12637
|
+
if (cache?.sourceMap === canonicalFieldsByDataElementId) {
|
|
12638
|
+
return cache.sortedFields;
|
|
12639
|
+
}
|
|
12640
|
+
const sortedFields = Array.from(canonicalFieldsByDataElementId.values());
|
|
12641
|
+
sortedFields.sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
12642
|
+
this.#sortedCanonicalStageFieldsCache = {
|
|
12643
|
+
sourceMap: canonicalFieldsByDataElementId,
|
|
12644
|
+
sortedFields,
|
|
12645
|
+
};
|
|
12646
|
+
return sortedFields;
|
|
12647
|
+
}
|
|
12648
|
+
// ---------------------------
|
|
12649
|
+
// Map a programStageDataElement => canonical form field
|
|
12650
|
+
// ---------------------------
|
|
12651
|
+
#mapProgramStageDataElementToField(programStageDataElement, programStageId) {
|
|
12652
|
+
const dataElementDefinition = programStageDataElement?.dataElement;
|
|
12653
|
+
if (!dataElementDefinition?.id)
|
|
12654
|
+
return null;
|
|
12655
|
+
const fieldBaseConfig = {
|
|
12656
|
+
id: dataElementDefinition.id,
|
|
12657
|
+
code: dataElementDefinition.code,
|
|
12658
|
+
formName: dataElementDefinition.formName,
|
|
12659
|
+
name: dataElementDefinition.displayName ?? dataElementDefinition.name ?? '',
|
|
12660
|
+
description: dataElementDefinition.description,
|
|
12661
|
+
mandatory: !!programStageDataElement.compulsory,
|
|
12662
|
+
valueType: dataElementDefinition.valueType,
|
|
12663
|
+
sortOrder: programStageDataElement.sortOrder,
|
|
12664
|
+
stepId: programStageId,
|
|
12665
|
+
allowFutureDate: programStageDataElement.allowFutureDate,
|
|
12666
|
+
optionSet: dataElementDefinition.optionSet,
|
|
12667
|
+
};
|
|
12668
|
+
const dropdownOptions = FieldDropdown.getDropdownOptions(fieldBaseConfig);
|
|
12669
|
+
const hasSelectableOptions = (dropdownOptions?.length ?? 0) > 0;
|
|
12670
|
+
const fieldExtension = this.config.formFieldExtensions?.find((extension) => extension?.id === fieldBaseConfig.id);
|
|
12671
|
+
const autoAssignedValue = this.#getAutoAssignedValue(fieldBaseConfig);
|
|
12672
|
+
if (!isUndefined(autoAssignedValue) &&
|
|
12673
|
+
this.config.hideCustomAssignedFields) {
|
|
12674
|
+
return null;
|
|
12675
|
+
}
|
|
12676
|
+
return new FormField({
|
|
12677
|
+
...fieldBaseConfig,
|
|
12678
|
+
label: fieldBaseConfig.formName || fieldBaseConfig.name,
|
|
12679
|
+
key: fieldBaseConfig.code
|
|
12680
|
+
? camelCase(fieldBaseConfig.code)
|
|
12681
|
+
: fieldBaseConfig.id,
|
|
12682
|
+
required: fieldBaseConfig.mandatory,
|
|
12683
|
+
type: FieldUtil.getFieldType(fieldBaseConfig.valueType),
|
|
12684
|
+
options: dropdownOptions,
|
|
12685
|
+
disabled: this.#getDisabledStatus(fieldBaseConfig),
|
|
12686
|
+
order: fieldBaseConfig.sortOrder,
|
|
12687
|
+
hasOptions: hasSelectableOptions,
|
|
12688
|
+
controlType: FieldUtil.getFieldControlType(fieldBaseConfig.valueType, hasSelectableOptions),
|
|
12689
|
+
extension: fieldExtension,
|
|
12690
|
+
});
|
|
12691
|
+
}
|
|
12692
|
+
// ---------------------------
|
|
12693
|
+
// Stage selection helpers
|
|
12694
|
+
// ---------------------------
|
|
12695
|
+
#getStageIdFromConfig() {
|
|
12696
|
+
const programStageRef = this.config?.programStage;
|
|
12697
|
+
if (!programStageRef)
|
|
12698
|
+
return null;
|
|
12699
|
+
if (typeof programStageRef === 'string' && programStageRef.trim()) {
|
|
12700
|
+
return programStageRef.trim();
|
|
12701
|
+
}
|
|
12702
|
+
const candidateId = programStageRef.id ??
|
|
12703
|
+
programStageRef.stageId ??
|
|
12704
|
+
programStageRef.programStageId ??
|
|
12705
|
+
programStageRef.value?.id ??
|
|
12706
|
+
null;
|
|
12707
|
+
return typeof candidateId === 'string' && candidateId.trim()
|
|
12708
|
+
? candidateId.trim()
|
|
12709
|
+
: null;
|
|
12710
|
+
}
|
|
12711
|
+
#findStageById(programStageId) {
|
|
12712
|
+
return ((this.program.programStages ?? []).find((stage) => stage?.id === programStageId) ?? null);
|
|
12713
|
+
}
|
|
12714
|
+
// ---------------------------
|
|
12715
|
+
// Extension hooks
|
|
12716
|
+
// ---------------------------
|
|
12717
|
+
#getAutoAssignedValue(field) {
|
|
12718
|
+
const impl = this?.['#getAutoAssignedValue'];
|
|
12719
|
+
return typeof impl === 'function' ? impl.call(this, field) : undefined;
|
|
12720
|
+
}
|
|
12721
|
+
#getDisabledStatus(field) {
|
|
12722
|
+
if (this.config?.disableForm) {
|
|
12723
|
+
return true;
|
|
12724
|
+
}
|
|
12725
|
+
const impl = this?.['#getDisabledStatus'];
|
|
12726
|
+
return typeof impl === 'function' ? impl.call(this, field) : false;
|
|
12727
|
+
}
|
|
12728
|
+
}
|
|
12729
|
+
|
|
12728
12730
|
// Copyright 2025 UDSM DHIS2 Lab. All rights reserved.
|
|
12729
12731
|
// Use of this source code is governed by a BSD-style
|
|
12730
12732
|
// license that can be found in the LICENSE file.
|
|
@@ -12762,6 +12764,9 @@ class ProgramEntryFormMetaData {
|
|
|
12762
12764
|
return this.autoAssignedFieldIdSet;
|
|
12763
12765
|
}
|
|
12764
12766
|
shouldDisableField(field) {
|
|
12767
|
+
if (this.config?.disableForm) {
|
|
12768
|
+
return true;
|
|
12769
|
+
}
|
|
12765
12770
|
const fieldIdentifiers = this.getFieldIdentifiers(field);
|
|
12766
12771
|
if (!fieldIdentifiers.length) {
|
|
12767
12772
|
return false;
|
|
@@ -12802,96 +12807,36 @@ class ProgramEntryFormMetaData {
|
|
|
12802
12807
|
.with(this.d2.programModule.trackedEntityTypeAttribute.select([
|
|
12803
12808
|
'trackedEntityAttribute',
|
|
12804
12809
|
])), 'ToOne')
|
|
12805
|
-
.with(this
|
|
12806
|
-
.
|
|
12807
|
-
|
|
12808
|
-
|
|
12809
|
-
|
|
12810
|
-
|
|
12810
|
+
.with(this.#getProgramRuleVariableQuery())
|
|
12811
|
+
.byId(program);
|
|
12812
|
+
// if (!this.config.programStage) {
|
|
12813
|
+
programQuery.with(this.#getProgramTrackedEntityAttributeQuery());
|
|
12814
|
+
// }
|
|
12815
|
+
// if (this.config.displayType === 'FLAT') {
|
|
12816
|
+
programQuery.with(this.#getProgramSectionQuery());
|
|
12817
|
+
// }
|
|
12818
|
+
programQuery.with(this.#getProgramStageQuery());
|
|
12819
|
+
return programQuery.get({ useIndexDb: true });
|
|
12820
|
+
}
|
|
12821
|
+
#getProgramRuleVariableQuery() {
|
|
12822
|
+
return this.d2.programModule.programRuleVariable
|
|
12823
|
+
.with(this.d2.dataElementModule.dataElement.select(['id', 'code', 'name']), 'ToOne')
|
|
12811
12824
|
.with(this.d2.programModule.trackedEntityAttribute.select([
|
|
12812
12825
|
'id',
|
|
12813
12826
|
'code',
|
|
12814
12827
|
'name',
|
|
12815
|
-
]), 'ToOne')
|
|
12816
|
-
.byId(program);
|
|
12817
|
-
if (!this.config.programStage) {
|
|
12818
|
-
programQuery.with(this.d2.programModule.programTrackedEntityAttribute.with(this.d2.programModule.trackedEntityAttribute.with(this.d2.optionSetModule.optionSet.with(this.d2.optionSetModule.option), 'ToOne'), 'ToOne'));
|
|
12819
|
-
}
|
|
12820
|
-
if (this.config.displayType === 'FLAT') {
|
|
12821
|
-
programQuery.with(this.d2.programModule.programSection.with(this.d2.programModule.trackedEntityAttribute.select(['id'])));
|
|
12822
|
-
}
|
|
12823
|
-
if (!this.config.excludeProgramStages || this.config.programStage) {
|
|
12824
|
-
const programStageQuery = this.d2.programModule.programStage
|
|
12825
|
-
.with(this.d2.programModule.programStageSection)
|
|
12826
|
-
.with(this.d2.programModule.programStageDataElement.with(this.d2.dataElementModule.dataElement.with(this.d2.optionSetModule.optionSet.with(this.d2.optionSetModule.option), 'ToOne'), 'ToOne'));
|
|
12827
|
-
programQuery.with(programStageQuery);
|
|
12828
|
-
}
|
|
12829
|
-
return programQuery.get();
|
|
12828
|
+
]), 'ToOne');
|
|
12830
12829
|
}
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
|
|
12834
|
-
|
|
12835
|
-
|
|
12836
|
-
|
|
12837
|
-
|
|
12838
|
-
|
|
12839
|
-
|
|
12840
|
-
|
|
12841
|
-
value: program,
|
|
12842
|
-
})
|
|
12843
|
-
.with(this.d2.programModule.programRuleAction
|
|
12844
|
-
.select([
|
|
12845
|
-
'id',
|
|
12846
|
-
'programRuleActionType',
|
|
12847
|
-
'data',
|
|
12848
|
-
'programRule',
|
|
12849
|
-
'displayContent',
|
|
12850
|
-
'content',
|
|
12851
|
-
])
|
|
12852
|
-
.with(this.d2.dataElementModule.dataElement.select([
|
|
12853
|
-
'id',
|
|
12854
|
-
'code',
|
|
12855
|
-
'name',
|
|
12856
|
-
'description',
|
|
12857
|
-
]), 'ToOne')
|
|
12858
|
-
.with(this.d2.programModule.trackedEntityAttribute.select([
|
|
12859
|
-
'id',
|
|
12860
|
-
'code',
|
|
12861
|
-
'name',
|
|
12862
|
-
'description',
|
|
12863
|
-
]), 'ToOne')
|
|
12864
|
-
.with(this.d2.programModule.programSection.select([
|
|
12865
|
-
'id',
|
|
12866
|
-
'code',
|
|
12867
|
-
'name',
|
|
12868
|
-
'description',
|
|
12869
|
-
]), 'ToOne')
|
|
12870
|
-
.with(this.d2.programModule.programStageSection.select([
|
|
12871
|
-
'id',
|
|
12872
|
-
'code',
|
|
12873
|
-
'name',
|
|
12874
|
-
'description',
|
|
12875
|
-
]), 'ToOne')
|
|
12876
|
-
.with(this.d2.optionSetModule.optionGroup
|
|
12877
|
-
.select(['id'])
|
|
12878
|
-
.with(this.d2.optionSetModule.option.select([
|
|
12879
|
-
'id',
|
|
12880
|
-
'code',
|
|
12881
|
-
'displayName',
|
|
12882
|
-
]), 'ToMany'), 'ToOne')
|
|
12883
|
-
.with(this.d2.optionSetModule.option.select([
|
|
12884
|
-
'id',
|
|
12885
|
-
'code',
|
|
12886
|
-
'displayName',
|
|
12887
|
-
]), 'ToOne'))
|
|
12888
|
-
.paginate(new Pager({ paging: false }))
|
|
12889
|
-
.get(),
|
|
12890
|
-
]);
|
|
12891
|
-
const [programResponse, programRuleResponse] = metaDataResponse;
|
|
12892
|
-
const metaData = programResponse.data;
|
|
12893
|
-
metaData.programRules = programRuleResponse.data;
|
|
12894
|
-
return metaData;
|
|
12830
|
+
#getProgramSectionQuery() {
|
|
12831
|
+
return this.d2.programModule.programSection.with(this.d2.programModule.trackedEntityAttribute.select(['id']));
|
|
12832
|
+
}
|
|
12833
|
+
#getProgramTrackedEntityAttributeQuery() {
|
|
12834
|
+
return this.d2.programModule.programTrackedEntityAttribute.with(this.d2.programModule.trackedEntityAttribute.with(this.d2.optionSetModule.optionSet.with(this.d2.optionSetModule.option), 'ToOne'), 'ToOne');
|
|
12835
|
+
}
|
|
12836
|
+
#getProgramStageQuery() {
|
|
12837
|
+
return this.d2.programModule.programStage
|
|
12838
|
+
.with(this.d2.programModule.programStageSection)
|
|
12839
|
+
.with(this.d2.programModule.programStageDataElement.with(this.d2.dataElementModule.dataElement.with(this.d2.optionSetModule.optionSet.with(this.d2.optionSetModule.option), 'ToOne'), 'ToOne'));
|
|
12895
12840
|
}
|
|
12896
12841
|
get formFields() {
|
|
12897
12842
|
if (!this.program) {
|
|
@@ -12903,7 +12848,11 @@ class ProgramEntryFormMetaData {
|
|
|
12903
12848
|
if (!autoAssigned?.length) {
|
|
12904
12849
|
return fields;
|
|
12905
12850
|
}
|
|
12906
|
-
return fields.map((field) =>
|
|
12851
|
+
return fields.map((field) => {
|
|
12852
|
+
return this.shouldDisableField(field)
|
|
12853
|
+
? this.withDisabledFlags(field)
|
|
12854
|
+
: field;
|
|
12855
|
+
});
|
|
12907
12856
|
}
|
|
12908
12857
|
// get sections(): IProgramEntryFormSection[] {
|
|
12909
12858
|
// if (!this.program) {
|
|
@@ -13030,7 +12979,7 @@ class ProgramEntryFormMetaData {
|
|
|
13030
12979
|
}
|
|
13031
12980
|
async #getCustomFieldConfigurations() {
|
|
13032
12981
|
try {
|
|
13033
|
-
const response = await this.d2.httpInstance.get('dataStore/field-extensions?fields=id,fieldOptionsDependsOn,optionSet&paging=false');
|
|
12982
|
+
const response = await this.d2.httpInstance.get('dataStore/field-extensions?fields=id,fieldOptionsDependsOn,optionSet&paging=false', { useIndexDb: true });
|
|
13034
12983
|
const responseData = response?.data;
|
|
13035
12984
|
const entries = Array.isArray(responseData)
|
|
13036
12985
|
? responseData
|
|
@@ -13054,11 +13003,14 @@ class ProgramEntryFormMetaData {
|
|
|
13054
13003
|
}
|
|
13055
13004
|
async get() {
|
|
13056
13005
|
try {
|
|
13057
|
-
const program = await
|
|
13006
|
+
const program = await window?.d2Web?.trackerModule?.trackedEntity
|
|
13007
|
+
?.setProgram(this.config?.program)
|
|
13008
|
+
?.getMetaData();
|
|
13058
13009
|
if (program) {
|
|
13059
13010
|
this.program = program;
|
|
13060
|
-
|
|
13061
|
-
|
|
13011
|
+
// TODO FIND ANOTHER WAY TO PASS IN CUSTOM FIELD CONFIGURATIONS, AVOID TIGHT COUPLING HERE
|
|
13012
|
+
// this.customFieldConfigurations =
|
|
13013
|
+
// await this.#getCustomFieldConfigurations();
|
|
13062
13014
|
if (this.config?.formFieldExtensions &&
|
|
13063
13015
|
this.config.formFieldExtensions.length > 0 &&
|
|
13064
13016
|
this.config.formFieldExtensions[0]?.optionsSourceCode) {
|
|
@@ -13116,6 +13068,8 @@ class ProgramEntryFormModule {
|
|
|
13116
13068
|
this.isFormValid$ = toObservable(this.isFormValid);
|
|
13117
13069
|
this.instance = signal(null, /* @ts-ignore */
|
|
13118
13070
|
...(ngDevMode ? [{ debugName: "instance" }] : /* istanbul ignore next */ []));
|
|
13071
|
+
this.trackedEntityInstance = signal(null, /* @ts-ignore */
|
|
13072
|
+
...(ngDevMode ? [{ debugName: "trackedEntityInstance" }] : /* istanbul ignore next */ []));
|
|
13119
13073
|
this.preprocess = input(/* @ts-ignore */
|
|
13120
13074
|
...(ngDevMode ? [undefined, { debugName: "preprocess" }] : /* istanbul ignore next */ []));
|
|
13121
13075
|
this.instanceSave = new EventEmitter();
|
|
@@ -13136,6 +13090,22 @@ class ProgramEntryFormModule {
|
|
|
13136
13090
|
return undefined;
|
|
13137
13091
|
}, /* @ts-ignore */
|
|
13138
13092
|
...(ngDevMode ? [{ debugName: "dataId" }] : /* istanbul ignore next */ []));
|
|
13093
|
+
this.dataEntities = computed(() => {
|
|
13094
|
+
if (!this.instance()) {
|
|
13095
|
+
return {};
|
|
13096
|
+
}
|
|
13097
|
+
const trackedEntity = this.trackedEntityInstance();
|
|
13098
|
+
const attributeValues = Object.keys(trackedEntity?.attributeEntities ?? {}).reduce((acc, key) => {
|
|
13099
|
+
acc[key] = trackedEntity?.attributeEntities?.[key]?.value;
|
|
13100
|
+
return acc;
|
|
13101
|
+
}, {});
|
|
13102
|
+
return {
|
|
13103
|
+
...attributeValues,
|
|
13104
|
+
...(trackedEntity?.reportEntities ?? {}),
|
|
13105
|
+
...(this.instance() || {}),
|
|
13106
|
+
};
|
|
13107
|
+
}, /* @ts-ignore */
|
|
13108
|
+
...(ngDevMode ? [{ debugName: "dataEntities" }] : /* istanbul ignore next */ []));
|
|
13139
13109
|
this.FormActionButtons = computed(() => {
|
|
13140
13110
|
if (this.config().hideActionButtons) {
|
|
13141
13111
|
return React__default.createElement(React__default.Fragment, null);
|
|
@@ -13160,7 +13130,7 @@ class ProgramEntryFormModule {
|
|
|
13160
13130
|
});
|
|
13161
13131
|
};
|
|
13162
13132
|
return (React__default.createElement(ButtonStrip$1, null,
|
|
13163
|
-
!this.config().hideSubmitButton && (React__default.createElement(Button$1, { primary: true, disabled: !isValid, loading: submitting, onClick: onSave }, this.config().submitButtonLabel)),
|
|
13133
|
+
!(this.config().hideSubmitButton || this.config().disableForm) && (React__default.createElement(Button$1, { primary: true, disabled: !isValid, loading: submitting, onClick: onSave }, this.config().submitButtonLabel)),
|
|
13164
13134
|
!this.config().hideCancelButton && (React__default.createElement(Button$1, { onClick: () => {
|
|
13165
13135
|
this.ngZone.run(() => {
|
|
13166
13136
|
this.onCancel();
|
|
@@ -13233,44 +13203,6 @@ class ProgramEntryFormModule {
|
|
|
13233
13203
|
}
|
|
13234
13204
|
return configuredKey;
|
|
13235
13205
|
}
|
|
13236
|
-
// #updateInstanceWithAutoAssignedValues(
|
|
13237
|
-
// autoAssignedValues: AutoAssignedValues[]
|
|
13238
|
-
// ) {
|
|
13239
|
-
// const assignedDataValues = autoAssignedValues.reduce(
|
|
13240
|
-
// (entities, assignedValue) => {
|
|
13241
|
-
// return {
|
|
13242
|
-
// ...entities,
|
|
13243
|
-
// [assignedValue.field]: assignedValue.value,
|
|
13244
|
-
// };
|
|
13245
|
-
// },
|
|
13246
|
-
// {}
|
|
13247
|
-
// );
|
|
13248
|
-
// this.#updateInstance(assignedDataValues);
|
|
13249
|
-
// }
|
|
13250
|
-
// #updateInstanceWithAutoAssignedValues(
|
|
13251
|
-
// autoAssignedValues: AutoAssignedValues[]
|
|
13252
|
-
// ) {
|
|
13253
|
-
// const valueCount = autoAssignedValues?.length ?? 0;
|
|
13254
|
-
// if (valueCount === 0) {
|
|
13255
|
-
// return;
|
|
13256
|
-
// }
|
|
13257
|
-
// const metaData = this.metaData();
|
|
13258
|
-
// const aggregatedValues: Record<string, unknown> = {};
|
|
13259
|
-
// for (let index = 0; index < valueCount; index++) {
|
|
13260
|
-
// const { field: configuredKey, value } = autoAssignedValues[index];
|
|
13261
|
-
// const semanticKey = metaData
|
|
13262
|
-
// ? this.#resolveFieldRuntimeId(configuredKey, metaData)
|
|
13263
|
-
// : configuredKey;
|
|
13264
|
-
// aggregatedValues[semanticKey] = value;
|
|
13265
|
-
// if (configuredKey !== semanticKey) {
|
|
13266
|
-
// aggregatedValues[configuredKey] = value;
|
|
13267
|
-
// }
|
|
13268
|
-
// }
|
|
13269
|
-
// if (Object.keys(aggregatedValues).length === 0) {
|
|
13270
|
-
// return;
|
|
13271
|
-
// }
|
|
13272
|
-
// this.#updateInstance(aggregatedValues);
|
|
13273
|
-
// }
|
|
13274
13206
|
#updateInstanceWithAutoAssignedValues(autoAssignedValues) {
|
|
13275
13207
|
const trackedEntityId = this.trackedEntity?.();
|
|
13276
13208
|
if (typeof trackedEntityId === 'string' &&
|
|
@@ -13298,21 +13230,6 @@ class ProgramEntryFormModule {
|
|
|
13298
13230
|
}
|
|
13299
13231
|
this.#updateInstance(aggregatedValues);
|
|
13300
13232
|
}
|
|
13301
|
-
// #updateInstance(dataValues: Record<string, unknown>) {
|
|
13302
|
-
// this.instance.update((instance) => {
|
|
13303
|
-
// instance?.updateDataValues(dataValues, this.config().updateTeiOrgUnit);
|
|
13304
|
-
// return instance;
|
|
13305
|
-
// });
|
|
13306
|
-
// }
|
|
13307
|
-
// #updateInstance(dataValues: Record<string, unknown>) {
|
|
13308
|
-
// this.instance.update((instance) => {
|
|
13309
|
-
// if (!instance) {
|
|
13310
|
-
// return instance;
|
|
13311
|
-
// }
|
|
13312
|
-
// instance.updateDataValues(dataValues, this.config().updateTeiOrgUnit);
|
|
13313
|
-
// return instance;
|
|
13314
|
-
// });
|
|
13315
|
-
// }
|
|
13316
13233
|
#updateInstance(dataValues) {
|
|
13317
13234
|
if (!dataValues || Object.keys(dataValues).length === 0) {
|
|
13318
13235
|
return;
|
|
@@ -13343,7 +13260,8 @@ class ProgramEntryFormModule {
|
|
|
13343
13260
|
if (this.config().autoComplete) {
|
|
13344
13261
|
this.instance().complete();
|
|
13345
13262
|
}
|
|
13346
|
-
|
|
13263
|
+
const instanceQuery = this.#getQuery('TRACKER');
|
|
13264
|
+
return instanceQuery
|
|
13347
13265
|
.setData(this.instance())
|
|
13348
13266
|
.save();
|
|
13349
13267
|
}
|
|
@@ -13351,9 +13269,8 @@ class ProgramEntryFormModule {
|
|
|
13351
13269
|
if (this.config().autoComplete) {
|
|
13352
13270
|
this.instance().complete();
|
|
13353
13271
|
}
|
|
13354
|
-
|
|
13355
|
-
|
|
13356
|
-
.save();
|
|
13272
|
+
const instanceQuery = this.#getQuery('EVENT');
|
|
13273
|
+
return instanceQuery.setData(this.instance()).save();
|
|
13357
13274
|
}
|
|
13358
13275
|
default:
|
|
13359
13276
|
return firstValueFrom(of(null));
|
|
@@ -13371,65 +13288,78 @@ class ProgramEntryFormModule {
|
|
|
13371
13288
|
});
|
|
13372
13289
|
return instance;
|
|
13373
13290
|
}
|
|
13374
|
-
|
|
13291
|
+
#getQuery(instanceType) {
|
|
13375
13292
|
const d2 = window.d2Web;
|
|
13376
|
-
|
|
13377
|
-
|
|
13378
|
-
|
|
13379
|
-
|
|
13293
|
+
switch (instanceType) {
|
|
13294
|
+
case 'TRACKER':
|
|
13295
|
+
return d2.trackerModule.trackedEntity
|
|
13296
|
+
.setProgram(this.config().program)
|
|
13297
|
+
.setOrgUnit(this.orgUnit());
|
|
13298
|
+
case 'EVENT':
|
|
13299
|
+
return d2.eventModule.event
|
|
13300
|
+
.setProgram(this.config().program)
|
|
13301
|
+
.setProgramStage(this.config().programStage)
|
|
13302
|
+
.setEnrollment(this.enrollment())
|
|
13303
|
+
.setTrackedEntity(this.trackedEntity())
|
|
13304
|
+
.setOrgUnit(this.orgUnit());
|
|
13305
|
+
default:
|
|
13306
|
+
throw new Error('Invalid form type');
|
|
13307
|
+
}
|
|
13308
|
+
}
|
|
13309
|
+
async #getTrackerInstance() {
|
|
13310
|
+
const instanceQuery = this.#getQuery('TRACKER');
|
|
13311
|
+
if (!instanceQuery) {
|
|
13380
13312
|
throw new Error('Could not initialize tracker query');
|
|
13381
13313
|
}
|
|
13382
13314
|
if (!this.trackedEntity()) {
|
|
13383
|
-
return await
|
|
13315
|
+
return await instanceQuery.create();
|
|
13384
13316
|
}
|
|
13385
|
-
const instanceResult = (await this.
|
|
13386
|
-
.setTrackedEntity(this.trackedEntity())
|
|
13387
|
-
.get()).data;
|
|
13317
|
+
const instanceResult = (await instanceQuery.setTrackedEntity(this.trackedEntity()).get()).data;
|
|
13388
13318
|
if (!instanceResult) {
|
|
13389
|
-
return await
|
|
13319
|
+
return await instanceQuery.create();
|
|
13390
13320
|
}
|
|
13391
|
-
|
|
13392
|
-
const instance = await
|
|
13321
|
+
instanceQuery.setInstanceFields(this.metaData()?.program);
|
|
13322
|
+
const instance = await instanceQuery.setReservedValues();
|
|
13393
13323
|
if (this.orgUnit()) {
|
|
13394
13324
|
instance.setOrgUnit(this.orgUnit());
|
|
13395
13325
|
}
|
|
13396
13326
|
return instance;
|
|
13397
13327
|
}
|
|
13398
13328
|
async #getEventInstance() {
|
|
13399
|
-
|
|
13400
|
-
.setProgram(this.config().program)
|
|
13401
|
-
.setProgramStage(this.config().programStage)
|
|
13402
|
-
.setEnrollment(this.enrollment())
|
|
13403
|
-
.setTrackedEntity(this.trackedEntity())
|
|
13404
|
-
.setOrgUnit(this.orgUnit());
|
|
13329
|
+
const instanceQuery = this.#getQuery('EVENT');
|
|
13405
13330
|
if (!this.event()) {
|
|
13406
|
-
return await
|
|
13331
|
+
return await instanceQuery.create();
|
|
13407
13332
|
}
|
|
13408
|
-
const instance = (await
|
|
13333
|
+
const instance = (await instanceQuery.setEvent(this.event()).get()).data;
|
|
13409
13334
|
if (!instance) {
|
|
13410
|
-
return await
|
|
13335
|
+
return await instanceQuery.create();
|
|
13411
13336
|
}
|
|
13412
13337
|
if (this.metaData()?.program) {
|
|
13413
13338
|
instance.setFields(this.metaData().program);
|
|
13414
13339
|
}
|
|
13415
13340
|
return instance;
|
|
13416
13341
|
}
|
|
13417
|
-
#getInstance() {
|
|
13342
|
+
async #getInstance() {
|
|
13418
13343
|
switch (this.config().formType) {
|
|
13419
13344
|
case 'TRACKER':
|
|
13420
13345
|
return this.#getTrackerInstance();
|
|
13421
|
-
case 'EVENT':
|
|
13346
|
+
case 'EVENT': {
|
|
13347
|
+
if (this.trackedEntity()) {
|
|
13348
|
+
const trackedEntityInstance = await this.#getTrackerInstance();
|
|
13349
|
+
this.trackedEntityInstance.set(trackedEntityInstance);
|
|
13350
|
+
}
|
|
13422
13351
|
return this.#getEventInstance();
|
|
13352
|
+
}
|
|
13423
13353
|
default:
|
|
13424
13354
|
return firstValueFrom(of(null));
|
|
13425
13355
|
}
|
|
13426
13356
|
}
|
|
13427
13357
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: ProgramEntryFormModule, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
13428
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: ProgramEntryFormModule, isStandalone: true, selector: "ng-dhis2-ui-program-entry-form", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null }, trackedEntity: { classPropertyName: "trackedEntity", publicName: "trackedEntity", isSignal: true, isRequired: false, transformFunction: null }, event: { classPropertyName: "event", publicName: "event", isSignal: true, isRequired: false, transformFunction: null }, enrollment: { classPropertyName: "enrollment", publicName: "enrollment", isSignal: true, isRequired: false, transformFunction: null }, orgUnit: { classPropertyName: "orgUnit", publicName: "orgUnit", isSignal: true, isRequired: false, transformFunction: null }, codeGeneratorOrgUnit: { classPropertyName: "codeGeneratorOrgUnit", publicName: "codeGeneratorOrgUnit", isSignal: true, isRequired: false, transformFunction: null }, customOrgUnitRoots: { classPropertyName: "customOrgUnitRoots", publicName: "customOrgUnitRoots", isSignal: true, isRequired: false, transformFunction: null }, formMetaData: { classPropertyName: "formMetaData", publicName: "formMetaData", isSignal: true, isRequired: false, transformFunction: null }, collapsibleSections: { classPropertyName: "collapsibleSections", publicName: "collapsibleSections", isSignal: true, isRequired: false, transformFunction: null }, preprocess: { classPropertyName: "preprocess", publicName: "preprocess", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { instanceSave: "instanceSave", instanceSaveCompleted: "instanceSaveCompleted", instanceUpdate: "instanceUpdate", formValidityUpdate: "formValidityUpdate", formCancel: "formCancel" }, ngImport: i0, template: "@if (loading()) {\n<div className=\"program-entry__form-loader\">\n <ng-dhis2-ui-wrapper [component]=\"FormLoader\" />\n</div>\n} @else if(metaData()) {\n\n<div>\n <!-- Form content -->\n @switch (config().displayType) {\n\n <!-- Flat display -->\n @case ('FLAT') {\n
|
|
13358
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: ProgramEntryFormModule, isStandalone: true, selector: "ng-dhis2-ui-program-entry-form", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null }, trackedEntity: { classPropertyName: "trackedEntity", publicName: "trackedEntity", isSignal: true, isRequired: false, transformFunction: null }, event: { classPropertyName: "event", publicName: "event", isSignal: true, isRequired: false, transformFunction: null }, enrollment: { classPropertyName: "enrollment", publicName: "enrollment", isSignal: true, isRequired: false, transformFunction: null }, orgUnit: { classPropertyName: "orgUnit", publicName: "orgUnit", isSignal: true, isRequired: false, transformFunction: null }, codeGeneratorOrgUnit: { classPropertyName: "codeGeneratorOrgUnit", publicName: "codeGeneratorOrgUnit", isSignal: true, isRequired: false, transformFunction: null }, customOrgUnitRoots: { classPropertyName: "customOrgUnitRoots", publicName: "customOrgUnitRoots", isSignal: true, isRequired: false, transformFunction: null }, formMetaData: { classPropertyName: "formMetaData", publicName: "formMetaData", isSignal: true, isRequired: false, transformFunction: null }, collapsibleSections: { classPropertyName: "collapsibleSections", publicName: "collapsibleSections", isSignal: true, isRequired: false, transformFunction: null }, preprocess: { classPropertyName: "preprocess", publicName: "preprocess", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { instanceSave: "instanceSave", instanceSaveCompleted: "instanceSaveCompleted", instanceUpdate: "instanceUpdate", formValidityUpdate: "formValidityUpdate", formCancel: "formCancel" }, ngImport: i0, template: "@if (loading()) {\n<div className=\"program-entry__form-loader\">\n <ng-dhis2-ui-wrapper [component]=\"FormLoader\" />\n</div>\n} @else if(metaData()) {\n\n<div>\n <!-- Form content -->\n @switch (config().displayType) {\n\n <!-- Flat display -->\n @case ('FLAT') {\n <ng-dhis2-ui-flat-form\n [programEntryFormConfig]=\"config()\"\n [optionCascadeConfigs]=\"config().optionCascadeConfigs || []\"\n [collapsibleSections]=\"collapsibleSections()\"\n [programEntryFormMetaData]=\"metaData()!\"\n [name]=\"metaData()!.name\"\n [dataValues]=\"dataEntities()\"\n [dataId]=\"dataId()\"\n [rules]=\"metaData()!.rules\"\n [fields]=\"metaData()!.formFields\"\n [customOrgUnitRoots]=\"customOrgUnitRoots()\"\n [coordinatePickerGeoConfig]=\"config().coordinatePickerGeoConfig\"\n (formUpdate)=\"onFormUpdate($event)\"\n (formValidityUpdate)=\"onValidityUpdate($event)\"\n />\n\n <!-- <ng-dhis2-ui-flat-form\n [name]=\"metaData()!.name\"\n [dataValues]=\"instance() || {}\"\n [dataId]=\"dataId()\"\n [rules]=\"metaData()!.rules\"\n [fields]=\"metaData()!.formFields\"\n [customOrgUnitRoots]=\"customOrgUnitRoots()\"\n [program]=\"config().program\"\n (formUpdate)=\"onFormUpdate($event)\"\n (formValidityUpdate)=\"onValidityUpdate($event)\"\n /> -->\n }\n\n <!-- SECTION display -->\n @case ('SECTION') { Section form }\n\n <!-- CUSTOM FORM -->\n @case ('CUSTOM') { } }\n\n <!-- Action buttons -->\n\n @if(!config().hideActionButtons) {\n <ng-dhis2-ui-wrapper [component]=\"FormActionButtons()\" />\n }\n</div>\n}\n", styles: ["::ng-deep .program-entry__form-loader{padding:8px}\n"], dependencies: [{ kind: "ngmodule", type: D2FormModule }, { kind: "component", type: FlatFormComponent, selector: "ng-dhis2-ui-flat-form", inputs: ["collapsibleSections", "programEntryFormConfig", "optionCascadeConfigs"] }, { kind: "directive", type: ReactWrapperModule, selector: "ng-dhis2-ui-wrapper", inputs: ["props", "component"] }], changeDetection: i0.ChangeDetectionStrategy.Eager }); }
|
|
13429
13359
|
}
|
|
13430
13360
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: ProgramEntryFormModule, decorators: [{
|
|
13431
13361
|
type: Component,
|
|
13432
|
-
args: [{ selector: 'ng-dhis2-ui-program-entry-form', changeDetection: ChangeDetectionStrategy.Eager, imports: [D2FormModule, ReactWrapperModule], template: "@if (loading()) {\n<div className=\"program-entry__form-loader\">\n <ng-dhis2-ui-wrapper [component]=\"FormLoader\" />\n</div>\n} @else if(metaData()) {\n\n<div>\n <!-- Form content -->\n @switch (config().displayType) {\n\n <!-- Flat display -->\n @case ('FLAT') {\n
|
|
13362
|
+
args: [{ selector: 'ng-dhis2-ui-program-entry-form', changeDetection: ChangeDetectionStrategy.Eager, imports: [D2FormModule, ReactWrapperModule], template: "@if (loading()) {\n<div className=\"program-entry__form-loader\">\n <ng-dhis2-ui-wrapper [component]=\"FormLoader\" />\n</div>\n} @else if(metaData()) {\n\n<div>\n <!-- Form content -->\n @switch (config().displayType) {\n\n <!-- Flat display -->\n @case ('FLAT') {\n <ng-dhis2-ui-flat-form\n [programEntryFormConfig]=\"config()\"\n [optionCascadeConfigs]=\"config().optionCascadeConfigs || []\"\n [collapsibleSections]=\"collapsibleSections()\"\n [programEntryFormMetaData]=\"metaData()!\"\n [name]=\"metaData()!.name\"\n [dataValues]=\"dataEntities()\"\n [dataId]=\"dataId()\"\n [rules]=\"metaData()!.rules\"\n [fields]=\"metaData()!.formFields\"\n [customOrgUnitRoots]=\"customOrgUnitRoots()\"\n [coordinatePickerGeoConfig]=\"config().coordinatePickerGeoConfig\"\n (formUpdate)=\"onFormUpdate($event)\"\n (formValidityUpdate)=\"onValidityUpdate($event)\"\n />\n\n <!-- <ng-dhis2-ui-flat-form\n [name]=\"metaData()!.name\"\n [dataValues]=\"instance() || {}\"\n [dataId]=\"dataId()\"\n [rules]=\"metaData()!.rules\"\n [fields]=\"metaData()!.formFields\"\n [customOrgUnitRoots]=\"customOrgUnitRoots()\"\n [program]=\"config().program\"\n (formUpdate)=\"onFormUpdate($event)\"\n (formValidityUpdate)=\"onValidityUpdate($event)\"\n /> -->\n }\n\n <!-- SECTION display -->\n @case ('SECTION') { Section form }\n\n <!-- CUSTOM FORM -->\n @case ('CUSTOM') { } }\n\n <!-- Action buttons -->\n\n @if(!config().hideActionButtons) {\n <ng-dhis2-ui-wrapper [component]=\"FormActionButtons()\" />\n }\n</div>\n}\n", styles: ["::ng-deep .program-entry__form-loader{padding:8px}\n"] }]
|
|
13433
13363
|
}], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], trackedEntity: [{ type: i0.Input, args: [{ isSignal: true, alias: "trackedEntity", required: false }] }], event: [{ type: i0.Input, args: [{ isSignal: true, alias: "event", required: false }] }], enrollment: [{ type: i0.Input, args: [{ isSignal: true, alias: "enrollment", required: false }] }], orgUnit: [{ type: i0.Input, args: [{ isSignal: true, alias: "orgUnit", required: false }] }], codeGeneratorOrgUnit: [{ type: i0.Input, args: [{ isSignal: true, alias: "codeGeneratorOrgUnit", required: false }] }], customOrgUnitRoots: [{ type: i0.Input, args: [{ isSignal: true, alias: "customOrgUnitRoots", required: false }] }], formMetaData: [{ type: i0.Input, args: [{ isSignal: true, alias: "formMetaData", required: false }] }], collapsibleSections: [{ type: i0.Input, args: [{ isSignal: true, alias: "collapsibleSections", required: false }] }], preprocess: [{ type: i0.Input, args: [{ isSignal: true, alias: "preprocess", required: false }] }], instanceSave: [{
|
|
13434
13364
|
type: Output
|
|
13435
13365
|
}], instanceSaveCompleted: [{
|