You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
4.3 KiB

2 years ago
  1. <template>
  2. <v-card>
  3. <v-card-title>{{ $t('overview.createProjectTitle') }}</v-card-title>
  4. <v-card-text>
  5. <v-form v-model="valid">
  6. <project-type-field v-model="editedItem.projectType" />
  7. <project-name-field v-model="editedItem.name" outlined autofocus />
  8. <project-description-field v-model="editedItem.description" outlined />
  9. <tag-list v-model="editedItem.tags" outlined />
  10. <v-checkbox
  11. v-if="showExclusiveCategories"
  12. v-model="editedItem.exclusiveCategories"
  13. :label="$t('overview.allowSingleLabel')"
  14. />
  15. <v-checkbox
  16. v-if="_canDefineLabel"
  17. v-model="editedItem.allowMemberToCreateLabelType"
  18. label="Allow project members to create label types"
  19. />
  20. <template v-if="isSequenceLabelingProject">
  21. <v-checkbox v-model="editedItem.allowOverlappingSpans" label="Allow overlapping spans" />
  22. <v-img
  23. :src="require('~/assets/project/creation.gif')"
  24. height="200"
  25. position="left"
  26. contain
  27. />
  28. <v-checkbox v-model="editedItem.useRelation" label="Use relation labeling" />
  29. <v-checkbox v-model="editedItem.enableGraphemeMode">
  30. <template #label>
  31. <div>
  32. Count
  33. <v-tooltip bottom>
  34. <template #activator="{ on }">
  35. <a
  36. target="_blank"
  37. href="https://unicode.org/reports/tr29/"
  38. @click.stop
  39. v-on="on"
  40. >
  41. grapheme clusters
  42. </a>
  43. </template>
  44. Like emoji(🌷, 💩, and 👍), CRLF(\r\n), and so on.
  45. </v-tooltip>
  46. as one character
  47. </div>
  48. </template>
  49. </v-checkbox>
  50. </template>
  51. <random-order-field v-model="editedItem.enableRandomOrder" />
  52. <sharing-mode-field v-model="editedItem.enableSharingMode" />
  53. </v-form>
  54. </v-card-text>
  55. <v-card-actions class="ps-4">
  56. <v-btn
  57. :disabled="!valid"
  58. color="primary"
  59. style="text-transform: none"
  60. outlined
  61. @click="create"
  62. >
  63. {{ $t('generic.create') }}
  64. </v-btn>
  65. </v-card-actions>
  66. </v-card>
  67. </template>
  68. <script lang="ts">
  69. import Vue from 'vue'
  70. import ProjectDescriptionField from '~/components/project/ProjectDescriptionField.vue'
  71. import ProjectNameField from '~/components/project/ProjectNameField.vue'
  72. import ProjectTypeField from '~/components/project/ProjectTypeField.vue'
  73. import RandomOrderField from '~/components/project/RandomOrderField.vue'
  74. import SharingModeField from '~/components/project/SharingModeField.vue'
  75. import TagList from '~/components/project/TagList.vue'
  76. import {
  77. DocumentClassification,
  78. ImageClassification,
  79. SequenceLabeling,
  80. canDefineLabel
  81. } from '~/domain/models/project/project'
  82. const initializeProject = () => {
  83. return {
  84. name: '',
  85. description: '',
  86. projectType: DocumentClassification,
  87. enableRandomOrder: false,
  88. enableSharingMode: false,
  89. exclusiveCategories: false,
  90. allowOverlappingSpans: false,
  91. enableGraphemeMode: false,
  92. useRelation: false,
  93. tags: [] as string[],
  94. guideline: '',
  95. allowMemberToCreateLabelType: false
  96. }
  97. }
  98. export default Vue.extend({
  99. components: {
  100. ProjectTypeField,
  101. ProjectNameField,
  102. ProjectDescriptionField,
  103. RandomOrderField,
  104. SharingModeField,
  105. TagList
  106. },
  107. layout: 'projects',
  108. middleware: ['check-auth', 'auth'],
  109. data() {
  110. return {
  111. valid: false,
  112. editedItem: initializeProject()
  113. }
  114. },
  115. computed: {
  116. showExclusiveCategories(): boolean {
  117. return [DocumentClassification, ImageClassification].includes(this.editedItem.projectType)
  118. },
  119. isSequenceLabelingProject(): boolean {
  120. return this.editedItem.projectType === SequenceLabeling
  121. },
  122. _canDefineLabel(): boolean {
  123. return canDefineLabel(this.editedItem.projectType as any)
  124. }
  125. },
  126. methods: {
  127. async create() {
  128. const project = await this.$services.project.create(this.editedItem)
  129. this.$router.push(`/projects/${project.id}`)
  130. this.$nextTick(() => {
  131. this.editedItem = initializeProject()
  132. })
  133. }
  134. }
  135. })
  136. </script>