35 lines
816 B
TypeScript
35 lines
816 B
TypeScript
import { UntypedFormGroup, UntypedFormBuilder } from '@angular/forms';
|
|
import { isNullOrUndefined } from '@app/utilities/enhancers/utils';
|
|
|
|
export class DatasetIdModel {
|
|
identifier: string;
|
|
type: string;
|
|
|
|
constructor(data: any) {
|
|
try{
|
|
const parsed = JSON.parse(data);
|
|
if (!isNullOrUndefined(parsed)) {
|
|
if(typeof parsed !== 'string'){
|
|
this.identifier = parsed.identifier;
|
|
this.type = parsed.type;
|
|
}
|
|
else{
|
|
const parsedObjectFromString = JSON.parse(parsed);
|
|
this.identifier = parsedObjectFromString.identifier;
|
|
this.type = parsedObjectFromString.type;
|
|
}
|
|
}
|
|
}
|
|
catch(error){
|
|
console.warn('Could not parse DatasetIdModel');
|
|
}
|
|
}
|
|
|
|
buildForm(): UntypedFormGroup {
|
|
return new UntypedFormBuilder().group({
|
|
identifier: [this.identifier],
|
|
type: [this.type]
|
|
});
|
|
}
|
|
}
|