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.

propertyFieldEditor.vue 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <div>
  3. <div>
  4. <div v-if="!edit" class="input-group-prepend">
  5. <input
  6. class="form-control"
  7. type="text"
  8. name="currentField.name"
  9. id="currentField.id"
  10. v-model="display"
  11. disabled
  12. />
  13. <span @click="EditClick()" class="input-group-text" style="color: #60CBEB">
  14. <eva-icon name="edit-outline" fill="#60CBEB"></eva-icon>
  15. </span>
  16. </div>
  17. <div v-if="edit" class="input-group-prepend">
  18. <!-- Text -->
  19. <input
  20. v-if="editType === 'text'"
  21. class="form-control"
  22. type="text"
  23. name="currentField.name"
  24. id="currentField.id"
  25. v-model="display"
  26. />
  27. <!-- Number -->
  28. <input
  29. v-if="editType === 'number'"
  30. class="form-control"
  31. type="number"
  32. name="currentField.name"
  33. id="currentField.id"
  34. v-model="display"
  35. />
  36. <!-- Selector -->
  37. <select
  38. v-if="editType === 'selector'"
  39. class="form-control"
  40. v-model="selectorSelection"
  41. @change="SelectorSelected"
  42. >
  43. <option value="0">Please select type</option>
  44. <option v-for="item in arrayObject" :value="item.id" :key="item.id">{{ item.description }}</option>
  45. </select>
  46. <!-- yesno -->
  47. <select v-if="editType === 'yesno'" class="form-control" @change="YesNoSelected">
  48. <option></option>
  49. <option value="yes">Yes</option>
  50. <option value="no">No</option>
  51. </select>
  52. <span @click="Save()" class="input-group-text" style="color: #60CBEB">
  53. <eva-icon name="checkmark-outline" fill="#60CBEB"></eva-icon>
  54. </span>
  55. <span @click="Close()" class="input-group-text" style="color: #60CBEB">
  56. <eva-icon name="close-outline" fill="#60CBEB"></eva-icon>
  57. </span>
  58. </div>
  59. </div>
  60. </div>
  61. </template>
  62. <script>
  63. export default {
  64. name: 'propertyFieldEdit',
  65. props: {
  66. display: String,
  67. arrayObject: [],
  68. canEdit: Boolean,
  69. editType: String,
  70. },
  71. data() {
  72. return {
  73. edit: false,
  74. selectorSelection: Object,
  75. };
  76. },
  77. methods: {
  78. EditClick() {
  79. this.edit = true;
  80. },
  81. Save() {
  82. this.edit = false;
  83. // Need to emit the parent controller
  84. },
  85. Close() {
  86. this.edit = false;
  87. },
  88. SelectorSelected(item) {
  89. if (item.target.options.selectedIndex > 0) {
  90. this.display = this.arrayObject[
  91. item.target.options.selectedIndex - 1
  92. ].description;
  93. console.log(
  94. this.arrayObject[item.target.options.selectedIndex - 1].description,
  95. );
  96. }
  97. },
  98. YesNoSelected(item) {
  99. if (item.target.options.selectedIndex === 1) {
  100. this.display = 'Yes';
  101. }
  102. if (item.target.options.selectedIndex === 2) {
  103. this.display = 'No';
  104. }
  105. },
  106. },
  107. };
  108. </script>