| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  | <template> | 
					
						
							|  |  |  |   <div> | 
					
						
							|  |  |  |     <div class="d-md-flex" style="gap: 10px"> | 
					
						
							| 
									
										
										
										
											2022-08-10 07:12:45 +02:00
										 |  |  |       <v-select v-model="inputDay" :items="MEAL_DAY_OPTIONS" :label="$t('meal-plan.rule-day')"></v-select> | 
					
						
							|  |  |  |       <v-select v-model="inputEntryType" :items="MEAL_TYPE_OPTIONS" :label="$t('meal-plan.meal-type')"></v-select> | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |     </div> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-03 20:12:32 -08:00
										 |  |  |     <RecipeOrganizerSelector v-model="inputCategories" selector-type="categories" /> | 
					
						
							|  |  |  |     <RecipeOrganizerSelector v-model="inputTags" selector-type="tags" /> | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-10 07:12:45 +02:00
										 |  |  |     <!-- TODO Make this localizable --> | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |     {{ inputDay === "unset" ? "This rule will apply to all days" : `This rule applies on ${inputDay}s` }} | 
					
						
							|  |  |  |     {{ inputEntryType === "unset" ? "for all meal types" : ` and for ${inputEntryType} meal types` }} | 
					
						
							|  |  |  |   </div> | 
					
						
							|  |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <script lang="ts"> | 
					
						
							| 
									
										
										
										
											2022-08-10 07:12:45 +02:00
										 |  |  | import { defineComponent, computed, useContext } from "@nuxtjs/composition-api"; | 
					
						
							| 
									
										
										
										
											2022-06-03 20:12:32 -08:00
										 |  |  | import RecipeOrganizerSelector from "~/components/Domain/Recipe/RecipeOrganizerSelector.vue"; | 
					
						
							| 
									
										
										
										
											2022-10-22 11:51:07 -08:00
										 |  |  | import { RecipeTag, RecipeCategory } from "~/lib/api/types/group"; | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  | 
 | 
					
						
							|  |  |  | export default defineComponent({ | 
					
						
							|  |  |  |   components: { | 
					
						
							| 
									
										
										
										
											2022-06-03 20:12:32 -08:00
										 |  |  |     RecipeOrganizerSelector, | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |   }, | 
					
						
							|  |  |  |   props: { | 
					
						
							|  |  |  |     day: { | 
					
						
							|  |  |  |       type: String, | 
					
						
							|  |  |  |       default: "unset", | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     entryType: { | 
					
						
							|  |  |  |       type: String, | 
					
						
							|  |  |  |       default: "unset", | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     categories: { | 
					
						
							| 
									
										
										
										
											2022-06-03 20:12:32 -08:00
										 |  |  |       type: Array as () => RecipeCategory[], | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |       default: () => [], | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     tags: { | 
					
						
							| 
									
										
										
										
											2022-06-03 20:12:32 -08:00
										 |  |  |       type: Array as () => RecipeTag[], | 
					
						
							| 
									
										
										
										
											2022-02-07 19:03:11 -09:00
										 |  |  |       default: () => [], | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     showHelp: { | 
					
						
							|  |  |  |       type: Boolean, | 
					
						
							|  |  |  |       default: false, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   setup(props, context) { | 
					
						
							| 
									
										
										
										
											2022-08-10 07:12:45 +02:00
										 |  |  |     const { i18n } = useContext(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const MEAL_TYPE_OPTIONS = [ | 
					
						
							|  |  |  |       { text: i18n.t("meal-plan.breakfast"), value: "breakfast" }, | 
					
						
							|  |  |  |       { text: i18n.t("meal-plan.lunch"), value: "lunch" }, | 
					
						
							|  |  |  |       { text: i18n.t("meal-plan.dinner"), value: "dinner" }, | 
					
						
							|  |  |  |       { text: i18n.t("meal-plan.side"), value: "side" }, | 
					
						
							|  |  |  |       { text: i18n.t("meal-plan.type-any"), value: "unset" }, | 
					
						
							|  |  |  |     ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const MEAL_DAY_OPTIONS = [ | 
					
						
							|  |  |  |       { text: i18n.t("general.monday"), value: "monday" }, | 
					
						
							|  |  |  |       { text: i18n.t("general.tuesday"), value: "tuesday" }, | 
					
						
							|  |  |  |       { text: i18n.t("general.wednesday"), value: "wednesday" }, | 
					
						
							|  |  |  |       { text: i18n.t("general.thursday"), value: "thursday" }, | 
					
						
							|  |  |  |       { text: i18n.t("general.friday"), value: "friday" }, | 
					
						
							|  |  |  |       { text: i18n.t("general.saturday"), value: "saturday" }, | 
					
						
							|  |  |  |       { text: i18n.t("general.sunday"), value: "sunday" }, | 
					
						
							|  |  |  |       { text: i18n.t("meal-plan.day-any"), value: "unset" }, | 
					
						
							|  |  |  |     ]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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); | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const inputCategories = computed({ | 
					
						
							|  |  |  |       get: () => { | 
					
						
							|  |  |  |         return props.categories; | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       set: (val) => { | 
					
						
							|  |  |  |         context.emit("update:categories", val); | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const inputTags = computed({ | 
					
						
							|  |  |  |       get: () => { | 
					
						
							|  |  |  |         return props.tags; | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       set: (val) => { | 
					
						
							|  |  |  |         context.emit("update:tags", val); | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       MEAL_TYPE_OPTIONS, | 
					
						
							|  |  |  |       MEAL_DAY_OPTIONS, | 
					
						
							|  |  |  |       inputDay, | 
					
						
							|  |  |  |       inputEntryType, | 
					
						
							|  |  |  |       inputCategories, | 
					
						
							|  |  |  |       inputTags, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | </script> |