| 
									
										
										
										
											2022-08-15 23:55:51 +02:00
										 |  |  | <template> | 
					
						
							| 
									
										
										
										
											2021-10-16 16:06:13 -08:00
										 |  |  |   <v-menu offset-y> | 
					
						
							|  |  |  |     <template #activator="{ on, attrs }"> | 
					
						
							| 
									
										
										
										
											2021-11-05 15:48:10 -08:00
										 |  |  |       <v-btn color="primary" v-bind="{ ...attrs, ...$attrs }" :class="btnClass" :disabled="disabled" v-on="on"> | 
					
						
							| 
									
										
										
										
											2021-10-16 16:06:13 -08:00
										 |  |  |         <v-icon v-if="activeObj.icon" left> | 
					
						
							|  |  |  |           {{ activeObj.icon }} | 
					
						
							|  |  |  |         </v-icon> | 
					
						
							| 
									
										
										
										
											2021-10-18 19:41:41 -08:00
										 |  |  |         {{ mode === MODES.model ? activeObj.text : btnText }} | 
					
						
							| 
									
										
										
										
											2021-10-16 16:06:13 -08:00
										 |  |  |         <v-icon right> | 
					
						
							|  |  |  |           {{ $globals.icons.chevronDown }} | 
					
						
							|  |  |  |         </v-icon> | 
					
						
							|  |  |  |       </v-btn> | 
					
						
							|  |  |  |     </template> | 
					
						
							| 
									
										
										
										
											2021-10-18 19:41:41 -08:00
										 |  |  |     <!--  Model --> | 
					
						
							|  |  |  |     <v-list v-if="mode === MODES.model" dense> | 
					
						
							| 
									
										
										
										
											2021-10-16 16:06:13 -08:00
										 |  |  |       <v-list-item-group v-model="itemGroup"> | 
					
						
							| 
									
										
										
										
											2023-11-21 15:31:05 +01:00
										 |  |  |         <template v-for="(item, index) in items"> | 
					
						
							|  |  |  |           <v-list-item :key="index" @click="setValue(item)"> | 
					
						
							|  |  |  |             <v-list-item-icon v-if="item.icon"> | 
					
						
							|  |  |  |               <v-icon>{{ item.icon }}</v-icon> | 
					
						
							|  |  |  |             </v-list-item-icon> | 
					
						
							|  |  |  |             <v-list-item-title>{{ item.text }}</v-list-item-title> | 
					
						
							|  |  |  |           </v-list-item> | 
					
						
							| 
									
										
										
										
											2024-03-21 16:11:18 +00:00
										 |  |  |           <v-divider v-if="item.divider" :key="`divider-${index}`" class="my-1" ></v-divider> | 
					
						
							| 
									
										
										
										
											2023-11-21 15:31:05 +01:00
										 |  |  |         </template> | 
					
						
							| 
									
										
										
										
											2021-10-16 16:06:13 -08:00
										 |  |  |       </v-list-item-group> | 
					
						
							|  |  |  |     </v-list> | 
					
						
							| 
									
										
										
										
											2022-01-08 22:24:34 -09:00
										 |  |  |     <!--  Links --> | 
					
						
							| 
									
										
										
										
											2021-10-18 19:41:41 -08:00
										 |  |  |     <v-list v-else-if="mode === MODES.link" dense> | 
					
						
							|  |  |  |       <v-list-item-group v-model="itemGroup"> | 
					
						
							| 
									
										
										
										
											2023-11-21 15:31:05 +01:00
										 |  |  |         <template v-for="(item, index) in items"> | 
					
						
							|  |  |  |           <v-list-item :key="index" :to="item.to"> | 
					
						
							| 
									
										
										
										
											2021-10-18 19:41:41 -08:00
										 |  |  |           <v-list-item-icon v-if="item.icon"> | 
					
						
							|  |  |  |             <v-icon>{{ item.icon }}</v-icon> | 
					
						
							|  |  |  |           </v-list-item-icon> | 
					
						
							|  |  |  |           <v-list-item-title>{{ item.text }}</v-list-item-title> | 
					
						
							| 
									
										
										
										
											2023-11-21 15:31:05 +01:00
										 |  |  |           </v-list-item> | 
					
						
							|  |  |  |           <v-divider v-if="item.divider" :key="`divider-${index}`" class="my-1" ></v-divider> | 
					
						
							|  |  |  |         </template> | 
					
						
							| 
									
										
										
										
											2021-10-18 19:41:41 -08:00
										 |  |  |       </v-list-item-group> | 
					
						
							|  |  |  |     </v-list> | 
					
						
							|  |  |  |     <!--  Event --> | 
					
						
							|  |  |  |     <v-list v-else-if="mode === MODES.event" dense> | 
					
						
							| 
									
										
										
										
											2023-11-21 15:31:05 +01:00
										 |  |  |       <template v-for="(item, index) in items"> | 
					
						
							|  |  |  |         <v-list-item :key="index" @click="$emit(item.event)"> | 
					
						
							|  |  |  |           <v-list-item-icon v-if="item.icon"> | 
					
						
							|  |  |  |             <v-icon>{{ item.icon }}</v-icon> | 
					
						
							|  |  |  |           </v-list-item-icon> | 
					
						
							|  |  |  |           <v-list-item-title>{{ item.text }}</v-list-item-title> | 
					
						
							|  |  |  |         </v-list-item> | 
					
						
							| 
									
										
										
										
											2024-03-21 16:11:18 +00:00
										 |  |  |         <v-divider v-if="item.divider" :key="`divider-${index}`" class="my-1" ></v-divider> | 
					
						
							| 
									
										
										
										
											2023-11-21 15:31:05 +01:00
										 |  |  |       </template> | 
					
						
							| 
									
										
										
										
											2021-10-18 19:41:41 -08:00
										 |  |  |     </v-list> | 
					
						
							| 
									
										
										
										
											2021-10-16 16:06:13 -08:00
										 |  |  |   </v-menu> | 
					
						
							|  |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <script lang="ts"> | 
					
						
							|  |  |  | import { defineComponent, ref } from "@nuxtjs/composition-api"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const INPUT_EVENT = "input"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-18 19:41:41 -08:00
										 |  |  | type modes = "model" | "link" | "event"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const MODES = { | 
					
						
							|  |  |  |   model: "model", | 
					
						
							|  |  |  |   link: "link", | 
					
						
							|  |  |  |   event: "event", | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-08 22:24:34 -09:00
										 |  |  | export interface MenuItem { | 
					
						
							|  |  |  |   text: string; | 
					
						
							| 
									
										
										
										
											2022-01-16 03:38:11 +01:00
										 |  |  |   icon?: string; | 
					
						
							| 
									
										
										
										
											2022-01-08 22:24:34 -09:00
										 |  |  |   to?: string; | 
					
						
							| 
									
										
										
										
											2022-01-16 03:38:11 +01:00
										 |  |  |   value?: string; | 
					
						
							|  |  |  |   event?: string; | 
					
						
							| 
									
										
										
										
											2023-11-21 15:31:05 +01:00
										 |  |  |   divider?: boolean; | 
					
						
							| 
									
										
										
										
											2022-01-08 22:24:34 -09:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-16 16:06:13 -08:00
										 |  |  | export default defineComponent({ | 
					
						
							|  |  |  |   props: { | 
					
						
							| 
									
										
										
										
											2021-10-18 19:41:41 -08:00
										 |  |  |     mode: { | 
					
						
							|  |  |  |       type: String as () => modes, | 
					
						
							|  |  |  |       default: "model", | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-10-16 16:06:13 -08:00
										 |  |  |     items: { | 
					
						
							| 
									
										
										
										
											2022-01-08 22:24:34 -09:00
										 |  |  |       type: Array as () => MenuItem[], | 
					
						
							| 
									
										
										
										
											2021-10-16 16:06:13 -08:00
										 |  |  |       required: true, | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-10-18 19:41:41 -08:00
										 |  |  |     disabled: { | 
					
						
							|  |  |  |       type: Boolean, | 
					
						
							|  |  |  |       required: false, | 
					
						
							| 
									
										
										
										
											2022-01-16 03:38:11 +01:00
										 |  |  |       default: false, | 
					
						
							| 
									
										
										
										
											2021-10-18 19:41:41 -08:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-10-16 16:06:13 -08:00
										 |  |  |     value: { | 
					
						
							|  |  |  |       type: String, | 
					
						
							|  |  |  |       required: false, | 
					
						
							|  |  |  |       default: "", | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     btnClass: { | 
					
						
							|  |  |  |       type: String, | 
					
						
							|  |  |  |       required: false, | 
					
						
							|  |  |  |       default: "", | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-10-18 19:41:41 -08:00
										 |  |  |     btnText: { | 
					
						
							|  |  |  |       type: String, | 
					
						
							|  |  |  |       required: false, | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |       default: function () { | 
					
						
							|  |  |  |         return this.$t("general.actions"); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2021-10-18 19:41:41 -08:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-10-16 16:06:13 -08:00
										 |  |  |   }, | 
					
						
							|  |  |  |   setup(props, context) { | 
					
						
							| 
									
										
										
										
											2022-01-16 03:38:11 +01:00
										 |  |  |     const activeObj = ref<MenuItem>({ | 
					
						
							| 
									
										
										
										
											2021-10-16 16:06:13 -08:00
										 |  |  |       text: "DEFAULT", | 
					
						
							|  |  |  |       value: "", | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     let startIndex = 0; | 
					
						
							|  |  |  |     props.items.forEach((item, index) => { | 
					
						
							|  |  |  |       if (item.value === props.value) { | 
					
						
							|  |  |  |         startIndex = index; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         activeObj.value = item; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |     const itemGroup = ref(startIndex); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-16 03:38:11 +01:00
										 |  |  |     function setValue(v: MenuItem) { | 
					
						
							| 
									
										
										
										
											2021-10-16 16:06:13 -08:00
										 |  |  |       context.emit(INPUT_EVENT, v.value); | 
					
						
							| 
									
										
										
										
											2022-08-15 23:55:51 +02:00
										 |  |  |       activeObj.value = v; | 
					
						
							| 
									
										
										
										
											2021-10-16 16:06:13 -08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return { | 
					
						
							| 
									
										
										
										
											2021-10-18 19:41:41 -08:00
										 |  |  |       MODES, | 
					
						
							| 
									
										
										
										
											2021-10-16 16:06:13 -08:00
										 |  |  |       activeObj, | 
					
						
							|  |  |  |       itemGroup, | 
					
						
							|  |  |  |       setValue, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | </script> |