mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-05-24 01:12:54 -04:00
* Activate more linting rules from eslint and typescript * Properly add VForm as type information * Fix usage of native types * Fix more linting issues * Rename vuetify types file, add VTooltip * Fix some more typing problems * Use composition API for more components * Convert RecipeRating * Convert RecipeNutrition * Convert more components to composition API * Fix globals plugin for type checking * Add missing icon types * Fix vuetify types in Nuxt context * Use composition API for RecipeActionMenu * Convert error.vue to composition API * Convert RecipeContextMenu to composition API * Use more composition API and type checking in recipe/create * Convert AppButtonUpload to composition API * Fix some type checking in RecipeContextMenu * Remove unused components BaseAutoForm and BaseColorPicker * Convert RecipeCategoryTagDialog to composition API * Convert RecipeCardSection to composition API * Convert RecipeCategoryTagSelector to composition API * Properly import vuetify type definitions * Convert BaseButton to composition API * Convert AutoForm to composition API * Remove unused requests API file * Remove static routes from recipe API * Fix more type errors * Convert AppHeader to composition API, fixing some search bar focus problems * Convert RecipeDialogSearch to composition API * Update API types from pydantic models, handle undefined values * Improve more typing problems * Add types to other plugins * Properly type the CRUD API access * Fix typing of static image routes * Fix more typing stuff * Fix some more typing problems * Turn off more rules
168 lines
3.8 KiB
Vue
168 lines
3.8 KiB
Vue
<template>
|
|
<v-data-table
|
|
v-model="selected"
|
|
item-key="id"
|
|
show-select
|
|
:headers="headers"
|
|
:items="recipes"
|
|
:items-per-page="15"
|
|
class="elevation-0"
|
|
:loading="loading"
|
|
@input="setValue(selected)"
|
|
>
|
|
<template #body.preappend>
|
|
<tr>
|
|
<td></td>
|
|
<td>Hello</td>
|
|
<td colspan="4"></td>
|
|
</tr>
|
|
</template>
|
|
<template #item.tags="{ item }">
|
|
<RecipeChip small :items="item.tags" />
|
|
</template>
|
|
<template #item.recipeCategory="{ item }">
|
|
<RecipeChip small :items="item.recipeCategory" />
|
|
</template>
|
|
<template #item.tools="{ item }">
|
|
<RecipeChip small :items="item.tools" />
|
|
</template>
|
|
<template #item.userId="{ item }">
|
|
<v-list-item class="justify-start">
|
|
<v-list-item-avatar>
|
|
<img src="https://i.pravatar.cc/300" alt="John" />
|
|
</v-list-item-avatar>
|
|
<v-list-item-content>
|
|
<v-list-item-title v-text="getMember(item.userId)"></v-list-item-title>
|
|
</v-list-item-content>
|
|
</v-list-item>
|
|
</template>
|
|
</v-data-table>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { computed, defineComponent, onMounted, ref } from "@nuxtjs/composition-api";
|
|
import RecipeChip from "./RecipeChips.vue";
|
|
import { Recipe } from "~/types/api-types/recipe";
|
|
import { useUserApi } from "~/composables/api";
|
|
import { UserOut } from "~/types/api-types/user";
|
|
|
|
const INPUT_EVENT = "input";
|
|
|
|
interface ShowHeaders {
|
|
id: boolean;
|
|
owner: boolean;
|
|
tags: boolean;
|
|
categories: boolean;
|
|
tools: boolean;
|
|
recipeYield: boolean;
|
|
dateAdded: boolean;
|
|
}
|
|
|
|
export default defineComponent({
|
|
components: { RecipeChip },
|
|
props: {
|
|
value: {
|
|
type: Array,
|
|
required: false,
|
|
default: () => [],
|
|
},
|
|
loading: {
|
|
type: Boolean,
|
|
required: false,
|
|
default: false,
|
|
},
|
|
recipes: {
|
|
type: Array as () => Recipe[],
|
|
default: () => [],
|
|
},
|
|
showHeaders: {
|
|
type: Object as () => ShowHeaders,
|
|
required: false,
|
|
default: () => {
|
|
return {
|
|
id: true,
|
|
owner: false,
|
|
tags: true,
|
|
categories: true,
|
|
recipeYield: true,
|
|
dateAdded: true,
|
|
};
|
|
},
|
|
},
|
|
},
|
|
setup(props, context) {
|
|
function setValue(value: Recipe[]) {
|
|
context.emit(INPUT_EVENT, value);
|
|
}
|
|
|
|
const show = props.showHeaders;
|
|
const headers = computed(() => {
|
|
const hdrs = [];
|
|
|
|
if (show.id) {
|
|
hdrs.push({ text: "Id", value: "id" });
|
|
}
|
|
if (show.owner) {
|
|
hdrs.push({ text: "Owner", value: "userId", align: "center" });
|
|
}
|
|
hdrs.push({ text: "Name", value: "name" });
|
|
if (show.categories) {
|
|
hdrs.push({ text: "Categories", value: "recipeCategory" });
|
|
}
|
|
|
|
if (show.tags) {
|
|
hdrs.push({ text: "Tags", value: "tags" });
|
|
}
|
|
if (show.tools) {
|
|
hdrs.push({ text: "Tools", value: "tools" });
|
|
}
|
|
if (show.recipeYield) {
|
|
hdrs.push({ text: "Yield", value: "recipeYield" });
|
|
}
|
|
if (show.dateAdded) {
|
|
hdrs.push({ text: "Date Added", value: "dateAdded" });
|
|
}
|
|
|
|
return hdrs;
|
|
});
|
|
|
|
// ============
|
|
// Group Members
|
|
const api = useUserApi();
|
|
const members = ref<UserOut[]>([]);
|
|
|
|
async function refreshMembers() {
|
|
const { data } = await api.groups.fetchMembers();
|
|
if (data) {
|
|
members.value = data;
|
|
}
|
|
}
|
|
|
|
onMounted(() => {
|
|
refreshMembers();
|
|
});
|
|
|
|
function getMember(id: string) {
|
|
if (members.value[0]) {
|
|
return members.value.find((m) => m.id === id)?.username;
|
|
}
|
|
|
|
return "None";
|
|
}
|
|
|
|
return { setValue, headers, members, getMember };
|
|
},
|
|
|
|
data() {
|
|
return {
|
|
selected: [],
|
|
};
|
|
},
|
|
watch: {
|
|
value(val) {
|
|
this.selected = val;
|
|
},
|
|
},
|
|
});
|
|
</script>
|