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.

123 lines
3.1 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. :value="enableRandomizeDocOrder"
  47. :label="$t('overview.randomizeDocOrder')"
  48. @change="updateValue('enableRandomizeDocOrder', $event === true)"
  49. />
  50. <v-checkbox
  51. :value="enableShareAnnotation"
  52. :label="$t('overview.shareAnnotations')"
  53. @change="updateValue('enableShareAnnotation', $event === true)"
  54. />
  55. </v-form>
  56. </template>
  57. </base-card>
  58. </template>
  59. <script lang="ts">
  60. import Vue from 'vue'
  61. import BaseCard from '@/components/utils/BaseCard.vue'
  62. import { projectNameRules, descriptionRules, projectTypeRules } from '@/rules/index'
  63. export default Vue.extend({
  64. components: {
  65. BaseCard
  66. },
  67. props: {
  68. name: {
  69. type: String,
  70. default: '',
  71. required: true
  72. },
  73. description: {
  74. type: String,
  75. default: '',
  76. required: true
  77. },
  78. projectType: {
  79. type: String,
  80. default: '',
  81. required: true
  82. },
  83. enableRandomizeDocOrder: {
  84. type: Boolean,
  85. default: false,
  86. required: true
  87. },
  88. enableShareAnnotation: {
  89. type: Boolean,
  90. default: false,
  91. required: true
  92. }
  93. },
  94. data() {
  95. return {
  96. valid: false,
  97. projectNameRules,
  98. projectTypeRules,
  99. descriptionRules
  100. }
  101. },
  102. computed: {
  103. projectTypes() {
  104. return ['DocumentClassification', 'SequenceLabeling', 'Seq2seq']
  105. }
  106. },
  107. methods: {
  108. updateValue(key: string, value: string) {
  109. this.$emit(`update:${key}`, value);
  110. },
  111. translateTypeName(type: string, types: string[]): string {
  112. const index = this.projectTypes.indexOf(type)
  113. return types[index]
  114. }
  115. }
  116. })
  117. </script>