@noatgnu/cupcake-vanilla 1.3.5 → 1.3.7
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.customOntologyFilters || 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,49 @@ 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 && (!o.customFilters || Object.keys(o.customFilters).length === 0));
|
|
4570
|
+
return index >= 0 ? index : 0;
|
|
4571
|
+
}
|
|
4572
|
+
console.log('[Column] Looking for ontology match:', {
|
|
4573
|
+
ontologyType,
|
|
4574
|
+
customFilters
|
|
4575
|
+
});
|
|
4576
|
+
// Handle both wrapped and unwrapped formats
|
|
4577
|
+
// Wrapped: {"ms_unique_vocabularies": {"term_type": "cell line"}}
|
|
4578
|
+
// Unwrapped: {"term_type": "cell line"}
|
|
4579
|
+
const actualFilters = customFilters[ontologyType] || customFilters;
|
|
4580
|
+
const matchingIndex = this.ontologyTypes.findIndex(opt => {
|
|
4581
|
+
if (opt.value !== ontologyType)
|
|
4582
|
+
return false;
|
|
4583
|
+
if (!opt.customFilters)
|
|
4584
|
+
return false;
|
|
4585
|
+
// Get the filter value from config (should be wrapped like {"ms_unique_vocabularies": {"term_type": "..."}})
|
|
4586
|
+
const optFilterValue = opt.customFilters[ontologyType];
|
|
4587
|
+
if (!optFilterValue)
|
|
4588
|
+
return false;
|
|
4589
|
+
const optFiltersJson = JSON.stringify(optFilterValue);
|
|
4590
|
+
const templateFiltersJson = JSON.stringify(actualFilters);
|
|
4591
|
+
const matches = optFiltersJson === templateFiltersJson;
|
|
4592
|
+
console.log('[Column] Comparing:', {
|
|
4593
|
+
label: opt.label,
|
|
4594
|
+
optFilters: optFilterValue,
|
|
4595
|
+
templateFilters: actualFilters,
|
|
4596
|
+
matches
|
|
4597
|
+
});
|
|
4598
|
+
return matches;
|
|
4599
|
+
});
|
|
4600
|
+
if (matchingIndex >= 0) {
|
|
4601
|
+
console.log('[Column] Found match at index:', matchingIndex, this.ontologyTypes[matchingIndex].label);
|
|
4602
|
+
}
|
|
4603
|
+
else {
|
|
4604
|
+
console.warn('[Column] No match found for:', { ontologyType, customFilters });
|
|
4605
|
+
}
|
|
4606
|
+
return matchingIndex >= 0 ? matchingIndex : 0;
|
|
4607
|
+
}
|
|
4566
4608
|
onSubmit() {
|
|
4567
4609
|
// For new columns, require either template or official column selection
|
|
4568
4610
|
if (!this.isEdit && !this.selectedTemplate && !this.selectedOfficialColumn) {
|
|
@@ -4715,28 +4757,22 @@ class ColumnEditModal {
|
|
|
4715
4757
|
const template = this.templates.find(t => t.id === Number(this.selectedTemplateId));
|
|
4716
4758
|
if (template) {
|
|
4717
4759
|
this.selectedTemplate = template;
|
|
4718
|
-
// Enable controls to update values, then disable again
|
|
4719
4760
|
this.editForm.get('name')?.enable();
|
|
4720
4761
|
this.editForm.get('type')?.enable();
|
|
4721
|
-
|
|
4722
|
-
const ontologyTypeIndex = template.ontologyType
|
|
4723
|
-
? this.ontologyTypes.findIndex(o => o.value === template.ontologyType)
|
|
4724
|
-
: 0;
|
|
4762
|
+
const ontologyTypeIndex = this.getOntologyTypeIndex(template.ontologyType, template.customOntologyFilters);
|
|
4725
4763
|
this.editForm.patchValue({
|
|
4726
4764
|
name: template.columnName,
|
|
4727
4765
|
type: template.columnType,
|
|
4728
4766
|
value: template.defaultValue || '',
|
|
4729
|
-
ontologyType: ontologyTypeIndex
|
|
4767
|
+
ontologyType: ontologyTypeIndex.toString(),
|
|
4730
4768
|
enableTypeahead: template.enableTypeahead || false,
|
|
4731
4769
|
mandatory: false,
|
|
4732
4770
|
hidden: false,
|
|
4733
4771
|
readonly: false,
|
|
4734
4772
|
notApplicable: false
|
|
4735
4773
|
});
|
|
4736
|
-
// Disable controls again
|
|
4737
4774
|
this.editForm.get('name')?.disable();
|
|
4738
4775
|
this.editForm.get('type')?.disable();
|
|
4739
|
-
// Mark form as touched to trigger validation display
|
|
4740
4776
|
Object.keys(this.editForm.controls).forEach(key => {
|
|
4741
4777
|
this.editForm.get(key)?.markAsTouched();
|
|
4742
4778
|
});
|
|
@@ -4926,29 +4962,23 @@ class ColumnEditModal {
|
|
|
4926
4962
|
swapToTemplate(template) {
|
|
4927
4963
|
this.selectedTemplate = template;
|
|
4928
4964
|
this.selectedTemplateId = template.id;
|
|
4929
|
-
// Update form with template data, preserving current value
|
|
4930
4965
|
const currentValue = this.editForm.get('value')?.value || '';
|
|
4931
|
-
// Enable controls to update values, then disable again
|
|
4932
4966
|
this.editForm.get('name')?.enable();
|
|
4933
4967
|
this.editForm.get('type')?.enable();
|
|
4934
|
-
const ontologyTypeIndex = template.ontologyType
|
|
4935
|
-
? this.ontologyTypes.findIndex(o => o.value === template.ontologyType)
|
|
4936
|
-
: 0;
|
|
4968
|
+
const ontologyTypeIndex = this.getOntologyTypeIndex(template.ontologyType, template.customOntologyFilters);
|
|
4937
4969
|
this.editForm.patchValue({
|
|
4938
4970
|
name: template.columnName,
|
|
4939
4971
|
type: template.columnType,
|
|
4940
4972
|
value: currentValue,
|
|
4941
|
-
ontologyType: ontologyTypeIndex
|
|
4973
|
+
ontologyType: ontologyTypeIndex.toString(),
|
|
4942
4974
|
enableTypeahead: template.enableTypeahead || false,
|
|
4943
4975
|
mandatory: this.editForm.get('mandatory')?.value || false,
|
|
4944
4976
|
hidden: this.editForm.get('hidden')?.value || false,
|
|
4945
4977
|
readonly: this.editForm.get('readonly')?.value || false,
|
|
4946
4978
|
notApplicable: this.editForm.get('notApplicable')?.value || false
|
|
4947
4979
|
});
|
|
4948
|
-
// Disable controls again
|
|
4949
4980
|
this.editForm.get('name')?.disable();
|
|
4950
4981
|
this.editForm.get('type')?.disable();
|
|
4951
|
-
// Mark form as touched
|
|
4952
4982
|
Object.keys(this.editForm.controls).forEach(key => {
|
|
4953
4983
|
this.editForm.get(key)?.markAsTouched();
|
|
4954
4984
|
});
|