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.

templateInnerItem.vue 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <div class="row">
  3. <div class="col-md-12" v-if="message !== undefined">
  4. <Alert :text="message" :type="'ERROR'" />
  5. </div>
  6. <div class="col-md-3">
  7. <input
  8. class="form-control"
  9. type="text"
  10. step="any"
  11. name="levy"
  12. placeholder="Name"
  13. v-model="item.name"
  14. />
  15. </div>
  16. <div class="col-md-3">
  17. <select class="form-control" v-model="item.class" @change="onClassChanged()">
  18. <option v-for="(item, i) in classes" :key="i" :value="item">{{item.name}}</option>
  19. </select>
  20. </div>
  21. <div class="col-md-3">
  22. <select class="form-control" v-model="item.property">
  23. <option v-for="(item, i) in properties" :key="i">{{item}}</option>
  24. </select>
  25. </div>
  26. <div class="col-md-3">
  27. <div class="btn btn-primary myBackground w-100" @click="onItemAdd()">Add</div>
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. import { mapState, mapActions } from 'vuex';
  33. import Alert from '../shared/alert.vue';
  34. export default {
  35. components: {
  36. Alert,
  37. },
  38. mounted() {
  39. this.init();
  40. },
  41. data() {
  42. return {
  43. message: undefined,
  44. item: {
  45. name: undefined,
  46. class: undefined,
  47. property: undefined,
  48. },
  49. };
  50. },
  51. computed: {
  52. ...mapState('info', ['classes', 'properties']),
  53. },
  54. methods: {
  55. ...mapActions('info', ['init', 'getClasses', 'getProperties']),
  56. onClassChanged() {
  57. this.getProperties(this.item.class);
  58. },
  59. onItemAdd() {
  60. this.message = undefined;
  61. let msg = '';
  62. if (this.item.name === undefined) {
  63. msg += 'Please give a name...';
  64. }
  65. if (this.item.class == undefined) {
  66. msg += 'Please choose a class...';
  67. }
  68. if (this.item.property == undefined) {
  69. msg += 'Please choose a property...';
  70. }
  71. if (msg.length > 0) {
  72. this.message = msg;
  73. } else {
  74. this.$emit('onItemAdd', this.item);
  75. }
  76. },
  77. },
  78. };
  79. </script>