mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 22:43:34 -07:00
fix cookbook re-ordering
This commit is contained in:
parent
939ef09fb0
commit
c583c5b398
1 changed files with 25 additions and 13 deletions
|
@ -75,7 +75,7 @@
|
||||||
:delay="250"
|
:delay="250"
|
||||||
:delay-on-touch-only="true"
|
:delay-on-touch-only="true"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
@change="actions.updateOrder(myCookbooks)"
|
@end="actions.updateOrder(myCookbooks)"
|
||||||
>
|
>
|
||||||
<v-expansion-panel
|
<v-expansion-panel
|
||||||
v-for="(cookbook, index) in myCookbooks"
|
v-for="(cookbook, index) in myCookbooks"
|
||||||
|
@ -163,13 +163,20 @@ export default defineNuxtComponent({
|
||||||
|
|
||||||
const $auth = useMealieAuth();
|
const $auth = useMealieAuth();
|
||||||
const { cookbooks: allCookbooks, actions } = useCookbooks();
|
const { cookbooks: allCookbooks, actions } = useCookbooks();
|
||||||
const _myCookbooks = computed(
|
|
||||||
() =>
|
// Make a local reactive copy of myCookbooks
|
||||||
allCookbooks.value?.filter((cookbook) => {
|
const myCookbooks = ref<ReadCookBook[]>([]);
|
||||||
return cookbook.householdId === $auth.user.value?.householdId;
|
watch(
|
||||||
}) ?? [],
|
allCookbooks,
|
||||||
|
(cookbooks) => {
|
||||||
|
myCookbooks.value =
|
||||||
|
cookbooks?.filter(
|
||||||
|
(cookbook) => cookbook.householdId === $auth.user.value?.householdId,
|
||||||
|
) ?? [];
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
);
|
);
|
||||||
const myCookbooks = toRef(_myCookbooks, "value");
|
|
||||||
const { household } = useHouseholdSelf();
|
const { household } = useHouseholdSelf();
|
||||||
const cookbookPreferences = useCookbookPreferences();
|
const cookbookPreferences = useCookbookPreferences();
|
||||||
|
|
||||||
|
@ -182,6 +189,11 @@ export default defineNuxtComponent({
|
||||||
String((myCookbooks.value?.length ?? 0) + 1),
|
String((myCookbooks.value?.length ?? 0) + 1),
|
||||||
]) as string;
|
]) as string;
|
||||||
await actions.createOne(name).then((cookbook) => {
|
await actions.createOne(name).then((cookbook) => {
|
||||||
|
if (!cookbook) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
myCookbooks.value.push(cookbook);
|
||||||
createTarget.value = cookbook as ReadCookBook;
|
createTarget.value = cookbook as ReadCookBook;
|
||||||
createTargetKey.value++;
|
createTargetKey.value++;
|
||||||
});
|
});
|
||||||
|
@ -194,21 +206,22 @@ export default defineNuxtComponent({
|
||||||
deleteTarget.value = item;
|
deleteTarget.value = item;
|
||||||
dialogStates.delete = true;
|
dialogStates.delete = true;
|
||||||
}
|
}
|
||||||
function deleteCookbook() {
|
async function deleteCookbook() {
|
||||||
if (!deleteTarget.value) {
|
if (!deleteTarget.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
actions.deleteOne(deleteTarget.value.id);
|
await actions.deleteOne(deleteTarget.value.id);
|
||||||
|
myCookbooks.value = myCookbooks.value.filter((c) => c.id !== deleteTarget.value?.id);
|
||||||
dialogStates.delete = false;
|
dialogStates.delete = false;
|
||||||
deleteTarget.value = null;
|
deleteTarget.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteCreateTarget() {
|
async function deleteCreateTarget() {
|
||||||
if (!createTarget.value?.id) {
|
if (!createTarget.value?.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
await actions.deleteOne(createTarget.value.id);
|
||||||
actions.deleteOne(createTarget.value.id);
|
myCookbooks.value = myCookbooks.value.filter((c) => c.id !== createTarget.value?.id);
|
||||||
dialogStates.create = false;
|
dialogStates.create = false;
|
||||||
createTarget.value = null;
|
createTarget.value = null;
|
||||||
}
|
}
|
||||||
|
@ -216,7 +229,6 @@ export default defineNuxtComponent({
|
||||||
if (!createTarget.value?.id || createTarget.value.queryFilterString) {
|
if (!createTarget.value?.id || createTarget.value.queryFilterString) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteCreateTarget();
|
deleteCreateTarget();
|
||||||
}
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue