Prevent the selection of an already selected dataset Templates
This commit is contained in:
parent
32e299fc45
commit
045dd51014
|
@ -248,6 +248,16 @@ export class DatasetInfoComponent extends BaseComponent implements OnInit {
|
|||
onOptionSelected(){
|
||||
try{
|
||||
const profiles = this.formGroup.get('profiles').value as {id:string, label:string}[];
|
||||
const profileCounts: Map<String, number> = new Map<String, number>();
|
||||
profiles.forEach((value) => profileCounts.set(value.id, (profileCounts.get(value.id) !== undefined ? profileCounts.get(value.id): 0 ) + 1));
|
||||
const duplicateProfiles = profiles.filter((value) => {
|
||||
let isOk = profileCounts.get(value.id) > 1;
|
||||
if (isOk) {
|
||||
profileCounts.set(value.id, 0);
|
||||
}
|
||||
return isOk;
|
||||
});
|
||||
duplicateProfiles.forEach((value) => profiles.splice(profiles.lastIndexOf(value), 1));
|
||||
profiles.sort((a,b)=> a.label.localeCompare(b.label));
|
||||
}catch{
|
||||
console.info('Could not sort Dataset Templates')
|
||||
|
|
Loading…
Reference in New Issue