diff --git a/src/app/core/config/config.model.ts b/src/app/core/config/config.model.ts index 595e41367..11c7fd61b 100644 --- a/src/app/core/config/config.model.ts +++ b/src/app/core/config/config.model.ts @@ -82,6 +82,7 @@ export interface Config { useApprovalAPI?: boolean; dummyWhoami?: Auth; enableStructureFeatures?: boolean; + StructureFeaturePriority?: Array; structureEditSearch?: boolean; } diff --git a/src/app/core/substance-form/structure/substance-form-structure-card.component.ts b/src/app/core/substance-form/structure/substance-form-structure-card.component.ts index 665f43bcc..dc7225643 100644 --- a/src/app/core/substance-form/structure/substance-form-structure-card.component.ts +++ b/src/app/core/substance-form/structure/substance-form-structure-card.component.ts @@ -47,6 +47,16 @@ export class SubstanceFormStructureCardComponent extends SubstanceFormBase imple featuresOnly = false; hideFeaturesTable = false; structureEditSearch = true; + StructureFeaturePriority = [ + 'Category Score', + 'Sum Of Scores', + 'AI Limit (US)', + 'Potency Category', + 'Potency Score', + 'type', + 'Type', + 'TYPE' + ]; @ViewChild(StructureEditorComponent) structureEditorComponent!: StructureEditorComponent; constructor( @@ -76,6 +86,13 @@ export class SubstanceFormStructureCardComponent extends SubstanceFormBase imple this.configService.configData.structureEditSearch !== null)) { this.structureEditSearch = this.configService.configData.structureEditSearch; } + + if (this.configService.configData && + (this.configService.configData.StructureFeaturePriority !== undefined && + this.configService.configData.StructureFeaturePriority !== null)) { + this.StructureFeaturePriority = this.configService.configData.StructureFeaturePriority; + } + if(this.activatedRoute.snapshot.routeConfig.path === 'structure-features') { this.featuresOnly = true; } @@ -185,15 +202,27 @@ export class SubstanceFormStructureCardComponent extends SubstanceFormBase imple } } + featureSort(a: any, b: any): number { + const indexA = this.StructureFeaturePriority.indexOf(a.key); + const indexB = this.StructureFeaturePriority.indexOf(b.key); + + + if (indexA !== -1 && indexB !== -1) { + return indexA - indexB; + } else if (indexA !== -1) { + return -1; // a comes first + } else if (indexB !== -1) { + return 1; // b comes first + } else { + return a.key.localeCompare(b.key); + } + } + processStructurePostResponse(structurePostResponse?: InterpretStructureResponse): void { if (structurePostResponse && structurePostResponse.structure) { let customSort = (array: any[]): any[] => { return array.sort((a, b) => { - if (a.key === 'Category Score') return -1; - if (b.key === 'Category Score') return 1; - if (a.key === 'Sum Of Scores') return a.key === 'Category Score' ? 1 : -1; - if (b.key === 'Sum Of Scores') return b.key === 'Category Score' ? -1 : 1; - return a.key.localeCompare(b.key); + return this.featureSort(a, b); }); }; @@ -219,6 +248,9 @@ export class SubstanceFormStructureCardComponent extends SubstanceFormBase imple if(key === 'sumOfScores'){ label = 'Sum Of Scores'; } + if (key.toLowerCase() === 'type') { + label = 'Type'; + } temp.push({'key': label,'value': structurePostResponse.featureList[type][0][key] }); }); }