[fix] fix public view by grid, revert wrong commit

This commit is contained in:
Tim Gröger 2021-11-15 10:12:20 +01:00
parent 7dc1a1febc
commit f9cfd668bb
2 changed files with 7 additions and 102 deletions

View File

@ -42,8 +42,8 @@
</div>
</div>
<div class="q-pa-sm">
<div v-for="(price, index) in volume.prices" :key="price.id">
<div v-if="isPublic(price, volume)" class="fit row justify-around q-py-sm">
<div v-for="(price, index) in filterPublic(volume.prices)" :key="price.id">
<div class="fit row justify-around q-py-sm">
<div
v-if="!editable || !hasPermission(PERMISSIONS.EDIT_PRICE)"
class="text-body1 col-3"
@ -93,7 +93,7 @@
</q-btn>
</div>
</div>
<q-separator v-if="index < volume.prices.length - 1" />
<q-separator v-if="index < filterPublic(volume.prices).length - 1" />
</div>
<div
v-if="!public && !nodetails && isUnderMinPrice"
@ -294,13 +294,11 @@ export default defineComponent({
emit('update:modelValue', volumes.value);
}
function isPublic(price: FG.DrinkPrice, drink) {
console.log('drink', drink);
function filterPublic(prices: Array<FG.DrinkPrice>) {
if (props.public) {
console.log(price);
return price.public;
return prices.filter((price) => price.public);
}
return true;
return prices;
}
const isUnderMinPrice = computed(() => {
@ -337,7 +335,7 @@ export default defineComponent({
isUnderMinPrice,
hasPermission,
PERMISSIONS,
isPublic,
filterPublic,
};
},
});

93
test.ts
View File

@ -1,93 +0,0 @@
declare namespace FG {
interface Notification {
id: number;
plugin: string;
text: string;
data?: any;
time: Date;
}
interface User {
userid: string;
display_name: string;
firstname: string;
lastname: string;
mail: string;
birthday?: Date;
roles: Array<string>;
permissions?: Array<string>;
avatar_url?: string;
}
interface Session {
expires: Date;
token: string;
lifetime: number;
browser: string;
platform: string;
userid: string;
}
type Permission = string;
interface Role {
id: number;
name: string;
permissions: Array<Permission>;
}
interface Drink {
id: number;
article_id?: string;
package_size?: number;
name: string;
volume?: number;
cost_per_volume?: number;
cost_per_package?: number;
uuid: string;
receipt?: Array<string>;
tags?: Array<Tag>;
type?: DrinkType;
volumes: Array<DrinkPriceVolume>;
}
interface DrinkIngredient {
id: number;
volume: number;
ingredient_id: number;
cost_per_volume: number;
name: string;
}
interface DrinkPrice {
id: number;
price: number;
volume: DrinkPriceVolume;
public: boolean;
description?: string;
}
interface DrinkPriceVolume {
id: number;
drink: Drink;
volume: number;
min_prices: Array<MinPrices>;
prices: Array<DrinkPrice>;
ingredients: Array<Ingredient>;
}
interface DrinkType {
id: number;
name: string;
}
interface ExtraIngredient {
id: number;
name: string;
price: number;
}
interface Ingredient {
id: number;
drink_ingredient?: DrinkIngredient;
extra_ingredient?: ExtraIngredient;
}
interface MinPrices {
percentage: number;
price: number;
}
interface Tag {
id: number;
name: string;
color: string;
}
}