35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { IListable } from '@iqser/common-ui';
|
|
import { ILegalBasis } from './legal-basis';
|
|
import { toSnakeCase } from '@utils/functions';
|
|
|
|
export class Justification implements ILegalBasis, IListable {
|
|
readonly description?: string;
|
|
readonly name: string;
|
|
readonly reason?: string;
|
|
readonly technicalName?: string;
|
|
|
|
constructor(justification: ILegalBasis) {
|
|
this.description = justification.description;
|
|
this.name = justification.name;
|
|
this.reason = justification.reason;
|
|
this.technicalName = justification.technicalName;
|
|
}
|
|
|
|
get id(): string {
|
|
return this.name;
|
|
}
|
|
|
|
get searchKey(): string {
|
|
return this.name;
|
|
}
|
|
|
|
static toTechnicalName(value: string) {
|
|
const baseTechnicalName = toSnakeCase(value.trim());
|
|
let technicalName = baseTechnicalName.replaceAll(/[^A-Za-z0-9_-]/g, '');
|
|
if (!technicalName.length && baseTechnicalName.length) {
|
|
technicalName = '_';
|
|
}
|
|
return technicalName;
|
|
}
|
|
}
|