Skip to content

Commit

Permalink
feat(prompts): food entry auto focus option (#V4-1357)
Browse files Browse the repository at this point in the history
  • Loading branch information
mechkg committed Jan 15, 2025
1 parent 0fbbfab commit 9bf1306
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
10 changes: 10 additions & 0 deletions apps/admin/src/components/prompts/standard/edit-meal-prompt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
:model-value="separateDrinks"
@update:model-value="update('separateDrinks', $event)"
/>
<v-switch
hide-details="auto"
:label="$t('survey-schemes.prompts.edit-meal-prompt.inputAutoFocus')"
:model-value="inputAutoFocus"
@update:model-value="update('inputAutoFocus', $event)"
/>
</v-col>
</v-row>
</v-tabs-window-item>
Expand All @@ -31,6 +37,10 @@ export default defineComponent({
type: Boolean as PropType<Prompts['edit-meal-prompt']['separateDrinks']>,
required: true,
},
inputAutoFocus: {
type: Boolean as PropType<Prompts['edit-meal-prompt']['inputAutoFocus']>,
required: true,
},
},
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<editable-food-list
v-model="foodsOnly"
v-bind="{ prompt, section }"
focus
:focus="prompt.inputAutoFocus"
mode="foodsOnly"
@delete="deleteFood"
/>
Expand All @@ -19,7 +19,7 @@
v-else
v-bind="{ prompt, section }"
v-model="state"
focus
:focus="prompt.inputAutoFocus"
@delete="deleteFood"
/>
<template #actions>
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/prompts/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ const generalAssociatedFoodsPrompt = baseStandardPrompt.merge(foodBrowser).exten
const editMealPrompt = baseStandardPrompt.extend({
component: z.literal('edit-meal-prompt'),
separateDrinks: z.boolean(),
inputAutoFocus: z.boolean(),
});

const externalSourcePrompt = baseStandardPrompt.extend({
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/prompts/standard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const editMealPrompt: Prompts['edit-meal-prompt'] = copy({
id: 'edit-meal-prompt',
name: 'Meal Edit prompt',
separateDrinks: false,
inputAutoFocus: true,
});

export const externalSourcePrompt: Prompts['external-source-prompt'] = copy({
Expand Down
3 changes: 2 additions & 1 deletion packages/i18n/src/admin/en/survey-schemes.json
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@
"edit-meal-prompt": {
"title": "Food list",
"subtitle": "List or edit foods in this meal as free text descriptions",
"separateDrinks": "Separate drinks list"
"separateDrinks": "Separate drinks list",
"inputAutoFocus": "Automatically set focus to the food entry text field"
},
"external-source-prompt": {
"title": "External source",
Expand Down

0 comments on commit 9bf1306

Please sign in to comment.