[fix] fix minor linting problems
This commit is contained in:
parent
bcb661cc3f
commit
a5e343ca37
|
@ -68,6 +68,7 @@ module.exports = {
|
|||
quotes: ['warn', 'single', { avoidEscape: true }],
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||
'vue/multi-word-component-names': 'off',
|
||||
|
||||
// allow debugger during development only
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||
|
|
|
@ -2,4 +2,5 @@ node_modules
|
|||
yarn-error.log
|
||||
# No need for sharing this
|
||||
yarn.lock
|
||||
.idea
|
||||
|
||||
|
|
|
@ -23,13 +23,13 @@ declare namespace FG {
|
|||
interface DrinkPrice {
|
||||
id: number;
|
||||
price: number;
|
||||
volume: Array<DrinkPriceVolume>;
|
||||
volume?: DrinkPriceVolume;
|
||||
public: boolean;
|
||||
description?: string;
|
||||
}
|
||||
interface DrinkPriceVolume {
|
||||
id: number;
|
||||
drink: Array<Drink>;
|
||||
drink?: Drink;
|
||||
volume: number;
|
||||
min_prices: Array<MinPrices>;
|
||||
prices: Array<DrinkPrice>;
|
||||
|
|
|
@ -203,7 +203,7 @@ export default defineComponent({
|
|||
id: -1,
|
||||
ingredient_id: newIngredient.value.id,
|
||||
volume: newIngredientVolume.value,
|
||||
cost_per_volume: newIngredient.value.cost_per_volume,
|
||||
cost_per_volume: <number>(<FG.Drink>newIngredient.value).cost_per_volume,
|
||||
name: newIngredient.value.name,
|
||||
},
|
||||
extra_ingredient: undefined,
|
||||
|
@ -243,17 +243,11 @@ export default defineComponent({
|
|||
emit('update:modelValue', unref(edit_ingredients));
|
||||
update();
|
||||
}
|
||||
//const drinks = computed(() =>
|
||||
// store.drinks.filter((drink) => {
|
||||
// console.log('computed drinks', drink.name, drink.cost_per_volume);
|
||||
// return drink.cost_per_volume;
|
||||
// })
|
||||
//);
|
||||
const drinks = ref<Array<Drink>>([]);
|
||||
const _extra_ingredients = computed(() => store.extraIngredients);
|
||||
const extra_ingredients = ref(_extra_ingredients.value);
|
||||
|
||||
async function filter_drinks(val, update) {
|
||||
async function filter_drinks(val: string, update: (a: () => void) => void) {
|
||||
let result = <Array<Drink>>[];
|
||||
if (val === '') {
|
||||
result = await store.getDrinks_no_store({ limit: 5, ingredient: true });
|
||||
|
@ -269,7 +263,7 @@ export default defineComponent({
|
|||
drinks.value = result;
|
||||
});
|
||||
}
|
||||
function filter_extra_ingredients(val, update) {
|
||||
function filter_extra_ingredients(val: string, update: (a: () => void) => void) {
|
||||
if (val === '') {
|
||||
update(() => {
|
||||
extra_ingredients.value = _extra_ingredients.value;
|
||||
|
@ -283,7 +277,7 @@ export default defineComponent({
|
|||
}
|
||||
}
|
||||
|
||||
async function filter(val, update) {
|
||||
async function filter(val: string, update: () => void) {
|
||||
await filter_drinks(val, update);
|
||||
filter_extra_ingredients(val, update);
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ import SearchInput from '../components/SearchInput.vue';
|
|||
import { usePricelistStore, Order } from '../store';
|
||||
import { useMainStore } from '@flaschengeist/api';
|
||||
import { Search, filter } from '../utils/filter';
|
||||
import drag from 'vuedraggable';
|
||||
import draggableComponent from 'vuedraggable';
|
||||
|
||||
interface Row {
|
||||
name: string;
|
||||
|
@ -96,7 +96,7 @@ interface Row {
|
|||
|
||||
export default defineComponent({
|
||||
name: 'Pricelist',
|
||||
components: { SearchInput, drag: <ComponentPublicInstance>drag },
|
||||
components: { SearchInput, drag: draggableComponent },
|
||||
props: {
|
||||
public: {
|
||||
type: Boolean,
|
||||
|
@ -115,7 +115,7 @@ export default defineComponent({
|
|||
} else {
|
||||
user.value = '';
|
||||
}
|
||||
onRequest({ pagination: pagination.value, filter: { limit: 10 } });
|
||||
void onRequest({ pagination: pagination.value });
|
||||
});
|
||||
|
||||
const _order = ref<Array<Order>>([
|
||||
|
@ -174,7 +174,7 @@ export default defineComponent({
|
|||
label: 'Name',
|
||||
//field: 'name',
|
||||
field: 'volume',
|
||||
format: (val: FG.DrinkPriceVolume) => val.drink.name,
|
||||
format: (val: FG.DrinkPriceVolume) => <string>val.drink?.name,
|
||||
sortable: true,
|
||||
filterable: true,
|
||||
align: 'left',
|
||||
|
@ -186,7 +186,7 @@ export default defineComponent({
|
|||
field: 'volume',
|
||||
sortable: true,
|
||||
filterable: true,
|
||||
format: (val: FG.DrinkPriceVolume) => val.drink.type.name,
|
||||
format: (val: FG.DrinkPriceVolume) => <string>val.drink?.type?.name,
|
||||
},
|
||||
{
|
||||
name: 'tags',
|
||||
|
@ -197,8 +197,8 @@ export default defineComponent({
|
|||
|
||||
format: (val: FG.DrinkPriceVolume) => {
|
||||
let retVal = '';
|
||||
val.drink.tags.forEach((tag, index) => {
|
||||
if (index >= val.length - 1 && index > 0) {
|
||||
val.drink?.tags?.forEach((tag, index) => {
|
||||
if (index >= (<Array<FG.Tag>>val.drink?.tags).length - 1 && index > 0) {
|
||||
retVal += ', ';
|
||||
}
|
||||
retVal += tag.name;
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import { innerRoutes, outerRoutes } from './routes';
|
||||
import { FG_Plugin } from '@flaschengeist/typings';
|
||||
import { FG_Plugin } from '@flaschengeist/types';
|
||||
|
||||
const plugin: FG_Plugin.Plugin = {
|
||||
id: 'pricelist',
|
||||
name: 'Pricelist',
|
||||
innerRoutes,
|
||||
outerRoutes,
|
||||
requiredModules: [],
|
||||
requiredBackendModules: ['pricelist'],
|
||||
requiredModules: [['pricelist']],
|
||||
version: '0.0.1',
|
||||
widgets: [],
|
||||
};
|
||||
|
|
|
@ -39,7 +39,7 @@ export default defineComponent({
|
|||
void store.get_min_prices().finally(() => {
|
||||
volume.value.min_prices = calc_min_prices(volume.value, undefined, store.min_prices);
|
||||
});
|
||||
void store.getDrinks();
|
||||
void store.getDrinks({ limit: 10 });
|
||||
void store.getDrinkTypes();
|
||||
void store.getExtraIngredients();
|
||||
});
|
||||
|
|
|
@ -25,7 +25,7 @@ export default defineComponent({
|
|||
const mainStore = useMainStore();
|
||||
|
||||
onBeforeMount(() => {
|
||||
void store.getDrinks();
|
||||
void store.getDrinks({ limit: 10 });
|
||||
void store.getPriceListView(mainStore.currentUser.userid);
|
||||
});
|
||||
|
||||
|
|
|
@ -71,10 +71,8 @@ export default defineComponent({
|
|||
setup() {
|
||||
const store = usePricelistStore();
|
||||
onBeforeMount(() => {
|
||||
//void store.getDrinks();
|
||||
onRequest({
|
||||
void onRequest({
|
||||
pagination: pagination.value,
|
||||
filter: { limit: 10, receipt: true },
|
||||
});
|
||||
});
|
||||
const drinks = computed(
|
||||
|
@ -192,8 +190,8 @@ export default defineComponent({
|
|||
offset: startRow,
|
||||
limit: fetchCount,
|
||||
descending,
|
||||
search_name: props.filter.value,
|
||||
search_key: props.filter.key,
|
||||
search_name: props.filter?.value,
|
||||
search_key: props.filter?.key,
|
||||
receipt: true,
|
||||
});
|
||||
pagination.value.page = page;
|
||||
|
|
|
@ -77,7 +77,7 @@ export default defineComponent({
|
|||
.catch((err) => console.log(err));
|
||||
void store.getTags();
|
||||
void store.getDrinkTypes();
|
||||
void store.getDrinks();
|
||||
void store.getDrinks({ limit: 10 });
|
||||
void store.get_min_prices();
|
||||
});
|
||||
|
||||
|
|
61
src/store.ts
61
src/store.ts
|
@ -14,16 +14,6 @@ interface Drink extends Omit<Omit<FG.Drink, 'cost_per_volume'>, 'volumes'> {
|
|||
_cost_per_volume?: number;
|
||||
}
|
||||
|
||||
interface Pricelist {
|
||||
name: string;
|
||||
type: FG.DrinkType;
|
||||
tags: Array<FG.Tag>;
|
||||
volume: number;
|
||||
price: number;
|
||||
public: boolean;
|
||||
description: string;
|
||||
}
|
||||
|
||||
class DrinkPriceVolume implements DrinkPriceVolume {
|
||||
constructor({ id, volume, prices, ingredients }: FG.DrinkPriceVolume) {
|
||||
this.id = id;
|
||||
|
@ -149,9 +139,12 @@ export const usePricelistStore = defineStore({
|
|||
}) {
|
||||
if (!filter) filter = { limit: 10 };
|
||||
console.log('filter_api', filter);
|
||||
const { data } = await api.get<Array<FG.Drink>>('pricelist/drinks', {
|
||||
params: filter,
|
||||
});
|
||||
const { data } = await api.get<{ drinks: Array<FG.Drink>; count: number }>(
|
||||
'pricelist/drinks',
|
||||
{
|
||||
params: filter,
|
||||
}
|
||||
);
|
||||
this.drinks = [];
|
||||
data.drinks.forEach((drink) => {
|
||||
const _drink = new Drink(drink);
|
||||
|
@ -187,7 +180,7 @@ export const usePricelistStore = defineStore({
|
|||
params: filter,
|
||||
}
|
||||
);
|
||||
const drinks = [];
|
||||
const drinks: Array<Drink> = [];
|
||||
data.drinks.forEach((drink) => {
|
||||
const _drink = new Drink(drink);
|
||||
drink.volumes.forEach((volume) => {
|
||||
|
@ -266,7 +259,9 @@ export const usePricelistStore = defineStore({
|
|||
_ingredient.drink_ingredient &&
|
||||
_ingredient.drink_ingredient.ingredient_id === drink.id
|
||||
) {
|
||||
_ingredient.drink_ingredient.cost_per_volume = drink.cost_per_volume;
|
||||
if (drink.cost_per_volume != null) {
|
||||
_ingredient.drink_ingredient.cost_per_volume = drink.cost_per_volume;
|
||||
}
|
||||
_ingredient.drink_ingredient.name = drink.name;
|
||||
}
|
||||
});
|
||||
|
@ -360,41 +355,7 @@ export const usePricelistStore = defineStore({
|
|||
this.pricelist_columns_order = data;
|
||||
},
|
||||
},
|
||||
getters: {
|
||||
/*pricelist() {
|
||||
const retVal: Array<Pricelist> = [];
|
||||
this.drinks.forEach((drink) => {
|
||||
drink.volumes.forEach((volume) => {
|
||||
volume.prices.forEach((price) => {
|
||||
retVal.push({
|
||||
name: drink.name,
|
||||
type: <FG.DrinkType>drink.type,
|
||||
tags: <Array<FG.Tag>>drink.tags,
|
||||
volume: <number>volume.volume,
|
||||
price: price.price,
|
||||
public: price.public,
|
||||
description: <string>price.description,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
return retVal;
|
||||
},*/
|
||||
computed_pricelist() {
|
||||
const retVal: Array<Pricelist> = [];
|
||||
this.pricelist.forEach((price) => {
|
||||
retVal.push({
|
||||
name: price.volume.drink.name,
|
||||
type: <FG.DrinkType>price.volume.drink.type,
|
||||
tags: <Array<FG.Tag>>price.volume.drink.tags,
|
||||
volume: <number>price.volume.volume,
|
||||
public: price.public,
|
||||
price: price.price,
|
||||
description: <string>price.description,
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
getters: {},
|
||||
});
|
||||
|
||||
export { DrinkPriceVolume, Drink, Order };
|
||||
|
|
Loading…
Reference in New Issue