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.

140 lines
3.6 KiB

  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="mdi-account-multiple"
  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="mdi-clipboard-text"
  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="mdi-keyboard"
  35. required
  36. @input="updateValue('projectType', $event)"
  37. >
  38. <template v-slot:item="props">
  39. {{ translateTypeName(props.item, $t('overview.projectTypes')) }}
  40. </template>
  41. <template v-slot: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. :value="enableRandomOrder"
  53. :label="$t('overview.randomizeDocOrder')"
  54. @change="updateValue('enableRandomOrder', $event === true)"
  55. />
  56. <v-checkbox
  57. :value="enableShareAnnotation"
  58. :label="$t('overview.shareAnnotations')"
  59. @change="updateValue('enableShareAnnotation', $event === true)"
  60. />
  61. </v-form>
  62. </template>
  63. </base-card>
  64. </template>
  65. <script lang="ts">
  66. import Vue from 'vue'
  67. import BaseCard from '@/components/utils/BaseCard.vue'
  68. import { projectNameRules, descriptionRules, projectTypeRules } from '@/rules/index'
  69. export default Vue.extend({
  70. components: {
  71. BaseCard
  72. },
  73. props: {
  74. name: {
  75. type: String,
  76. default: '',
  77. required: true
  78. },
  79. description: {
  80. type: String,
  81. default: '',
  82. required: true
  83. },
  84. projectType: {
  85. type: String,
  86. default: '',
  87. required: true
  88. },
  89. enableRandomOrder: {
  90. type: Boolean,
  91. default: false,
  92. required: true
  93. },
  94. enableShareAnnotation: {
  95. type: Boolean,
  96. default: false,
  97. required: true
  98. },
  99. singleClassClassification: {
  100. type: Boolean,
  101. default: false,
  102. required: true
  103. }
  104. },
  105. data() {
  106. return {
  107. valid: false,
  108. projectNameRules,
  109. projectTypeRules,
  110. descriptionRules
  111. }
  112. },
  113. computed: {
  114. projectTypes() {
  115. return ['DocumentClassification', 'SequenceLabeling', 'Seq2seq', 'ImageClassification']
  116. },
  117. hasSingleLabelOption() {
  118. return [
  119. 'DocumentClassification',
  120. 'ImageClassification',
  121. ].includes(this.projectType)
  122. }
  123. },
  124. methods: {
  125. updateValue(key: string, value: string) {
  126. this.$emit(`update:${key}`, value);
  127. },
  128. translateTypeName(type: string, types: string[]): string {
  129. const index = this.projectTypes.indexOf(type)
  130. return types[index]
  131. }
  132. }
  133. })
  134. </script>