mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
fix household creation (not sure)
This commit is contained in:
parent
94d55a7ca5
commit
a76ed4eb97
1 changed files with 62 additions and 85 deletions
|
@ -94,10 +94,7 @@
|
||||||
icon
|
icon
|
||||||
color="error"
|
color="error"
|
||||||
variant="text"
|
variant="text"
|
||||||
@click.stop="
|
@click.stop="confirmDialog = true; deleteTarget = item.id"
|
||||||
confirmDialog = true;
|
|
||||||
deleteTarget = +item.id;
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<v-icon>
|
<v-icon>
|
||||||
{{ $globals.icons.delete }}
|
{{ $globals.icons.delete }}
|
||||||
|
@ -114,7 +111,7 @@
|
||||||
</v-container>
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import { fieldTypes } from "~/composables/forms";
|
import { fieldTypes } from "~/composables/forms";
|
||||||
import { useGroups } from "~/composables/use-groups";
|
import { useGroups } from "~/composables/use-groups";
|
||||||
import { useAdminHouseholds } from "~/composables/use-households";
|
import { useAdminHouseholds } from "~/composables/use-households";
|
||||||
|
@ -122,92 +119,72 @@ import { validators } from "~/composables/use-validators";
|
||||||
import type { HouseholdInDB } from "~/lib/api/types/household";
|
import type { HouseholdInDB } from "~/lib/api/types/household";
|
||||||
import type { VForm } from "~/types/auto-forms";
|
import type { VForm } from "~/types/auto-forms";
|
||||||
|
|
||||||
export default defineNuxtComponent({
|
definePageMeta({
|
||||||
setup() {
|
layout: "admin",
|
||||||
definePageMeta({
|
});
|
||||||
layout: "admin",
|
|
||||||
});
|
|
||||||
|
|
||||||
const i18n = useI18n();
|
const i18n = useI18n();
|
||||||
|
|
||||||
// Set page title
|
useSeoMeta({
|
||||||
useSeoMeta({
|
title: i18n.t("household.manage-households"),
|
||||||
title: i18n.t("household.manage-households"),
|
});
|
||||||
});
|
|
||||||
|
|
||||||
const { groups } = useGroups();
|
const { groups } = useGroups();
|
||||||
const { households, refreshAllHouseholds, deleteHousehold, createHousehold } = useAdminHouseholds();
|
const { households, deleteHousehold, createHousehold } = useAdminHouseholds();
|
||||||
const refNewHouseholdForm = ref<VForm | null>(null);
|
const refNewHouseholdForm = ref<VForm | null>(null);
|
||||||
|
|
||||||
const state = reactive({
|
const createDialog = ref(false);
|
||||||
createDialog: false,
|
const confirmDialog = ref(false);
|
||||||
confirmDialog: false,
|
const deleteTarget = ref<string>("");
|
||||||
loading: false,
|
const search = ref("");
|
||||||
deleteTarget: 0,
|
const updateMode = ref(false);
|
||||||
search: "",
|
|
||||||
headers: [
|
|
||||||
{
|
|
||||||
title: i18n.t("household.household"),
|
|
||||||
align: "start",
|
|
||||||
sortable: false,
|
|
||||||
value: "id",
|
|
||||||
},
|
|
||||||
{ title: i18n.t("general.name"), value: "name" },
|
|
||||||
{ title: i18n.t("group.group"), value: "group" },
|
|
||||||
{ title: i18n.t("user.total-users"), value: "users" },
|
|
||||||
{ title: i18n.t("user.webhooks-enabled"), value: "webhookEnable" },
|
|
||||||
{ title: i18n.t("general.delete"), value: "actions" },
|
|
||||||
],
|
|
||||||
updateMode: false,
|
|
||||||
createHouseholdForm: {
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
label: i18n.t("household.household-name"),
|
|
||||||
varName: "name",
|
|
||||||
type: fieldTypes.TEXT,
|
|
||||||
rules: ["required"],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
data: {
|
|
||||||
groupId: "",
|
|
||||||
name: "",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
function openDialog() {
|
const headers = [
|
||||||
state.createDialog = true;
|
{
|
||||||
state.createHouseholdForm.data.name = "";
|
title: i18n.t("household.household"),
|
||||||
state.createHouseholdForm.data.groupId = "";
|
align: "start",
|
||||||
}
|
sortable: false,
|
||||||
|
value: "id",
|
||||||
|
},
|
||||||
|
{ title: i18n.t("general.name"), value: "name" },
|
||||||
|
{ title: i18n.t("group.group"), value: "group" },
|
||||||
|
{ title: i18n.t("user.total-users"), value: "users" },
|
||||||
|
{ title: i18n.t("user.webhooks-enabled"), value: "webhookEnable" },
|
||||||
|
{ title: i18n.t("general.delete"), value: "actions" },
|
||||||
|
];
|
||||||
|
|
||||||
const router = useRouter();
|
const createHouseholdForm = reactive({
|
||||||
|
items: [
|
||||||
function handleRowClick(item: HouseholdInDB) {
|
{
|
||||||
router.push(`/admin/manage/households/${item.id}`);
|
label: i18n.t("household.household-name"),
|
||||||
}
|
varName: "name",
|
||||||
|
type: fieldTypes.TEXT,
|
||||||
async function handleCreateSubmit() {
|
rules: ["required"],
|
||||||
if (!refNewHouseholdForm.value?.validate()) {
|
},
|
||||||
return;
|
],
|
||||||
}
|
data: {
|
||||||
|
groupId: "",
|
||||||
state.createDialog = false;
|
name: "",
|
||||||
await createHousehold(state.createHouseholdForm.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
...toRefs(state),
|
|
||||||
refNewHouseholdForm,
|
|
||||||
groups,
|
|
||||||
households,
|
|
||||||
validators,
|
|
||||||
refreshAllHouseholds,
|
|
||||||
deleteHousehold,
|
|
||||||
handleCreateSubmit,
|
|
||||||
openDialog,
|
|
||||||
handleRowClick,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function openDialog() {
|
||||||
|
createDialog.value = true;
|
||||||
|
createHouseholdForm.data.name = "";
|
||||||
|
createHouseholdForm.data.groupId = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
function handleRowClick(item: HouseholdInDB) {
|
||||||
|
router.push(`/admin/manage/households/${item.id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleCreateSubmit() {
|
||||||
|
if (!refNewHouseholdForm.value?.validate()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
createDialog.value = false;
|
||||||
|
await createHousehold(createHouseholdForm.data);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue