From 51fcc6f9beb41115766aa0ef4ea6299c2c6a72df Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 19 Mar 2021 16:33:27 +0100 Subject: [PATCH] [Vue3][pinia] Make pricelist compile with vue3, needs more work! --- .vscode/settings.json | 1 - package.json | 2 +- src/plugins/pricelist/{store => }/altStore.ts | 63 ++++----- .../pricelist/components/CalculationTable.vue | 125 +++++++++--------- .../CalculationTable/Ingredients.vue | 45 ++++--- .../CalculationTable/PriceTable.vue | 28 ++-- .../pricelist/components/ExtraIngredients.vue | 20 +-- yarn.lock | 2 +- 8 files changed, 148 insertions(+), 138 deletions(-) rename src/plugins/pricelist/{store => }/altStore.ts (94%) diff --git a/.vscode/settings.json b/.vscode/settings.json index 5041d4d..187d7a4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -26,6 +26,5 @@ }, "vetur.format.defaultFormatter.ts": "prettier-tslint", "typescript.format.enable": false, - "prettier.packageManager": "yarn", "prettier.configPath": "./package.json" } diff --git a/package.json b/package.json index 19bfc79..708e7b8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "flaschengeist-frontend", - "version": "0.0.1", + "version": "0.1.0-alpha.1", "description": "Dynamischen Managementsystem für Studentenclubs", "productName": "Flaschengeist", "author": "Tim Gröger ", diff --git a/src/plugins/pricelist/store/altStore.ts b/src/plugins/pricelist/altStore.ts similarity index 94% rename from src/plugins/pricelist/store/altStore.ts rename to src/plugins/pricelist/altStore.ts index ef227c6..6bf3718 100644 --- a/src/plugins/pricelist/store/altStore.ts +++ b/src/plugins/pricelist/altStore.ts @@ -1,7 +1,7 @@ -import { reactive, computed, ComputedRef, WritableComputedRef } from '@vue/composition-api'; -import { axios } from 'src/boot/axios'; +import { reactive, computed, WritableComputedRef } from 'vue'; +import { api } from 'src/boot/axios'; import { AxiosResponse } from 'axios'; - +/* const state = reactive<{ drinks: Drink[]; tags: FG.Tag[]; @@ -121,15 +121,15 @@ class Drink { this.tags = tags; this.type = type; this.volumes = []; - /*volumes.forEach(volume => { - this.volumes.push(new DrinkPriceVolume(volume, this)); - });*/ + //volumes.forEach(volume => { + // this.volumes.push(new DrinkPriceVolume(volume, this)); + //}); } } const actions = { getDrinks() { - axios + api .get('pricelist/drinks') .then((response: AxiosResponse) => { state.drinks = []; @@ -146,7 +146,7 @@ const actions = { .catch((err) => console.warn(err)); }, setPrice(price: FG.DrinkPrice, volume: DrinkPriceVolume) { - axios + api .post(`pricelist/volumes/${volume.id}/prices`, price) .then((response: AxiosResponse) => { volume.prices.push(response.data); @@ -162,7 +162,7 @@ const actions = { }); }, deletePrice(price: FG.DrinkPrice, volume: FG.DrinkPriceVolume) { - axios + api .delete(`pricelist/prices/${price.id}`) .then(() => { const index = volume.prices.findIndex((a) => a.id == price.id); @@ -173,7 +173,7 @@ const actions = { .catch((err) => console.warn(err)); }, updatePrice(price: FG.DrinkPrice, volume: DrinkPriceVolume) { - axios + api .put(`pricelist/prices/${price.id}`, price) .then((response: AxiosResponse) => { const index = volume.prices.findIndex((a) => a.id === price.id); @@ -185,7 +185,7 @@ const actions = { }, setVolume(volume: DrinkPriceVolume, drink: Drink) { console.log(volume); - axios + api .post(`pricelist/drinks/${drink.id}/volumes`, { ...volume, volume: volume.volume, @@ -196,7 +196,7 @@ const actions = { .catch((err) => console.warn(err)); }, updateVolume(volume: DrinkPriceVolume, drink: Drink) { - axios + api .put(`pricelist/volumes/${volume.id}`, { ...volume, volume: volume.volume?.value, @@ -204,7 +204,7 @@ const actions = { .catch((err) => console.warn(err)); }, deleteVolume(volume: FG.DrinkPriceVolume, drink: FG.Drink) { - axios + api .delete(`pricelist/volumes/${volume.id}`) .then(() => { const index = drink.volumes.findIndex((a) => a.id === volume.id); @@ -215,7 +215,7 @@ const actions = { .catch((err) => console.warn(err)); }, getExtraIngredients() { - axios + api .get('pricelist/ingredients/extraIngredients') .then((response: AxiosResponse) => { state.extraIngredients = response.data; @@ -223,7 +223,7 @@ const actions = { .catch((err) => console.log(err)); }, setIngredient(ingredient: FG.Ingredient, volume: DrinkPriceVolume) { - axios + api .post(`pricelist/volumes/${volume.id}/ingredients`, ingredient) .then((response: AxiosResponse) => { volume.ingredients.push(response.data); @@ -231,18 +231,18 @@ const actions = { .catch((err) => console.warn(err)); }, updateIngredient(ingredient: FG.Ingredient, volume: DrinkPriceVolume) { - axios + api .put(`pricelist/ingredients/${ingredient.id}`, ingredient) .then((response: AxiosResponse) => { - /*const index = volume.ingredients.findIndex(a => a.id === response.data.id); - if (index > -1) { - volume.ingredients[index] = response.data; - }*/ + //const index = volume.ingredients.findIndex(a => a.id === response.data.id); + //if (index > -1) { + // volume.ingredients[index] = response.data; + //} }) .catch((err) => console.warn(err)); }, deleteIngredient(ingredient: FG.Ingredient, volume: DrinkPriceVolume) { - axios + api .delete(`pricelist/ingredients/${ingredient.id}`) .then(() => { const index = volume.ingredients.findIndex((a) => a.id === ingredient.id); @@ -253,7 +253,7 @@ const actions = { .catch((err) => console.warn(err)); }, getDrinkTypes() { - axios + api .get('pricelist/drink-types') .then((response: AxiosResponse) => { state.drinkTypes = response.data; @@ -261,7 +261,7 @@ const actions = { .catch((err) => console.warn(err)); }, setDrink(drink: FG.Drink) { - axios + api .post('pricelist/drinks', drink) .then((response: AxiosResponse) => { state.drinks.push(new Drink(response.data)); @@ -273,7 +273,7 @@ const actions = { .catch((err) => console.warn(err)); }, updateDrink(drink: Drink) { - axios + api .put(`pricelist/drinks/${drink.id}`, { ...drink, cost_price_pro_volume: drink.cost_price_pro_volume?.value, @@ -281,7 +281,7 @@ const actions = { .catch((err) => console.warn(err)); }, deleteDrink(drink: Drink) { - axios + api .delete(`pricelist/drinks/${drink.id}`) .then(() => { const index = state.drinks.findIndex((a) => a.id === drink.id); @@ -292,15 +292,15 @@ const actions = { .catch((err) => console.warn(err)); }, setExtraIngredient(ingredient: FG.ExtraIngredient) { - axios - .post(`pricelist/ingredients/extraIngredients`, ingredient) + api + .post('pricelist/ingredients/extraIngredients', ingredient) .then((response: AxiosResponse) => { state.extraIngredients.push(response.data); }) .catch((err) => console.warn(err)); }, updateExtraIngredient(ingredient: FG.ExtraIngredient) { - axios + api .put(`pricelist/ingredients/extraIngredients/${ingredient.id}`, ingredient) .then((response: AxiosResponse) => { const index = state.extraIngredients.findIndex((a) => a.id === ingredient.id); @@ -313,7 +313,7 @@ const actions = { .catch((err) => console.warn(err)); }, deleteExtraIngredient(ingredient: FG.ExtraIngredient) { - axios + api .delete(`pricelist/ingredients/extraIngredients/${ingredient.id}`) .then(() => { const index = state.extraIngredients.findIndex((a) => a.id === ingredient.id); @@ -324,7 +324,7 @@ const actions = { .catch((err) => console.warn(err)); }, getPriceCalcColumn(userid: string) { - axios + api .get(`pricelist/users/${userid}/pricecalc_columns`) .then(({ data }: AxiosResponse>) => { if (data.length > 0) { @@ -334,7 +334,7 @@ const actions = { .catch((err) => console.log(err)); }, updatePriceCalcColumn(userid: string, data: Array) { - axios + api .put(`pricelist/users/${userid}/pricecalc_columns`, data) .then(() => { state.pricecalc_columns = data; @@ -390,3 +390,4 @@ export default { actions, getters, }; +*/ diff --git a/src/plugins/pricelist/components/CalculationTable.vue b/src/plugins/pricelist/components/CalculationTable.vue index d49998a..82095e6 100644 --- a/src/plugins/pricelist/components/CalculationTable.vue +++ b/src/plugins/pricelist/components/CalculationTable.vue @@ -1,5 +1,6 @@