[fix] fix minor linting problems

This commit is contained in:
Tim Gröger 2021-11-16 09:52:09 +01:00
parent bcb661cc3f
commit a5e343ca37
11 changed files with 34 additions and 80 deletions

View File

@ -68,6 +68,7 @@ module.exports = {
quotes: ['warn', 'single', { avoidEscape: true }], quotes: ['warn', 'single', { avoidEscape: true }],
'@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off',
'vue/multi-word-component-names': 'off',
// allow debugger during development only // allow debugger during development only
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',

1
.gitignore vendored
View File

@ -2,4 +2,5 @@ node_modules
yarn-error.log yarn-error.log
# No need for sharing this # No need for sharing this
yarn.lock yarn.lock
.idea

4
src/api.d.ts vendored
View File

@ -23,13 +23,13 @@ declare namespace FG {
interface DrinkPrice { interface DrinkPrice {
id: number; id: number;
price: number; price: number;
volume: Array<DrinkPriceVolume>; volume?: DrinkPriceVolume;
public: boolean; public: boolean;
description?: string; description?: string;
} }
interface DrinkPriceVolume { interface DrinkPriceVolume {
id: number; id: number;
drink: Array<Drink>; drink?: Drink;
volume: number; volume: number;
min_prices: Array<MinPrices>; min_prices: Array<MinPrices>;
prices: Array<DrinkPrice>; prices: Array<DrinkPrice>;

View File

@ -203,7 +203,7 @@ export default defineComponent({
id: -1, id: -1,
ingredient_id: newIngredient.value.id, ingredient_id: newIngredient.value.id,
volume: newIngredientVolume.value, 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, name: newIngredient.value.name,
}, },
extra_ingredient: undefined, extra_ingredient: undefined,
@ -243,17 +243,11 @@ export default defineComponent({
emit('update:modelValue', unref(edit_ingredients)); emit('update:modelValue', unref(edit_ingredients));
update(); 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 drinks = ref<Array<Drink>>([]);
const _extra_ingredients = computed(() => store.extraIngredients); const _extra_ingredients = computed(() => store.extraIngredients);
const extra_ingredients = ref(_extra_ingredients.value); 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>>[]; let result = <Array<Drink>>[];
if (val === '') { if (val === '') {
result = await store.getDrinks_no_store({ limit: 5, ingredient: true }); result = await store.getDrinks_no_store({ limit: 5, ingredient: true });
@ -269,7 +263,7 @@ export default defineComponent({
drinks.value = result; drinks.value = result;
}); });
} }
function filter_extra_ingredients(val, update) { function filter_extra_ingredients(val: string, update: (a: () => void) => void) {
if (val === '') { if (val === '') {
update(() => { update(() => {
extra_ingredients.value = _extra_ingredients.value; 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); await filter_drinks(val, update);
filter_extra_ingredients(val, update); filter_extra_ingredients(val, update);
} }

View File

@ -82,7 +82,7 @@ import SearchInput from '../components/SearchInput.vue';
import { usePricelistStore, Order } from '../store'; import { usePricelistStore, Order } from '../store';
import { useMainStore } from '@flaschengeist/api'; import { useMainStore } from '@flaschengeist/api';
import { Search, filter } from '../utils/filter'; import { Search, filter } from '../utils/filter';
import drag from 'vuedraggable'; import draggableComponent from 'vuedraggable';
interface Row { interface Row {
name: string; name: string;
@ -96,7 +96,7 @@ interface Row {
export default defineComponent({ export default defineComponent({
name: 'Pricelist', name: 'Pricelist',
components: { SearchInput, drag: <ComponentPublicInstance>drag }, components: { SearchInput, drag: draggableComponent },
props: { props: {
public: { public: {
type: Boolean, type: Boolean,
@ -115,7 +115,7 @@ export default defineComponent({
} else { } else {
user.value = ''; user.value = '';
} }
onRequest({ pagination: pagination.value, filter: { limit: 10 } }); void onRequest({ pagination: pagination.value });
}); });
const _order = ref<Array<Order>>([ const _order = ref<Array<Order>>([
@ -174,7 +174,7 @@ export default defineComponent({
label: 'Name', label: 'Name',
//field: 'name', //field: 'name',
field: 'volume', field: 'volume',
format: (val: FG.DrinkPriceVolume) => val.drink.name, format: (val: FG.DrinkPriceVolume) => <string>val.drink?.name,
sortable: true, sortable: true,
filterable: true, filterable: true,
align: 'left', align: 'left',
@ -186,7 +186,7 @@ export default defineComponent({
field: 'volume', field: 'volume',
sortable: true, sortable: true,
filterable: true, filterable: true,
format: (val: FG.DrinkPriceVolume) => val.drink.type.name, format: (val: FG.DrinkPriceVolume) => <string>val.drink?.type?.name,
}, },
{ {
name: 'tags', name: 'tags',
@ -197,8 +197,8 @@ export default defineComponent({
format: (val: FG.DrinkPriceVolume) => { format: (val: FG.DrinkPriceVolume) => {
let retVal = ''; let retVal = '';
val.drink.tags.forEach((tag, index) => { val.drink?.tags?.forEach((tag, index) => {
if (index >= val.length - 1 && index > 0) { if (index >= (<Array<FG.Tag>>val.drink?.tags).length - 1 && index > 0) {
retVal += ', '; retVal += ', ';
} }
retVal += tag.name; retVal += tag.name;

View File

@ -1,13 +1,12 @@
import { innerRoutes, outerRoutes } from './routes'; import { innerRoutes, outerRoutes } from './routes';
import { FG_Plugin } from '@flaschengeist/typings'; import { FG_Plugin } from '@flaschengeist/types';
const plugin: FG_Plugin.Plugin = { const plugin: FG_Plugin.Plugin = {
id: 'pricelist', id: 'pricelist',
name: 'Pricelist', name: 'Pricelist',
innerRoutes, innerRoutes,
outerRoutes, outerRoutes,
requiredModules: [], requiredModules: [['pricelist']],
requiredBackendModules: ['pricelist'],
version: '0.0.1', version: '0.0.1',
widgets: [], widgets: [],
}; };

View File

@ -39,7 +39,7 @@ export default defineComponent({
void store.get_min_prices().finally(() => { void store.get_min_prices().finally(() => {
volume.value.min_prices = calc_min_prices(volume.value, undefined, store.min_prices); 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.getDrinkTypes();
void store.getExtraIngredients(); void store.getExtraIngredients();
}); });

View File

@ -25,7 +25,7 @@ export default defineComponent({
const mainStore = useMainStore(); const mainStore = useMainStore();
onBeforeMount(() => { onBeforeMount(() => {
void store.getDrinks(); void store.getDrinks({ limit: 10 });
void store.getPriceListView(mainStore.currentUser.userid); void store.getPriceListView(mainStore.currentUser.userid);
}); });

View File

@ -71,10 +71,8 @@ export default defineComponent({
setup() { setup() {
const store = usePricelistStore(); const store = usePricelistStore();
onBeforeMount(() => { onBeforeMount(() => {
//void store.getDrinks(); void onRequest({
onRequest({
pagination: pagination.value, pagination: pagination.value,
filter: { limit: 10, receipt: true },
}); });
}); });
const drinks = computed( const drinks = computed(
@ -192,8 +190,8 @@ export default defineComponent({
offset: startRow, offset: startRow,
limit: fetchCount, limit: fetchCount,
descending, descending,
search_name: props.filter.value, search_name: props.filter?.value,
search_key: props.filter.key, search_key: props.filter?.key,
receipt: true, receipt: true,
}); });
pagination.value.page = page; pagination.value.page = page;

View File

@ -77,7 +77,7 @@ export default defineComponent({
.catch((err) => console.log(err)); .catch((err) => console.log(err));
void store.getTags(); void store.getTags();
void store.getDrinkTypes(); void store.getDrinkTypes();
void store.getDrinks(); void store.getDrinks({ limit: 10 });
void store.get_min_prices(); void store.get_min_prices();
}); });

View File

@ -14,16 +14,6 @@ interface Drink extends Omit<Omit<FG.Drink, 'cost_per_volume'>, 'volumes'> {
_cost_per_volume?: number; _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 { class DrinkPriceVolume implements DrinkPriceVolume {
constructor({ id, volume, prices, ingredients }: FG.DrinkPriceVolume) { constructor({ id, volume, prices, ingredients }: FG.DrinkPriceVolume) {
this.id = id; this.id = id;
@ -149,9 +139,12 @@ export const usePricelistStore = defineStore({
}) { }) {
if (!filter) filter = { limit: 10 }; if (!filter) filter = { limit: 10 };
console.log('filter_api', filter); console.log('filter_api', filter);
const { data } = await api.get<Array<FG.Drink>>('pricelist/drinks', { const { data } = await api.get<{ drinks: Array<FG.Drink>; count: number }>(
params: filter, 'pricelist/drinks',
}); {
params: filter,
}
);
this.drinks = []; this.drinks = [];
data.drinks.forEach((drink) => { data.drinks.forEach((drink) => {
const _drink = new Drink(drink); const _drink = new Drink(drink);
@ -187,7 +180,7 @@ export const usePricelistStore = defineStore({
params: filter, params: filter,
} }
); );
const drinks = []; const drinks: Array<Drink> = [];
data.drinks.forEach((drink) => { data.drinks.forEach((drink) => {
const _drink = new Drink(drink); const _drink = new Drink(drink);
drink.volumes.forEach((volume) => { drink.volumes.forEach((volume) => {
@ -266,7 +259,9 @@ export const usePricelistStore = defineStore({
_ingredient.drink_ingredient && _ingredient.drink_ingredient &&
_ingredient.drink_ingredient.ingredient_id === drink.id _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; _ingredient.drink_ingredient.name = drink.name;
} }
}); });
@ -360,41 +355,7 @@ export const usePricelistStore = defineStore({
this.pricelist_columns_order = data; this.pricelist_columns_order = data;
}, },
}, },
getters: { 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,
});
});
},
},
}); });
export { DrinkPriceVolume, Drink, Order }; export { DrinkPriceVolume, Drink, Order };