Переглянути джерело

Restaurant Menu Category screens

master
George Williams 4 роки тому
джерело
коміт
56b60e13ae

+ 96
- 0
src/components/restaurants/restaurantMenuCategories.vue Переглянути файл

@@ -0,0 +1,96 @@
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%">Menu 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="categories"
20
+            :showColumnChooser="false"
21
+            :editable="true"
22
+            :deleteable="true"
23
+            :displayColumns="columns"
24
+            @onEdit="Edit"
25
+            @onDelete="Delete"
26
+            @onNew="New"
27
+          />
28
+        </div>
29
+        <modal name="Category" :width="600" :height="220">
30
+          <Category @CategoryUpdate="CategoryUpdate" :editCategory="CurrentCategory" />
31
+        </modal>
32
+      </div>
33
+      <div v-if="wait" id="preloader"></div>
34
+    </div>
35
+  </div>
36
+</template>
37
+
38
+<script>
39
+import Category from "../restaurants/restaurantMenuCateory";
40
+import ListView from "../shared/listView";
41
+import { mapState, mapActions } from "vuex";
42
+
43
+export default {
44
+  name: "RestaurantCategoryList",
45
+  components: {
46
+    ListView,
47
+    Category
48
+  },
49
+  data() {
50
+    return {
51
+      wait: true,
52
+      category: {},
53
+      columns: ["id", "description"]
54
+    };
55
+  },
56
+  methods: {
57
+    ...mapActions("menuCategories", [
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
+      item.restaurantId = 5;
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("menuCategories", ["categories"]),
86
+    CurrentCategory() {
87
+      return this.category;
88
+    }
89
+  },
90
+  mounted() {
91
+    this.getCategories(5).then(() => {
92
+      this.wait = false;
93
+    });
94
+  }
95
+};
96
+</script>

+ 60
- 0
src/components/restaurants/restaurantMenuCateory.vue Переглянути файл

@@ -0,0 +1,60 @@
1
+<template>
2
+  <div class="container">
3
+    <div class="row">
4
+      <div class="col-md-12" style="margin-bottom: 1em">
5
+        <h1>Category</h1>
6
+      </div>
7
+    </div>
8
+    <div class="row" style="text-align:left">
9
+      <div class="col-md-12" style="margin-bottom: 1em">
10
+        <label>Description</label>
11
+        <div class="input-group-prepend">
12
+          <span class="input-group-text">
13
+            <eva-icon name="credit-card-outline" fill="#24aae1"></eva-icon>
14
+          </span>
15
+          <input class="form-control" type="text" name="description" v-model="category.description" />
16
+        </div>
17
+      </div>
18
+    </div>
19
+    <div class="row"></div>
20
+    <div class="row">
21
+      <div class="col-md-12" style="margin-bottom: 1em">
22
+        <div class="input-group-prepend">
23
+          <b-button class="btn btn-b-n" @click="Ok">Ok</b-button>
24
+        </div>
25
+      </div>
26
+    </div>
27
+  </div>
28
+</template>
29
+
30
+<script>
31
+export default {
32
+  name: "Category",
33
+  props: {
34
+    editCategory: { default: {} }
35
+  },
36
+  data() {
37
+    return {
38
+      category: {
39
+        id: 0,
40
+        description: ""
41
+      }
42
+    };
43
+  },
44
+  methods: {
45
+    Ok() {
46
+      this.$emit("CategoryUpdate", this.category);
47
+    }
48
+  },
49
+  watch: {
50
+    editCategory: {
51
+      immediate: true,
52
+      handler(val, oldVal) {
53
+        if (val) {
54
+          this.category = val;
55
+        }
56
+      }
57
+    }
58
+  }
59
+};
60
+</script>

+ 4
- 0
src/components/shared/navBar.vue Переглянути файл

@@ -93,6 +93,10 @@
93 93
                 aria-labelledby="navbarDropdown"
94 94
               >
95 95
                 <a class="dropdown-item cursor-pointer" @click="routerGoTo('/Restaurant')">Details</a>
96
+                <a
97
+                  class="dropdown-item cursor-pointer"
98
+                  @click="routerGoTo('/MenuCategory')"
99
+                >Menu Categories</a>
96 100
                 <a
97 101
                   class="dropdown-item cursor-pointer"
98 102
                   @click="routerGoTo('/status/timeshareAdmin')"

+ 6
- 0
src/router/index.js Переглянути файл

@@ -15,6 +15,7 @@ import Restaurant from "../components/restaurants/restaurantDetails.vue";
15 15
 import CustomerDetails from "../components/customer/customerDetails.vue";
16 16
 import CustomerOrders from "../components/customer/customerOrders.vue";
17 17
 import CustomerList from "../components/customer/customerList.vue";
18
+import RestaurantMenuCategories from "../components/restaurants/restaurantMenuCategories.vue";
18 19
 
19 20
 Vue.use(Router);
20 21
 
@@ -85,6 +86,11 @@ export default new Router({
85 86
       path: "/Restaurant",
86 87
       name: "Restaurant",
87 88
       component: Restaurant
89
+    },
90
+    {
91
+      path: "/MenuCategory",
92
+      name: "MenuCategory",
93
+      component: RestaurantMenuCategories
88 94
     }
89 95
   ]
90 96
 });

+ 3
- 2
src/store/index.js Переглянути файл

@@ -8,18 +8,19 @@ import RestaurantCategories from './modules/restaurants/restaurantCategories';
8 8
 import Restaurant from './modules/restaurants/restaurant';
9 9
 import MOPs from './modules/shared/restaurantMOP'
10 10
 import User from './modules/users/user';
11
+import MenuCategories from './modules/restaurants/restaurantMenuCategories';
11 12
 
12 13
 Vue.use(Vuex);
13 14
 /* eslint no-param-reassign: ["error", { "props": false }] */
14 15
 export default new Vuex.Store({
15 16
   modules: {
16
-
17 17
     registration: Registration,
18 18
     authentiaction: Authentication,
19 19
     restaurantSearch: RestaurantSearch,
20 20
     restaurantCategories: RestaurantCategories,
21 21
     restaurant: Restaurant,
22 22
     user: User,
23
-    mop: MOPs
23
+    mop: MOPs,
24
+    menuCategories: MenuCategories
24 25
   },
25 26
 });

+ 52
- 0
src/store/modules/restaurants/restaurantMenuCategories.js Переглянути файл

@@ -0,0 +1,52 @@
1
+import axios from 'axios';
2
+
3
+export default {
4
+  namespaced: true,
5
+  state: {
6
+    categories: [],
7
+    category: {}
8
+  },
9
+  mutations: {
10
+    setCategories(state, categories) {
11
+      state.categories = categories;
12
+    },
13
+    setCategory(state, category) {
14
+      state.category = category;
15
+      state.categories.push(category);
16
+    },
17
+    removeCategory(state, category) {
18
+      state.categories.pop(category);
19
+    }
20
+  },
21
+  getters: {},
22
+  actions: {
23
+    getCategories({
24
+      commit
25
+    }, restId) {
26
+      axios
27
+        .get(`/api/MenuCategory/GetRestaurantCategories/${restId}`)
28
+        .then(result => commit("setCategories", result.data));
29
+    },
30
+    addCategory({
31
+      commit
32
+    }, category) {
33
+      axios
34
+        .post('/api/MenuCategory', category)
35
+        .then(result => commit("setCategory", result.data));
36
+    },
37
+    updateCategory({
38
+      commit
39
+    }, category) {
40
+      axios
41
+        .put('/api/MenuCategory', category)
42
+        .then(result => commit("setCategory", result.data));
43
+    },
44
+    deleteCategory({
45
+      commit
46
+    }, id) {
47
+      axios
48
+        .delete(`/api/MenuCategory/${id}`)
49
+        .then(result => commit("removeCategory", result.data));
50
+    }
51
+  }
52
+}

Завантаження…
Відмінити
Зберегти