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

feat: add unit abbreviation support (#1332)

* add 'use-abbreviation' db column

* type generation

* add view and edit elements

* check for use_abbreviation to display

* fix: alembic version check

* test: add use_abbreviation prop tests
This commit is contained in:
Hayden 2022-06-01 11:59:50 -08:00 committed by GitHub
parent 592b1de39d
commit 52fbf6b833
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 77 additions and 9 deletions

View file

@ -19,6 +19,8 @@ export function parseIngredientText(ingredient: RecipeIngredient, disableAmount:
let returnQty = "";
let unitDisplay = unit?.name;
// casting to number is required as sometimes quantity is a string
if (quantity && Number(quantity) !== 0) {
console.log("Using Quantity", quantity, typeof quantity);
@ -34,8 +36,12 @@ export function parseIngredientText(ingredient: RecipeIngredient, disableAmount:
} else {
returnQty = (quantity * scale).toString();
}
if (unit?.useAbbreviation && unit.abbreviation) {
unitDisplay = unit.abbreviation;
}
}
const text = `${returnQty} ${unit?.name || " "} ${food?.name || " "} ${note || " "}`.replace(/ {2,}/g, " ");
const text = `${returnQty} ${unitDisplay || " "} ${food?.name || " "} ${note || " "}`.replace(/ {2,}/g, " ");
return sanitizeIngredientHTML(text);
}

View file

@ -36,6 +36,7 @@
<v-text-field v-model="editTarget.abbreviation" label="Abbreviation"></v-text-field>
<v-text-field v-model="editTarget.description" label="Description"></v-text-field>
<v-checkbox v-model="editTarget.fraction" hide-details label="Display as Fraction"></v-checkbox>
<v-checkbox v-model="editTarget.useAbbreviation" hide-details label="Use Abbreviation"></v-checkbox>
</v-form>
</v-card-text>
</BaseDialog>
@ -106,6 +107,11 @@
Combine
</BaseButton>
</template>
<template #item.useAbbreviation="{ item }">
<v-icon :color="item.useAbbreviation ? 'success' : undefined">
{{ item.useAbbreviation ? $globals.icons.check : $globals.icons.close }}
</v-icon>
</template>
<template #item.fraction="{ item }">
<v-icon :color="item.fraction ? 'success' : undefined">
{{ item.fraction ? $globals.icons.check : $globals.icons.close }}
@ -153,10 +159,15 @@ export default defineComponent({
value: "abbreviation",
show: true,
},
{
text: "Use Abbv.",
value: "useAbbreviation",
show: true,
},
{
text: "Description",
value: "description",
show: true,
show: false,
},
{
text: "Fraction",

View file

@ -133,6 +133,7 @@ export interface IngredientUnit {
description?: string;
fraction?: boolean;
abbreviation?: string;
useAbbreviation?: boolean;
id: string;
}
export interface CreateIngredientUnit {
@ -140,6 +141,7 @@ export interface CreateIngredientUnit {
description?: string;
fraction?: boolean;
abbreviation?: string;
useAbbreviation?: boolean;
}
export interface IngredientFood {
name: string;

View file

@ -112,6 +112,7 @@ export interface IngredientUnit {
description?: string;
fraction?: boolean;
abbreviation?: string;
useAbbreviation?: boolean;
id: string;
}
export interface CreateIngredientUnit {
@ -119,6 +120,7 @@ export interface CreateIngredientUnit {
description?: string;
fraction?: boolean;
abbreviation?: string;
useAbbreviation?: boolean;
}
export interface IngredientFood {
name: string;

View file

@ -207,6 +207,7 @@ export interface IngredientUnit {
description?: string;
fraction?: boolean;
abbreviation?: string;
useAbbreviation?: boolean;
id: string;
}
export interface ReadGroupPreferences {
@ -287,6 +288,7 @@ export interface CreateIngredientUnit {
description?: string;
fraction?: boolean;
abbreviation?: string;
useAbbreviation?: boolean;
}
export interface CreateIngredientFood {
name: string;

View file

@ -148,6 +148,7 @@ export interface IngredientUnit {
description?: string;
fraction?: boolean;
abbreviation?: string;
useAbbreviation?: boolean;
id: string;
}
export interface CreateIngredientUnit {
@ -155,6 +156,7 @@ export interface CreateIngredientUnit {
description?: string;
fraction?: boolean;
abbreviation?: string;
useAbbreviation?: boolean;
}
export interface IngredientFood {
name: string;

View file

@ -49,6 +49,7 @@ export interface CreateIngredientUnit {
description?: string;
fraction?: boolean;
abbreviation?: string;
useAbbreviation?: boolean;
}
export interface CreateRecipe {
name: string;
@ -117,6 +118,7 @@ export interface IngredientUnit {
description?: string;
fraction?: boolean;
abbreviation?: string;
useAbbreviation?: boolean;
id: string;
}
export interface IngredientsRequest {
@ -340,6 +342,7 @@ export interface SaveIngredientUnit {
description?: string;
fraction?: boolean;
abbreviation?: string;
useAbbreviation?: boolean;
groupId: string;
}
export interface ScrapeRecipe {

View file

@ -164,6 +164,7 @@ export interface IngredientUnit {
description?: string;
fraction?: boolean;
abbreviation?: string;
useAbbreviation?: boolean;
id: string;
}
export interface CreateIngredientUnit {
@ -171,6 +172,7 @@ export interface CreateIngredientUnit {
description?: string;
fraction?: boolean;
abbreviation?: string;
useAbbreviation?: boolean;
}
export interface IngredientFood {
name: string;