| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  | <template> | 
					
						
							|  |  |  |   <div class="text-center"> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     <v-dialog | 
					
						
							|  |  |  |       v-model="dialog" | 
					
						
							|  |  |  |       width="800" | 
					
						
							|  |  |  |     > | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  |       <template #activator="{ props: activatorProps }"> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         <BaseButton | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  |           v-bind="activatorProps" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |           @click="inputText = inputTextProp" | 
					
						
							|  |  |  |         > | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  |           {{ $t("new-recipe.bulk-add") }} | 
					
						
							| 
									
										
										
										
											2021-08-23 12:24:38 -08:00
										 |  |  |         </BaseButton> | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  |       </template> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       <v-card> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         <v-app-bar | 
					
						
							|  |  |  |           density="compact" | 
					
						
							|  |  |  |           dark | 
					
						
							|  |  |  |           color="primary" | 
					
						
							|  |  |  |           class="mb-2 position-relative left-0 top-0 w-100" | 
					
						
							|  |  |  |         > | 
					
						
							|  |  |  |           <v-icon | 
					
						
							|  |  |  |             size="large" | 
					
						
							|  |  |  |             start | 
					
						
							|  |  |  |           > | 
					
						
							| 
									
										
										
										
											2021-10-31 14:46:46 -08:00
										 |  |  |             {{ $globals.icons.createAlt }} | 
					
						
							|  |  |  |           </v-icon> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |           <v-toolbar-title class="headline"> | 
					
						
							|  |  |  |             {{ $t("new-recipe.bulk-add") }} | 
					
						
							|  |  |  |           </v-toolbar-title> | 
					
						
							|  |  |  |           <v-spacer /> | 
					
						
							| 
									
										
										
										
											2021-10-31 14:46:46 -08:00
										 |  |  |         </v-app-bar> | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         <v-card-text> | 
					
						
							| 
									
										
										
										
											2021-10-31 14:46:46 -08:00
										 |  |  |           <v-textarea | 
					
						
							|  |  |  |             v-model="inputText" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |             variant="outlined" | 
					
						
							| 
									
										
										
										
											2021-11-05 15:48:10 -08:00
										 |  |  |             rows="12" | 
					
						
							| 
									
										
										
										
											2022-05-11 17:14:03 -08:00
										 |  |  |             hide-details | 
					
						
							| 
									
										
										
										
											2021-10-31 14:46:46 -08:00
										 |  |  |             :placeholder="$t('new-recipe.paste-in-your-recipe-data-each-line-will-be-treated-as-an-item-in-a-list')" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |           /> | 
					
						
							| 
									
										
										
										
											2022-05-11 17:14:03 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |           <v-divider /> | 
					
						
							|  |  |  |           <template | 
					
						
							|  |  |  |             v-for="(util) in utilities" | 
					
						
							|  |  |  |             :key="util.id" | 
					
						
							|  |  |  |           > | 
					
						
							|  |  |  |             <v-list-item | 
					
						
							|  |  |  |               density="compact" | 
					
						
							|  |  |  |               class="py-1" | 
					
						
							|  |  |  |             > | 
					
						
							| 
									
										
										
										
											2022-05-11 17:14:03 -08:00
										 |  |  |               <v-list-item-title> | 
					
						
							|  |  |  |                 <v-list-item-subtitle class="wrap-word"> | 
					
						
							|  |  |  |                   {{ util.description }} | 
					
						
							|  |  |  |                 </v-list-item-subtitle> | 
					
						
							|  |  |  |               </v-list-item-title> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |               <BaseButton | 
					
						
							|  |  |  |                 size="small" | 
					
						
							|  |  |  |                 color="info" | 
					
						
							|  |  |  |                 @click="util.action" | 
					
						
							|  |  |  |               > | 
					
						
							|  |  |  |                 <template #icon> | 
					
						
							|  |  |  |                   {{ $globals.icons.robot }} | 
					
						
							|  |  |  |                 </template> | 
					
						
							| 
									
										
										
										
											2022-08-10 07:12:45 +02:00
										 |  |  |                 {{ $t("general.run") }} | 
					
						
							| 
									
										
										
										
											2022-05-11 17:14:03 -08:00
										 |  |  |               </BaseButton> | 
					
						
							|  |  |  |             </v-list-item> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |             <v-divider class="mx-2" /> | 
					
						
							| 
									
										
										
										
											2022-05-11 17:14:03 -08:00
										 |  |  |           </template> | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  |         </v-card-text> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         <v-divider /> | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         <v-card-actions> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |           <BaseButton | 
					
						
							|  |  |  |             cancel | 
					
						
							|  |  |  |             @click="dialog = false" | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |           <v-spacer /> | 
					
						
							|  |  |  |           <BaseButton | 
					
						
							|  |  |  |             save | 
					
						
							|  |  |  |             color="success" | 
					
						
							|  |  |  |             @click="save" | 
					
						
							|  |  |  |           /> | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  |         </v-card-actions> | 
					
						
							|  |  |  |       </v-card> | 
					
						
							|  |  |  |     </v-dialog> | 
					
						
							|  |  |  |   </div> | 
					
						
							|  |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  | <script setup lang="ts"> | 
					
						
							|  |  |  | interface Props { | 
					
						
							|  |  |  |   inputTextProp?: string; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | const props = withDefaults(defineProps<Props>(), { | 
					
						
							|  |  |  |   inputTextProp: "", | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const emit = defineEmits<{ | 
					
						
							|  |  |  |   "bulk-data": [data: string[]]; | 
					
						
							|  |  |  | }>(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const dialog = ref(false); | 
					
						
							|  |  |  | const inputText = ref(props.inputTextProp); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function splitText() { | 
					
						
							|  |  |  |   return inputText.value.split("\n").filter(line => !(line === "\n" || !line)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function removeFirstCharacter() { | 
					
						
							|  |  |  |   inputText.value = splitText() | 
					
						
							|  |  |  |     .map(line => line.substring(1)) | 
					
						
							|  |  |  |     .join("\n"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const numberedLineRegex = /\d+[.):] /gm; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function splitByNumberedLine() { | 
					
						
							|  |  |  |   // Split inputText by numberedLineRegex
 | 
					
						
							|  |  |  |   const matches = inputText.value.match(numberedLineRegex); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   matches?.forEach((match, idx) => { | 
					
						
							|  |  |  |     const replaceText = idx === 0 ? "" : "\n"; | 
					
						
							|  |  |  |     inputText.value = inputText.value.replace(match, replaceText); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function trimAllLines() { | 
					
						
							|  |  |  |   const splitLines = splitText(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   splitLines.forEach((element: string, index: number) => { | 
					
						
							|  |  |  |     splitLines[index] = element.trim(); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   inputText.value = splitLines.join("\n"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function save() { | 
					
						
							|  |  |  |   emit("bulk-data", splitText()); | 
					
						
							|  |  |  |   dialog.value = false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const i18n = useI18n(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const utilities = [ | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     id: "trim-whitespace", | 
					
						
							|  |  |  |     description: i18n.t("new-recipe.trim-whitespace-description"), | 
					
						
							|  |  |  |     action: trimAllLines, | 
					
						
							| 
									
										
										
										
											2022-09-25 15:00:45 -08:00
										 |  |  |   }, | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  |   { | 
					
						
							|  |  |  |     id: "trim-prefix", | 
					
						
							|  |  |  |     description: i18n.t("new-recipe.trim-prefix-description"), | 
					
						
							|  |  |  |     action: removeFirstCharacter, | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  |   }, | 
					
						
							| 
									
										
										
										
											2025-07-30 20:37:02 +02:00
										 |  |  |   { | 
					
						
							|  |  |  |     id: "split-by-numbered-line", | 
					
						
							|  |  |  |     description: i18n.t("new-recipe.split-by-numbered-line-description"), | 
					
						
							|  |  |  |     action: splitByNumberedLine, | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  | ]; | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  | </script> |