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.

restaurantCategories.vue 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <div>
  3. <div class="container">
  4. <div class="container">
  5. <div class="row">
  6. <div class="col-md-12 col-lg-8">
  7. <div class="title-box-d">
  8. <br />
  9. <h1 class="title-d" style="text-align:left; font-size: 250%">Restaurant Categories</h1>
  10. </div>
  11. </div>
  12. </div>
  13. </div>
  14. </div>
  15. <div class="container">
  16. <div class="form-group row">
  17. <div class="col-md-12">
  18. <ListView
  19. :items="restaurantsCategories"
  20. :showColumnChooser="false"
  21. :editable="true"
  22. :hideSearch="true"
  23. :deleteable="true"
  24. :displayFormats="formats"
  25. :sortKey="Description"
  26. @onEdit="Edit"
  27. @onDelete="Delete"
  28. @onNew="New"
  29. />
  30. </div>
  31. <modal name="Category" :width="600" :height="600">
  32. <Category @CategoryUpdate="CategoryUpdate" :editCategory="CurrentCategory" />
  33. </modal>
  34. </div>
  35. <div v-if="wait" id="preloader"></div>
  36. </div>
  37. </div>
  38. </template>
  39. <script>
  40. import Category from "../restaurants/restaurantCategory";
  41. import ListView from "../shared/listView";
  42. import { mapState, mapActions } from "vuex";
  43. export default {
  44. name: "RestaurantCategoryList",
  45. components: {
  46. ListView,
  47. Category
  48. },
  49. data() {
  50. return {
  51. wait: true,
  52. formats: ["", "", "image"],
  53. category: {}
  54. };
  55. },
  56. methods: {
  57. ...mapActions("restaurantCategories", [
  58. "getCategories",
  59. "addCategory",
  60. "updateCategory",
  61. "deleteCategory"
  62. ]),
  63. New() {
  64. this.category = null;
  65. this.$modal.show("Category");
  66. },
  67. Edit(item) {
  68. this.category = item;
  69. this.$modal.show("Category");
  70. },
  71. Delete(item) {
  72. this.deleteCategory(item.id);
  73. },
  74. CategoryUpdate(item) {
  75. //Add new
  76. if (item.id == 0) {
  77. this.addCategory(item);
  78. } else {
  79. this.updateCategory(item);
  80. }
  81. this.$modal.hide("Category");
  82. }
  83. },
  84. computed: {
  85. ...mapState("restaurantCategories", ["restaurantsCategories"]),
  86. CurrentCategory() {
  87. return this.category;
  88. }
  89. },
  90. mounted() {
  91. this.getCategories().then(() => {
  92. this.wait = false;
  93. });
  94. }
  95. };
  96. </script>