diff --git a/frontend/components/Domain/Recipe/RecipeIngredientEditor.vue b/frontend/components/Domain/Recipe/RecipeIngredientEditor.vue index 62436f5f1192..2579cbe9787d 100644 --- a/frontend/components/Domain/Recipe/RecipeIngredientEditor.vue +++ b/frontend/components/Domain/Recipe/RecipeIngredientEditor.vue @@ -20,6 +20,7 @@ class="mx-1" type="number" placeholder="Quantity" + @keypress="quantityFilter" > {{ $globals.icons.arrowUpDown }} @@ -166,7 +167,7 @@ export default defineComponent({ if (state.showTitle) { value.title = ""; } - state.showTitle = !state.showTitle + state.showTitle = !state.showTitle; } function toggleOriginalText() { @@ -211,7 +212,15 @@ export default defineComponent({ return options; }); + function quantityFilter(e: KeyboardEvent) { + // if digit is pressed, add to quantity + if (e.key === "-" || e.key === "+" || e.key === "e") { + e.preventDefault(); + } + } + return { + quantityFilter, toggleOriginalText, contextMenuOptions, handleUnitEnter, diff --git a/frontend/components/Domain/Recipe/RecipeIngredients.vue b/frontend/components/Domain/Recipe/RecipeIngredients.vue index 1b84e1a7813a..412d0a2b8b84 100644 --- a/frontend/components/Domain/Recipe/RecipeIngredients.vue +++ b/frontend/components/Domain/Recipe/RecipeIngredients.vue @@ -10,11 +10,8 @@ - - + + @@ -58,11 +55,7 @@ export default defineComponent({ }); const ingredientCopyText = computed(() => { - return props.value - .map((ingredient) => { - return `- [ ] ${parseIngredientText(ingredient, props.disableAmount, props.scale)}`; - }) - .join("\n"); + return ingredientDisplay.value.join("\n"); }); function toggleChecked(index: number) { @@ -71,7 +64,14 @@ export default defineComponent({ state.checked.splice(index, 1, !state.checked[index]); } + const ingredientDisplay = computed(() => { + return props.value.map((ingredient) => { + return `${parseIngredientText(ingredient, props.disableAmount, props.scale)}`; + }); + }); + return { + ingredientDisplay, ...toRefs(state), parseIngredientText, ingredientCopyText, diff --git a/frontend/composables/recipes/use-recipe-ingredients.ts b/frontend/composables/recipes/use-recipe-ingredients.ts index f4e3878592c2..9d2bd06d65c3 100644 --- a/frontend/composables/recipes/use-recipe-ingredients.ts +++ b/frontend/composables/recipes/use-recipe-ingredients.ts @@ -5,8 +5,8 @@ const { frac } = useFraction(); function sanitizeIngredientHTML(rawHtml: string) { return DOMPurify.sanitize(rawHtml, { - "USE_PROFILES": {html: true}, - "ALLOWED_TAGS": ["b", "q", "i", "strong", "sup"] + USE_PROFILES: { html: true }, + ALLOWED_TAGS: ["b", "q", "i", "strong", "sup"], }); } @@ -18,7 +18,10 @@ export function parseIngredientText(ingredient: RecipeIngredient, disableAmount: const { quantity, food, unit, note } = ingredient; let returnQty = ""; - if (quantity !== undefined && quantity !== 0) { + + // casting to number is required as sometimes quantity is a string + if (quantity && Number(quantity) !== 0) { + console.log("Using Quantity", quantity, typeof quantity); if (unit?.fraction) { const fraction = frac(quantity * scale, 10, true); if (fraction[0] !== undefined && fraction[0] > 0) { diff --git a/frontend/pages/register/register.vue b/frontend/pages/register/register.vue index 28baecdb7205..339dee652fc6 100644 --- a/frontend/pages/register/register.vue +++ b/frontend/pages/register/register.vue @@ -18,7 +18,7 @@
- + @@ -225,14 +225,14 @@ {{ $t("general.confirm") }} -