mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
Alias Manager
This commit is contained in:
parent
1cb1a0552b
commit
8a68278290
2 changed files with 56 additions and 76 deletions
|
@ -33,7 +33,7 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import { whenever } from "@vueuse/core";
|
import { whenever } from "@vueuse/core";
|
||||||
import { validators } from "~/composables/use-validators";
|
import { validators } from "~/composables/use-validators";
|
||||||
import type { IngredientFood, IngredientUnit } from "~/lib/api/types/recipe";
|
import type { IngredientFood, IngredientUnit } from "~/lib/api/types/recipe";
|
||||||
|
@ -42,28 +42,19 @@ export interface GenericAlias {
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineNuxtComponent({
|
interface Props {
|
||||||
props: {
|
data: IngredientFood | IngredientUnit;
|
||||||
modelValue: {
|
}
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
const props = defineProps<Props>();
|
||||||
},
|
|
||||||
data: {
|
const emit = defineEmits<{
|
||||||
type: Object as () => IngredientFood | IngredientUnit,
|
submit: [aliases: GenericAlias[]];
|
||||||
required: true,
|
cancel: [];
|
||||||
},
|
}>();
|
||||||
},
|
|
||||||
emits: ["submit", "update:modelValue", "cancel"],
|
|
||||||
setup(props, context) {
|
|
||||||
// V-Model Support
|
// V-Model Support
|
||||||
const dialog = computed({
|
const dialog = defineModel<boolean>({ default: false });
|
||||||
get: () => {
|
|
||||||
return props.modelValue;
|
|
||||||
},
|
|
||||||
set: (val) => {
|
|
||||||
context.emit("update:modelValue", val);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
function createAlias() {
|
function createAlias() {
|
||||||
aliases.value.push({
|
aliases.value.push({
|
||||||
|
@ -85,7 +76,7 @@ export default defineNuxtComponent({
|
||||||
|
|
||||||
initAliases();
|
initAliases();
|
||||||
whenever(
|
whenever(
|
||||||
() => props.modelValue,
|
() => dialog.value,
|
||||||
() => {
|
() => {
|
||||||
initAliases();
|
initAliases();
|
||||||
},
|
},
|
||||||
|
@ -111,17 +102,6 @@ export default defineNuxtComponent({
|
||||||
});
|
});
|
||||||
|
|
||||||
aliases.value = keepAliases;
|
aliases.value = keepAliases;
|
||||||
context.emit("submit", keepAliases);
|
emit("submit", keepAliases);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
|
||||||
aliases,
|
|
||||||
createAlias,
|
|
||||||
dialog,
|
|
||||||
deleteAlias,
|
|
||||||
saveAliases,
|
|
||||||
validators,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
<!-- Alias Sub-Dialog -->
|
<!-- Alias Sub-Dialog -->
|
||||||
<RecipeDataAliasManagerDialog
|
<RecipeDataAliasManagerDialog
|
||||||
v-if="editTarget"
|
v-if="editTarget"
|
||||||
:value="aliasManagerDialog"
|
v-model="aliasManagerDialog"
|
||||||
:data="editTarget"
|
:data="editTarget"
|
||||||
can-submit
|
can-submit
|
||||||
@submit="updateUnitAlias"
|
@submit="updateUnitAlias"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue