| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  | <template> | 
					
						
							|  |  |  |   <div class="text-center"> | 
					
						
							|  |  |  |     <v-dialog v-model="dialog" width="600"> | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |       <template #activator="{ on, attrs }"> | 
					
						
							| 
									
										
										
										
											2021-08-23 12:24:38 -08:00
										 |  |  |         <BaseButton v-bind="attrs" v-on="on" @click="inputText = ''"> | 
					
						
							| 
									
										
										
										
											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> | 
					
						
							| 
									
										
										
										
											2021-10-31 14:46:46 -08:00
										 |  |  |         <v-app-bar dark color="primary" class="mt-n1 mb-3"> | 
					
						
							|  |  |  |           <v-icon large left> | 
					
						
							|  |  |  |             {{ $globals.icons.createAlt }} | 
					
						
							|  |  |  |           </v-icon> | 
					
						
							|  |  |  |           <v-toolbar-title class="headline"> {{ $t("new-recipe.bulk-add") }}</v-toolbar-title> | 
					
						
							|  |  |  |           <v-spacer></v-spacer> | 
					
						
							|  |  |  |         </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" | 
					
						
							|  |  |  |             outlined | 
					
						
							|  |  |  |             rows="10" | 
					
						
							|  |  |  |             :placeholder="$t('new-recipe.paste-in-your-recipe-data-each-line-will-be-treated-as-an-item-in-a-list')" | 
					
						
							|  |  |  |           > | 
					
						
							|  |  |  |           </v-textarea> | 
					
						
							|  |  |  |           <v-btn outlined color="info" small @click="trimAllLines"> Trim Whitespace </v-btn> | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  |         </v-card-text> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         <v-divider></v-divider> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         <v-card-actions> | 
					
						
							| 
									
										
										
										
											2021-10-31 14:46:46 -08:00
										 |  |  |           <BaseButton cancel @click="dialog = false"> </BaseButton> | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  |           <v-spacer></v-spacer> | 
					
						
							| 
									
										
										
										
											2021-10-31 14:46:46 -08:00
										 |  |  |           <BaseButton save color="success" @click="save"> </BaseButton> | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  |         </v-card-actions> | 
					
						
							|  |  |  |       </v-card> | 
					
						
							|  |  |  |     </v-dialog> | 
					
						
							|  |  |  |   </div> | 
					
						
							|  |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-31 14:46:46 -08:00
										 |  |  | <script lang="ts"> | 
					
						
							| 
									
										
										
										
											2021-11-04 14:01:37 -08:00
										 |  |  | import { reactive, toRefs, defineComponent } from "@nuxtjs/composition-api"; | 
					
						
							|  |  |  | export default defineComponent({ | 
					
						
							| 
									
										
										
										
											2021-10-31 14:46:46 -08:00
										 |  |  |   setup(_, context) { | 
					
						
							|  |  |  |     const state = reactive({ | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  |       dialog: false, | 
					
						
							|  |  |  |       inputText: "", | 
					
						
							| 
									
										
										
										
											2021-10-31 14:46:46 -08:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function splitText() { | 
					
						
							|  |  |  |       return state.inputText.split("\n").filter((line) => !(line === "\n" || !line)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function trimAllLines() { | 
					
						
							|  |  |  |       const splitLintes = splitText(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       splitLintes.forEach((element: string, index: number) => { | 
					
						
							|  |  |  |         splitLintes[index] = element.trim(); | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-31 14:46:46 -08:00
										 |  |  |       state.inputText = splitLintes.join("\n"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function save() { | 
					
						
							|  |  |  |       context.emit("bulk-data", splitText()); | 
					
						
							|  |  |  |       state.dialog = false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       splitText, | 
					
						
							|  |  |  |       trimAllLines, | 
					
						
							|  |  |  |       save, | 
					
						
							|  |  |  |       ...toRefs(state), | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  |   }, | 
					
						
							| 
									
										
										
										
											2021-11-04 14:01:37 -08:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  | </script> |