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.

94 lines
1.8 KiB

  1. <template>
  2. <base-card
  3. title="Create Label"
  4. agree-text="Create"
  5. cancel-text="Cancel"
  6. :disabled="!valid"
  7. @agree="create"
  8. @cancel="cancel"
  9. >
  10. <template #content>
  11. <v-form
  12. ref="form"
  13. v-model="valid"
  14. >
  15. <v-text-field
  16. v-model="labelName"
  17. :rules="labelNameRules"
  18. label="Label name"
  19. prepend-icon="label"
  20. />
  21. <v-select
  22. v-model="suffixKey"
  23. :items="keys"
  24. label="Key"
  25. prepend-icon="mdi-keyboard"
  26. />
  27. <v-color-picker
  28. v-model="color"
  29. :rules="colorRules"
  30. show-swatches
  31. hide-mode-switch
  32. width="800"
  33. mode="hexa"
  34. class="ma-2"
  35. />
  36. </v-form>
  37. </template>
  38. </base-card>
  39. </template>
  40. <script>
  41. import BaseCard from '@/components/molecules/BaseCard'
  42. import { colorRules, labelNameRules } from '@/rules/index'
  43. export default {
  44. components: {
  45. BaseCard
  46. },
  47. props: {
  48. createLabel: {
  49. type: Function,
  50. default: () => {},
  51. required: true
  52. },
  53. keys: {
  54. type: Array,
  55. default: () => 'abcdefghijklmnopqrstuvwxyz'.split('')
  56. }
  57. },
  58. data() {
  59. return {
  60. valid: false,
  61. labelName: '',
  62. suffixKey: '',
  63. color: '',
  64. labelNameRules,
  65. colorRules
  66. }
  67. },
  68. methods: {
  69. cancel() {
  70. this.$emit('close')
  71. },
  72. validate() {
  73. return this.$refs.form.validate()
  74. },
  75. reset() {
  76. this.$refs.form.reset()
  77. },
  78. create() {
  79. if (this.validate()) {
  80. this.createLabel({
  81. text: this.labelName,
  82. suffix_key: this.suffixKey,
  83. background_color: this.color
  84. })
  85. this.reset()
  86. this.cancel()
  87. }
  88. }
  89. }
  90. }
  91. </script>