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.

200 lines
5.2 KiB

3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <base-card
  3. :disabled="!valid"
  4. :title="$t('overview.createProjectTitle')"
  5. :agree-text="$t('generic.save')"
  6. :cancel-text="$t('generic.cancel')"
  7. @agree="$emit('save')"
  8. @cancel="$emit('cancel')"
  9. >
  10. <template #content>
  11. <v-form v-model="valid">
  12. <v-text-field
  13. :value="name"
  14. :rules="projectNameRules($t('rules.projectNameRules'))"
  15. :label="$t('overview.projectName')"
  16. :prepend-icon="mdiAccountMultiple"
  17. required
  18. autofocus
  19. @input="updateValue('name', $event)"
  20. />
  21. <v-text-field
  22. :value="description"
  23. :rules="descriptionRules($t('rules.descriptionRules'))"
  24. :label="$t('generic.description')"
  25. :prepend-icon="mdiClipboardText"
  26. required
  27. @input="updateValue('description', $event)"
  28. />
  29. <v-select
  30. :value="projectType"
  31. :items="projectTypes"
  32. :rules="projectTypeRules($t('rules.projectTypeRules'))"
  33. :label="$t('overview.projectType')"
  34. :prepend-icon="mdiKeyboard"
  35. required
  36. @input="updateValue('projectType', $event)"
  37. >
  38. <template #item="props">
  39. {{ translateTypeName(props.item, $t('overview.projectTypes')) }}
  40. </template>
  41. <template #selection="props">
  42. {{ translateTypeName(props.item, $t('overview.projectTypes')) }}
  43. </template>
  44. </v-select>
  45. <v-checkbox
  46. v-if="hasSingleLabelOption"
  47. :value="singleClassClassification"
  48. label="Allow single label"
  49. @change="updateValue('singleClassClassification', $event === true)"
  50. />
  51. <v-checkbox
  52. v-if="isSequenceLabelingProject"
  53. :value="allowOverlapping"
  54. label="Allow overlapping entity"
  55. @change="updateValue('allowOverlapping', $event === true)"
  56. />
  57. <v-img
  58. v-if="isSequenceLabelingProject"
  59. :src="require('~/assets/project/creation.gif')"
  60. height="200"
  61. position="left"
  62. contain
  63. />
  64. <v-checkbox
  65. v-if="isSequenceLabelingProject"
  66. :value="graphemeMode"
  67. @change="updateValue('graphemeMode', $event === true)"
  68. >
  69. <template #label>
  70. <div>
  71. Count
  72. <v-tooltip bottom>
  73. <template #activator="{ on }">
  74. <a
  75. target="_blank"
  76. href="https://unicode.org/reports/tr29/"
  77. @click.stop
  78. v-on="on"
  79. >
  80. grapheme clusters
  81. </a>
  82. </template>
  83. Like emoji(🌷, 💩, and 👍), CRLF(\r\n), and so on.
  84. </v-tooltip>
  85. as one character
  86. </div>
  87. </template>
  88. </v-checkbox>
  89. <v-checkbox
  90. :value="enableRandomOrder"
  91. :label="$t('overview.randomizeDocOrder')"
  92. @change="updateValue('enableRandomOrder', $event === true)"
  93. />
  94. <v-checkbox
  95. :value="enableShareAnnotation"
  96. :label="$t('overview.shareAnnotations')"
  97. @change="updateValue('enableShareAnnotation', $event === true)"
  98. />
  99. </v-form>
  100. </template>
  101. </base-card>
  102. </template>
  103. <script lang="ts">
  104. import Vue from 'vue'
  105. import { mdiAccountMultiple, mdiClipboardText, mdiKeyboard } from '@mdi/js'
  106. import BaseCard from '@/components/utils/BaseCard.vue'
  107. import { projectNameRules, descriptionRules, projectTypeRules } from '@/rules/index'
  108. export default Vue.extend({
  109. components: {
  110. BaseCard
  111. },
  112. props: {
  113. name: {
  114. type: String,
  115. default: '',
  116. required: true
  117. },
  118. description: {
  119. type: String,
  120. default: '',
  121. required: true
  122. },
  123. projectType: {
  124. type: String,
  125. default: '',
  126. required: true
  127. },
  128. enableRandomOrder: {
  129. type: Boolean,
  130. default: false,
  131. required: true
  132. },
  133. enableShareAnnotation: {
  134. type: Boolean,
  135. default: false,
  136. required: true
  137. },
  138. singleClassClassification: {
  139. type: Boolean,
  140. default: false,
  141. required: true
  142. },
  143. allowOverlapping: {
  144. type: Boolean,
  145. default: false
  146. },
  147. graphemeMode: {
  148. type: Boolean,
  149. default: false
  150. }
  151. },
  152. data() {
  153. return {
  154. valid: false,
  155. projectNameRules,
  156. projectTypeRules,
  157. descriptionRules,
  158. mdiAccountMultiple,
  159. mdiClipboardText,
  160. mdiKeyboard
  161. }
  162. },
  163. computed: {
  164. projectTypes() {
  165. return [
  166. 'DocumentClassification',
  167. 'SequenceLabeling',
  168. 'Seq2seq',
  169. 'IntentDetectionAndSlotFilling',
  170. 'ImageClassification',
  171. 'Speech2text',
  172. ]
  173. },
  174. hasSingleLabelOption() {
  175. return [
  176. 'DocumentClassification',
  177. 'ImageClassification',
  178. ].includes(this.projectType)
  179. },
  180. isSequenceLabelingProject() {
  181. return this.projectType === 'SequenceLabeling'
  182. }
  183. },
  184. methods: {
  185. updateValue(key: string, value: string) {
  186. this.$emit(`update:${key}`, value);
  187. },
  188. translateTypeName(type: string, types: string[]): string {
  189. const index = this.projectTypes.indexOf(type)
  190. return types[index]
  191. }
  192. }
  193. })
  194. </script>