@bildvitta/quasar-ui-asteroid 2.16.0 → 3.0.0-alpha.2
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/dist/api/QasActions.json +40 -0
- package/dist/api/QasActionsMenu.json +64 -0
- package/dist/api/QasAlert.json +40 -0
- package/dist/api/QasAppBar.json +52 -0
- package/dist/api/QasAppMenu.json +38 -0
- package/dist/api/QasAvatar.json +44 -0
- package/dist/api/QasBox.json +16 -0
- package/dist/api/QasBreakline.json +32 -0
- package/dist/api/QasBtn.json +16 -0
- package/dist/api/QasCard.json +52 -0
- package/dist/api/QasCheckboxGroup.json +38 -0
- package/dist/api/QasCopy.json +29 -0
- package/dist/api/QasDateTimeInput.json +60 -0
- package/dist/api/QasDebugger.json +13 -0
- package/dist/api/QasDelete.json +64 -0
- package/dist/api/QasDialog.json +109 -0
- package/dist/api/QasDialogRouter.json +31 -0
- package/dist/api/QasField.json +56 -0
- package/dist/api/QasFilters.json +111 -0
- package/dist/api/QasFormGenerator.json +92 -0
- package/dist/api/QasFormView.json +228 -0
- package/dist/api/QasGallery.json +54 -0
- package/dist/api/QasGridGenerator.json +108 -0
- package/dist/api/QasInput.json +40 -0
- package/dist/api/QasLabel.json +40 -0
- package/dist/api/QasLayout.json +47 -0
- package/dist/api/QasListItems.json +72 -0
- package/dist/api/QasListView.json +161 -0
- package/dist/api/QasMap.json +41 -0
- package/dist/api/QasNestedFields.json +223 -0
- package/dist/api/QasNumericInput.json +68 -0
- package/dist/api/QasPageHeader.json +36 -0
- package/dist/api/QasPasswordInput.json +121 -0
- package/dist/api/QasPasswordStrengthChecker.json +126 -0
- package/dist/api/QasProfile.json +74 -0
- package/dist/api/QasResizer.json +34 -0
- package/dist/api/QasSearchBox.json +91 -0
- package/dist/api/QasSelect.json +88 -0
- package/dist/api/QasSelectList.json +134 -0
- package/dist/api/QasSignaturePad.json +63 -0
- package/dist/api/QasSignatureUploader.json +41 -0
- package/dist/api/QasSingleView.json +147 -0
- package/dist/api/QasSortable.json +80 -0
- package/dist/api/QasTableGenerator.json +56 -0
- package/dist/api/QasTabsGenerator.json +90 -0
- package/dist/api/QasTextTruncate.json +38 -0
- package/dist/api/QasTransfer.json +70 -0
- package/dist/api/QasUploader.json +143 -0
- package/dist/asteroid.cjs.css +1 -0
- package/dist/asteroid.cjs.js +9307 -0
- package/dist/asteroid.cjs.min.js +6 -0
- package/dist/asteroid.esm.css +1 -0
- package/dist/asteroid.esm.js +9298 -0
- package/dist/asteroid.esm.min.js +6 -0
- package/dist/asteroid.umd.css +1 -0
- package/dist/asteroid.umd.js +9301 -0
- package/dist/asteroid.umd.min.js +6 -0
- package/dist/vetur/asteroid-attributes.json +1178 -0
- package/dist/vetur/asteroid-tags.json +535 -0
- package/package.json +41 -56
- package/src/assets/logo-modular.svg +1 -1
- package/src/asteroid.js +1 -0
- package/src/components/actions/QasActions.vue +45 -0
- package/src/components/actions/QasActions.yml +24 -0
- package/src/components/actions-menu/QasActionsMenu.vue +41 -14
- package/src/components/actions-menu/QasActionsMenu.yml +63 -0
- package/src/components/alert/QasAlert.vue +90 -0
- package/src/components/alert/QasAlert.yml +33 -0
- package/src/components/app-bar/QasAppBar.vue +16 -13
- package/src/components/app-bar/QasAppBar.yml +51 -0
- package/src/components/app-menu/QasAppMenu.vue +10 -12
- package/src/components/app-menu/QasAppMenu.yml +32 -0
- package/src/components/avatar/QasAvatar.vue +17 -9
- package/src/components/avatar/QasAvatar.yml +38 -0
- package/src/components/box/QasBox.vue +12 -4
- package/src/components/box/QasBox.yml +13 -0
- package/src/components/breakline/QasBreakline.vue +37 -0
- package/src/components/breakline/QasBreakline.yml +25 -0
- package/src/components/btn/QasBtn.vue +27 -24
- package/src/components/btn/QasBtn.yml +13 -0
- package/src/components/card/QasCard.vue +32 -33
- package/src/components/card/QasCard.yml +42 -0
- package/src/components/checkbox-group/QasCheckboxGroup.vue +50 -17
- package/src/components/checkbox-group/QasCheckboxGroup.yml +30 -0
- package/src/components/copy/QasCopy.vue +22 -11
- package/src/components/copy/QasCopy.yml +20 -0
- package/src/components/date-time-input/QasDateTimeInput.vue +18 -26
- package/src/components/date-time-input/QasDateTimeInput.yml +54 -0
- package/src/components/debugger/QasDebugger.vue +2 -0
- package/src/components/debugger/QasDebugger.yml +10 -0
- package/src/components/delete/QasDelete.vue +43 -16
- package/src/components/delete/QasDelete.yml +52 -0
- package/src/components/dialog/QasDialog.vue +63 -67
- package/src/components/dialog/QasDialog.yml +86 -0
- package/src/components/dialog-router/QasDialogRouter.vue +14 -4
- package/src/components/dialog-router/QasDialogRouter.yml +23 -0
- package/src/components/field/QasField.vue +21 -24
- package/src/components/field/QasField.yml +31 -0
- package/src/components/filters/QasFilters.vue +33 -26
- package/src/components/filters/QasFilters.yml +91 -0
- package/src/components/form-generator/QasFormGenerator.vue +13 -15
- package/src/components/form-generator/QasFormGenerator.yml +64 -0
- package/src/components/form-view/QasFormView.vue +129 -69
- package/src/components/form-view/QasFormView.yml +179 -0
- package/src/components/gallery/QasGallery.vue +47 -30
- package/src/components/gallery/QasGallery.yml +51 -0
- package/src/components/grid-generator/QasGridGenerator.vue +15 -7
- package/src/components/grid-generator/QasGridGenerator.yml +73 -0
- package/src/components/index.js +0 -0
- package/src/components/input/QasInput.vue +43 -36
- package/src/components/input/QasInput.yml +32 -0
- package/src/components/label/QasLabel.vue +14 -15
- package/src/components/label/QasLabel.yml +28 -0
- package/src/components/layout/QasLayout.vue +13 -21
- package/src/components/layout/QasLayout.yml +38 -0
- package/src/components/list-items/QasListItems.vue +15 -12
- package/src/components/list-items/QasListItems.yml +57 -0
- package/src/components/list-view/QasListView.vue +57 -31
- package/src/components/list-view/QasListView.yml +132 -0
- package/src/components/map/QasMap.vue +15 -31
- package/src/components/map/QasMap.yml +33 -0
- package/src/components/nested-fields/QasNestedFields.vue +57 -47
- package/src/components/nested-fields/QasNestedFields.yml +180 -0
- package/src/components/numeric-input/QasNumericInput.vue +31 -22
- package/src/components/numeric-input/QasNumericInput.yml +51 -0
- package/src/components/page-header/QasPageHeader.vue +20 -11
- package/src/components/page-header/QasPageHeader.yml +24 -0
- package/src/components/password-input/QasPasswordInput.vue +24 -21
- package/src/components/password-input/QasPasswordInput.yml +103 -0
- package/src/components/password-strength-checker/QasPasswordStrengthChecker.vue +51 -34
- package/src/components/password-strength-checker/QasPasswordStrengthChecker.yml +103 -0
- package/src/components/profile/QasProfile.vue +15 -13
- package/src/components/profile/QasProfile.yml +60 -0
- package/src/components/resizer/QasResizer.vue +3 -3
- package/src/components/resizer/QasResizer.yml +23 -0
- package/src/components/search-box/QasSearchBox.vue +50 -21
- package/src/components/search-box/QasSearchBox.yml +76 -0
- package/src/components/select/QasSelect.vue +51 -50
- package/src/components/select/QasSelect.yml +62 -0
- package/src/components/select-list/QasSelectList.vue +72 -53
- package/src/components/select-list/QasSelectList.yml +116 -0
- package/src/components/signature-pad/QasSignaturePad.vue +60 -40
- package/src/components/signature-pad/QasSignaturePad.yml +53 -0
- package/src/components/signature-uploader/QasSignatureUploader.vue +19 -17
- package/src/components/signature-uploader/QasSignatureUploader.yml +36 -0
- package/src/components/single-view/QasSingleView.vue +41 -22
- package/src/components/single-view/QasSingleView.yml +116 -0
- package/src/components/sortable/QasSortable.vue +51 -30
- package/src/components/sortable/QasSortable.yml +65 -0
- package/src/components/table-generator/QasTableGenerator.vue +112 -21
- package/src/components/table-generator/QasTableGenerator.yml +46 -0
- package/src/components/tabs-generator/QasTabsGenerator.vue +37 -25
- package/src/components/tabs-generator/QasTabsGenerator.yml +67 -0
- package/src/components/text-truncate/QasTextTruncate.vue +25 -17
- package/src/components/text-truncate/QasTextTruncate.yml +32 -0
- package/src/components/transfer/QasTransfer.vue +48 -49
- package/src/components/transfer/QasTransfer.yml +59 -0
- package/src/components/uploader/QasUploader.vue +169 -48
- package/src/components/uploader/QasUploader.yml +117 -0
- package/src/css/background.scss +1 -1
- package/src/css/border.scss +7 -6
- package/src/css/design-system.scss +0 -43
- package/src/css/fonts.scss +2 -28
- package/src/css/opacity.scss +0 -4
- package/src/css/set-brand.scss +15 -0
- package/src/css/transitions.scss +1 -1
- package/src/helpers/add-counter-suffix.js +3 -0
- package/src/helpers/{base64ToBlob.js → base-64-to-blob.js} +0 -0
- package/src/helpers/{constructObject.js → construct-object.js} +0 -0
- package/src/helpers/filter-object.js +8 -6
- package/src/helpers/filters.js +8 -4
- package/src/helpers/{greatestCommonDivisor.js → get-greatest-common-divisor.js} +0 -0
- package/src/helpers/get-slot-children-text.js +15 -0
- package/src/helpers/images.js +28 -0
- package/src/helpers/index.js +11 -59
- package/src/helpers/{isLocalDevelopment.js → is-local-development.js} +0 -0
- package/src/helpers/set-scroll-on-grab.js +61 -0
- package/src/index.cjs.js +1 -0
- package/src/index.esm.js +4 -0
- package/src/index.scss +19 -21
- package/src/index.umd.js +2 -0
- package/src/mixins/context.js +1 -1
- package/src/mixins/dialog-router.js +17 -0
- package/src/mixins/form.js +4 -12
- package/src/mixins/generator.js +14 -14
- package/src/mixins/index.js +2 -8
- package/src/mixins/password.js +73 -11
- package/src/mixins/screen.js +8 -6
- package/src/mixins/view.js +62 -22
- package/src/plugins/dialog/Dialog.js +14 -0
- package/src/plugins/dialog/Dialog.yml +10 -0
- package/src/plugins/index.js +4 -2
- package/src/plugins/{NotifyError.js → notify-error/NotifyError.js} +0 -0
- package/src/plugins/notify-error/NotifyError.yml +11 -0
- package/src/plugins/{NotifySuccess.js → notify-success/NotifySuccess.js} +3 -3
- package/src/plugins/notify-success/NotifySuccess.yml +11 -0
- package/src/store/history.js +43 -0
- package/src/store/index.js +1 -0
- package/src/vue-plugin.js +185 -0
- package/.babelrc +0 -12
- package/.storybook/main.js +0 -35
- package/.storybook/preview.js +0 -26
- package/debug.log +0 -1
- package/index.js +0 -4
- package/jest-setup.js +0 -1
- package/jest.config.json +0 -22
- package/postcss.config.js +0 -5
- package/src/components/Introduction.stories.mdx +0 -12
- package/src/components/actions-menu/QasActionsMenu.stories.js +0 -73
- package/src/components/app-bar/QasAppBar.stories.js +0 -84
- package/src/components/app-menu/QasAppMenu.stories.js +0 -66
- package/src/components/apps-menu/QasAppsMenu.spec.js +0 -58
- package/src/components/apps-menu/QasAppsMenu.stories.js +0 -54
- package/src/components/apps-menu/QasAppsMenu.vue +0 -48
- package/src/components/avatar/QasAvatar.spec.js +0 -14
- package/src/components/avatar/QasAvatar.stories.js +0 -52
- package/src/components/box/QasBox.spec.js +0 -18
- package/src/components/box/QasBox.stories.js +0 -35
- package/src/components/break-line/QasBreakLine.stories.js +0 -57
- package/src/components/break-line/QasBreakLine.vue +0 -52
- package/src/components/btn/QasBtn.stories.js +0 -45
- package/src/components/btn-actions/QasBtnActions.stories.js +0 -77
- package/src/components/btn-actions/QasBtnActions.vue +0 -54
- package/src/components/card/QasCard.stories.js +0 -126
- package/src/components/checkbox-group/QasCheckboxGroup.stories.js +0 -59
- package/src/components/copy/QasCopy.stories.js +0 -41
- package/src/components/date-time-input/QasDateTimeInput.stories.js +0 -67
- package/src/components/debugger/QasDebugger.stories.js +0 -33
- package/src/components/delete/QasDelete.stories.js +0 -80
- package/src/components/dialog/QasDialog.stories.js +0 -139
- package/src/components/dialog-router/QasDialogRouter.stories.js +0 -38
- package/src/components/field/QasField.stories.js +0 -181
- package/src/components/filters/QasFilters.stories.js +0 -121
- package/src/components/form-generator/QasFormGenerator.stories.js +0 -115
- package/src/components/form-view/QasFormView.stories.js +0 -236
- package/src/components/gallery/QasGallery.stories.js +0 -91
- package/src/components/grid-generator/QasGridGenerator.stories.js +0 -142
- package/src/components/input/QasInput.stories.js +0 -78
- package/src/components/label/QasLabel.stories.js +0 -60
- package/src/components/layout/QasLayout.stories.js +0 -104
- package/src/components/list-items/QasListItems.stories.js +0 -135
- package/src/components/list-view/QasListView.stories.js +0 -168
- package/src/components/map/QasMap.stories.js +0 -75
- package/src/components/nested-fields/QasNestedFields.stories.js +0 -255
- package/src/components/numeric-input/QasNumericInput.stories.js +0 -92
- package/src/components/page-header/QasPageHeader.stories.js +0 -61
- package/src/components/password-input/QasPasswordInput.stories.js +0 -76
- package/src/components/password-strength-checker/QasPasswordStrengthChecker.stories.js +0 -54
- package/src/components/profile/QasProfile.stories.js +0 -131
- package/src/components/resizer/QasResizer.stories.js +0 -43
- package/src/components/search-box/QasSearchBox.stories.js +0 -111
- package/src/components/select/QasSelect.stories.js +0 -113
- package/src/components/select-list/QasSelectList.stories.js +0 -153
- package/src/components/signature-pad/QasSignaturePad.stories.js +0 -51
- package/src/components/signature-uploader/QasSignatureUploader.stories.js +0 -69
- package/src/components/single-view/QasSingleView.stories.js +0 -130
- package/src/components/sortable/QasSortable.stories.js +0 -80
- package/src/components/table-generator/QasTableGenerator.stories.js +0 -120
- package/src/components/tabs-generator/QasTabsGenerator.stories.js +0 -145
- package/src/components/text-truncate/QasTextTruncate.stories.js +0 -55
- package/src/components/tip/QasTip.stories.js +0 -57
- package/src/components/tip/QasTip.vue +0 -68
- package/src/components/tooltip/QasTooltip.stories.js +0 -63
- package/src/components/tooltip/QasTooltip.vue +0 -81
- package/src/components/transfer/QasTransfer.stories.js +0 -118
- package/src/components/uploader/QasCustomUploader.vue +0 -120
- package/src/components/uploader/QasUploader.stories.js +0 -139
- package/src/directives/Test.js +0 -13
- package/src/helpers/historyHandler.js +0 -52
- package/src/helpers/label.js +0 -3
- package/src/index.js +0 -249
- package/src/mixins/map-markers.js +0 -26
- package/src/mixins/unsaved-changes.js +0 -24
- package/src/mixins/uploader.js +0 -30
- package/src/mocks/json/user.json +0 -27
- package/src/mocks/json/users-new.json +0 -23
- package/src/mocks/json/users.json +0 -97
- package/src/mocks/storeModule.js +0 -71
- package/src/pages/Forbidden.vue +0 -6
- package/src/pages/NotFound.vue +0 -6
|
@@ -1,55 +1,58 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<component :is="
|
|
3
|
-
<header v-if="
|
|
4
|
-
<slot
|
|
2
|
+
<component :is="mx_componentTag">
|
|
3
|
+
<header v-if="mx_hasHeaderSlot">
|
|
4
|
+
<slot name="header" />
|
|
5
5
|
</header>
|
|
6
6
|
|
|
7
7
|
<q-form ref="form" @submit="submit">
|
|
8
|
-
<slot
|
|
8
|
+
<slot />
|
|
9
9
|
|
|
10
|
-
<slot v-if="!readOnly"
|
|
10
|
+
<slot v-if="!readOnly" name="actions">
|
|
11
11
|
<div class="justify-end q-col-gutter-md q-my-lg row">
|
|
12
12
|
<div v-if="hasCancelButton" class="col-12 col-sm-2" :class="cancelButtonClass">
|
|
13
13
|
<qas-btn v-close-popup="dialog" class="full-width" :data-cy="`btnCancel-${entity}`" :disable="isCancelButtonDisabled" :label="cancelButton" outline type="button" @click="cancel" />
|
|
14
14
|
</div>
|
|
15
15
|
<div class="col-12 col-sm-2" :class="saveButtonClass">
|
|
16
|
-
<qas-btn class="full-width" :data-cy="`btnSave-${entity}`" :disable="disable" :label="submitButton" :loading="
|
|
16
|
+
<qas-btn class="full-width" :data-cy="`btnSave-${entity}`" :disable="disable" :label="submitButton" :loading="isSubmitting" type="submit" />
|
|
17
17
|
</div>
|
|
18
18
|
</div>
|
|
19
19
|
</slot>
|
|
20
20
|
</q-form>
|
|
21
21
|
|
|
22
|
-
<footer v-if="
|
|
23
|
-
<slot
|
|
22
|
+
<footer v-if="mx_hasFooterSlot">
|
|
23
|
+
<slot name="footer" />
|
|
24
24
|
</footer>
|
|
25
25
|
|
|
26
|
-
<qas-dialog v-model="showDialog" v-bind="
|
|
26
|
+
<qas-dialog v-model="showDialog" v-bind="defaultDialogProps" />
|
|
27
27
|
|
|
28
|
-
<q-inner-loading :showing="
|
|
28
|
+
<q-inner-loading :showing="mx_isFetching">
|
|
29
29
|
<q-spinner color="grey" size="3em" />
|
|
30
30
|
</q-inner-loading>
|
|
31
31
|
</component>
|
|
32
32
|
</template>
|
|
33
33
|
|
|
34
34
|
<script>
|
|
35
|
-
import {
|
|
35
|
+
import { isEqualWith } from 'lodash-es'
|
|
36
36
|
import { extend } from 'quasar'
|
|
37
|
+
import { onBeforeRouteLeave } from 'vue-router'
|
|
37
38
|
|
|
38
|
-
import {
|
|
39
|
+
import { addRoute, history } from '../../store/history'
|
|
39
40
|
import { NotifyError, NotifySuccess } from '../../plugins'
|
|
40
41
|
|
|
41
|
-
import QasBtn from '../btn/QasBtn'
|
|
42
|
-
import QasDialog from '../dialog/QasDialog'
|
|
42
|
+
import QasBtn from '../btn/QasBtn.vue'
|
|
43
|
+
import QasDialog from '../dialog/QasDialog.vue'
|
|
43
44
|
|
|
44
|
-
import viewMixin from '../../mixins
|
|
45
|
+
import { viewMixin, screenMixin } from '../../mixins'
|
|
45
46
|
|
|
46
47
|
export default {
|
|
48
|
+
name: 'QasFormView',
|
|
49
|
+
|
|
47
50
|
components: {
|
|
48
51
|
QasBtn,
|
|
49
52
|
QasDialog
|
|
50
53
|
},
|
|
51
54
|
|
|
52
|
-
mixins: [viewMixin],
|
|
55
|
+
mixins: [viewMixin, screenMixin],
|
|
53
56
|
|
|
54
57
|
props: {
|
|
55
58
|
cancelButton: {
|
|
@@ -90,46 +93,60 @@ export default {
|
|
|
90
93
|
type: Boolean
|
|
91
94
|
},
|
|
92
95
|
|
|
96
|
+
ignoreKeysInUnsavedChanges: {
|
|
97
|
+
default: () => [],
|
|
98
|
+
type: Array
|
|
99
|
+
},
|
|
100
|
+
|
|
93
101
|
submitButton: {
|
|
94
102
|
default: 'Salvar',
|
|
95
103
|
type: String
|
|
96
104
|
},
|
|
97
105
|
|
|
98
|
-
|
|
106
|
+
modelValue: {
|
|
99
107
|
default: () => ({}),
|
|
100
108
|
type: Object
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
submitting: {
|
|
112
|
+
type: Boolean
|
|
101
113
|
}
|
|
102
114
|
},
|
|
103
115
|
|
|
116
|
+
emits: [
|
|
117
|
+
'submit-success',
|
|
118
|
+
'submit-error',
|
|
119
|
+
'fetch-success',
|
|
120
|
+
'fetch-error',
|
|
121
|
+
'update:modelValue',
|
|
122
|
+
'update:submitting',
|
|
123
|
+
'update:errors'
|
|
124
|
+
],
|
|
125
|
+
|
|
104
126
|
data () {
|
|
105
127
|
return {
|
|
106
128
|
cachedResult: {},
|
|
107
129
|
hasResult: false,
|
|
108
|
-
|
|
130
|
+
isSubmitting: false,
|
|
109
131
|
showDialog: false,
|
|
132
|
+
ignoreRouterGuard: false,
|
|
110
133
|
|
|
111
|
-
|
|
134
|
+
defaultDialogProps: {
|
|
112
135
|
card: {
|
|
113
136
|
title: 'Atenção!',
|
|
114
137
|
description: 'Você está deixando a página e suas alterações serão perdidas. Tem certeza que deseja sair sem salvar?'
|
|
115
138
|
},
|
|
116
139
|
|
|
117
|
-
ok: {
|
|
118
|
-
props: { label: 'Continuar editando' },
|
|
119
|
-
events: null
|
|
120
|
-
},
|
|
140
|
+
ok: { label: 'Continuar editando' },
|
|
121
141
|
|
|
122
|
-
cancel: {
|
|
123
|
-
props: { label: 'Sair' },
|
|
124
|
-
events: null
|
|
125
|
-
}
|
|
142
|
+
cancel: { label: 'Sair' }
|
|
126
143
|
}
|
|
127
144
|
}
|
|
128
145
|
},
|
|
129
146
|
|
|
130
147
|
computed: {
|
|
131
148
|
cancelButtonClass () {
|
|
132
|
-
return this.
|
|
149
|
+
return this.mx_isSmall && 'order-last'
|
|
133
150
|
},
|
|
134
151
|
|
|
135
152
|
fetchURL () {
|
|
@@ -148,10 +165,6 @@ export default {
|
|
|
148
165
|
return this.mode === 'create'
|
|
149
166
|
},
|
|
150
167
|
|
|
151
|
-
isMobile () {
|
|
152
|
-
return this.$q.screen.xs
|
|
153
|
-
},
|
|
154
|
-
|
|
155
168
|
resolvedRoute () {
|
|
156
169
|
if (this.route && Object.keys(this.route).length) {
|
|
157
170
|
return this.route
|
|
@@ -161,40 +174,60 @@ export default {
|
|
|
161
174
|
},
|
|
162
175
|
|
|
163
176
|
saveButtonClass () {
|
|
164
|
-
return this.
|
|
177
|
+
return this.mx_isSmall && 'order-first'
|
|
165
178
|
},
|
|
166
179
|
|
|
167
180
|
isCancelButtonDisabled () {
|
|
168
181
|
return this.disable || this.isSubmitting
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
history () {
|
|
185
|
+
return history.list
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
fieldsNameWithDefaultValue () {
|
|
189
|
+
return Object.keys(this.fields).filter(field => 'default' in this.fields[field])
|
|
169
190
|
}
|
|
170
191
|
},
|
|
171
192
|
|
|
172
193
|
watch: {
|
|
173
|
-
|
|
174
|
-
const models = { ...this.getModelsByFields(fields), ...this.
|
|
175
|
-
this.$emit('input', models)
|
|
194
|
+
mx_fields (fields) {
|
|
195
|
+
const models = { ...this.getModelsByFields(fields), ...this.modelValue }
|
|
176
196
|
|
|
177
197
|
if (!this.hasResult && this.showDialogOnUnsavedChanges) {
|
|
178
|
-
this.cachedResult =
|
|
198
|
+
this.cachedResult = extend(true, {}, models)
|
|
179
199
|
}
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
isSubmitting (value) {
|
|
203
|
+
this.$emit('update:submitting', value)
|
|
180
204
|
}
|
|
181
205
|
},
|
|
182
206
|
|
|
183
207
|
created () {
|
|
208
|
+
onBeforeRouteLeave(this.beforeRouteLeave)
|
|
209
|
+
window.addEventListener('delete-success', this.setIgnoreRouterGuard)
|
|
184
210
|
this.fetch()
|
|
185
211
|
},
|
|
186
212
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
return null
|
|
191
|
-
}
|
|
213
|
+
onUnmounted () {
|
|
214
|
+
window.removeEventListener('delete-success', this.setIgnoreRouterGuard)
|
|
215
|
+
},
|
|
192
216
|
|
|
193
|
-
|
|
217
|
+
methods: {
|
|
218
|
+
beforeRouteLeave (to, from, next) {
|
|
219
|
+
if (
|
|
220
|
+
!this.showDialogOnUnsavedChanges ||
|
|
221
|
+
this.ignoreRouterGuard ||
|
|
222
|
+
isEqualWith(this.modelValue, this.cachedResult, this.handleIgnoreKeysInUnsavedChanges)
|
|
223
|
+
) {
|
|
194
224
|
return next()
|
|
195
225
|
}
|
|
196
226
|
|
|
197
|
-
this.handleDialog(
|
|
227
|
+
this.handleDialog(() => {
|
|
228
|
+
this.ignoreRouterGuard = true
|
|
229
|
+
next()
|
|
230
|
+
})
|
|
198
231
|
},
|
|
199
232
|
|
|
200
233
|
cancel () {
|
|
@@ -204,7 +237,7 @@ export default {
|
|
|
204
237
|
},
|
|
205
238
|
|
|
206
239
|
async fetch (params) {
|
|
207
|
-
this.
|
|
240
|
+
this.mx_isFetching = true
|
|
208
241
|
|
|
209
242
|
try {
|
|
210
243
|
const response = await this.$store.dispatch(
|
|
@@ -213,22 +246,28 @@ export default {
|
|
|
213
246
|
|
|
214
247
|
const { errors, fields, metadata, result } = response.data
|
|
215
248
|
|
|
216
|
-
this.
|
|
217
|
-
this.
|
|
218
|
-
this.
|
|
249
|
+
this.mx_setErrors(errors)
|
|
250
|
+
this.mx_setFields(fields)
|
|
251
|
+
this.mx_setMetadata(metadata)
|
|
252
|
+
|
|
253
|
+
this.mx_updateModels({
|
|
254
|
+
errors: errors,
|
|
255
|
+
fields: this.mx_fields,
|
|
256
|
+
metadata: metadata
|
|
257
|
+
})
|
|
219
258
|
|
|
220
259
|
if (result) {
|
|
221
260
|
this.hasResult = true
|
|
222
|
-
this.$emit('
|
|
261
|
+
this.$emit('update:modelValue', { ...this.modelValue, ...result })
|
|
223
262
|
this.cachedResult = this.showDialogOnUnsavedChanges && extend(true, {}, result)
|
|
224
263
|
}
|
|
225
264
|
|
|
226
|
-
this.$emit('fetch-success', response, this.
|
|
265
|
+
this.$emit('fetch-success', response, this.modelValue)
|
|
227
266
|
} catch (error) {
|
|
228
|
-
this.
|
|
267
|
+
this.mx_fetchError(error)
|
|
229
268
|
this.$emit('fetch-error', error)
|
|
230
269
|
} finally {
|
|
231
|
-
this.
|
|
270
|
+
this.mx_isFetching = false
|
|
232
271
|
}
|
|
233
272
|
},
|
|
234
273
|
|
|
@@ -243,27 +282,44 @@ export default {
|
|
|
243
282
|
},
|
|
244
283
|
|
|
245
284
|
handleCancelRoute () {
|
|
246
|
-
|
|
285
|
+
const acceptTypes = ['string', 'object']
|
|
286
|
+
|
|
287
|
+
if (this.cancelRoute && acceptTypes.includes(typeof this.cancelRoute)) {
|
|
247
288
|
return this.$router.push(this.cancelRoute)
|
|
248
289
|
}
|
|
249
290
|
|
|
250
291
|
const [, path] = this.$route.path.split('/')
|
|
251
|
-
const resolvedPath = this.$router.resolve(`/${path}`)
|
|
292
|
+
const resolvedPath = this.$router.resolve(`/${path}`)
|
|
252
293
|
|
|
253
294
|
this.$router.push(resolvedPath)
|
|
254
295
|
},
|
|
255
296
|
|
|
256
|
-
handleDialog (
|
|
297
|
+
handleDialog (next) {
|
|
257
298
|
this.openDialog()
|
|
258
299
|
|
|
259
|
-
this.
|
|
260
|
-
this.
|
|
300
|
+
this.defaultDialogProps.ok.onClick = () => addRoute(this.$route)
|
|
301
|
+
this.defaultDialogProps.cancel.onClick = next
|
|
261
302
|
},
|
|
262
303
|
|
|
263
304
|
openDialog () {
|
|
264
305
|
this.showDialog = true
|
|
265
306
|
},
|
|
266
307
|
|
|
308
|
+
// ignora chaves na hora de validar quando usuário está saindo da página
|
|
309
|
+
handleIgnoreKeysInUnsavedChanges (firstValue, secondValue) {
|
|
310
|
+
const toIgnore = [
|
|
311
|
+
...this.fieldsNameWithDefaultValue,
|
|
312
|
+
...this.ignoreKeysInUnsavedChanges
|
|
313
|
+
]
|
|
314
|
+
|
|
315
|
+
if (!toIgnore.length) return
|
|
316
|
+
|
|
317
|
+
toIgnore.forEach(key => {
|
|
318
|
+
delete firstValue[key]
|
|
319
|
+
delete secondValue[key]
|
|
320
|
+
})
|
|
321
|
+
},
|
|
322
|
+
|
|
267
323
|
async submit (event) {
|
|
268
324
|
if (event) {
|
|
269
325
|
event.preventDefault()
|
|
@@ -273,36 +329,40 @@ export default {
|
|
|
273
329
|
return null
|
|
274
330
|
}
|
|
275
331
|
|
|
276
|
-
this.
|
|
332
|
+
this.isSubmitting = true
|
|
277
333
|
|
|
278
334
|
try {
|
|
279
335
|
const response = await this.$store.dispatch(
|
|
280
336
|
`${this.entity}/${this.mode}`,
|
|
281
|
-
{ id: this.id, payload: this.
|
|
337
|
+
{ id: this.id, payload: this.modelValue, url: this.url }
|
|
282
338
|
)
|
|
283
339
|
|
|
284
340
|
if (this.showDialogOnUnsavedChanges) {
|
|
285
|
-
this.cachedResult =
|
|
341
|
+
this.cachedResult = extend(true, {}, this.modelValue)
|
|
286
342
|
}
|
|
287
343
|
|
|
288
|
-
this.
|
|
344
|
+
this.mx_setErrors()
|
|
289
345
|
NotifySuccess(response.data.status.text || 'Item salvo com sucesso!')
|
|
290
|
-
this.$emit('submit-success', response, this.
|
|
346
|
+
this.$emit('submit-success', response, this.modelValue)
|
|
291
347
|
} catch (error) {
|
|
292
|
-
const errors =
|
|
293
|
-
const message =
|
|
348
|
+
const errors = error?.response?.data?.errors
|
|
349
|
+
const message = error?.response?.data?.status?.text
|
|
350
|
+
const exceptionResponse = error?.response?.data?.exception
|
|
351
|
+
const exception = errors ? 'Existem erros de validação no formulário.' : exceptionResponse || error.message
|
|
294
352
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
: get(error, 'response.data.exception') || error.message
|
|
353
|
+
this.mx_setErrors(errors)
|
|
354
|
+
this.$emit('update:errors', this.mx_errors)
|
|
298
355
|
|
|
299
|
-
this.setErrors(errors)
|
|
300
356
|
NotifyError(message || 'Ops! Erro ao salvar item.', exception)
|
|
301
357
|
|
|
302
358
|
this.$emit('submit-error', error)
|
|
303
359
|
} finally {
|
|
304
|
-
this.
|
|
360
|
+
this.isSubmitting = false
|
|
305
361
|
}
|
|
362
|
+
},
|
|
363
|
+
|
|
364
|
+
setIgnoreRouterGuard ({ detail: { id, entity } }) {
|
|
365
|
+
this.ignoreRouterGuard = this.id === id && this.entity === entity
|
|
306
366
|
}
|
|
307
367
|
}
|
|
308
368
|
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
type: component
|
|
2
|
+
|
|
3
|
+
meta:
|
|
4
|
+
desc: Componente para C.R.U.D. responsável pela pela criação (Create) e edição (Update).
|
|
5
|
+
|
|
6
|
+
props:
|
|
7
|
+
cancel-button:
|
|
8
|
+
desc: Rótulo do botão "cancelar".
|
|
9
|
+
default: Cancelar
|
|
10
|
+
type: String
|
|
11
|
+
|
|
12
|
+
cancel-route:
|
|
13
|
+
desc: Configuração do botão de "cancelar", caso seja "false", não exibe o botão, caso precise passar uma path direto use como string, e se precisar passar uma configuração como "name" ou "params" passe como objeto.
|
|
14
|
+
default: "''"
|
|
15
|
+
type: [Boolean, Object, String]
|
|
16
|
+
examples: [/users, "false", "{ name: 'UsersForm', params: { id: 'uuid-1' } }"]
|
|
17
|
+
|
|
18
|
+
custom-id:
|
|
19
|
+
desc: Por padrão, o componente vai pegar o "id" que vem como parâmetro na url, caso queira que o id seja diferente da url, use esta prop.
|
|
20
|
+
type: String
|
|
21
|
+
examples: ['my-custom-id']
|
|
22
|
+
|
|
23
|
+
disable:
|
|
24
|
+
desc: Desabilita o submit.
|
|
25
|
+
type: Boolean
|
|
26
|
+
|
|
27
|
+
mode:
|
|
28
|
+
desc: Existem 3 modos no QasFormView, para criação (create) (equivalente a um método POST no http), e edição que são 2 diferentes, replace (equivalente a um método PUT no http) e update (equivalente a um método PATCH no http).
|
|
29
|
+
default: create
|
|
30
|
+
type: String
|
|
31
|
+
examples: [create, replace, update]
|
|
32
|
+
|
|
33
|
+
read-only:
|
|
34
|
+
desc: Controla o slot de actions.
|
|
35
|
+
type: Boolean
|
|
36
|
+
|
|
37
|
+
route:
|
|
38
|
+
desc: Você pode passar uma configuração de rota customizada.
|
|
39
|
+
default: {}
|
|
40
|
+
type: Object
|
|
41
|
+
|
|
42
|
+
show-dialog-on-unsaved-changes:
|
|
43
|
+
desc: Vamos imaginar um cenário onde o usuário entra na nossa tela de editar/criar, faz tudo o que precisa e sem querer clica no menu para ir para outra tela, caso essa prop esteja "true", vai aparece um modal perguntando se ele quer continuar editando ou ir para a tela no qual foi inicialmente redirecionado.
|
|
44
|
+
default: true
|
|
45
|
+
type: Boolean
|
|
46
|
+
|
|
47
|
+
ignore-keys-in-unsaved-changes:
|
|
48
|
+
desc: Vamos imaginar um cenário onde você precisa alterar valores do v-model por qualquer motivo que seja, mas quando o usuário sair da tela, não pode aparecer o modal perguntando se ele quer sair ou continuar editando, por que o usuário de fato não fez nenhuma alteração nos dados, esta prop serve para você dizer quais keys dentro do v-model você quer ignorar.
|
|
49
|
+
default: []
|
|
50
|
+
type: Array
|
|
51
|
+
examples: ["['isActive']"]
|
|
52
|
+
|
|
53
|
+
submit-button:
|
|
54
|
+
desc: Rótulo do botão "salvar".
|
|
55
|
+
default: Salvar
|
|
56
|
+
type: String
|
|
57
|
+
|
|
58
|
+
model-value:
|
|
59
|
+
desc: Model do componente, controla o payload que será enviado para as actions dos modos create, replace e update.
|
|
60
|
+
default: {}
|
|
61
|
+
type: Object
|
|
62
|
+
examples: [v-model="values"]
|
|
63
|
+
model: true
|
|
64
|
+
|
|
65
|
+
submitting:
|
|
66
|
+
desc: Model que que mostra quando o componente está fazendo um submitting ou não.
|
|
67
|
+
type: Boolean
|
|
68
|
+
examples: [v-model:submitting="isSubmitting"]
|
|
69
|
+
model: true
|
|
70
|
+
|
|
71
|
+
entity:
|
|
72
|
+
desc: Entidade da store, por exemplo se tiver que trabalhar com modulo de usuários, teremos o model "users" na store, que vai ser nossa "entity".
|
|
73
|
+
required: true
|
|
74
|
+
type: String
|
|
75
|
+
|
|
76
|
+
dialog:
|
|
77
|
+
desc: Este componente pode ser utilizado dentro de um dialog, neste caso o componente pai não pode ser um "QPage" e sim uma "div", esta prop cuida disto.
|
|
78
|
+
type: Boolean
|
|
79
|
+
|
|
80
|
+
url:
|
|
81
|
+
desc: Envia como parâmetro para a action "fetchSingle" do modulo correspondente a "entity".
|
|
82
|
+
type: String
|
|
83
|
+
|
|
84
|
+
fields:
|
|
85
|
+
desc: Model de fields, utilizado para recuperar os fields fora do template.
|
|
86
|
+
default: {}
|
|
87
|
+
type: Object
|
|
88
|
+
examples: [v-model:fields="fields"]
|
|
89
|
+
model: true
|
|
90
|
+
|
|
91
|
+
errors:
|
|
92
|
+
desc: Model de errors, utilizado para recuperar os errors fora do template.
|
|
93
|
+
default: {}
|
|
94
|
+
type: Object
|
|
95
|
+
examples: [v-model:errors="errors"]
|
|
96
|
+
model: true
|
|
97
|
+
|
|
98
|
+
metadata:
|
|
99
|
+
desc: Model de metadata, utilizado para recuperar os metadata fora do template.
|
|
100
|
+
default: {}
|
|
101
|
+
type: Object
|
|
102
|
+
examples: [v-model:metadata="metadata"]
|
|
103
|
+
model: true
|
|
104
|
+
|
|
105
|
+
fetching:
|
|
106
|
+
desc: Model de fetching, utilizado para saber se o componente está fazendo fetching de dados.
|
|
107
|
+
type: Boolean
|
|
108
|
+
examples: [v-model:fetching="isFetching"]
|
|
109
|
+
model: true
|
|
110
|
+
|
|
111
|
+
slots:
|
|
112
|
+
header:
|
|
113
|
+
desc: Slot para acessar o header.
|
|
114
|
+
|
|
115
|
+
default:
|
|
116
|
+
desc: Slot para ter o conteúdo principal (dentro do main).
|
|
117
|
+
|
|
118
|
+
actions:
|
|
119
|
+
desc: Slot para acessar a seção onde ficam os botões de ações (salvar e cancelar).
|
|
120
|
+
|
|
121
|
+
footer:
|
|
122
|
+
desc: Slot para acessar o footer.
|
|
123
|
+
|
|
124
|
+
events:
|
|
125
|
+
'@update:model-value -> function(value)':
|
|
126
|
+
desc: Dispara toda vez que o model atualiza.
|
|
127
|
+
params:
|
|
128
|
+
value:
|
|
129
|
+
desc: usado para v-model.
|
|
130
|
+
type: Object
|
|
131
|
+
|
|
132
|
+
'@update:submitting -> function(value)':
|
|
133
|
+
desc: Dispara logo antes da action do modo "replace" ou "update" e ao cair no bloco "finally", ou seja, quando começar o submeter e após terminar.
|
|
134
|
+
params:
|
|
135
|
+
value:
|
|
136
|
+
desc: Retorna se está ou não submetendo os dados.
|
|
137
|
+
type: Boolean
|
|
138
|
+
|
|
139
|
+
'@update:fields -> function(value)':
|
|
140
|
+
desc: Dispara quando a action "fetchSingle" é executada com sucesso, é chamado antes do evento "fetch-success".
|
|
141
|
+
params:
|
|
142
|
+
value:
|
|
143
|
+
desc: fields.
|
|
144
|
+
type: Object
|
|
145
|
+
|
|
146
|
+
'@update:errors -> function(value)':
|
|
147
|
+
desc: Dispara quando a action "fetchSingle" é chamada.
|
|
148
|
+
params:
|
|
149
|
+
value:
|
|
150
|
+
desc: Errors durante o fetch.
|
|
151
|
+
type: Object
|
|
152
|
+
|
|
153
|
+
'@update:metadata -> function(value)':
|
|
154
|
+
desc: Dispara quando a action "fetchSingle" acontece com sucesso, é chamado antes do evento "fetch-success".
|
|
155
|
+
params:
|
|
156
|
+
value:
|
|
157
|
+
desc: metadata.
|
|
158
|
+
type: Object
|
|
159
|
+
|
|
160
|
+
'@update:fetching -> function(value)':
|
|
161
|
+
desc: Dispara logo antes da action "fetchSingle" e ao cair no bloco "finally", ou seja, quando começar o fetching e após terminar.
|
|
162
|
+
params:
|
|
163
|
+
value:
|
|
164
|
+
desc: Retorna se está ou não fazendo fetching de dados.
|
|
165
|
+
type: Boolean
|
|
166
|
+
|
|
167
|
+
'@fetch-success -> function(value)':
|
|
168
|
+
desc: Dispara quando a action "fetchSingle" é executada com sucesso.
|
|
169
|
+
params:
|
|
170
|
+
value:
|
|
171
|
+
desc: Retorna todos os dados "cru" respondido pelo fetch.
|
|
172
|
+
type: Object
|
|
173
|
+
|
|
174
|
+
'@fetch-error -> function(value)':
|
|
175
|
+
desc: Dispara quando a action "fetchSingle" cai em uma exceção.
|
|
176
|
+
params:
|
|
177
|
+
value:
|
|
178
|
+
desc: Retorna todos os dados "cru" respondido na exceção do fetch.
|
|
179
|
+
type: Object
|