@noatgnu/cupcake-vanilla 1.3.5 → 1.3.6
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.
|
@@ -4545,14 +4545,13 @@ class ColumnEditModal {
|
|
|
4545
4545
|
}
|
|
4546
4546
|
populateForm() {
|
|
4547
4547
|
if (this.column) {
|
|
4548
|
-
const
|
|
4549
|
-
|
|
4550
|
-
: 0;
|
|
4548
|
+
const customFilters = this.column.ontologyOptions || undefined;
|
|
4549
|
+
const ontologyTypeIndex = this.getOntologyTypeIndex(this.column.ontologyType, customFilters);
|
|
4551
4550
|
this.editForm.patchValue({
|
|
4552
4551
|
name: this.column.name,
|
|
4553
4552
|
type: this.getCorrectedColumnType(this.column.name, this.column.type),
|
|
4554
4553
|
value: this.column.value || '',
|
|
4555
|
-
ontologyType: ontologyTypeIndex
|
|
4554
|
+
ontologyType: ontologyTypeIndex.toString(),
|
|
4556
4555
|
enableTypeahead: this.column.enableTypeahead || false,
|
|
4557
4556
|
mandatory: this.column.mandatory || false,
|
|
4558
4557
|
hidden: this.column.hidden || false,
|
|
@@ -4563,6 +4562,30 @@ class ColumnEditModal {
|
|
|
4563
4562
|
});
|
|
4564
4563
|
}
|
|
4565
4564
|
}
|
|
4565
|
+
getOntologyTypeIndex(ontologyType, customFilters) {
|
|
4566
|
+
if (!ontologyType)
|
|
4567
|
+
return 0;
|
|
4568
|
+
if (!customFilters || Object.keys(customFilters).length === 0) {
|
|
4569
|
+
const index = this.ontologyTypes.findIndex(o => o.value === ontologyType);
|
|
4570
|
+
return index >= 0 ? index : 0;
|
|
4571
|
+
}
|
|
4572
|
+
const matchingIndex = this.ontologyTypes.findIndex(opt => {
|
|
4573
|
+
if (opt.value !== ontologyType)
|
|
4574
|
+
return false;
|
|
4575
|
+
if (!opt.customFilters)
|
|
4576
|
+
return false;
|
|
4577
|
+
const optFilterKey = Object.keys(opt.customFilters)[0];
|
|
4578
|
+
const templateFilterKey = Object.keys(customFilters)[0];
|
|
4579
|
+
if (optFilterKey !== templateFilterKey)
|
|
4580
|
+
return false;
|
|
4581
|
+
const optFilterValue = opt.customFilters[optFilterKey];
|
|
4582
|
+
const templateFilterValue = customFilters[templateFilterKey];
|
|
4583
|
+
const optTermType = optFilterValue?.['term_type'];
|
|
4584
|
+
const templateTermType = templateFilterValue?.['term_type'];
|
|
4585
|
+
return optTermType === templateTermType;
|
|
4586
|
+
});
|
|
4587
|
+
return matchingIndex >= 0 ? matchingIndex : 0;
|
|
4588
|
+
}
|
|
4566
4589
|
onSubmit() {
|
|
4567
4590
|
// For new columns, require either template or official column selection
|
|
4568
4591
|
if (!this.isEdit && !this.selectedTemplate && !this.selectedOfficialColumn) {
|
|
@@ -4715,28 +4738,22 @@ class ColumnEditModal {
|
|
|
4715
4738
|
const template = this.templates.find(t => t.id === Number(this.selectedTemplateId));
|
|
4716
4739
|
if (template) {
|
|
4717
4740
|
this.selectedTemplate = template;
|
|
4718
|
-
// Enable controls to update values, then disable again
|
|
4719
4741
|
this.editForm.get('name')?.enable();
|
|
4720
4742
|
this.editForm.get('type')?.enable();
|
|
4721
|
-
|
|
4722
|
-
const ontologyTypeIndex = template.ontologyType
|
|
4723
|
-
? this.ontologyTypes.findIndex(o => o.value === template.ontologyType)
|
|
4724
|
-
: 0;
|
|
4743
|
+
const ontologyTypeIndex = this.getOntologyTypeIndex(template.ontologyType, template.customOntologyFilters);
|
|
4725
4744
|
this.editForm.patchValue({
|
|
4726
4745
|
name: template.columnName,
|
|
4727
4746
|
type: template.columnType,
|
|
4728
4747
|
value: template.defaultValue || '',
|
|
4729
|
-
ontologyType: ontologyTypeIndex
|
|
4748
|
+
ontologyType: ontologyTypeIndex.toString(),
|
|
4730
4749
|
enableTypeahead: template.enableTypeahead || false,
|
|
4731
4750
|
mandatory: false,
|
|
4732
4751
|
hidden: false,
|
|
4733
4752
|
readonly: false,
|
|
4734
4753
|
notApplicable: false
|
|
4735
4754
|
});
|
|
4736
|
-
// Disable controls again
|
|
4737
4755
|
this.editForm.get('name')?.disable();
|
|
4738
4756
|
this.editForm.get('type')?.disable();
|
|
4739
|
-
// Mark form as touched to trigger validation display
|
|
4740
4757
|
Object.keys(this.editForm.controls).forEach(key => {
|
|
4741
4758
|
this.editForm.get(key)?.markAsTouched();
|
|
4742
4759
|
});
|
|
@@ -4926,29 +4943,23 @@ class ColumnEditModal {
|
|
|
4926
4943
|
swapToTemplate(template) {
|
|
4927
4944
|
this.selectedTemplate = template;
|
|
4928
4945
|
this.selectedTemplateId = template.id;
|
|
4929
|
-
// Update form with template data, preserving current value
|
|
4930
4946
|
const currentValue = this.editForm.get('value')?.value || '';
|
|
4931
|
-
// Enable controls to update values, then disable again
|
|
4932
4947
|
this.editForm.get('name')?.enable();
|
|
4933
4948
|
this.editForm.get('type')?.enable();
|
|
4934
|
-
const ontologyTypeIndex = template.ontologyType
|
|
4935
|
-
? this.ontologyTypes.findIndex(o => o.value === template.ontologyType)
|
|
4936
|
-
: 0;
|
|
4949
|
+
const ontologyTypeIndex = this.getOntologyTypeIndex(template.ontologyType, template.customOntologyFilters);
|
|
4937
4950
|
this.editForm.patchValue({
|
|
4938
4951
|
name: template.columnName,
|
|
4939
4952
|
type: template.columnType,
|
|
4940
4953
|
value: currentValue,
|
|
4941
|
-
ontologyType: ontologyTypeIndex
|
|
4954
|
+
ontologyType: ontologyTypeIndex.toString(),
|
|
4942
4955
|
enableTypeahead: template.enableTypeahead || false,
|
|
4943
4956
|
mandatory: this.editForm.get('mandatory')?.value || false,
|
|
4944
4957
|
hidden: this.editForm.get('hidden')?.value || false,
|
|
4945
4958
|
readonly: this.editForm.get('readonly')?.value || false,
|
|
4946
4959
|
notApplicable: this.editForm.get('notApplicable')?.value || false
|
|
4947
4960
|
});
|
|
4948
|
-
// Disable controls again
|
|
4949
4961
|
this.editForm.get('name')?.disable();
|
|
4950
4962
|
this.editForm.get('type')?.disable();
|
|
4951
|
-
// Mark form as touched
|
|
4952
4963
|
Object.keys(this.editForm.controls).forEach(key => {
|
|
4953
4964
|
this.editForm.get(key)?.markAsTouched();
|
|
4954
4965
|
});
|