Skip to content

Commit

Permalink
changes for nitrosamine table
Browse files Browse the repository at this point in the history
  • Loading branch information
NikoAnderson committed Aug 27, 2024
1 parent d77df67 commit 96f76ee
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/app/core/config/config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export interface Config {
useApprovalAPI?: boolean;
dummyWhoami?: Auth;
enableStructureFeatures?: boolean;
StructureFeaturePriority?: Array<string>;
structureEditSearch?: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
});
};

Expand All @@ -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] });
});
}
Expand Down

0 comments on commit 96f76ee

Please sign in to comment.