From 2ee7478952e3168a4f7d1bcebdb70b4e3c3d2f6e Mon Sep 17 00:00:00 2001 From: Hironsan Date: Tue, 2 Mar 2021 08:53:19 +0900 Subject: [PATCH] Add project model --- frontend/models/project.ts | 86 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 frontend/models/project.ts diff --git a/frontend/models/project.ts b/frontend/models/project.ts new file mode 100644 index 00000000..88f70c20 --- /dev/null +++ b/frontend/models/project.ts @@ -0,0 +1,86 @@ +export interface CurrentUsersRole { + is_project_admin: boolean; + is_annotator: boolean; + is_annotation_approver: boolean; +} + + +export class ProjectItem { + constructor( + public id: number, + public name: string, + public description: string, + public guideline: string, + public users: number[], + public current_users_role: CurrentUsersRole, + public project_type: string, + public updated_at: string, + public randomize_document_order: boolean, + public collaborative_annotation: boolean, + public single_class_classification: boolean, + public resourcetype: string, + ) {} + + static valueOf( + { + id, + name, + description, + guideline, + users, + current_users_role, + project_type, + updated_at, + randomize_document_order, + collaborative_annotation, + single_class_classification, + resourcetype + }: + { + id: number, + name: string, + description: string, + guideline: string, + users: number[], + current_users_role: CurrentUsersRole, + project_type: string, + updated_at: string, + randomize_document_order: boolean, + collaborative_annotation: boolean, + single_class_classification: boolean, + resourcetype: string + } + ): ProjectItem { + return new ProjectItem( + id, + name, + description, + guideline, + users, + current_users_role, + project_type, + updated_at, + randomize_document_order, + collaborative_annotation, + single_class_classification, + resourcetype + ) + } + + toObject(): Object { + return { + id: this.id, + name: this.name, + description: this.description, + guideline: this.guideline, + users: this.users, + current_users_role: this.current_users_role, + project_type: this.project_type, + updated_at: this.updated_at, + randomize_document_order: this.randomize_document_order, + collaborative_annotation: this.collaborative_annotation, + single_class_classification: this.single_class_classification, + resourcetype: this.resourcetype + } + } +}