@bildvitta/quasar-ui-asteroid 2.12.4 → 3.0.0-alpha.1
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/QasBox.json +16 -0
- package/dist/api/QasBreakline.json +32 -0
- package/dist/api/QasBtn.json +15 -0
- package/dist/api/QasDebugger.json +13 -0
- package/dist/asteroid.cjs.css +1 -0
- package/dist/asteroid.cjs.js +9154 -0
- package/dist/asteroid.cjs.min.js +6 -0
- package/dist/asteroid.esm.css +1 -0
- package/dist/asteroid.esm.js +9145 -0
- package/dist/asteroid.esm.min.js +6 -0
- package/dist/asteroid.umd.css +1 -0
- package/dist/asteroid.umd.js +9148 -0
- package/dist/asteroid.umd.min.js +6 -0
- package/dist/vetur/asteroid-attributes.json +30 -0
- package/dist/vetur/asteroid-tags.json +29 -0
- package/package.json +42 -56
- package/src/assets/logo-modular.svg +1 -0
- package/src/asteroid.js +1 -0
- package/src/components/actions/QasActions.vue +45 -0
- package/src/components/actions-menu/QasActionsMenu.vue +8 -19
- package/src/components/alert/QasAlert.vue +90 -0
- package/src/components/app-bar/QasAppBar.vue +59 -61
- package/src/components/app-menu/QasAppMenu.vue +128 -41
- package/src/components/avatar/QasAvatar.vue +7 -3
- 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 +12 -0
- package/src/components/card/QasCard.vue +29 -21
- package/src/components/checkbox-group/QasCheckboxGroup.vue +31 -17
- package/src/components/copy/QasCopy.vue +22 -11
- package/src/components/date-time-input/QasDateTimeInput.vue +16 -26
- package/src/components/debugger/QasDebugger.vue +2 -0
- package/src/components/debugger/QasDebugger.yml +10 -0
- package/src/components/delete/QasDelete.vue +28 -15
- package/src/components/dialog/QasDialog.vue +71 -67
- package/src/components/dialog-router/QasDialogRouter.vue +12 -4
- package/src/components/field/QasField.vue +22 -25
- package/src/components/filters/QasFilters.vue +31 -24
- package/src/components/form-generator/QasFormGenerator.vue +13 -15
- package/src/components/form-view/QasFormView.vue +117 -66
- package/src/components/gallery/QasGallery.vue +39 -26
- package/src/components/grid-generator/QasGridGenerator.vue +12 -6
- package/src/components/index.js +0 -0
- package/src/components/input/QasInput.vue +38 -36
- package/src/components/label/QasLabel.vue +14 -15
- package/src/components/layout/QasLayout.vue +81 -0
- package/src/components/list-items/QasListItems.vue +16 -8
- package/src/components/list-view/QasListView.vue +31 -28
- package/src/components/map/QasMap.vue +15 -25
- package/src/components/nested-fields/QasNestedFields.vue +39 -36
- package/src/components/numeric-input/QasNumericInput.vue +125 -0
- package/src/components/page-header/QasPageHeader.vue +19 -10
- package/src/components/password-input/QasPasswordInput.vue +20 -18
- package/src/components/password-strength-checker/QasPasswordStrengthChecker.vue +52 -31
- package/src/components/profile/QasProfile.vue +14 -12
- package/src/components/resizer/QasResizer.vue +1 -1
- package/src/components/search-box/QasSearchBox.vue +36 -20
- package/src/components/select/QasSelect.vue +43 -44
- package/src/components/select-list/QasSelectList.vue +64 -51
- package/src/components/signature-pad/QasSignaturePad.vue +57 -41
- package/src/components/signature-uploader/QasSignatureUploader.vue +15 -13
- package/src/components/single-view/QasSingleView.vue +31 -17
- package/src/components/sortable/QasSortable.vue +45 -27
- package/src/components/table-generator/QasTableGenerator.vue +95 -22
- package/src/components/tabs-generator/QasTabsGenerator.vue +36 -24
- package/src/components/text-truncate/QasTextTruncate.vue +25 -17
- package/src/components/transfer/QasTransfer.vue +57 -53
- package/src/components/uploader/QasUploader.vue +169 -48
- 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 +3 -4
- package/src/helpers/get-slot-children-text.js +15 -0
- package/src/helpers/{greatestCommonDivisor.js → greatest-common-divisor.js} +0 -0
- package/src/helpers/images.js +28 -0
- package/src/helpers/index.js +11 -57
- package/src/helpers/is-local-development.js +3 -0
- package/src/helpers/scroll-on-grap.js +61 -0
- package/src/index.cjs.js +1 -0
- package/src/index.esm.js +4 -0
- package/src/index.scss +18 -20
- 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 +57 -20
- package/src/plugins/Dialog.js +14 -0
- package/src/plugins/NotifySuccess.js +3 -3
- package/src/plugins/index.js +4 -2
- 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 -88
- package/src/components/app-menu/QasAppMenu.stories.js +0 -62
- 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/decimal-input/QasDecimalInput.stories.js +0 -82
- package/src/components/decimal-input/QasDecimalInput.vue +0 -92
- 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 -138
- package/src/components/input/QasInput.stories.js +0 -78
- package/src/components/label/QasLabel.stories.js +0 -60
- package/src/components/list-items/QasListItems.stories.js +0 -130
- 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/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 -116
- 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 -121
- 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 -245
- 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,13 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<component :is="
|
|
3
|
-
<header v-if="
|
|
4
|
-
<slot :errors="
|
|
2
|
+
<component :is="mx_componentTag">
|
|
3
|
+
<header v-if="mx_hasHeaderSlot">
|
|
4
|
+
<slot :errors="mx_errors" :fields="mx_fields" :metadata="mx_metadata" name="header" />
|
|
5
5
|
</header>
|
|
6
6
|
|
|
7
7
|
<q-form ref="form" @submit="submit">
|
|
8
|
-
<slot :errors="
|
|
8
|
+
<slot :errors="mx_errors" :fields="mx_fields" :metadata="mx_metadata" />
|
|
9
9
|
|
|
10
|
-
<slot v-if="!readOnly" :errors="
|
|
10
|
+
<slot v-if="!readOnly" :errors="mx_errors" :fields="mx_fields" :metadata="mx_metadata" 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" />
|
|
@@ -19,37 +19,40 @@
|
|
|
19
19
|
</slot>
|
|
20
20
|
</q-form>
|
|
21
21
|
|
|
22
|
-
<footer v-if="
|
|
23
|
-
<slot :errors="
|
|
22
|
+
<footer v-if="mx_hasFooterSlot">
|
|
23
|
+
<slot :errors="mx_errors" :fields="mx_fields" :metadata="mx_metadata" 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
|
+
submiting: {
|
|
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:submiting',
|
|
123
|
+
'update:errors'
|
|
124
|
+
],
|
|
125
|
+
|
|
104
126
|
data () {
|
|
105
127
|
return {
|
|
106
128
|
cachedResult: {},
|
|
107
129
|
hasResult: false,
|
|
108
130
|
isSubmiting: 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: { props: { label: 'Continuar editando' } },
|
|
121
141
|
|
|
122
|
-
cancel: {
|
|
123
|
-
props: { label: 'Sair' },
|
|
124
|
-
events: null
|
|
125
|
-
}
|
|
142
|
+
cancel: { props: { 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,56 @@ 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
|
-
return this.disable || this.
|
|
181
|
+
return this.disable || this.isSubmiting
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
history () {
|
|
185
|
+
return history.list
|
|
169
186
|
}
|
|
170
187
|
},
|
|
171
188
|
|
|
172
189
|
watch: {
|
|
173
|
-
|
|
174
|
-
const models = { ...this.getModelsByFields(fields), ...this.
|
|
175
|
-
this.$emit('input', models)
|
|
190
|
+
mx_fields (fields) {
|
|
191
|
+
const models = { ...this.getModelsByFields(fields), ...this.modelValue }
|
|
176
192
|
|
|
177
193
|
if (!this.hasResult && this.showDialogOnUnsavedChanges) {
|
|
178
|
-
this.cachedResult =
|
|
194
|
+
this.cachedResult = extend(true, {}, models)
|
|
179
195
|
}
|
|
196
|
+
},
|
|
197
|
+
|
|
198
|
+
isSubmiting (value) {
|
|
199
|
+
this.$emit('update:submiting', value)
|
|
180
200
|
}
|
|
181
201
|
},
|
|
182
202
|
|
|
183
203
|
created () {
|
|
204
|
+
onBeforeRouteLeave(this.beforeRouteLeave)
|
|
205
|
+
window.addEventListener('delete-success', this.setIgnoreRouterGuard)
|
|
184
206
|
this.fetch()
|
|
185
207
|
},
|
|
186
208
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
return null
|
|
191
|
-
}
|
|
209
|
+
onUnmounted () {
|
|
210
|
+
window.removeEventListener('delete-success', this.setIgnoreRouterGuard)
|
|
211
|
+
},
|
|
192
212
|
|
|
193
|
-
|
|
213
|
+
methods: {
|
|
214
|
+
beforeRouteLeave (to, from, next) {
|
|
215
|
+
if (
|
|
216
|
+
!this.showDialogOnUnsavedChanges ||
|
|
217
|
+
this.ignoreRouterGuard ||
|
|
218
|
+
isEqualWith(this.modelValue, this.cachedResult, this.handleIgnoreKeysInUnsavedChanges)
|
|
219
|
+
) {
|
|
194
220
|
return next()
|
|
195
221
|
}
|
|
196
222
|
|
|
197
|
-
this.handleDialog(
|
|
223
|
+
this.handleDialog(() => {
|
|
224
|
+
this.ignoreRouterGuard = true
|
|
225
|
+
next()
|
|
226
|
+
})
|
|
198
227
|
},
|
|
199
228
|
|
|
200
229
|
cancel () {
|
|
@@ -204,7 +233,7 @@ export default {
|
|
|
204
233
|
},
|
|
205
234
|
|
|
206
235
|
async fetch (params) {
|
|
207
|
-
this.
|
|
236
|
+
this.mx_isFetching = true
|
|
208
237
|
|
|
209
238
|
try {
|
|
210
239
|
const response = await this.$store.dispatch(
|
|
@@ -213,22 +242,28 @@ export default {
|
|
|
213
242
|
|
|
214
243
|
const { errors, fields, metadata, result } = response.data
|
|
215
244
|
|
|
216
|
-
this.
|
|
217
|
-
this.
|
|
218
|
-
this.
|
|
245
|
+
this.mx_setErrors(errors)
|
|
246
|
+
this.mx_setFields(fields)
|
|
247
|
+
this.mx_setMetadata(metadata)
|
|
248
|
+
|
|
249
|
+
this.mx_updateModels({
|
|
250
|
+
errors: errors,
|
|
251
|
+
fields: this.mx_fields,
|
|
252
|
+
metadata: metadata
|
|
253
|
+
})
|
|
219
254
|
|
|
220
255
|
if (result) {
|
|
221
256
|
this.hasResult = true
|
|
222
|
-
this.$emit('
|
|
257
|
+
this.$emit('update:modelValue', { ...this.modelValue, ...result })
|
|
223
258
|
this.cachedResult = this.showDialogOnUnsavedChanges && extend(true, {}, result)
|
|
224
259
|
}
|
|
225
260
|
|
|
226
|
-
this.$emit('fetch-success', response, this.
|
|
261
|
+
this.$emit('fetch-success', response, this.modelValue)
|
|
227
262
|
} catch (error) {
|
|
228
|
-
this.
|
|
263
|
+
this.mx_fetchError(error)
|
|
229
264
|
this.$emit('fetch-error', error)
|
|
230
265
|
} finally {
|
|
231
|
-
this.
|
|
266
|
+
this.mx_isFetching = false
|
|
232
267
|
}
|
|
233
268
|
},
|
|
234
269
|
|
|
@@ -243,27 +278,39 @@ export default {
|
|
|
243
278
|
},
|
|
244
279
|
|
|
245
280
|
handleCancelRoute () {
|
|
246
|
-
|
|
281
|
+
const acceptTypes = ['string', 'object']
|
|
282
|
+
|
|
283
|
+
if (this.cancelRoute && acceptTypes.includes(typeof this.cancelRoute)) {
|
|
247
284
|
return this.$router.push(this.cancelRoute)
|
|
248
285
|
}
|
|
249
286
|
|
|
250
287
|
const [, path] = this.$route.path.split('/')
|
|
251
|
-
const resolvedPath = this.$router.resolve(`/${path}`)
|
|
288
|
+
const resolvedPath = this.$router.resolve(`/${path}`)
|
|
252
289
|
|
|
253
290
|
this.$router.push(resolvedPath)
|
|
254
291
|
},
|
|
255
292
|
|
|
256
|
-
handleDialog (
|
|
293
|
+
handleDialog (next) {
|
|
257
294
|
this.openDialog()
|
|
258
295
|
|
|
259
|
-
this.
|
|
260
|
-
this.
|
|
296
|
+
this.defaultDialogProps.ok.props.onClick = () => addRoute(this.$route)
|
|
297
|
+
this.defaultDialogProps.cancel.props.onClick = next
|
|
261
298
|
},
|
|
262
299
|
|
|
263
300
|
openDialog () {
|
|
264
301
|
this.showDialog = true
|
|
265
302
|
},
|
|
266
303
|
|
|
304
|
+
// ignora chaves na hora de validar quando usuário está saindo da página
|
|
305
|
+
handleIgnoreKeysInUnsavedChanges (firstValue, secondValue) {
|
|
306
|
+
if (!this.ignoreKeysInUnsavedChanges.length) return
|
|
307
|
+
|
|
308
|
+
this.ignoreKeysInUnsavedChanges.forEach(key => {
|
|
309
|
+
delete firstValue[key]
|
|
310
|
+
delete secondValue[key]
|
|
311
|
+
})
|
|
312
|
+
},
|
|
313
|
+
|
|
267
314
|
async submit (event) {
|
|
268
315
|
if (event) {
|
|
269
316
|
event.preventDefault()
|
|
@@ -278,31 +325,35 @@ export default {
|
|
|
278
325
|
try {
|
|
279
326
|
const response = await this.$store.dispatch(
|
|
280
327
|
`${this.entity}/${this.mode}`,
|
|
281
|
-
{ id: this.id, payload: this.
|
|
328
|
+
{ id: this.id, payload: this.modelValue, url: this.url }
|
|
282
329
|
)
|
|
283
330
|
|
|
284
331
|
if (this.showDialogOnUnsavedChanges) {
|
|
285
|
-
this.cachedResult =
|
|
332
|
+
this.cachedResult = extend(true, {}, this.modelValue)
|
|
286
333
|
}
|
|
287
334
|
|
|
288
|
-
this.
|
|
335
|
+
this.mx_setErrors()
|
|
289
336
|
NotifySuccess(response.data.status.text || 'Item salvo com sucesso!')
|
|
290
|
-
this.$emit('submit-success', response, this.
|
|
337
|
+
this.$emit('submit-success', response, this.modelValue)
|
|
291
338
|
} catch (error) {
|
|
292
|
-
const errors =
|
|
293
|
-
const message =
|
|
339
|
+
const errors = error?.response?.data?.errors
|
|
340
|
+
const message = error?.response?.data?.status?.text
|
|
341
|
+
const exceptionResponse = error?.response?.data?.exception
|
|
342
|
+
const exception = errors ? 'Existem erros de validação no formulário.' : exceptionResponse || error.message
|
|
294
343
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
: get(error, 'response.data.exception') || error.message
|
|
344
|
+
this.mx_setErrors(errors)
|
|
345
|
+
this.$emit('update:errors', this.mx_errors)
|
|
298
346
|
|
|
299
|
-
this.setErrors(errors)
|
|
300
347
|
NotifyError(message || 'Ops! Erro ao salvar item.', exception)
|
|
301
348
|
|
|
302
349
|
this.$emit('submit-error', error)
|
|
303
350
|
} finally {
|
|
304
351
|
this.isSubmiting = false
|
|
305
352
|
}
|
|
353
|
+
},
|
|
354
|
+
|
|
355
|
+
setIgnoreRouterGuard ({ detail: { id, entity } }) {
|
|
356
|
+
this.ignoreRouterGuard = this.id === id && this.entity === entity
|
|
306
357
|
}
|
|
307
358
|
}
|
|
308
359
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
|
|
1
2
|
<template>
|
|
2
|
-
<qas-box class="
|
|
3
|
+
<qas-box class="gallery">
|
|
3
4
|
<div class="q-col-gutter-md row">
|
|
4
|
-
<div v-for="(
|
|
5
|
-
<q-img class="cursor-pointer rounded-borders" :height="
|
|
5
|
+
<div v-for="(image, index) in initialImages()" :key="index" :class="galleryColumnsClasses">
|
|
6
|
+
<q-img class="cursor-pointer rounded-borders" :height="imageHeight" :src="image" @click="toggleCarouselDialog(index)" @error="onError(image)" />
|
|
6
7
|
</div>
|
|
7
8
|
<slot name="default">
|
|
8
9
|
<div v-if="!hideShowMore" class="full-width text-center">
|
|
@@ -16,9 +17,9 @@
|
|
|
16
17
|
</div>
|
|
17
18
|
</template>
|
|
18
19
|
<template #description>
|
|
19
|
-
<q-carousel v-model="
|
|
20
|
-
<q-carousel-slide v-for="(
|
|
21
|
-
<div v-if="
|
|
20
|
+
<q-carousel v-model="imageIndex" animated :arrows="!mx_isSmall" control-text-color="primary" :fullscreen="mx_isSmall" :height="carouselImageHeight" :next-icon="carouselNextIcon" :prev-icon="carouselPreviousIcon" swipeable :thumbnails="showThumbnails">
|
|
21
|
+
<q-carousel-slide v-for="(image, index) in clonedImages" :key="index" class="bg-no-repeat bg-size-contain" :img-src="image" :name="index">
|
|
22
|
+
<div v-if="mx_isSmall" class="full-width justify-end row">
|
|
22
23
|
<qas-btn dense flat icon="o_close" @click="toggleCarouselDialog" />
|
|
23
24
|
</div>
|
|
24
25
|
</q-carousel-slide>
|
|
@@ -33,6 +34,8 @@
|
|
|
33
34
|
import screenMixin from '../../mixins/screen'
|
|
34
35
|
|
|
35
36
|
export default {
|
|
37
|
+
name: 'QasGallery',
|
|
38
|
+
|
|
36
39
|
mixins: [screenMixin],
|
|
37
40
|
|
|
38
41
|
props: {
|
|
@@ -56,7 +59,7 @@ export default {
|
|
|
56
59
|
default: 6
|
|
57
60
|
},
|
|
58
61
|
|
|
59
|
-
|
|
62
|
+
images: {
|
|
60
63
|
type: Array,
|
|
61
64
|
default: () => []
|
|
62
65
|
},
|
|
@@ -75,64 +78,74 @@ export default {
|
|
|
75
78
|
data () {
|
|
76
79
|
return {
|
|
77
80
|
carouselDialog: false,
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
clonedImages: [],
|
|
82
|
+
imageIndex: [],
|
|
83
|
+
displayedImages: this.initialLength
|
|
80
84
|
}
|
|
81
85
|
},
|
|
82
86
|
|
|
83
87
|
computed: {
|
|
84
|
-
|
|
85
|
-
if (this.
|
|
88
|
+
imageHeight () {
|
|
89
|
+
if (this.isSingleImage) {
|
|
86
90
|
return this.height || 'auto'
|
|
87
91
|
}
|
|
88
92
|
|
|
89
|
-
return this
|
|
93
|
+
return this.mx_isSmall ? '90px' : '120px'
|
|
90
94
|
},
|
|
91
95
|
|
|
92
96
|
galleryColumnsClasses () {
|
|
93
|
-
if (this.
|
|
97
|
+
if (this.isSingleImage) return 'col-12'
|
|
94
98
|
|
|
95
|
-
return this
|
|
99
|
+
return this.mx_isSmall ? 'col-6' : 'col-2'
|
|
96
100
|
},
|
|
97
101
|
|
|
98
102
|
hideShowMore () {
|
|
99
|
-
return this.
|
|
103
|
+
return this.clonedImages.length <= this.displayedImages
|
|
100
104
|
},
|
|
101
105
|
|
|
102
|
-
|
|
106
|
+
carouselImageHeight () {
|
|
103
107
|
return 'calc((500/976) * 100vh)'
|
|
104
108
|
},
|
|
105
109
|
|
|
106
110
|
showThumbnails () {
|
|
107
|
-
return !this.
|
|
111
|
+
return !this.isSingleImage
|
|
108
112
|
},
|
|
109
113
|
|
|
110
|
-
|
|
111
|
-
return this.
|
|
114
|
+
isSingleImage () {
|
|
115
|
+
return this.clonedImages.length === 1
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
watch: {
|
|
120
|
+
images: {
|
|
121
|
+
handler (value) {
|
|
122
|
+
this.clonedImages = [...value]
|
|
123
|
+
},
|
|
124
|
+
immediate: true
|
|
112
125
|
}
|
|
113
126
|
},
|
|
114
127
|
|
|
115
128
|
methods: {
|
|
116
|
-
toggleCarouselDialog (
|
|
117
|
-
this.
|
|
129
|
+
toggleCarouselDialog (image) {
|
|
130
|
+
this.imageIndex = image
|
|
118
131
|
this.carouselDialog = !this.carouselDialog
|
|
119
132
|
},
|
|
120
133
|
|
|
121
134
|
showMore () {
|
|
122
|
-
this.
|
|
135
|
+
this.displayedImages += this.loadLength
|
|
123
136
|
},
|
|
124
137
|
|
|
125
138
|
onError (error) {
|
|
126
|
-
const index = this.
|
|
139
|
+
const index = this.clonedImages.findIndex(image => image === error)
|
|
127
140
|
|
|
128
141
|
if (~index) {
|
|
129
|
-
this
|
|
142
|
+
this.clonedImages.splice(index, 1)
|
|
130
143
|
this.$forceUpdate()
|
|
131
144
|
}
|
|
132
145
|
},
|
|
133
146
|
|
|
134
|
-
|
|
135
|
-
return this.
|
|
147
|
+
initialImages () {
|
|
148
|
+
return this.clonedImages.slice(0, this.displayedImages)
|
|
136
149
|
}
|
|
137
150
|
}
|
|
138
151
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div :class="
|
|
3
|
-
<div v-for="(field, key) in formattedFields" :key="key" :class="
|
|
2
|
+
<div :class="mx_classes">
|
|
3
|
+
<div v-for="(field, key) in formattedFields" :key="key" :class="mx_getFieldClass(key, true)">
|
|
4
4
|
<slot :field="slotValue[key]" :name="`field-${field.name}`">
|
|
5
5
|
<slot :field="slotValue[key]" name="header">
|
|
6
6
|
<div :class="headerClass">{{ field.label }}</div>
|
|
@@ -15,12 +15,14 @@
|
|
|
15
15
|
</template>
|
|
16
16
|
|
|
17
17
|
<script>
|
|
18
|
-
import generatorMixin from '../../mixins
|
|
18
|
+
import { generatorMixin } from '../../mixins'
|
|
19
19
|
import { humanize } from '../../helpers/filters'
|
|
20
20
|
import { extend } from 'quasar'
|
|
21
|
-
import { isObject } from 'lodash'
|
|
21
|
+
import { isObject } from 'lodash-es'
|
|
22
22
|
|
|
23
23
|
export default {
|
|
24
|
+
name: 'QasGridGenerator',
|
|
25
|
+
|
|
24
26
|
mixins: [generatorMixin],
|
|
25
27
|
|
|
26
28
|
props: {
|
|
@@ -74,14 +76,18 @@ export default {
|
|
|
74
76
|
},
|
|
75
77
|
|
|
76
78
|
resultsByFields () {
|
|
79
|
+
return this.getResultsByFields()
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
methods: {
|
|
84
|
+
getResultsByFields () {
|
|
77
85
|
const formattedResult = {}
|
|
78
86
|
const result = extend(true, {}, this.result)
|
|
79
87
|
|
|
80
88
|
for (const key in result) {
|
|
81
89
|
if (this.formattedFields[key]?.type) {
|
|
82
90
|
formattedResult[key] = humanize(this.formattedFields[key], result[key])
|
|
83
|
-
// TODO: Rever.
|
|
84
|
-
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
|
|
85
91
|
this.slotValue[key] = { ...this.formattedFields[key], formattedResult: formattedResult[key] }
|
|
86
92
|
}
|
|
87
93
|
}
|
|
File without changes
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<q-input ref="
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
<slot :name="key" v-bind="scope" />
|
|
3
|
+
<q-input ref="input" v-model="model" bottom-slots v-bind="$attrs" :mask="mask" :unmasked-value="unmaskedValue">
|
|
4
|
+
<template v-for="(_, name) in $slots" #[name]="context">
|
|
5
|
+
<slot :name="name" v-bind="context || {}" />
|
|
7
6
|
</template>
|
|
8
7
|
</q-input>
|
|
9
8
|
</div>
|
|
@@ -13,43 +12,36 @@
|
|
|
13
12
|
export default {
|
|
14
13
|
name: 'QasInput',
|
|
15
14
|
|
|
15
|
+
inheritAttrs: false,
|
|
16
|
+
|
|
16
17
|
props: {
|
|
17
|
-
|
|
18
|
+
modelValue: {
|
|
18
19
|
default: '',
|
|
19
20
|
type: String
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
unmaskedValue: {
|
|
24
|
+
default: true,
|
|
25
|
+
type: Boolean
|
|
20
26
|
}
|
|
21
27
|
},
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
model: {
|
|
25
|
-
get () {
|
|
26
|
-
return this.value
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
set (value) {
|
|
30
|
-
return this.$emit('input', value)
|
|
31
|
-
}
|
|
32
|
-
},
|
|
29
|
+
emits: ['update:modelValue'],
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return
|
|
31
|
+
computed: {
|
|
32
|
+
hasError () {
|
|
33
|
+
return this.inputReference.hasError
|
|
37
34
|
},
|
|
38
35
|
|
|
39
36
|
inputReference () {
|
|
40
|
-
return this.$refs.
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
hasError () {
|
|
44
|
-
return this.inputReference.hasError
|
|
37
|
+
return this.$refs.input
|
|
45
38
|
},
|
|
46
39
|
|
|
47
40
|
mask () {
|
|
48
41
|
const { mask } = this.$attrs
|
|
42
|
+
const hasDefaultMask = Object.prototype.hasOwnProperty.call(this.masks, mask)
|
|
49
43
|
|
|
50
|
-
return
|
|
51
|
-
? this.masks[mask]()
|
|
52
|
-
: mask
|
|
44
|
+
return hasDefaultMask ? this.masks[mask]() : mask
|
|
53
45
|
},
|
|
54
46
|
|
|
55
47
|
masks () {
|
|
@@ -60,12 +52,22 @@ export default {
|
|
|
60
52
|
phone: () => this.toggleMask('(##) ####-#####', '(##) #####-####'),
|
|
61
53
|
'postal-code': () => '#####-###'
|
|
62
54
|
}
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
model: {
|
|
58
|
+
get () {
|
|
59
|
+
return this.modelValue
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
set (value) {
|
|
63
|
+
return this.$emit('update:modelValue', value)
|
|
64
|
+
}
|
|
63
65
|
}
|
|
64
66
|
},
|
|
65
67
|
|
|
66
68
|
watch: {
|
|
67
69
|
mask () {
|
|
68
|
-
const input = this
|
|
70
|
+
const input = this.inputReference.$el?.querySelector('input')
|
|
69
71
|
|
|
70
72
|
requestAnimationFrame(() => {
|
|
71
73
|
input.selectionStart = input.value ? input.value.length : ''
|
|
@@ -74,21 +76,21 @@ export default {
|
|
|
74
76
|
},
|
|
75
77
|
|
|
76
78
|
methods: {
|
|
77
|
-
toggleMask (first, second) {
|
|
78
|
-
const length = first.split('#').length - 2
|
|
79
|
-
return this.value?.length > length ? second : first
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
validate (value) {
|
|
83
|
-
return this.inputReference.validate(value)
|
|
84
|
-
},
|
|
85
|
-
|
|
86
79
|
focus () {
|
|
87
80
|
return this.inputReference.focus()
|
|
88
81
|
},
|
|
89
82
|
|
|
90
83
|
resetValidation () {
|
|
91
84
|
return this.inputReference.resetValidation()
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
toggleMask (first, second) {
|
|
88
|
+
const length = first.split('#').length - 2
|
|
89
|
+
return this.modelValue?.length > length ? second : first
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
validate (value) {
|
|
93
|
+
return this.inputReference.validate(value)
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
}
|