| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- interface ICompetence {
- id: number;
- name: string;
- description: string;
- isPreference: boolean;
- isTeachable: boolean;
- }
- export default class Competence {
- static maxId = 0;
- id: number;
- name: string;
- description: string;
- isPreference: boolean;
- isTeachable: boolean;
- constructor(id: number, name: string, description: string, isPreference: boolean) {
- // Change the current max id
- if (!isNaN(id)) Competence.maxId = id > Competence.maxId ? id : Competence.maxId;
- this.id = id;
- this.name = name;
- this.description = description;
- this.isPreference = isPreference;
- this.isTeachable = false;
- }
- get renderPreference(): string {
- const icon = this.isPreference ? "check_box" : "check_box_outline_blank";
- return '<i class="material-icons">' + icon + "</i>";
- }
- get renderTeachable(): string {
- const icon = this.isTeachable ? "check_box" : "check_box_outline_blank";
- return '<i class="material-icons">' + icon + "</i>";
- }
- get overflowDescription(): string {
- return this.description;
- }
- get fullname(): string {
- return this.name + (this.isPreference ? " (P)" : " (C)");
- }
- static fromObject(obj: ICompetence): Competence {
- let id: number;
- if (isNaN(obj.id)) {
- this.maxId += 1;
- id = this.maxId;
- } else {
- id = obj.id;
- this.maxId = obj.id > this.maxId ? obj.id : this.maxId;
- }
- return new Competence(
- id,
- obj.name,
- obj.description ? obj.description : "",
- obj.isPreference ? obj.isPreference : false
- );
- }
- toPlainObject(): ICompetence {
- return {
- id: this.id,
- name: this.name,
- description: this.description,
- isPreference: this.isPreference,
- isTeachable: this.isTeachable,
- };
- }
- }
|