| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  | <template> | 
					
						
							|  |  |  |   <div> | 
					
						
							|  |  |  |     <!-- Create New Dialog --> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     <BaseDialog | 
					
						
							|  |  |  |       v-model="state.createDialog" | 
					
						
							|  |  |  |       :title="$t('data-pages.labels.new-label')" | 
					
						
							|  |  |  |       :icon="$globals.icons.tags" | 
					
						
							|  |  |  |       can-submit | 
					
						
							|  |  |  |       @submit="createLabel" | 
					
						
							|  |  |  |     > | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |       <v-card-text> | 
					
						
							|  |  |  |         <MultiPurposeLabel :label="createLabelData" /> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         <div class="mt-4"> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |           <v-text-field | 
					
						
							|  |  |  |             v-model="createLabelData.name" | 
					
						
							|  |  |  |             :label="$t('general.name')" | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |           <InputColor v-model="createLabelData.color!" /> | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |         </div> | 
					
						
							|  |  |  |       </v-card-text> | 
					
						
							|  |  |  |     </BaseDialog> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <!-- Edit Dialog --> | 
					
						
							|  |  |  |     <BaseDialog | 
					
						
							|  |  |  |       v-model="state.editDialog" | 
					
						
							|  |  |  |       :icon="$globals.icons.tags" | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |       :title="$t('data-pages.labels.edit-label')" | 
					
						
							| 
									
										
										
										
											2024-05-04 22:27:04 +02:00
										 |  |  |       :submit-icon="$globals.icons.save" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       :submit-text="$t('general.save')" | 
					
						
							|  |  |  |       can-submit | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |       @submit="editSaveLabel" | 
					
						
							|  |  |  |     > | 
					
						
							|  |  |  |       <v-card-text v-if="editLabel"> | 
					
						
							|  |  |  |         <MultiPurposeLabel :label="editLabel" /> | 
					
						
							|  |  |  |         <div class="mt-4"> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |           <v-text-field | 
					
						
							|  |  |  |             v-model="editLabel.name" | 
					
						
							|  |  |  |             :label="$t('general.name')" | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |           <InputColor v-model="editLabel.color!" /> | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |         </div> | 
					
						
							|  |  |  |       </v-card-text> | 
					
						
							|  |  |  |     </BaseDialog> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <!-- Delete Dialog --> | 
					
						
							|  |  |  |     <BaseDialog | 
					
						
							|  |  |  |       v-model="state.deleteDialog" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       :title="$t('general.confirm')" | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |       :icon="$globals.icons.alertCircle" | 
					
						
							|  |  |  |       color="error" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       can-confirm | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |       @confirm="deleteLabel" | 
					
						
							|  |  |  |     > | 
					
						
							|  |  |  |       <v-card-text> | 
					
						
							| 
									
										
										
										
											2023-11-21 15:22:36 +00:00
										 |  |  |         {{ $t("general.confirm-delete-generic") }} | 
					
						
							| 
									
										
										
										
											2024-01-04 12:00:21 +00:00
										 |  |  |         <v-row> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |           <MultiPurposeLabel | 
					
						
							|  |  |  |             v-if="deleteTarget" | 
					
						
							|  |  |  |             class="mt-4 ml-4 mb-1" | 
					
						
							|  |  |  |             :label="deleteTarget" | 
					
						
							|  |  |  |           /> | 
					
						
							| 
									
										
										
										
											2024-01-04 12:00:21 +00:00
										 |  |  |         </v-row> | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |       </v-card-text> | 
					
						
							|  |  |  |     </BaseDialog> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 19:55:14 +01:00
										 |  |  |     <!-- Bulk Delete Dialog --> | 
					
						
							|  |  |  |     <BaseDialog | 
					
						
							|  |  |  |       v-model="state.bulkDeleteDialog" | 
					
						
							|  |  |  |       width="650px" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       :title="$t('general.confirm')" | 
					
						
							| 
									
										
										
										
											2024-02-04 19:55:14 +01:00
										 |  |  |       :icon="$globals.icons.alertCircle" | 
					
						
							|  |  |  |       color="error" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       can-confirm | 
					
						
							| 
									
										
										
										
											2024-02-04 19:55:14 +01:00
										 |  |  |       @confirm="deleteSelected" | 
					
						
							|  |  |  |     > | 
					
						
							|  |  |  |       <v-card-text> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         <p class="h4"> | 
					
						
							|  |  |  |           {{ $t('general.confirm-delete-generic-items') }} | 
					
						
							|  |  |  |         </p> | 
					
						
							|  |  |  |         <v-card variant="outlined"> | 
					
						
							|  |  |  |           <v-virtual-scroll | 
					
						
							|  |  |  |             height="400" | 
					
						
							|  |  |  |             item-height="25" | 
					
						
							|  |  |  |             :items="bulkDeleteTarget" | 
					
						
							|  |  |  |           > | 
					
						
							| 
									
										
										
										
											2024-02-04 19:55:14 +01:00
										 |  |  |             <template #default="{ item }"> | 
					
						
							|  |  |  |               <v-list-item class="pb-2"> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |                 <v-list-item-title>{{ item.name }}</v-list-item-title> | 
					
						
							| 
									
										
										
										
											2024-02-04 19:55:14 +01:00
										 |  |  |               </v-list-item> | 
					
						
							|  |  |  |             </template> | 
					
						
							|  |  |  |           </v-virtual-scroll> | 
					
						
							|  |  |  |         </v-card> | 
					
						
							|  |  |  |       </v-card-text> | 
					
						
							|  |  |  |     </BaseDialog> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     <!-- Seed Dialog --> | 
					
						
							| 
									
										
										
										
											2022-05-06 12:17:30 -08:00
										 |  |  |     <BaseDialog | 
					
						
							|  |  |  |       v-model="seedDialog" | 
					
						
							|  |  |  |       :icon="$globals.icons.foods" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       :title="$t('data-pages.seed-data')" | 
					
						
							|  |  |  |       can-confirm | 
					
						
							| 
									
										
										
										
											2022-05-06 12:17:30 -08:00
										 |  |  |       @confirm="seedDatabase" | 
					
						
							|  |  |  |     > | 
					
						
							|  |  |  |       <v-card-text> | 
					
						
							|  |  |  |         <div class="pb-2"> | 
					
						
							|  |  |  |           {{ $t("data-pages.labels.seed-dialog-text") }} | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |         <v-autocomplete | 
					
						
							|  |  |  |           v-model="locale" | 
					
						
							|  |  |  |           :items="locales" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |           item-title="name" | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |           :label="$t('data-pages.select-language')" | 
					
						
							| 
									
										
										
										
											2022-05-06 12:17:30 -08:00
										 |  |  |           class="my-3" | 
					
						
							|  |  |  |           hide-details | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |           variant="outlined" | 
					
						
							| 
									
										
										
										
											2022-05-06 12:17:30 -08:00
										 |  |  |           offset | 
					
						
							|  |  |  |         > | 
					
						
							|  |  |  |           <template #item="{ item }"> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |             <v-list-item-title> {{ item.raw.name }} </v-list-item-title> | 
					
						
							|  |  |  |             <v-list-item-subtitle> | 
					
						
							|  |  |  |               {{ item.raw.progress }}% {{ $t("language-dialog.translated") }} | 
					
						
							|  |  |  |             </v-list-item-subtitle> | 
					
						
							| 
									
										
										
										
											2022-05-06 12:17:30 -08:00
										 |  |  |           </template> | 
					
						
							|  |  |  |         </v-autocomplete> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         <v-alert | 
					
						
							|  |  |  |           v-if="labels && labels.length > 0" | 
					
						
							|  |  |  |           type="error" | 
					
						
							|  |  |  |           class="mb-0 text-body-2" | 
					
						
							|  |  |  |         > | 
					
						
							| 
									
										
										
										
											2022-05-06 12:17:30 -08:00
										 |  |  |           {{ $t("data-pages.foods.seed-dialog-warning") }} | 
					
						
							|  |  |  |         </v-alert> | 
					
						
							|  |  |  |       </v-card-text> | 
					
						
							|  |  |  |     </BaseDialog> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 14:44:41 +00:00
										 |  |  |     <!-- Data Table --> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     <BaseCardSectionTitle | 
					
						
							|  |  |  |       :icon="$globals.icons.tags" | 
					
						
							|  |  |  |       section | 
					
						
							|  |  |  |       :title="$t('data-pages.labels.labels')" | 
					
						
							|  |  |  |     /> | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |     <CrudTable | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       v-model:headers="tableHeaders" | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |       :table-config="tableConfig" | 
					
						
							| 
									
										
										
										
											2022-05-29 17:29:59 -08:00
										 |  |  |       :data="labels || []" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       :bulk-actions="[{ icon: $globals.icons.delete, text: $t('general.delete'), event: 'delete-selected' }]" | 
					
						
							| 
									
										
										
										
											2024-09-22 09:59:20 -05:00
										 |  |  |       initial-sort="name" | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |       @delete-one="deleteEventHandler" | 
					
						
							|  |  |  |       @edit-one="editEventHandler" | 
					
						
							| 
									
										
										
										
											2024-02-04 19:55:14 +01:00
										 |  |  |       @delete-selected="bulkDeleteEventHandler" | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |     > | 
					
						
							|  |  |  |       <template #button-row> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         <BaseButton | 
					
						
							|  |  |  |           create | 
					
						
							|  |  |  |           @click="state.createDialog = true" | 
					
						
							|  |  |  |         > | 
					
						
							|  |  |  |           {{ $t("general.create") }} | 
					
						
							|  |  |  |         </BaseButton> | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |       </template> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       <template #[`item.name`]="{ item }"> | 
					
						
							|  |  |  |         <MultiPurposeLabel | 
					
						
							|  |  |  |           v-if="item" | 
					
						
							|  |  |  |           :label="item" | 
					
						
							|  |  |  |         > | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |           {{ item.name }} | 
					
						
							|  |  |  |         </MultiPurposeLabel> | 
					
						
							|  |  |  |       </template> | 
					
						
							| 
									
										
										
										
											2022-05-06 12:17:30 -08:00
										 |  |  |       <template #button-bottom> | 
					
						
							|  |  |  |         <BaseButton @click="seedDialog = true"> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |           <template #icon> | 
					
						
							|  |  |  |             {{ $globals.icons.database }} | 
					
						
							|  |  |  |           </template> | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |           {{ $t('data-pages.seed') }} | 
					
						
							| 
									
										
										
										
											2022-05-06 12:17:30 -08:00
										 |  |  |         </BaseButton> | 
					
						
							|  |  |  |       </template> | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |     </CrudTable> | 
					
						
							|  |  |  |   </div> | 
					
						
							|  |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <script lang="ts"> | 
					
						
							| 
									
										
										
										
											2022-05-06 12:17:30 -08:00
										 |  |  | import type { LocaleObject } from "@nuxtjs/i18n"; | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  | import { validators } from "~/composables/use-validators"; | 
					
						
							|  |  |  | import { useUserApi } from "~/composables/api"; | 
					
						
							|  |  |  | import MultiPurposeLabel from "~/components/Domain/ShoppingList/MultiPurposeLabel.vue"; | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | import type { MultiPurposeLabelSummary } from "~/lib/api/types/labels"; | 
					
						
							| 
									
										
										
										
											2022-05-06 12:17:30 -08:00
										 |  |  | import { useLocales } from "~/composables/use-locales"; | 
					
						
							| 
									
										
										
										
											2022-05-29 17:29:59 -08:00
										 |  |  | import { useLabelData, useLabelStore } from "~/composables/store"; | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | export default defineNuxtComponent({ | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |   components: { MultiPurposeLabel }, | 
					
						
							|  |  |  |   setup() { | 
					
						
							|  |  |  |     const userApi = useUserApi(); | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     const i18n = useI18n(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |     const tableConfig = { | 
					
						
							|  |  |  |       hideColumns: true, | 
					
						
							|  |  |  |       canExport: true, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     const tableHeaders = [ | 
					
						
							|  |  |  |       { | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |         text: i18n.t("general.id"), | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |         value: "id", | 
					
						
							|  |  |  |         show: false, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       { | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |         text: i18n.t("general.name"), | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |         value: "name", | 
					
						
							|  |  |  |         show: true, | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         sortable: true, | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |       }, | 
					
						
							|  |  |  |     ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const state = reactive({ | 
					
						
							|  |  |  |       createDialog: false, | 
					
						
							|  |  |  |       editDialog: false, | 
					
						
							|  |  |  |       deleteDialog: false, | 
					
						
							| 
									
										
										
										
											2024-02-04 19:55:14 +01:00
										 |  |  |       bulkDeleteDialog: false, | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // ============================================================
 | 
					
						
							|  |  |  |     // Labels
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-29 17:29:59 -08:00
										 |  |  |     const labelData = useLabelData(); | 
					
						
							|  |  |  |     const labelStore = useLabelStore(); | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Create
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     async function createLabel() { | 
					
						
							| 
									
										
										
										
											2022-05-29 17:29:59 -08:00
										 |  |  |       await labelStore.actions.createOne(labelData.data); | 
					
						
							|  |  |  |       labelData.reset(); | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |       state.createDialog = false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Delete
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const deleteTarget = ref<MultiPurposeLabelSummary | null>(null); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function deleteEventHandler(item: MultiPurposeLabelSummary) { | 
					
						
							|  |  |  |       state.deleteDialog = true; | 
					
						
							|  |  |  |       deleteTarget.value = item; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     async function deleteLabel() { | 
					
						
							|  |  |  |       if (!deleteTarget.value) { | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-05-29 17:29:59 -08:00
										 |  |  |       await labelStore.actions.deleteOne(deleteTarget.value.id); | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |       state.deleteDialog = false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 19:55:14 +01:00
										 |  |  |     // Bulk Delete
 | 
					
						
							|  |  |  |     const bulkDeleteTarget = ref<MultiPurposeLabelSummary[]>([]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function bulkDeleteEventHandler(selection: MultiPurposeLabelSummary[]) { | 
					
						
							|  |  |  |       bulkDeleteTarget.value = selection; | 
					
						
							|  |  |  |       state.bulkDeleteDialog = true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     async function deleteSelected() { | 
					
						
							|  |  |  |       for (const item of bulkDeleteTarget.value) { | 
					
						
							|  |  |  |         await labelStore.actions.deleteOne(item.id); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       bulkDeleteTarget.value = []; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |     // Edit
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const editLabel = ref<MultiPurposeLabelSummary | null>(null); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function editEventHandler(item: MultiPurposeLabelSummary) { | 
					
						
							|  |  |  |       state.editDialog = true; | 
					
						
							|  |  |  |       editLabel.value = item; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       if (!editLabel.value.color) { | 
					
						
							| 
									
										
										
										
											2024-09-24 09:29:06 -05:00
										 |  |  |         editLabel.value.color = "#959595"; | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     async function editSaveLabel() { | 
					
						
							|  |  |  |       if (!editLabel.value) { | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-05-29 17:29:59 -08:00
										 |  |  |       await labelStore.actions.updateOne(editLabel.value); | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |       state.editDialog = false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-06 12:17:30 -08:00
										 |  |  |     // ============================================================
 | 
					
						
							|  |  |  |     // Seed
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const seedDialog = ref(false); | 
					
						
							|  |  |  |     const locale = ref(""); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |     const { locales: LOCALES, locale: currentLocale } = useLocales(); | 
					
						
							| 
									
										
										
										
											2022-05-06 12:17:30 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     onMounted(() => { | 
					
						
							|  |  |  |       locale.value = currentLocale.value; | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     const locales = LOCALES.filter(locale => | 
					
						
							|  |  |  |       (i18n.locales.value as LocaleObject[]).map(i18nLocale => i18nLocale.code).includes(locale.value), | 
					
						
							| 
									
										
										
										
											2022-05-06 12:17:30 -08:00
										 |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     async function seedDatabase() { | 
					
						
							|  |  |  |       const { data } = await userApi.seeders.labels({ locale: locale.value }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       if (data) { | 
					
						
							| 
									
										
										
										
											2022-05-29 17:29:59 -08:00
										 |  |  |         labelStore.actions.refresh(); | 
					
						
							| 
									
										
										
										
											2022-05-06 12:17:30 -08:00
										 |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |     return { | 
					
						
							|  |  |  |       state, | 
					
						
							|  |  |  |       tableConfig, | 
					
						
							|  |  |  |       tableHeaders, | 
					
						
							| 
									
										
										
										
											2024-09-22 09:59:20 -05:00
										 |  |  |       labels: labelStore.store, | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |       validators, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-20 17:09:16 +00:00
										 |  |  |       // create
 | 
					
						
							|  |  |  |       createLabel, | 
					
						
							|  |  |  |       createLabelData: labelData.data, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       // edit
 | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |       editLabel, | 
					
						
							|  |  |  |       editEventHandler, | 
					
						
							|  |  |  |       editSaveLabel, | 
					
						
							| 
									
										
										
										
											2023-11-20 17:09:16 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |       // delete
 | 
					
						
							|  |  |  |       deleteEventHandler, | 
					
						
							|  |  |  |       deleteLabel, | 
					
						
							|  |  |  |       deleteTarget, | 
					
						
							| 
									
										
										
										
											2024-02-04 19:55:14 +01:00
										 |  |  |       bulkDeleteEventHandler, | 
					
						
							|  |  |  |       deleteSelected, | 
					
						
							|  |  |  |       bulkDeleteTarget, | 
					
						
							| 
									
										
										
										
											2022-05-06 12:17:30 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |       // Seed
 | 
					
						
							|  |  |  |       seedDatabase, | 
					
						
							|  |  |  |       locales, | 
					
						
							|  |  |  |       locale, | 
					
						
							|  |  |  |       seedDialog, | 
					
						
							| 
									
										
										
										
											2022-03-19 11:31:17 -08:00
										 |  |  |     }; | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | </script> |