From 18d0098bb39cdd68c9b5d16866ad5603eec3ed69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sat, 17 Apr 2021 18:26:21 +0200 Subject: [PATCH] [pricelist][#6] draggable change of order of pricelist columns --- package.json | 3 +- .../pricelist/components/Pricelist.vue | 117 ++++++++++++++++-- src/plugins/pricelist/store.ts | 18 ++- yarn.lock | 14 ++- 4 files changed, 142 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 805b20a..1589986 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "axios": "^0.21.1", "cordova": "^10.0.0", "pinia": "^2.0.0-alpha.10", - "quasar": "^2.0.0-beta.12" + "quasar": "^2.0.0-beta.12", + "vuedraggable": "^4.0.1" }, "devDependencies": { "@quasar/app": "^3.0.0-beta.13", diff --git a/src/plugins/pricelist/components/Pricelist.vue b/src/plugins/pricelist/components/Pricelist.vue index 24fef58..d1c26bd 100644 --- a/src/plugins/pricelist/components/Pricelist.vue +++ b/src/plugins/pricelist/components/Pricelist.vue @@ -26,6 +26,20 @@ option-value="name" options-cover /> + + Reihenfolge ändern + + + + + + - + diff --git a/src/plugins/pricelist/store.ts b/src/plugins/pricelist/store.ts index 3fd34a2..a0da12a 100644 --- a/src/plugins/pricelist/store.ts +++ b/src/plugins/pricelist/store.ts @@ -68,6 +68,11 @@ class Drink { } } +interface Order { + label: string; + name: string; +} + export const usePricelistStore = defineStore({ id: 'pricelist', @@ -79,6 +84,7 @@ export const usePricelistStore = defineStore({ tags: [] as Array, pricecalc_columns: [] as Array, pricelist_view: false as boolean, + pricelist_columns_order: [] as Array, }), actions: { @@ -270,6 +276,16 @@ export const usePricelistStore = defineStore({ await api.put>(`pricelist/users/${userid}/pricelist`, { value: data }); this.pricelist_view = data; }, + async getPriceListColumnOrder(userid: string) { + const { data } = await api.get>( + `pricelist/users/${userid}/pricecalc_columns_order` + ); + this.pricelist_columns_order = data; + }, + async updatePriceListColumnOrder(userid: string, data: Array) { + await api.put>(`pricelist/users/${userid}/pricecalc_columns_order`, data); + this.pricelist_columns_order = data; + }, }, getters: { pricelist() { @@ -294,4 +310,4 @@ export const usePricelistStore = defineStore({ }, }); -export { DrinkPriceVolume, Drink }; +export { DrinkPriceVolume, Drink, Order }; diff --git a/yarn.lock b/yarn.lock index a85d24a..023678d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1155,7 +1155,7 @@ "@quasar/quasar-app-extension-qcalendar@file:deps/quasar-ui-qcalendar/app-extension": version "4.0.0-alpha.1" dependencies: - "@quasar/quasar-ui-qcalendar" "link:../../Library/Caches/Yarn/v6/npm-@quasar-quasar-app-extension-qcalendar-4.0.0-alpha.1-5c1bc627-3876-4022-8043-d12aa47b1a6c-1618600205818/node_modules/@quasar/ui" + "@quasar/quasar-ui-qcalendar" "link:../../Library/Caches/Yarn/v6/npm-@quasar-quasar-app-extension-qcalendar-4.0.0-alpha.1-c42f9f4b-6777-438d-bf23-9bdcfb44ae8c-1618669700018/node_modules/@quasar/ui" "@quasar/quasar-ui-qcalendar@link:deps/quasar-ui-qcalendar/ui": version "0.0.0" @@ -9525,6 +9525,11 @@ sort-keys@^1.0.0: dependencies: is-plain-obj "^1.0.0" +sortablejs@1.10.2: + version "1.10.2" + resolved "https://registry.yarnpkg.com/sortablejs/-/sortablejs-1.10.2.tgz#6e40364d913f98b85a14f6678f92b5c1221f5290" + integrity sha512-YkPGufevysvfwn5rfdlGyrGjt7/CRHwvRPogD/lC+TnvcN29jDpCifKP+rBqf+LRldfXSTh+0CGLcSg0VIxq3A== + source-list-map@^2.0.0, source-list-map@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34" @@ -10647,6 +10652,13 @@ vue@3.0.11: "@vue/runtime-dom" "3.0.11" "@vue/shared" "3.0.11" +vuedraggable@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/vuedraggable/-/vuedraggable-4.0.1.tgz#3bcaab0808b7944030b7d9a29f9a63d59dfa12c5" + integrity sha512-7qN5jhB1SLfx5P+HCm3JUW+pvgA1bSLgYLSVOeLWBDH9z+zbaEH0OlyZBVMLOxFR+JUHJjwDD0oy7T4r9TEgDA== + dependencies: + sortablejs "1.10.2" + vuex@4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/vuex/-/vuex-4.0.0.tgz#ac877aa76a9c45368c979471e461b520d38e6cf5"