| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  | <template> | 
					
						
							|  |  |  |   <div> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     <div | 
					
						
							|  |  |  |       class="d-md-flex" | 
					
						
							|  |  |  |       style="gap: 10px" | 
					
						
							|  |  |  |     > | 
					
						
							|  |  |  |       <v-select | 
					
						
							|  |  |  |         v-model="inputDay" | 
					
						
							|  |  |  |         :items="MEAL_DAY_OPTIONS" | 
					
						
							|  |  |  |         :label="$t('meal-plan.rule-day')" | 
					
						
							|  |  |  |       /> | 
					
						
							|  |  |  |       <v-select | 
					
						
							|  |  |  |         v-model="inputEntryType" | 
					
						
							|  |  |  |         :items="MEAL_TYPE_OPTIONS" | 
					
						
							|  |  |  |         :label="$t('meal-plan.meal-type')" | 
					
						
							|  |  |  |       /> | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |     </div> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-27 09:06:45 -05:00
										 |  |  |     <div class="mb-5"> | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  |       <QueryFilterBuilder | 
					
						
							|  |  |  |         :field-defs="fieldDefs" | 
					
						
							|  |  |  |         :initial-query-filter="queryFilter" | 
					
						
							|  |  |  |         @input="handleQueryFilterInput" | 
					
						
							| 
									
										
										
										
											2024-09-27 09:06:45 -05:00
										 |  |  |       /> | 
					
						
							|  |  |  |     </div> | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |     <!-- TODO: proper pluralization of inputDay --> | 
					
						
							|  |  |  |     {{ $t('meal-plan.this-rule-will-apply', { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       dayCriteria: inputDay === "unset" ? $t('meal-plan.to-all-days') : $t('meal-plan.on-days', [inputDay]), | 
					
						
							|  |  |  |       mealTypeCriteria: inputEntryType === "unset" ? $t('meal-plan.for-all-meal-types') : $t('meal-plan.for-type-meal-types', [inputEntryType]), | 
					
						
							|  |  |  |     }) }} | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |   </div> | 
					
						
							|  |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <script lang="ts"> | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  | import QueryFilterBuilder from "~/components/Domain/QueryFilterBuilder.vue"; | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | import type { FieldDefinition } from "~/composables/use-query-filter-builder"; | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  | import { Organizer } from "~/lib/api/types/non-generated"; | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | import type { QueryFilterJSON } from "~/lib/api/types/response"; | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | export default defineNuxtComponent({ | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |   components: { | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  |     QueryFilterBuilder, | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |   }, | 
					
						
							|  |  |  |   props: { | 
					
						
							|  |  |  |     day: { | 
					
						
							|  |  |  |       type: String, | 
					
						
							|  |  |  |       default: "unset", | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     entryType: { | 
					
						
							|  |  |  |       type: String, | 
					
						
							|  |  |  |       default: "unset", | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  |     queryFilterString: { | 
					
						
							|  |  |  |       type: String, | 
					
						
							|  |  |  |       default: "", | 
					
						
							| 
									
										
										
										
											2024-09-27 09:06:45 -05:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  |     queryFilter: { | 
					
						
							|  |  |  |       type: Object as () => QueryFilterJSON, | 
					
						
							|  |  |  |       default: null, | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |     }, | 
					
						
							|  |  |  |     showHelp: { | 
					
						
							|  |  |  |       type: Boolean, | 
					
						
							|  |  |  |       default: false, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |   }, | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |   emits: ["update:day", "update:entry-type", "update:query-filter-string"], | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |   setup(props, context) { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     const i18n = useI18n(); | 
					
						
							| 
									
										
										
										
											2022-08-10 07:12:45 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const MEAL_TYPE_OPTIONS = [ | 
					
						
							| 
									
										
										
										
											2025-06-28 15:59:58 +02:00
										 |  |  |       { title: i18n.t("meal-plan.breakfast"), value: "breakfast" }, | 
					
						
							|  |  |  |       { title: i18n.t("meal-plan.lunch"), value: "lunch" }, | 
					
						
							|  |  |  |       { title: i18n.t("meal-plan.dinner"), value: "dinner" }, | 
					
						
							|  |  |  |       { title: i18n.t("meal-plan.side"), value: "side" }, | 
					
						
							|  |  |  |       { title: i18n.t("meal-plan.type-any"), value: "unset" }, | 
					
						
							| 
									
										
										
										
											2022-08-10 07:12:45 +02:00
										 |  |  |     ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const MEAL_DAY_OPTIONS = [ | 
					
						
							| 
									
										
										
										
											2025-06-28 15:59:58 +02:00
										 |  |  |       { title: i18n.t("general.monday"), value: "monday" }, | 
					
						
							|  |  |  |       { title: i18n.t("general.tuesday"), value: "tuesday" }, | 
					
						
							|  |  |  |       { title: i18n.t("general.wednesday"), value: "wednesday" }, | 
					
						
							|  |  |  |       { title: i18n.t("general.thursday"), value: "thursday" }, | 
					
						
							|  |  |  |       { title: i18n.t("general.friday"), value: "friday" }, | 
					
						
							|  |  |  |       { title: i18n.t("general.saturday"), value: "saturday" }, | 
					
						
							|  |  |  |       { title: i18n.t("general.sunday"), value: "sunday" }, | 
					
						
							|  |  |  |       { title: i18n.t("meal-plan.day-any"), value: "unset" }, | 
					
						
							| 
									
										
										
										
											2022-08-10 07:12:45 +02:00
										 |  |  |     ]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |     const inputDay = computed({ | 
					
						
							|  |  |  |       get: () => { | 
					
						
							|  |  |  |         return props.day; | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       set: (val) => { | 
					
						
							|  |  |  |         context.emit("update:day", val); | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const inputEntryType = computed({ | 
					
						
							|  |  |  |       get: () => { | 
					
						
							|  |  |  |         return props.entryType; | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       set: (val) => { | 
					
						
							|  |  |  |         context.emit("update:entry-type", val); | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  |     const inputQueryFilterString = computed({ | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |       get: () => { | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  |         return props.queryFilterString; | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |       }, | 
					
						
							|  |  |  |       set: (val) => { | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  |         context.emit("update:query-filter-string", val); | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |       }, | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  |     function handleQueryFilterInput(value: string | undefined) { | 
					
						
							|  |  |  |       inputQueryFilterString.value = value || ""; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const fieldDefs: FieldDefinition[] = [ | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         name: "recipe_category.id", | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         label: i18n.t("category.categories"), | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  |         type: Organizer.Category, | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |       }, | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  |       { | 
					
						
							|  |  |  |         name: "tags.id", | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         label: i18n.t("tag.tags"), | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  |         type: Organizer.Tag, | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |       }, | 
					
						
							| 
									
										
										
										
											2024-11-11 11:20:29 -06:00
										 |  |  |       { | 
					
						
							|  |  |  |         name: "recipe_ingredient.food.id", | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         label: i18n.t("recipe.ingredients"), | 
					
						
							| 
									
										
										
										
											2024-11-11 11:20:29 -06:00
										 |  |  |         type: Organizer.Food, | 
					
						
							|  |  |  |       }, | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  |       { | 
					
						
							|  |  |  |         name: "tools.id", | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         label: i18n.t("tool.tools"), | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  |         type: Organizer.Tool, | 
					
						
							| 
									
										
										
										
											2024-09-27 09:06:45 -05:00
										 |  |  |       }, | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  |       { | 
					
						
							|  |  |  |         name: "household_id", | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         label: i18n.t("household.households"), | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  |         type: Organizer.Household, | 
					
						
							| 
									
										
										
										
											2024-09-27 09:06:45 -05:00
										 |  |  |       }, | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  |       { | 
					
						
							|  |  |  |         name: "last_made", | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         label: i18n.t("general.last-made"), | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  |         type: "date", | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         name: "created_at", | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         label: i18n.t("general.date-created"), | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  |         type: "date", | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         name: "updated_at", | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         label: i18n.t("general.date-updated"), | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  |         type: "date", | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     ]; | 
					
						
							| 
									
										
										
										
											2024-09-27 09:06:45 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |     return { | 
					
						
							|  |  |  |       MEAL_TYPE_OPTIONS, | 
					
						
							|  |  |  |       MEAL_DAY_OPTIONS, | 
					
						
							|  |  |  |       inputDay, | 
					
						
							|  |  |  |       inputEntryType, | 
					
						
							| 
									
										
										
										
											2024-10-17 10:35:39 -05:00
										 |  |  |       inputQueryFilterString, | 
					
						
							|  |  |  |       handleQueryFilterInput, | 
					
						
							|  |  |  |       fieldDefs, | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |     }; | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | </script> |