@bildvitta/quasar-ui-asteroid 3.17.0-beta.20 → 3.17.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/assets/sounds/nave-notification.mp3 +0 -0
- package/src/asteroid.js +4 -4
- package/src/components/actions/QasActions.vue +81 -81
- package/src/components/actions/QasActions.yml +34 -34
- package/src/components/actions-menu/QasActionsMenu.vue +251 -251
- package/src/components/actions-menu/QasActionsMenu.yml +89 -89
- package/src/components/actions-menu/composables/use-delete.js +30 -30
- package/src/components/actions-menu/composables/use-double-split-actions.js +42 -42
- package/src/components/actions-menu/composables/use-options-actions.js +27 -27
- package/src/components/actions-menu/composables/use-single-action.js +17 -17
- package/src/components/actions-menu/composables/use-single-split-actions.js +35 -35
- package/src/components/actions-menu/composables/use-tooltips.js +43 -43
- package/src/components/actions-menu/utils/get-label.js +3 -3
- package/src/components/actions-menu/utils/set-click-handler.js +6 -6
- package/src/components/alert/QasAlert.test.js +43 -43
- package/src/components/alert/QasAlert.vue +110 -110
- package/src/components/alert/QasAlert.yml +39 -39
- package/src/components/app-bar/QasAppBar.vue +119 -119
- package/src/components/app-bar/QasAppBar.yml +44 -44
- package/src/components/app-menu/QasAppMenu.vue +392 -392
- package/src/components/app-menu/QasAppMenu.yml +73 -73
- package/src/components/app-menu/composables/use-app-menu-dropdown.js +71 -71
- package/src/components/app-menu/composables/use-app-user.js +49 -49
- package/src/components/app-menu/composables/use-development-badge.js +23 -23
- package/src/components/app-menu/private/PvAppMenuDropdown.vue +71 -71
- package/src/components/app-menu/private/PvAppMenuHelpChat.vue +222 -222
- package/src/components/app-user/QasAppUser.vue +281 -281
- package/src/components/app-user/QasAppUser.yml +56 -56
- package/src/components/avatar/QasAvatar.vue +95 -95
- package/src/components/avatar/QasAvatar.yml +38 -38
- package/src/components/avatar/enums/AvatarColors.js +10 -10
- package/src/components/badge/QasBadge.vue +87 -87
- package/src/components/badge/QasBadge.yml +55 -55
- package/src/components/board-generator/QasBoardGenerator.vue +712 -712
- package/src/components/board-generator/QasBoardGenerator.yml +167 -167
- package/src/components/box/QasBox.vue +51 -51
- package/src/components/box/QasBox.yml +29 -29
- package/src/components/breakline/QasBreakline.vue +38 -38
- package/src/components/breakline/QasBreakline.yml +25 -25
- package/src/components/btn/QasBtn.vue +148 -148
- package/src/components/btn/QasBtn.yml +48 -48
- package/src/components/btn-dropdown/QasBtnDropdown.vue +146 -146
- package/src/components/btn-dropdown/QasBtnDropdown.yml +59 -59
- package/src/components/card/QasCard.vue +132 -132
- package/src/components/card/QasCard.yml +44 -44
- package/src/components/card-image/QasCardImage.vue +95 -95
- package/src/components/card-image/QasCardImage.yml +48 -48
- package/src/components/chart-view/QasChartView.vue +441 -441
- package/src/components/chart-view/QasChartView.yml +109 -109
- package/src/components/chart-view/config/charts/bar.js +45 -45
- package/src/components/chart-view/config/charts/doughnut.js +43 -43
- package/src/components/chart-view/config/charts/index.js +9 -9
- package/src/components/chart-view/config/charts/line.js +57 -57
- package/src/components/chart-view/config/defaults/colors.js +19 -19
- package/src/components/chart-view/config/defaults/font.js +5 -5
- package/src/components/chart-view/config/defaults/index.js +2 -2
- package/src/components/chart-view/config/index.js +3 -3
- package/src/components/chart-view/config/plugins/index.js +3 -3
- package/src/components/chart-view/config/plugins/legend.js +9 -9
- package/src/components/chart-view/config/plugins/tooltip.js +15 -15
- package/src/components/chart-view/config/plugins/zoom.js +31 -31
- package/src/components/checkbox/QasCheckbox.vue +150 -150
- package/src/components/checkbox/QasCheckbox.yml +36 -36
- package/src/components/copy/QasCopy.vue +46 -46
- package/src/components/copy/QasCopy.yml +23 -23
- package/src/components/date/QasDate.vue +600 -600
- package/src/components/date/QasDate.yml +69 -69
- package/src/components/date/enums/DateMaskOptions.js +6 -6
- package/src/components/date-time-input/QasDateTimeInput.vue +269 -269
- package/src/components/date-time-input/QasDateTimeInput.yml +64 -64
- package/src/components/debugger/QasDebugger.vue +31 -31
- package/src/components/debugger/QasDebugger.yml +10 -10
- package/src/components/delete/QasDelete.vue +100 -100
- package/src/components/delete/QasDelete.yml +60 -60
- package/src/components/dialog/QasDialog.vue +217 -217
- package/src/components/dialog/QasDialog.yml +117 -117
- package/src/components/dialog/composables/use-cancel.js +40 -40
- package/src/components/dialog/composables/use-dynamic-components.js +86 -86
- package/src/components/dialog/composables/use-ok.js +45 -45
- package/src/components/dialog-router/QasDialogRouter.vue +86 -86
- package/src/components/dialog-router/QasDialogRouter.yml +23 -23
- package/src/components/drawer/QasDrawer.vue +118 -118
- package/src/components/drawer/QasDrawer.yml +58 -58
- package/src/components/empty-result-text/QasEmptyResultText.vue +18 -18
- package/src/components/empty-result-text/QasEmptyResultText.yml +14 -14
- package/src/components/expansion-item/QasExpansionItem.vue +291 -291
- package/src/components/expansion-item/QasExpansionItem.yml +76 -76
- package/src/components/field/QasField.vue +220 -220
- package/src/components/field/QasField.yml +36 -36
- package/src/components/filters/QasFilters.vue +472 -472
- package/src/components/filters/QasFilters.yml +171 -171
- package/src/components/filters/private/PvFiltersButton.vue +101 -101
- package/src/components/form-generator/QasFormGenerator.vue +274 -274
- package/src/components/form-generator/QasFormGenerator.yml +109 -109
- package/src/components/form-view/QasFormView.vue +484 -484
- package/src/components/form-view/QasFormView.yml +253 -253
- package/src/components/gallery/QasGallery.vue +243 -243
- package/src/components/gallery/QasGallery.yml +188 -188
- package/src/components/gallery/composables/use-delete.js +54 -54
- package/src/components/gallery/private/PvGalleryCarouselDialog.vue +92 -92
- package/src/components/gallery/private/PvGalleryDeleteDialog.vue +54 -54
- package/src/components/gallery-card/QasGalleryCard.vue +153 -153
- package/src/components/gallery-card/QasGalleryCard.yml +61 -61
- package/src/components/grabbable/QasGrabbable.vue +185 -185
- package/src/components/grabbable/QasGrabbable.yml +26 -26
- package/src/components/grid-generator/QasGridGenerator.vue +210 -210
- package/src/components/grid-generator/QasGridGenerator.yml +127 -127
- package/src/components/grid-item/QasGridItem.vue +89 -89
- package/src/components/grid-item/QasGridItem.yml +22 -22
- package/src/components/header/QasHeader.vue +152 -152
- package/src/components/header/QasHeader.yml +50 -50
- package/src/components/infinite-scroll/QasInfiniteScroll.vue +168 -168
- package/src/components/infinite-scroll/QasInfiniteScroll.yml +78 -78
- package/src/components/info/QasInfo.vue +155 -155
- package/src/components/info/QasInfo.yml +34 -34
- package/src/components/input/QasInput.vue +252 -252
- package/src/components/input/QasInput.yml +65 -65
- package/src/components/label/QasLabel.vue +61 -61
- package/src/components/label/QasLabel.yml +44 -44
- package/src/components/layout/QasLayout.vue +101 -101
- package/src/components/layout/QasLayout.yml +46 -46
- package/src/components/layout/private/PvLayoutNotificationCard.vue +86 -86
- package/src/components/layout/private/PvLayoutNotificationsDrawer.vue +140 -140
- package/src/components/list-items/QasListItems.vue +125 -125
- package/src/components/list-items/QasListItems.yml +71 -71
- package/src/components/list-view/QasListView.vue +302 -302
- package/src/components/list-view/QasListView.yml +169 -169
- package/src/components/map/QasMap.vue +75 -75
- package/src/components/map/QasMap.yml +33 -33
- package/src/components/nested-fields/QasNestedFields.vue +584 -584
- package/src/components/nested-fields/QasNestedFields.yml +296 -296
- package/src/components/numeric-input/QasNumericInput.vue +206 -206
- package/src/components/numeric-input/QasNumericInput.yml +85 -85
- package/src/components/option-group/QasOptionGroup.vue +54 -54
- package/src/components/option-group/QasOptionGroup.yml +30 -30
- package/src/components/page-header/QasPageHeader.vue +143 -143
- package/src/components/page-header/QasPageHeader.yml +42 -42
- package/src/components/pagination/QasPagination.vue +71 -71
- package/src/components/pagination/QasPagination.yml +4 -4
- package/src/components/password-input/QasPasswordInput.vue +110 -110
- package/src/components/password-input/QasPasswordInput.yml +111 -111
- package/src/components/password-strength-checker/QasPasswordStrengthChecker.vue +71 -71
- package/src/components/password-strength-checker/QasPasswordStrengthChecker.yml +103 -103
- package/src/components/profile/QasProfile.vue +98 -98
- package/src/components/profile/QasProfile.yml +60 -60
- package/src/components/radio/QasRadio.vue +62 -62
- package/src/components/radio/QasRadio.yml +11 -11
- package/src/components/resizer/QasResizer.vue +90 -90
- package/src/components/resizer/QasResizer.yml +24 -24
- package/src/components/search-box/QasSearchBox.vue +294 -294
- package/src/components/search-box/QasSearchBox.yml +154 -154
- package/src/components/search-input/QasSearchInput.vue +106 -106
- package/src/components/search-input/QasSearchInput.yml +48 -48
- package/src/components/select/QasSelect.vue +514 -514
- package/src/components/select/QasSelect.yml +157 -157
- package/src/components/select-list/QasSelectList.vue +238 -238
- package/src/components/select-list/QasSelectList.yml +108 -108
- package/src/components/select-list/private/PvSelectListCheckbox.vue +31 -31
- package/src/components/select-list-dialog/QasSelectListDialog.vue +395 -395
- package/src/components/select-list-dialog/QasSelectListDialog.yml +108 -108
- package/src/components/signature-pad/QasSignaturePad.vue +122 -122
- package/src/components/signature-pad/QasSignaturePad.yml +53 -53
- package/src/components/signature-uploader/QasSignatureUploader.vue +164 -164
- package/src/components/signature-uploader/QasSignatureUploader.yml +37 -37
- package/src/components/single-view/QasSingleView.vue +175 -175
- package/src/components/single-view/QasSingleView.yml +131 -131
- package/src/components/sortable/QasSortable.vue +151 -151
- package/src/components/sortable/QasSortable.yml +65 -65
- package/src/components/status/QasStatus.test.js +11 -11
- package/src/components/status/QasStatus.vue +29 -29
- package/src/components/status/QasStatus.yml +10 -10
- package/src/components/stepper/QasStepper.vue +152 -152
- package/src/components/stepper/QasStepper.yml +35 -35
- package/src/components/stepper-form-view/QasStepperFormView.vue +84 -84
- package/src/components/stepper-form-view/QasStepperFormView.yml +58 -58
- package/src/components/table-generator/QasTableGenerator.vue +416 -416
- package/src/components/table-generator/QasTableGenerator.yml +94 -94
- package/src/components/tabs-generator/QasTabsGenerator.vue +196 -196
- package/src/components/tabs-generator/QasTabsGenerator.yml +53 -53
- package/src/components/text-truncate/QasTextTruncate.vue +274 -274
- package/src/components/text-truncate/QasTextTruncate.yml +60 -60
- package/src/components/timeline/QasTimeline.vue +140 -140
- package/src/components/timeline/QasTimeline.yml +36 -36
- package/src/components/toggle/QasToggle.vue +14 -14
- package/src/components/toggle/QasToggle.yml +5 -5
- package/src/components/toggle-visibility/QasToggleVisibility.vue +79 -79
- package/src/components/toggle-visibility/QasToggleVisibility.yml +30 -30
- package/src/components/transfer/QasTransfer.vue +239 -239
- package/src/components/transfer/QasTransfer.yml +60 -60
- package/src/components/tree-generator/QasTreeForm.vue +62 -62
- package/src/components/tree-generator/QasTreeGenerator.vue +488 -488
- package/src/components/tree-generator/QasTreeGenerator.yml +81 -81
- package/src/components/uploader/QasUploader.vue +645 -645
- package/src/components/uploader/QasUploader.yml +192 -192
- package/src/components/uploader/private/PvUploaderGalleryCard.vue +357 -357
- package/src/components/welcome/QasWelcome.vue +125 -125
- package/src/components/welcome/QasWelcome.yml +23 -23
- package/src/components/welcome/private/PvWelcomeShortcutCard.vue +58 -58
- package/src/components/whatsapp-link/QasWhatsappLink.vue +34 -34
- package/src/components/whatsapp-link/QasWhatsappLink.yml +18 -18
- package/src/composables/index.js +8 -8
- package/src/composables/private/index.js +3 -3
- package/src/composables/private/use-generator.js +174 -174
- package/src/composables/private/use-toggle-visibility.js +48 -48
- package/src/composables/private/use-view.js +186 -186
- package/src/composables/use-context.js +15 -15
- package/src/composables/use-form.js +32 -32
- package/src/composables/use-history.js +46 -46
- package/src/composables/use-notifications.js +128 -114
- package/src/composables/use-query-cache.js +60 -60
- package/src/composables/use-screen.js +42 -42
- package/src/css/base/font-face.scss +28 -28
- package/src/css/base/index.scss +1 -1
- package/src/css/components/base.scss +12 -12
- package/src/css/components/button.scss +116 -116
- package/src/css/components/checkbox.scss +14 -14
- package/src/css/components/editor.scss +7 -7
- package/src/css/components/field.scss +88 -88
- package/src/css/components/index.scss +10 -10
- package/src/css/components/item.scss +52 -52
- package/src/css/components/radio.scss +18 -18
- package/src/css/components/scrollbar.scss +20 -20
- package/src/css/components/tabs.scss +3 -3
- package/src/css/components/toggle.scss +13 -13
- package/src/css/mixins/index.scss +3 -3
- package/src/css/mixins/set-brand.scss +15 -15
- package/src/css/mixins/set-button.scss +26 -26
- package/src/css/mixins/set-typography.scss +8 -8
- package/src/css/plugins/index.scss +2 -2
- package/src/css/plugins/loading.scss +5 -5
- package/src/css/plugins/notify.scss +100 -100
- package/src/css/utils/background.scss +34 -34
- package/src/css/utils/border-radius.scss +29 -29
- package/src/css/utils/border.scss +42 -42
- package/src/css/utils/container.scss +36 -36
- package/src/css/utils/fonts.scss +5 -5
- package/src/css/utils/index.scss +10 -10
- package/src/css/utils/line-height.scss +19 -19
- package/src/css/utils/opacity.scss +5 -5
- package/src/css/utils/scroll.scss +21 -21
- package/src/css/utils/text.scss +15 -15
- package/src/css/utils/unset.scss +8 -8
- package/src/css/variables/button.scss +4 -4
- package/src/css/variables/index.scss +6 -6
- package/src/css/variables/scrollbar.scss +11 -11
- package/src/css/variables/separator.scss +2 -2
- package/src/css/variables/shadow.scss +3 -3
- package/src/css/variables/spacing.scss +98 -98
- package/src/css/variables/typography.scss +149 -149
- package/src/directives/Test.js +13 -13
- package/src/enums/Align.js +7 -7
- package/src/enums/Spacing.js +98 -98
- package/src/enums/Status.js +33 -33
- package/src/helpers/add-counter-suffix.js +3 -3
- package/src/helpers/base-64-to-blob.js +21 -21
- package/src/helpers/camelize-fields-name.js +15 -15
- package/src/helpers/construct-object.js +29 -29
- package/src/helpers/copy-to-clipboard.js +15 -15
- package/src/helpers/destroy-nested-children-by-key.js +33 -33
- package/src/helpers/download-file.js +21 -21
- package/src/helpers/filter-list-by-handle.js +31 -31
- package/src/helpers/filter-object-to-array.js +29 -29
- package/src/helpers/filter-object.js +34 -34
- package/src/helpers/filters.js +163 -163
- package/src/helpers/find-children-by-key.js +14 -14
- package/src/helpers/get-greatest-common-divisor.js +16 -16
- package/src/helpers/get-normalized-options.js +20 -20
- package/src/helpers/get-placeholder.js +19 -19
- package/src/helpers/get-required-label.js +3 -3
- package/src/helpers/get-slot-children-text.js +15 -15
- package/src/helpers/handle-process.js +13 -13
- package/src/helpers/images.js +28 -28
- package/src/helpers/index.js +25 -25
- package/src/helpers/is-empty.js +3 -3
- package/src/helpers/is-local-development.js +3 -3
- package/src/helpers/private/gutter-validator.js +15 -15
- package/src/helpers/private/has-parent-by-class-name.js +15 -15
- package/src/helpers/promise-handler.js +40 -40
- package/src/helpers/rules.js +7 -7
- package/src/helpers/set-scroll-on-grab.js +128 -128
- package/src/index.cjs.js +1 -1
- package/src/index.esm.js +4 -4
- package/src/index.scss +38 -38
- package/src/index.umd.js +2 -2
- package/src/mixins/context.js +8 -8
- package/src/mixins/delete.js +48 -48
- package/src/mixins/dialog-router.js +17 -17
- package/src/mixins/form.js +11 -11
- package/src/mixins/generator.js +94 -94
- package/src/mixins/index.js +17 -17
- package/src/mixins/password.js +86 -86
- package/src/mixins/search-filter.js +354 -354
- package/src/mixins/view.js +156 -156
- package/src/pages/ErrorComponent.vue +74 -74
- package/src/pages/Forbidden.vue +29 -29
- package/src/pages/NotFound.vue +29 -29
- package/src/pages/ServerError.vue +29 -29
- package/src/pages/Unauthorized.vue +29 -29
- package/src/plugins/delete/Delete.js +107 -107
- package/src/plugins/delete/Delete.yml +75 -75
- package/src/plugins/dialog/Dialog.js +14 -14
- package/src/plugins/dialog/Dialog.yml +10 -10
- package/src/plugins/index.js +13 -13
- package/src/plugins/notify-error/NotifyError.js +13 -13
- package/src/plugins/notify-error/NotifyError.yml +11 -11
- package/src/plugins/notify-success/NotifySuccess.js +13 -13
- package/src/plugins/notify-success/NotifySuccess.yml +11 -11
- package/src/plugins/screen/Screen.js +35 -35
- package/src/plugins/screen/Screen.yml +16 -16
- package/src/shared/date-config.js +26 -26
- package/src/shared/fuse-config.js +4 -4
- package/src/shared/notify-config.js +7 -7
- package/src/vue-plugin/third-party-component-handler.js +29 -29
- package/src/vue-plugin.js +282 -282
|
@@ -1,488 +1,488 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="qas-tree-generator">
|
|
3
|
-
<q-tree ref="tree" v-bind="treeProps" node-key="uuid" :nodes="parsedNodes" @lazy-load="onLazyLoad">
|
|
4
|
-
<template #default-header="{ node, tree }">
|
|
5
|
-
<div>
|
|
6
|
-
<span>
|
|
7
|
-
{{ node.label }}
|
|
8
|
-
</span>
|
|
9
|
-
|
|
10
|
-
<span v-if="hasMenuButton(node)" class="q-ml-sm">
|
|
11
|
-
<!-- TODO: rever para o uso QasActionsMenu -->
|
|
12
|
-
<qas-btn color="grey-10" icon="sym_r_more_vert" variant="tertiary" @click.stop.prevent>
|
|
13
|
-
<q-menu auto-close>
|
|
14
|
-
<q-list separator>
|
|
15
|
-
<q-item v-if="useAddButton" v-ripple class="qas-tree-generator__item" clickable @click="handleTreeFormDialog(node, true, tree)">
|
|
16
|
-
<q-item-section avatar>
|
|
17
|
-
<q-icon name="sym_r_add_circle_outline" />
|
|
18
|
-
</q-item-section>
|
|
19
|
-
|
|
20
|
-
<q-item-section>Adicionar subnível</q-item-section>
|
|
21
|
-
</q-item>
|
|
22
|
-
|
|
23
|
-
<q-item v-if="useEditButton" v-ripple class="qas-tree-generator__item" clickable @click="handleTreeFormDialog(node)">
|
|
24
|
-
<q-item-section avatar>
|
|
25
|
-
<q-icon name="sym_r_edit" />
|
|
26
|
-
</q-item-section>
|
|
27
|
-
|
|
28
|
-
<q-item-section>Editar</q-item-section>
|
|
29
|
-
</q-item>
|
|
30
|
-
|
|
31
|
-
<q-item v-if="hasDestroyButton(node)" v-ripple class="qas-tree-generator__item" clickable @click="onDestroy(node)">
|
|
32
|
-
<q-item-section avatar>
|
|
33
|
-
<q-icon name="sym_r_highlight_off" />
|
|
34
|
-
</q-item-section>
|
|
35
|
-
|
|
36
|
-
<q-item-section>Excluir</q-item-section>
|
|
37
|
-
</q-item>
|
|
38
|
-
</q-list>
|
|
39
|
-
</q-menu>
|
|
40
|
-
</qas-btn>
|
|
41
|
-
</span>
|
|
42
|
-
</div>
|
|
43
|
-
</template>
|
|
44
|
-
</q-tree>
|
|
45
|
-
|
|
46
|
-
<qas-dialog v-model="showDestroyDialog" v-bind="destroyDialogConfig" />
|
|
47
|
-
|
|
48
|
-
<qas-dialog v-model="showFormDialog" v-bind="formDialogConfig" use-form @hide="resetModels" @validate="onValidate">
|
|
49
|
-
<template #description>
|
|
50
|
-
<div>
|
|
51
|
-
<qas-field v-if="hasAddField" v-model="editModel" :disable="isAdd" :field="addField" :label="nodeTitle" :rules="[required]" />
|
|
52
|
-
|
|
53
|
-
<qas-nested-fields v-if="hasNestedAdd" v-model="nestedModel" class="q-mt-md" :field="nestedFieldProp" :fields-props="fieldsProps" :form-columns="nestedColumns" :row-object="rowObject" :use-duplicate="false" use-inline-actions />
|
|
54
|
-
|
|
55
|
-
<qas-tree-form v-if="hasFormView" ref="treeForm" v-model:submitting="isSubmitting" :form-generator-props="formGeneratorProps" :form-view-props="defaultFormViewProps" @submit-success="onSubmitSuccess" />
|
|
56
|
-
</div>
|
|
57
|
-
</template>
|
|
58
|
-
</qas-dialog>
|
|
59
|
-
</div>
|
|
60
|
-
</template>
|
|
61
|
-
|
|
62
|
-
<script>
|
|
63
|
-
import destroyNestedChildrenByKey from '../../helpers/destroy-nested-children-by-key.js'
|
|
64
|
-
import findChildrenByKey from '../../helpers/find-children-by-key.js'
|
|
65
|
-
import promiseHandler from '../../helpers/promise-handler.js'
|
|
66
|
-
import { required } from '../../helpers/rules.js'
|
|
67
|
-
import { extend } from 'quasar'
|
|
68
|
-
import axios from 'axios'
|
|
69
|
-
|
|
70
|
-
import QasTreeForm from './QasTreeForm.vue'
|
|
71
|
-
|
|
72
|
-
export default {
|
|
73
|
-
name: 'QasTreeGenerator',
|
|
74
|
-
|
|
75
|
-
components: {
|
|
76
|
-
QasTreeForm
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
props: {
|
|
80
|
-
formGeneratorProps: {
|
|
81
|
-
type: Object,
|
|
82
|
-
default: () => ({})
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
formViewProps: {
|
|
86
|
-
type: Object,
|
|
87
|
-
default: () => ({})
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
labelKey: {
|
|
91
|
-
type: String,
|
|
92
|
-
default: 'name'
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
lazyNodes: {
|
|
96
|
-
type: Array,
|
|
97
|
-
default: () => []
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
nodes: {
|
|
101
|
-
type: Array,
|
|
102
|
-
default: () => []
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
readonly: {
|
|
106
|
-
type: Boolean
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
resource: {
|
|
110
|
-
type: String,
|
|
111
|
-
default: ''
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
treeProps: {
|
|
115
|
-
type: Object,
|
|
116
|
-
default: () => ({})
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
useAddButton: {
|
|
120
|
-
type: Boolean,
|
|
121
|
-
default: true
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
useDestroyButton: {
|
|
125
|
-
type: Boolean,
|
|
126
|
-
default: true
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
useDestroyOnFirstNode: {
|
|
130
|
-
type: Boolean
|
|
131
|
-
},
|
|
132
|
-
|
|
133
|
-
useEditButton: {
|
|
134
|
-
type: Boolean,
|
|
135
|
-
default: true
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
useFormViewEdit: {
|
|
139
|
-
type: Boolean
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
useFormViewAdd: {
|
|
143
|
-
type: Boolean
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
|
|
147
|
-
emits: [
|
|
148
|
-
'update:lazyNodes'
|
|
149
|
-
],
|
|
150
|
-
|
|
151
|
-
data () {
|
|
152
|
-
return {
|
|
153
|
-
showDestroyDialog: false,
|
|
154
|
-
currentNode: {},
|
|
155
|
-
showFormDialog: false,
|
|
156
|
-
nestedModel: [],
|
|
157
|
-
singleModel: { label: '' },
|
|
158
|
-
editModel: '',
|
|
159
|
-
isAdd: true,
|
|
160
|
-
parsedNodes: [],
|
|
161
|
-
isSubmitting: false
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
|
|
165
|
-
computed: {
|
|
166
|
-
addField () {
|
|
167
|
-
return { name: 'add', type: 'text', label: this.nodeTitle }
|
|
168
|
-
},
|
|
169
|
-
|
|
170
|
-
destroyDialogConfig () {
|
|
171
|
-
return {
|
|
172
|
-
card: {
|
|
173
|
-
description: 'Todas as informações serão perdidas. Deseja realmente continuar?'
|
|
174
|
-
},
|
|
175
|
-
ok: {
|
|
176
|
-
label: 'Excluir',
|
|
177
|
-
onClick: this.destroy
|
|
178
|
-
},
|
|
179
|
-
cancel: {
|
|
180
|
-
onClick: this.resetCurrentNode
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
|
|
185
|
-
formDialogConfig () {
|
|
186
|
-
return {
|
|
187
|
-
card: {
|
|
188
|
-
title: this.isAdd ? 'Adicionar ramo' : 'Editar ramo'
|
|
189
|
-
},
|
|
190
|
-
ok: {
|
|
191
|
-
label: 'Salvar',
|
|
192
|
-
loading: this.isSubmitting
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
nestedFieldProp () {
|
|
198
|
-
return {
|
|
199
|
-
type: 'nested',
|
|
200
|
-
label: 'Adicionar itens',
|
|
201
|
-
name: 'nested',
|
|
202
|
-
children: {
|
|
203
|
-
label: {
|
|
204
|
-
type: 'text',
|
|
205
|
-
label: 'Adicionar um novo item',
|
|
206
|
-
name: 'label'
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
|
|
212
|
-
rowObject () {
|
|
213
|
-
return { label: '' }
|
|
214
|
-
},
|
|
215
|
-
|
|
216
|
-
nestedColumns () {
|
|
217
|
-
return {
|
|
218
|
-
label: {
|
|
219
|
-
col: 12
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
},
|
|
223
|
-
|
|
224
|
-
nodeTitle () {
|
|
225
|
-
if (!this.isAdd) {
|
|
226
|
-
return 'Nome do ramo'
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return this.currentNode.label || 'ramo'
|
|
230
|
-
},
|
|
231
|
-
|
|
232
|
-
fieldsProps () {
|
|
233
|
-
return {
|
|
234
|
-
label: {
|
|
235
|
-
rules: [required]
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
|
|
240
|
-
messages () {
|
|
241
|
-
return {
|
|
242
|
-
error: 'Ops! Erro ao salvar item.',
|
|
243
|
-
success: 'Item salvo com sucesso!'
|
|
244
|
-
}
|
|
245
|
-
},
|
|
246
|
-
|
|
247
|
-
defaultFormViewProps () {
|
|
248
|
-
return {
|
|
249
|
-
...this.formViewProps,
|
|
250
|
-
...(!this.isAdd && { customId: this.currentNode.uuid }),
|
|
251
|
-
...(this.isAdd && { parent: this.currentNode.uuid }),
|
|
252
|
-
mode: this.isAdd ? 'create' : 'replace'
|
|
253
|
-
}
|
|
254
|
-
},
|
|
255
|
-
|
|
256
|
-
hasAddField () {
|
|
257
|
-
return this.isAdd || !this.hasFormView
|
|
258
|
-
},
|
|
259
|
-
|
|
260
|
-
hasNestedAdd () {
|
|
261
|
-
return (!this.hasFormView || !this.useFormViewAdd) && this.isAdd
|
|
262
|
-
},
|
|
263
|
-
|
|
264
|
-
hasFormView () {
|
|
265
|
-
return this.isAdd ? this.useFormViewAdd : this.useFormViewEdit
|
|
266
|
-
},
|
|
267
|
-
|
|
268
|
-
parentsList () {
|
|
269
|
-
return this.nodes.map(({ uuid }) => uuid)
|
|
270
|
-
}
|
|
271
|
-
},
|
|
272
|
-
|
|
273
|
-
watch: {
|
|
274
|
-
nodes: {
|
|
275
|
-
handler () {
|
|
276
|
-
this.setInitialValue()
|
|
277
|
-
},
|
|
278
|
-
immediate: true,
|
|
279
|
-
deep: true
|
|
280
|
-
},
|
|
281
|
-
|
|
282
|
-
parsedNodes: {
|
|
283
|
-
handler (nodes) {
|
|
284
|
-
this.$emit('update:lazyNodes', nodes)
|
|
285
|
-
},
|
|
286
|
-
immediate: true,
|
|
287
|
-
deep: true
|
|
288
|
-
}
|
|
289
|
-
},
|
|
290
|
-
|
|
291
|
-
methods: {
|
|
292
|
-
required,
|
|
293
|
-
|
|
294
|
-
handleTreeFormDialog (node, isAdd) {
|
|
295
|
-
this.showFormDialog = !this.showFormDialog
|
|
296
|
-
this.isAdd = !!isAdd
|
|
297
|
-
this.currentNode = node
|
|
298
|
-
|
|
299
|
-
if (!this.isAdd) {
|
|
300
|
-
this.editModel = node.label
|
|
301
|
-
}
|
|
302
|
-
},
|
|
303
|
-
|
|
304
|
-
async add () {
|
|
305
|
-
const { data, error } = await promiseHandler(
|
|
306
|
-
this.nestedModel.map(({ label }) => {
|
|
307
|
-
return axios.post(this.resource, { parent: this.currentNode.uuid, [this.labelKey]: label, lazy: true })
|
|
308
|
-
}),
|
|
309
|
-
{
|
|
310
|
-
successMessage: this.messages.success,
|
|
311
|
-
errorMessage: this.messages.error
|
|
312
|
-
}
|
|
313
|
-
)
|
|
314
|
-
|
|
315
|
-
if (error) return
|
|
316
|
-
|
|
317
|
-
const nestedResponse = data.map(response => {
|
|
318
|
-
const { result } = response.data
|
|
319
|
-
const { name, uuid } = result
|
|
320
|
-
|
|
321
|
-
return {
|
|
322
|
-
label: name,
|
|
323
|
-
lazy: true,
|
|
324
|
-
uuid
|
|
325
|
-
}
|
|
326
|
-
})
|
|
327
|
-
|
|
328
|
-
// Precisa abrir antes de adicionar para casos de ramos que ainda não foram abertos.
|
|
329
|
-
this.$refs.tree.setExpanded(this.currentNode.uuid, true)
|
|
330
|
-
|
|
331
|
-
if (this.currentNode.children) {
|
|
332
|
-
this.currentNode.children.push(...nestedResponse)
|
|
333
|
-
} else {
|
|
334
|
-
this.currentNode.children = [...nestedResponse]
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
this.$nextTick(() => this.$refs.tree.setExpanded(this.currentNode.uuid, true))
|
|
338
|
-
},
|
|
339
|
-
|
|
340
|
-
async edit () {
|
|
341
|
-
const { uuid } = this.currentNode
|
|
342
|
-
|
|
343
|
-
const { error } = await promiseHandler(
|
|
344
|
-
axios.put(
|
|
345
|
-
`${this.resource}/${uuid}`,
|
|
346
|
-
{
|
|
347
|
-
[this.labelKey]: this.editModel,
|
|
348
|
-
uuid,
|
|
349
|
-
lazy: true
|
|
350
|
-
}
|
|
351
|
-
),
|
|
352
|
-
{
|
|
353
|
-
successMessage: this.messages.success,
|
|
354
|
-
errorMessage: this.messages.error
|
|
355
|
-
}
|
|
356
|
-
)
|
|
357
|
-
|
|
358
|
-
if (error) return
|
|
359
|
-
|
|
360
|
-
this.currentNode.label = this.editModel
|
|
361
|
-
this.$refs.tree.setExpanded(uuid, true)
|
|
362
|
-
},
|
|
363
|
-
|
|
364
|
-
onDestroy (children) {
|
|
365
|
-
this.showDestroyDialog = !this.showDestroyDialog
|
|
366
|
-
this.currentNode = children
|
|
367
|
-
},
|
|
368
|
-
|
|
369
|
-
async destroy () {
|
|
370
|
-
const { error } = await promiseHandler(
|
|
371
|
-
axios.delete(`${this.resource}/${this.currentNode.uuid}`),
|
|
372
|
-
{
|
|
373
|
-
successMessage: 'Item deletado com sucesso!',
|
|
374
|
-
errorMessage: 'Ops! Não foi possível deletar o item.'
|
|
375
|
-
}
|
|
376
|
-
)
|
|
377
|
-
|
|
378
|
-
if (error) return
|
|
379
|
-
|
|
380
|
-
this.currentNode.destroyed = true
|
|
381
|
-
destroyNestedChildrenByKey(this.parsedNodes)
|
|
382
|
-
},
|
|
383
|
-
|
|
384
|
-
resetCurrentNode () {
|
|
385
|
-
this.currentNode = {}
|
|
386
|
-
},
|
|
387
|
-
|
|
388
|
-
resetModels () {
|
|
389
|
-
this.nestedModel = [{ label: '' }]
|
|
390
|
-
this.singleModel = {}
|
|
391
|
-
this.editModel = ''
|
|
392
|
-
},
|
|
393
|
-
|
|
394
|
-
async onValidate (isValid) {
|
|
395
|
-
if (isValid) {
|
|
396
|
-
const canUseFormViewOnAdd = this.isAdd && this.useFormViewAdd
|
|
397
|
-
const canUseFormViewOnEdit = !this.isAdd && this.useFormViewEdit
|
|
398
|
-
|
|
399
|
-
if (canUseFormViewOnAdd || canUseFormViewOnEdit) {
|
|
400
|
-
this.$refs.treeForm.submit()
|
|
401
|
-
return
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
// espera requisição finalizar para poder adicionar/editar
|
|
405
|
-
this.isAdd ? await this.add() : await this.edit()
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
this.showFormDialog = !isValid
|
|
409
|
-
},
|
|
410
|
-
|
|
411
|
-
/*
|
|
412
|
-
* neste método pode ser implementado uma logica para receber os nós da árvore parcialmente
|
|
413
|
-
* utilizando chamadas de API.
|
|
414
|
-
*/
|
|
415
|
-
onLazyLoad ({ key, done }) {
|
|
416
|
-
// retorna um proximo nó caso exista.
|
|
417
|
-
return done(this.findNextNode(this.nodes, key, true) || [])
|
|
418
|
-
},
|
|
419
|
-
|
|
420
|
-
setInitialValue () {
|
|
421
|
-
const { children, ...payload } = { ...this.nodes?.[0] }
|
|
422
|
-
this.parsedNodes = Object.keys(payload).length ? [payload] : []
|
|
423
|
-
},
|
|
424
|
-
|
|
425
|
-
findNextNode (list, key, deleteMode) {
|
|
426
|
-
const children = findChildrenByKey(list, 'uuid', key)?.children
|
|
427
|
-
|
|
428
|
-
if (!children?.length) return []
|
|
429
|
-
|
|
430
|
-
// retorna um proximo nó caso exista.
|
|
431
|
-
return (extend(true, [], children).map(item => {
|
|
432
|
-
if (deleteMode) {
|
|
433
|
-
delete item.children
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
return item
|
|
437
|
-
}))
|
|
438
|
-
},
|
|
439
|
-
|
|
440
|
-
onSubmitSuccess (response) {
|
|
441
|
-
const { data: { result } } = response
|
|
442
|
-
|
|
443
|
-
this.currentNode.label = result[this.labelKey]
|
|
444
|
-
this.showFormDialog = false
|
|
445
|
-
},
|
|
446
|
-
|
|
447
|
-
hasDestroyButton ({ uuid }) {
|
|
448
|
-
if (!this.useDestroyButton) return false
|
|
449
|
-
|
|
450
|
-
return !this.useDestroyOnFirstNode ? !this.parentsList.includes(uuid) : true
|
|
451
|
-
},
|
|
452
|
-
|
|
453
|
-
hasMenuButton (node) {
|
|
454
|
-
if (this.readonly) return false
|
|
455
|
-
|
|
456
|
-
const hasEditOrAddButton = this.useAddButton || this.useEditButton
|
|
457
|
-
|
|
458
|
-
if (!this.useDestroyOnFirstNode) {
|
|
459
|
-
const hasDestroyButton = this.hasDestroyButton(node)
|
|
460
|
-
|
|
461
|
-
return hasEditOrAddButton || hasDestroyButton
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
return hasEditOrAddButton || this.useDestroyButton
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
</script>
|
|
469
|
-
|
|
470
|
-
<style lang="scss">
|
|
471
|
-
.qas-tree-generator {
|
|
472
|
-
&__item:hover {
|
|
473
|
-
color: var(--q-primary);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
.q-tree__node-header {
|
|
477
|
-
margin-top: 16px;
|
|
478
|
-
|
|
479
|
-
&::before {
|
|
480
|
-
top: -16px;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
&::after {
|
|
484
|
-
top: -16px;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="qas-tree-generator">
|
|
3
|
+
<q-tree ref="tree" v-bind="treeProps" node-key="uuid" :nodes="parsedNodes" @lazy-load="onLazyLoad">
|
|
4
|
+
<template #default-header="{ node, tree }">
|
|
5
|
+
<div>
|
|
6
|
+
<span>
|
|
7
|
+
{{ node.label }}
|
|
8
|
+
</span>
|
|
9
|
+
|
|
10
|
+
<span v-if="hasMenuButton(node)" class="q-ml-sm">
|
|
11
|
+
<!-- TODO: rever para o uso QasActionsMenu -->
|
|
12
|
+
<qas-btn color="grey-10" icon="sym_r_more_vert" variant="tertiary" @click.stop.prevent>
|
|
13
|
+
<q-menu auto-close>
|
|
14
|
+
<q-list separator>
|
|
15
|
+
<q-item v-if="useAddButton" v-ripple class="qas-tree-generator__item" clickable @click="handleTreeFormDialog(node, true, tree)">
|
|
16
|
+
<q-item-section avatar>
|
|
17
|
+
<q-icon name="sym_r_add_circle_outline" />
|
|
18
|
+
</q-item-section>
|
|
19
|
+
|
|
20
|
+
<q-item-section>Adicionar subnível</q-item-section>
|
|
21
|
+
</q-item>
|
|
22
|
+
|
|
23
|
+
<q-item v-if="useEditButton" v-ripple class="qas-tree-generator__item" clickable @click="handleTreeFormDialog(node)">
|
|
24
|
+
<q-item-section avatar>
|
|
25
|
+
<q-icon name="sym_r_edit" />
|
|
26
|
+
</q-item-section>
|
|
27
|
+
|
|
28
|
+
<q-item-section>Editar</q-item-section>
|
|
29
|
+
</q-item>
|
|
30
|
+
|
|
31
|
+
<q-item v-if="hasDestroyButton(node)" v-ripple class="qas-tree-generator__item" clickable @click="onDestroy(node)">
|
|
32
|
+
<q-item-section avatar>
|
|
33
|
+
<q-icon name="sym_r_highlight_off" />
|
|
34
|
+
</q-item-section>
|
|
35
|
+
|
|
36
|
+
<q-item-section>Excluir</q-item-section>
|
|
37
|
+
</q-item>
|
|
38
|
+
</q-list>
|
|
39
|
+
</q-menu>
|
|
40
|
+
</qas-btn>
|
|
41
|
+
</span>
|
|
42
|
+
</div>
|
|
43
|
+
</template>
|
|
44
|
+
</q-tree>
|
|
45
|
+
|
|
46
|
+
<qas-dialog v-model="showDestroyDialog" v-bind="destroyDialogConfig" />
|
|
47
|
+
|
|
48
|
+
<qas-dialog v-model="showFormDialog" v-bind="formDialogConfig" use-form @hide="resetModels" @validate="onValidate">
|
|
49
|
+
<template #description>
|
|
50
|
+
<div>
|
|
51
|
+
<qas-field v-if="hasAddField" v-model="editModel" :disable="isAdd" :field="addField" :label="nodeTitle" :rules="[required]" />
|
|
52
|
+
|
|
53
|
+
<qas-nested-fields v-if="hasNestedAdd" v-model="nestedModel" class="q-mt-md" :field="nestedFieldProp" :fields-props="fieldsProps" :form-columns="nestedColumns" :row-object="rowObject" :use-duplicate="false" use-inline-actions />
|
|
54
|
+
|
|
55
|
+
<qas-tree-form v-if="hasFormView" ref="treeForm" v-model:submitting="isSubmitting" :form-generator-props="formGeneratorProps" :form-view-props="defaultFormViewProps" @submit-success="onSubmitSuccess" />
|
|
56
|
+
</div>
|
|
57
|
+
</template>
|
|
58
|
+
</qas-dialog>
|
|
59
|
+
</div>
|
|
60
|
+
</template>
|
|
61
|
+
|
|
62
|
+
<script>
|
|
63
|
+
import destroyNestedChildrenByKey from '../../helpers/destroy-nested-children-by-key.js'
|
|
64
|
+
import findChildrenByKey from '../../helpers/find-children-by-key.js'
|
|
65
|
+
import promiseHandler from '../../helpers/promise-handler.js'
|
|
66
|
+
import { required } from '../../helpers/rules.js'
|
|
67
|
+
import { extend } from 'quasar'
|
|
68
|
+
import axios from 'axios'
|
|
69
|
+
|
|
70
|
+
import QasTreeForm from './QasTreeForm.vue'
|
|
71
|
+
|
|
72
|
+
export default {
|
|
73
|
+
name: 'QasTreeGenerator',
|
|
74
|
+
|
|
75
|
+
components: {
|
|
76
|
+
QasTreeForm
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
props: {
|
|
80
|
+
formGeneratorProps: {
|
|
81
|
+
type: Object,
|
|
82
|
+
default: () => ({})
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
formViewProps: {
|
|
86
|
+
type: Object,
|
|
87
|
+
default: () => ({})
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
labelKey: {
|
|
91
|
+
type: String,
|
|
92
|
+
default: 'name'
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
lazyNodes: {
|
|
96
|
+
type: Array,
|
|
97
|
+
default: () => []
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
nodes: {
|
|
101
|
+
type: Array,
|
|
102
|
+
default: () => []
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
readonly: {
|
|
106
|
+
type: Boolean
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
resource: {
|
|
110
|
+
type: String,
|
|
111
|
+
default: ''
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
treeProps: {
|
|
115
|
+
type: Object,
|
|
116
|
+
default: () => ({})
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
useAddButton: {
|
|
120
|
+
type: Boolean,
|
|
121
|
+
default: true
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
useDestroyButton: {
|
|
125
|
+
type: Boolean,
|
|
126
|
+
default: true
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
useDestroyOnFirstNode: {
|
|
130
|
+
type: Boolean
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
useEditButton: {
|
|
134
|
+
type: Boolean,
|
|
135
|
+
default: true
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
useFormViewEdit: {
|
|
139
|
+
type: Boolean
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
useFormViewAdd: {
|
|
143
|
+
type: Boolean
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
emits: [
|
|
148
|
+
'update:lazyNodes'
|
|
149
|
+
],
|
|
150
|
+
|
|
151
|
+
data () {
|
|
152
|
+
return {
|
|
153
|
+
showDestroyDialog: false,
|
|
154
|
+
currentNode: {},
|
|
155
|
+
showFormDialog: false,
|
|
156
|
+
nestedModel: [],
|
|
157
|
+
singleModel: { label: '' },
|
|
158
|
+
editModel: '',
|
|
159
|
+
isAdd: true,
|
|
160
|
+
parsedNodes: [],
|
|
161
|
+
isSubmitting: false
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
computed: {
|
|
166
|
+
addField () {
|
|
167
|
+
return { name: 'add', type: 'text', label: this.nodeTitle }
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
destroyDialogConfig () {
|
|
171
|
+
return {
|
|
172
|
+
card: {
|
|
173
|
+
description: 'Todas as informações serão perdidas. Deseja realmente continuar?'
|
|
174
|
+
},
|
|
175
|
+
ok: {
|
|
176
|
+
label: 'Excluir',
|
|
177
|
+
onClick: this.destroy
|
|
178
|
+
},
|
|
179
|
+
cancel: {
|
|
180
|
+
onClick: this.resetCurrentNode
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
formDialogConfig () {
|
|
186
|
+
return {
|
|
187
|
+
card: {
|
|
188
|
+
title: this.isAdd ? 'Adicionar ramo' : 'Editar ramo'
|
|
189
|
+
},
|
|
190
|
+
ok: {
|
|
191
|
+
label: 'Salvar',
|
|
192
|
+
loading: this.isSubmitting
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
nestedFieldProp () {
|
|
198
|
+
return {
|
|
199
|
+
type: 'nested',
|
|
200
|
+
label: 'Adicionar itens',
|
|
201
|
+
name: 'nested',
|
|
202
|
+
children: {
|
|
203
|
+
label: {
|
|
204
|
+
type: 'text',
|
|
205
|
+
label: 'Adicionar um novo item',
|
|
206
|
+
name: 'label'
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
rowObject () {
|
|
213
|
+
return { label: '' }
|
|
214
|
+
},
|
|
215
|
+
|
|
216
|
+
nestedColumns () {
|
|
217
|
+
return {
|
|
218
|
+
label: {
|
|
219
|
+
col: 12
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
nodeTitle () {
|
|
225
|
+
if (!this.isAdd) {
|
|
226
|
+
return 'Nome do ramo'
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return this.currentNode.label || 'ramo'
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
fieldsProps () {
|
|
233
|
+
return {
|
|
234
|
+
label: {
|
|
235
|
+
rules: [required]
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
|
|
240
|
+
messages () {
|
|
241
|
+
return {
|
|
242
|
+
error: 'Ops! Erro ao salvar item.',
|
|
243
|
+
success: 'Item salvo com sucesso!'
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
defaultFormViewProps () {
|
|
248
|
+
return {
|
|
249
|
+
...this.formViewProps,
|
|
250
|
+
...(!this.isAdd && { customId: this.currentNode.uuid }),
|
|
251
|
+
...(this.isAdd && { parent: this.currentNode.uuid }),
|
|
252
|
+
mode: this.isAdd ? 'create' : 'replace'
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
|
|
256
|
+
hasAddField () {
|
|
257
|
+
return this.isAdd || !this.hasFormView
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
hasNestedAdd () {
|
|
261
|
+
return (!this.hasFormView || !this.useFormViewAdd) && this.isAdd
|
|
262
|
+
},
|
|
263
|
+
|
|
264
|
+
hasFormView () {
|
|
265
|
+
return this.isAdd ? this.useFormViewAdd : this.useFormViewEdit
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
parentsList () {
|
|
269
|
+
return this.nodes.map(({ uuid }) => uuid)
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
|
|
273
|
+
watch: {
|
|
274
|
+
nodes: {
|
|
275
|
+
handler () {
|
|
276
|
+
this.setInitialValue()
|
|
277
|
+
},
|
|
278
|
+
immediate: true,
|
|
279
|
+
deep: true
|
|
280
|
+
},
|
|
281
|
+
|
|
282
|
+
parsedNodes: {
|
|
283
|
+
handler (nodes) {
|
|
284
|
+
this.$emit('update:lazyNodes', nodes)
|
|
285
|
+
},
|
|
286
|
+
immediate: true,
|
|
287
|
+
deep: true
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
|
|
291
|
+
methods: {
|
|
292
|
+
required,
|
|
293
|
+
|
|
294
|
+
handleTreeFormDialog (node, isAdd) {
|
|
295
|
+
this.showFormDialog = !this.showFormDialog
|
|
296
|
+
this.isAdd = !!isAdd
|
|
297
|
+
this.currentNode = node
|
|
298
|
+
|
|
299
|
+
if (!this.isAdd) {
|
|
300
|
+
this.editModel = node.label
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
|
|
304
|
+
async add () {
|
|
305
|
+
const { data, error } = await promiseHandler(
|
|
306
|
+
this.nestedModel.map(({ label }) => {
|
|
307
|
+
return axios.post(this.resource, { parent: this.currentNode.uuid, [this.labelKey]: label, lazy: true })
|
|
308
|
+
}),
|
|
309
|
+
{
|
|
310
|
+
successMessage: this.messages.success,
|
|
311
|
+
errorMessage: this.messages.error
|
|
312
|
+
}
|
|
313
|
+
)
|
|
314
|
+
|
|
315
|
+
if (error) return
|
|
316
|
+
|
|
317
|
+
const nestedResponse = data.map(response => {
|
|
318
|
+
const { result } = response.data
|
|
319
|
+
const { name, uuid } = result
|
|
320
|
+
|
|
321
|
+
return {
|
|
322
|
+
label: name,
|
|
323
|
+
lazy: true,
|
|
324
|
+
uuid
|
|
325
|
+
}
|
|
326
|
+
})
|
|
327
|
+
|
|
328
|
+
// Precisa abrir antes de adicionar para casos de ramos que ainda não foram abertos.
|
|
329
|
+
this.$refs.tree.setExpanded(this.currentNode.uuid, true)
|
|
330
|
+
|
|
331
|
+
if (this.currentNode.children) {
|
|
332
|
+
this.currentNode.children.push(...nestedResponse)
|
|
333
|
+
} else {
|
|
334
|
+
this.currentNode.children = [...nestedResponse]
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
this.$nextTick(() => this.$refs.tree.setExpanded(this.currentNode.uuid, true))
|
|
338
|
+
},
|
|
339
|
+
|
|
340
|
+
async edit () {
|
|
341
|
+
const { uuid } = this.currentNode
|
|
342
|
+
|
|
343
|
+
const { error } = await promiseHandler(
|
|
344
|
+
axios.put(
|
|
345
|
+
`${this.resource}/${uuid}`,
|
|
346
|
+
{
|
|
347
|
+
[this.labelKey]: this.editModel,
|
|
348
|
+
uuid,
|
|
349
|
+
lazy: true
|
|
350
|
+
}
|
|
351
|
+
),
|
|
352
|
+
{
|
|
353
|
+
successMessage: this.messages.success,
|
|
354
|
+
errorMessage: this.messages.error
|
|
355
|
+
}
|
|
356
|
+
)
|
|
357
|
+
|
|
358
|
+
if (error) return
|
|
359
|
+
|
|
360
|
+
this.currentNode.label = this.editModel
|
|
361
|
+
this.$refs.tree.setExpanded(uuid, true)
|
|
362
|
+
},
|
|
363
|
+
|
|
364
|
+
onDestroy (children) {
|
|
365
|
+
this.showDestroyDialog = !this.showDestroyDialog
|
|
366
|
+
this.currentNode = children
|
|
367
|
+
},
|
|
368
|
+
|
|
369
|
+
async destroy () {
|
|
370
|
+
const { error } = await promiseHandler(
|
|
371
|
+
axios.delete(`${this.resource}/${this.currentNode.uuid}`),
|
|
372
|
+
{
|
|
373
|
+
successMessage: 'Item deletado com sucesso!',
|
|
374
|
+
errorMessage: 'Ops! Não foi possível deletar o item.'
|
|
375
|
+
}
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
if (error) return
|
|
379
|
+
|
|
380
|
+
this.currentNode.destroyed = true
|
|
381
|
+
destroyNestedChildrenByKey(this.parsedNodes)
|
|
382
|
+
},
|
|
383
|
+
|
|
384
|
+
resetCurrentNode () {
|
|
385
|
+
this.currentNode = {}
|
|
386
|
+
},
|
|
387
|
+
|
|
388
|
+
resetModels () {
|
|
389
|
+
this.nestedModel = [{ label: '' }]
|
|
390
|
+
this.singleModel = {}
|
|
391
|
+
this.editModel = ''
|
|
392
|
+
},
|
|
393
|
+
|
|
394
|
+
async onValidate (isValid) {
|
|
395
|
+
if (isValid) {
|
|
396
|
+
const canUseFormViewOnAdd = this.isAdd && this.useFormViewAdd
|
|
397
|
+
const canUseFormViewOnEdit = !this.isAdd && this.useFormViewEdit
|
|
398
|
+
|
|
399
|
+
if (canUseFormViewOnAdd || canUseFormViewOnEdit) {
|
|
400
|
+
this.$refs.treeForm.submit()
|
|
401
|
+
return
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// espera requisição finalizar para poder adicionar/editar
|
|
405
|
+
this.isAdd ? await this.add() : await this.edit()
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
this.showFormDialog = !isValid
|
|
409
|
+
},
|
|
410
|
+
|
|
411
|
+
/*
|
|
412
|
+
* neste método pode ser implementado uma logica para receber os nós da árvore parcialmente
|
|
413
|
+
* utilizando chamadas de API.
|
|
414
|
+
*/
|
|
415
|
+
onLazyLoad ({ key, done }) {
|
|
416
|
+
// retorna um proximo nó caso exista.
|
|
417
|
+
return done(this.findNextNode(this.nodes, key, true) || [])
|
|
418
|
+
},
|
|
419
|
+
|
|
420
|
+
setInitialValue () {
|
|
421
|
+
const { children, ...payload } = { ...this.nodes?.[0] }
|
|
422
|
+
this.parsedNodes = Object.keys(payload).length ? [payload] : []
|
|
423
|
+
},
|
|
424
|
+
|
|
425
|
+
findNextNode (list, key, deleteMode) {
|
|
426
|
+
const children = findChildrenByKey(list, 'uuid', key)?.children
|
|
427
|
+
|
|
428
|
+
if (!children?.length) return []
|
|
429
|
+
|
|
430
|
+
// retorna um proximo nó caso exista.
|
|
431
|
+
return (extend(true, [], children).map(item => {
|
|
432
|
+
if (deleteMode) {
|
|
433
|
+
delete item.children
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
return item
|
|
437
|
+
}))
|
|
438
|
+
},
|
|
439
|
+
|
|
440
|
+
onSubmitSuccess (response) {
|
|
441
|
+
const { data: { result } } = response
|
|
442
|
+
|
|
443
|
+
this.currentNode.label = result[this.labelKey]
|
|
444
|
+
this.showFormDialog = false
|
|
445
|
+
},
|
|
446
|
+
|
|
447
|
+
hasDestroyButton ({ uuid }) {
|
|
448
|
+
if (!this.useDestroyButton) return false
|
|
449
|
+
|
|
450
|
+
return !this.useDestroyOnFirstNode ? !this.parentsList.includes(uuid) : true
|
|
451
|
+
},
|
|
452
|
+
|
|
453
|
+
hasMenuButton (node) {
|
|
454
|
+
if (this.readonly) return false
|
|
455
|
+
|
|
456
|
+
const hasEditOrAddButton = this.useAddButton || this.useEditButton
|
|
457
|
+
|
|
458
|
+
if (!this.useDestroyOnFirstNode) {
|
|
459
|
+
const hasDestroyButton = this.hasDestroyButton(node)
|
|
460
|
+
|
|
461
|
+
return hasEditOrAddButton || hasDestroyButton
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
return hasEditOrAddButton || this.useDestroyButton
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
</script>
|
|
469
|
+
|
|
470
|
+
<style lang="scss">
|
|
471
|
+
.qas-tree-generator {
|
|
472
|
+
&__item:hover {
|
|
473
|
+
color: var(--q-primary);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
.q-tree__node-header {
|
|
477
|
+
margin-top: 16px;
|
|
478
|
+
|
|
479
|
+
&::before {
|
|
480
|
+
top: -16px;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
&::after {
|
|
484
|
+
top: -16px;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
</style>
|