1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-02 20:15:24 +02:00

Feature/group items editor (#1064)

* update types

* remove toolbox routes

* remove unused ""

* add generic crud table

* update calls for type safety

* recreate food/unit editors

* fix type error

* remove shopping list link

* add transition

* add basic search box

* conditional show-select

* styling + basic download support

* generic download as json function

* add fraction support

* add export option

* add label text
This commit is contained in:
Hayden 2022-03-17 10:30:10 -08:00 committed by GitHub
parent 86b450fb8c
commit 8c0c8be659
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 674 additions and 364 deletions

View file

@ -1,10 +1,10 @@
import { useAsync, ref, reactive, Ref } from "@nuxtjs/composition-api";
import { useAsyncKey } from "../use-utils";
import { useUserApi } from "~/composables/api";
import { Unit } from "~/api/class-interfaces/recipe-units";
import { VForm } from "~/types/vuetify";
import { IngredientUnit } from "~/types/api-types/recipe";
let unitStore: Ref<Unit[] | null> | null = null;
let unitStore: Ref<IngredientUnit[] | null> | null = null;
export const useUnits = function () {
const api = useUserApi();
@ -12,8 +12,8 @@ export const useUnits = function () {
const deleteTargetId = ref(0);
const validForm = ref(true);
const workingUnitData = reactive({
id: 0,
const workingUnitData: IngredientUnit = reactive({
id: "",
name: "",
fraction: true,
abbreviation: "",
@ -79,12 +79,12 @@ export const useUnits = function () {
}
},
resetWorking() {
workingUnitData.id = 0;
workingUnitData.id = "";
workingUnitData.name = "";
workingUnitData.abbreviation = "";
workingUnitData.description = "";
},
setWorking(item: Unit) {
setWorking(item: IngredientUnit) {
workingUnitData.id = item.id;
workingUnitData.name = item.name;
workingUnitData.fraction = item.fraction;

View file

@ -96,3 +96,14 @@ export function deepCopy<T>(obj: T): T {
}
return rv as T;
}
export function downloadAsJson(data: any, filename: string) {
const content = JSON.stringify(data);
const blob = new Blob([content], { type: "application/json" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.download = filename;
a.href = url;
a.click();
URL.revokeObjectURL(url);
}