diff --git a/backend/projects/serializers.py b/backend/projects/serializers.py index febcd86b..36b05072 100644 --- a/backend/projects/serializers.py +++ b/backend/projects/serializers.py @@ -74,9 +74,15 @@ class ProjectSerializer(serializers.ModelSerializer): "can_define_relation", "can_define_category", "can_define_span", - "tags", ) + def create(self, validated_data): + tags = TagSerializer(data=validated_data.pop("tags", []), many=True) + project = self.Meta.model.objects.create(**validated_data) + tags.is_valid() + tags.save(project=project) + return project + class TextClassificationProjectSerializer(ProjectSerializer): class Meta(ProjectSerializer.Meta): diff --git a/frontend/components/project/FormCreate.vue b/frontend/components/project/FormCreate.vue index 6459f3f6..c722ce31 100644 --- a/frontend/components/project/FormCreate.vue +++ b/frontend/components/project/FormCreate.vue @@ -51,6 +51,18 @@ required @input="updateValue('description', $event)" /> + [], } }, diff --git a/frontend/domain/models/project/project.ts b/frontend/domain/models/project/project.ts index 6bd3ca78..c564c902 100644 --- a/frontend/domain/models/project/project.ts +++ b/frontend/domain/models/project/project.ts @@ -101,6 +101,7 @@ export class ProjectWriteItem { public allow_overlapping: boolean, public grapheme_mode: boolean, public use_relation: boolean, + public tags: string[], ) {} get resourceType(): string { @@ -128,6 +129,7 @@ export class ProjectWriteItem { allow_overlapping: this.allow_overlapping, grapheme_mode: this.grapheme_mode, use_relation: this.use_relation, + tags: this.tags.map(tag => ({text: tag})), resourcetype: this.resourceType } } diff --git a/frontend/pages/projects/create.vue b/frontend/pages/projects/create.vue index 3043d485..e8c6a0ab 100644 --- a/frontend/pages/projects/create.vue +++ b/frontend/pages/projects/create.vue @@ -31,6 +31,7 @@ export default Vue.extend({ allowOverlapping: false, graphemeMode: false, useRelation: false, + tags: [] as string[], } as ProjectWriteDTO, defaultItem: { name: '', @@ -42,6 +43,7 @@ export default Vue.extend({ allowOverlapping: false, graphemeMode: false, useRelation: false, + tags: [] as string[], } as ProjectWriteDTO, } }, diff --git a/frontend/services/application/project/projectApplicationService.ts b/frontend/services/application/project/projectApplicationService.ts index 70df1a46..ae50b497 100644 --- a/frontend/services/application/project/projectApplicationService.ts +++ b/frontend/services/application/project/projectApplicationService.ts @@ -58,7 +58,8 @@ export class ProjectApplicationService { item.singleClassClassification, item.allowOverlapping, item.graphemeMode, - item.useRelation + item.useRelation, + item.tags ) } } diff --git a/frontend/services/application/project/projectData.ts b/frontend/services/application/project/projectData.ts index 65f09d88..1294afea 100644 --- a/frontend/services/application/project/projectData.ts +++ b/frontend/services/application/project/projectData.ts @@ -11,7 +11,7 @@ export class ProjectDTO { enableShareAnnotation: boolean singleClassClassification: boolean pageLink: string - tags: Object[] + tags: Object[] | string[] canDefineLabel: boolean canDefineRelation: boolean isTextProject: boolean @@ -46,7 +46,7 @@ export class ProjectDTO { } } -export type ProjectWriteDTO = Pick +export type ProjectWriteDTO = Pick & { tags: string[] } export class ProjectListDTO { count: number