@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.
Files changed (188) hide show
  1. package/dist/api/QasBox.json +16 -0
  2. package/dist/api/QasBreakline.json +32 -0
  3. package/dist/api/QasBtn.json +15 -0
  4. package/dist/api/QasDebugger.json +13 -0
  5. package/dist/asteroid.cjs.css +1 -0
  6. package/dist/asteroid.cjs.js +9154 -0
  7. package/dist/asteroid.cjs.min.js +6 -0
  8. package/dist/asteroid.esm.css +1 -0
  9. package/dist/asteroid.esm.js +9145 -0
  10. package/dist/asteroid.esm.min.js +6 -0
  11. package/dist/asteroid.umd.css +1 -0
  12. package/dist/asteroid.umd.js +9148 -0
  13. package/dist/asteroid.umd.min.js +6 -0
  14. package/dist/vetur/asteroid-attributes.json +30 -0
  15. package/dist/vetur/asteroid-tags.json +29 -0
  16. package/package.json +42 -56
  17. package/src/assets/logo-modular.svg +1 -0
  18. package/src/asteroid.js +1 -0
  19. package/src/components/actions/QasActions.vue +45 -0
  20. package/src/components/actions-menu/QasActionsMenu.vue +8 -19
  21. package/src/components/alert/QasAlert.vue +90 -0
  22. package/src/components/app-bar/QasAppBar.vue +59 -61
  23. package/src/components/app-menu/QasAppMenu.vue +128 -41
  24. package/src/components/avatar/QasAvatar.vue +7 -3
  25. package/src/components/box/QasBox.vue +12 -4
  26. package/src/components/box/QasBox.yml +13 -0
  27. package/src/components/breakline/QasBreakline.vue +37 -0
  28. package/src/components/breakline/QasBreakline.yml +25 -0
  29. package/src/components/btn/QasBtn.vue +27 -24
  30. package/src/components/btn/QasBtn.yml +12 -0
  31. package/src/components/card/QasCard.vue +29 -21
  32. package/src/components/checkbox-group/QasCheckboxGroup.vue +31 -17
  33. package/src/components/copy/QasCopy.vue +22 -11
  34. package/src/components/date-time-input/QasDateTimeInput.vue +16 -26
  35. package/src/components/debugger/QasDebugger.vue +2 -0
  36. package/src/components/debugger/QasDebugger.yml +10 -0
  37. package/src/components/delete/QasDelete.vue +28 -15
  38. package/src/components/dialog/QasDialog.vue +71 -67
  39. package/src/components/dialog-router/QasDialogRouter.vue +12 -4
  40. package/src/components/field/QasField.vue +22 -25
  41. package/src/components/filters/QasFilters.vue +31 -24
  42. package/src/components/form-generator/QasFormGenerator.vue +13 -15
  43. package/src/components/form-view/QasFormView.vue +117 -66
  44. package/src/components/gallery/QasGallery.vue +39 -26
  45. package/src/components/grid-generator/QasGridGenerator.vue +12 -6
  46. package/src/components/index.js +0 -0
  47. package/src/components/input/QasInput.vue +38 -36
  48. package/src/components/label/QasLabel.vue +14 -15
  49. package/src/components/layout/QasLayout.vue +81 -0
  50. package/src/components/list-items/QasListItems.vue +16 -8
  51. package/src/components/list-view/QasListView.vue +31 -28
  52. package/src/components/map/QasMap.vue +15 -25
  53. package/src/components/nested-fields/QasNestedFields.vue +39 -36
  54. package/src/components/numeric-input/QasNumericInput.vue +125 -0
  55. package/src/components/page-header/QasPageHeader.vue +19 -10
  56. package/src/components/password-input/QasPasswordInput.vue +20 -18
  57. package/src/components/password-strength-checker/QasPasswordStrengthChecker.vue +52 -31
  58. package/src/components/profile/QasProfile.vue +14 -12
  59. package/src/components/resizer/QasResizer.vue +1 -1
  60. package/src/components/search-box/QasSearchBox.vue +36 -20
  61. package/src/components/select/QasSelect.vue +43 -44
  62. package/src/components/select-list/QasSelectList.vue +64 -51
  63. package/src/components/signature-pad/QasSignaturePad.vue +57 -41
  64. package/src/components/signature-uploader/QasSignatureUploader.vue +15 -13
  65. package/src/components/single-view/QasSingleView.vue +31 -17
  66. package/src/components/sortable/QasSortable.vue +45 -27
  67. package/src/components/table-generator/QasTableGenerator.vue +95 -22
  68. package/src/components/tabs-generator/QasTabsGenerator.vue +36 -24
  69. package/src/components/text-truncate/QasTextTruncate.vue +25 -17
  70. package/src/components/transfer/QasTransfer.vue +57 -53
  71. package/src/components/uploader/QasUploader.vue +169 -48
  72. package/src/css/background.scss +1 -1
  73. package/src/css/border.scss +7 -6
  74. package/src/css/design-system.scss +0 -43
  75. package/src/css/fonts.scss +2 -28
  76. package/src/css/opacity.scss +0 -4
  77. package/src/css/set-brand.scss +15 -0
  78. package/src/css/transitions.scss +1 -1
  79. package/src/helpers/add-counter-suffix.js +3 -0
  80. package/src/helpers/{base64ToBlob.js → base-64-to-blob.js} +0 -0
  81. package/src/helpers/{constructObject.js → construct-object.js} +0 -0
  82. package/src/helpers/filter-object.js +8 -6
  83. package/src/helpers/filters.js +3 -4
  84. package/src/helpers/get-slot-children-text.js +15 -0
  85. package/src/helpers/{greatestCommonDivisor.js → greatest-common-divisor.js} +0 -0
  86. package/src/helpers/images.js +28 -0
  87. package/src/helpers/index.js +11 -57
  88. package/src/helpers/is-local-development.js +3 -0
  89. package/src/helpers/scroll-on-grap.js +61 -0
  90. package/src/index.cjs.js +1 -0
  91. package/src/index.esm.js +4 -0
  92. package/src/index.scss +18 -20
  93. package/src/index.umd.js +2 -0
  94. package/src/mixins/context.js +1 -1
  95. package/src/mixins/dialog-router.js +17 -0
  96. package/src/mixins/form.js +4 -12
  97. package/src/mixins/generator.js +14 -14
  98. package/src/mixins/index.js +2 -8
  99. package/src/mixins/password.js +73 -11
  100. package/src/mixins/screen.js +8 -6
  101. package/src/mixins/view.js +57 -20
  102. package/src/plugins/Dialog.js +14 -0
  103. package/src/plugins/NotifySuccess.js +3 -3
  104. package/src/plugins/index.js +4 -2
  105. package/src/store/history.js +43 -0
  106. package/src/store/index.js +1 -0
  107. package/src/vue-plugin.js +185 -0
  108. package/.babelrc +0 -12
  109. package/.storybook/main.js +0 -35
  110. package/.storybook/preview.js +0 -26
  111. package/debug.log +0 -1
  112. package/index.js +0 -4
  113. package/jest-setup.js +0 -1
  114. package/jest.config.json +0 -22
  115. package/postcss.config.js +0 -5
  116. package/src/components/Introduction.stories.mdx +0 -12
  117. package/src/components/actions-menu/QasActionsMenu.stories.js +0 -73
  118. package/src/components/app-bar/QasAppBar.stories.js +0 -88
  119. package/src/components/app-menu/QasAppMenu.stories.js +0 -62
  120. package/src/components/apps-menu/QasAppsMenu.spec.js +0 -58
  121. package/src/components/apps-menu/QasAppsMenu.stories.js +0 -54
  122. package/src/components/apps-menu/QasAppsMenu.vue +0 -48
  123. package/src/components/avatar/QasAvatar.spec.js +0 -14
  124. package/src/components/avatar/QasAvatar.stories.js +0 -52
  125. package/src/components/box/QasBox.spec.js +0 -18
  126. package/src/components/box/QasBox.stories.js +0 -35
  127. package/src/components/break-line/QasBreakLine.stories.js +0 -57
  128. package/src/components/break-line/QasBreakLine.vue +0 -52
  129. package/src/components/btn/QasBtn.stories.js +0 -45
  130. package/src/components/btn-actions/QasBtnActions.stories.js +0 -77
  131. package/src/components/btn-actions/QasBtnActions.vue +0 -54
  132. package/src/components/card/QasCard.stories.js +0 -126
  133. package/src/components/checkbox-group/QasCheckboxGroup.stories.js +0 -59
  134. package/src/components/copy/QasCopy.stories.js +0 -41
  135. package/src/components/date-time-input/QasDateTimeInput.stories.js +0 -67
  136. package/src/components/debugger/QasDebugger.stories.js +0 -33
  137. package/src/components/decimal-input/QasDecimalInput.stories.js +0 -82
  138. package/src/components/decimal-input/QasDecimalInput.vue +0 -92
  139. package/src/components/delete/QasDelete.stories.js +0 -80
  140. package/src/components/dialog/QasDialog.stories.js +0 -139
  141. package/src/components/dialog-router/QasDialogRouter.stories.js +0 -38
  142. package/src/components/field/QasField.stories.js +0 -181
  143. package/src/components/filters/QasFilters.stories.js +0 -121
  144. package/src/components/form-generator/QasFormGenerator.stories.js +0 -115
  145. package/src/components/form-view/QasFormView.stories.js +0 -236
  146. package/src/components/gallery/QasGallery.stories.js +0 -91
  147. package/src/components/grid-generator/QasGridGenerator.stories.js +0 -138
  148. package/src/components/input/QasInput.stories.js +0 -78
  149. package/src/components/label/QasLabel.stories.js +0 -60
  150. package/src/components/list-items/QasListItems.stories.js +0 -130
  151. package/src/components/list-view/QasListView.stories.js +0 -168
  152. package/src/components/map/QasMap.stories.js +0 -75
  153. package/src/components/nested-fields/QasNestedFields.stories.js +0 -255
  154. package/src/components/page-header/QasPageHeader.stories.js +0 -61
  155. package/src/components/password-input/QasPasswordInput.stories.js +0 -76
  156. package/src/components/password-strength-checker/QasPasswordStrengthChecker.stories.js +0 -54
  157. package/src/components/profile/QasProfile.stories.js +0 -131
  158. package/src/components/resizer/QasResizer.stories.js +0 -43
  159. package/src/components/search-box/QasSearchBox.stories.js +0 -111
  160. package/src/components/select/QasSelect.stories.js +0 -113
  161. package/src/components/select-list/QasSelectList.stories.js +0 -153
  162. package/src/components/signature-pad/QasSignaturePad.stories.js +0 -51
  163. package/src/components/signature-uploader/QasSignatureUploader.stories.js +0 -69
  164. package/src/components/single-view/QasSingleView.stories.js +0 -130
  165. package/src/components/sortable/QasSortable.stories.js +0 -80
  166. package/src/components/table-generator/QasTableGenerator.stories.js +0 -116
  167. package/src/components/tabs-generator/QasTabsGenerator.stories.js +0 -145
  168. package/src/components/text-truncate/QasTextTruncate.stories.js +0 -55
  169. package/src/components/tip/QasTip.stories.js +0 -57
  170. package/src/components/tip/QasTip.vue +0 -68
  171. package/src/components/tooltip/QasTooltip.stories.js +0 -63
  172. package/src/components/tooltip/QasTooltip.vue +0 -81
  173. package/src/components/transfer/QasTransfer.stories.js +0 -118
  174. package/src/components/uploader/QasCustomUploader.vue +0 -121
  175. package/src/components/uploader/QasUploader.stories.js +0 -139
  176. package/src/directives/Test.js +0 -13
  177. package/src/helpers/historyHandler.js +0 -52
  178. package/src/helpers/label.js +0 -3
  179. package/src/index.js +0 -245
  180. package/src/mixins/map-markers.js +0 -26
  181. package/src/mixins/unsaved-changes.js +0 -24
  182. package/src/mixins/uploader.js +0 -30
  183. package/src/mocks/json/user.json +0 -27
  184. package/src/mocks/json/users-new.json +0 -23
  185. package/src/mocks/json/users.json +0 -97
  186. package/src/mocks/storeModule.js +0 -71
  187. package/src/pages/Forbidden.vue +0 -6
  188. package/src/pages/NotFound.vue +0 -6
@@ -1,13 +1,13 @@
1
1
  <template>
2
- <component :is="componentTag">
3
- <header v-if="hasHeaderSlot">
4
- <slot :errors="errors" :fields="fields" :metadata="metadata" name="header" />
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="errors" :fields="fields" :metadata="metadata" />
8
+ <slot :errors="mx_errors" :fields="mx_fields" :metadata="mx_metadata" />
9
9
 
10
- <slot v-if="!readOnly" :errors="errors" :fields="fields" :metadata="metadata" name="actions">
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="hasFooterSlot">
23
- <slot :errors="errors" :fields="fields" :metadata="metadata" name="footer" />
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="dialogConfig" />
26
+ <qas-dialog v-model="showDialog" v-bind="defaultDialogProps" />
27
27
 
28
- <q-inner-loading :showing="isFetching">
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 { get, isEqual, cloneDeep } from 'lodash'
35
+ import { isEqualWith } from 'lodash-es'
36
36
  import { extend } from 'quasar'
37
+ import { onBeforeRouteLeave } from 'vue-router'
37
38
 
38
- import { handleHistory } from '../../helpers/historyHandler'
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/view'
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
- value: {
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
- dialogConfig: {
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.isMobile && 'order-last'
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.isMobile && 'order-first'
177
+ return this.mx_isSmall && 'order-first'
165
178
  },
166
179
 
167
180
  isCancelButtonDisabled () {
168
- return this.disable || this.isSubmitting
181
+ return this.disable || this.isSubmiting
182
+ },
183
+
184
+ history () {
185
+ return history.list
169
186
  }
170
187
  },
171
188
 
172
189
  watch: {
173
- fields (fields) {
174
- const models = { ...this.getModelsByFields(fields), ...this.value }
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 = cloneDeep(models)
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
- methods: {
188
- beforeRouteLeave (to, from, next, fromDelete) {
189
- if (!this.showDialogOnUnsavedChanges) {
190
- return null
191
- }
209
+ onUnmounted () {
210
+ window.removeEventListener('delete-success', this.setIgnoreRouterGuard)
211
+ },
192
212
 
193
- if (fromDelete || isEqual(this.value, this.cachedResult)) {
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(next)
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.isFetching = true
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.setErrors(errors)
217
- this.setFields(fields)
218
- this.setMetadata(metadata)
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('input', { ...this.value, ...result })
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.value)
261
+ this.$emit('fetch-success', response, this.modelValue)
227
262
  } catch (error) {
228
- this.fetchError(error)
263
+ this.mx_fetchError(error)
229
264
  this.$emit('fetch-error', error)
230
265
  } finally {
231
- this.isFetching = false
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
- if (this.cancelRoute) {
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}`).route.path
288
+ const resolvedPath = this.$router.resolve(`/${path}`)
252
289
 
253
290
  this.$router.push(resolvedPath)
254
291
  },
255
292
 
256
- handleDialog (fn) {
293
+ handleDialog (next) {
257
294
  this.openDialog()
258
295
 
259
- this.dialogConfig.ok.events = { click: () => handleHistory().push(this.$route) }
260
- this.dialogConfig.cancel.events = { click: fn }
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.value, url: this.url }
328
+ { id: this.id, payload: this.modelValue, url: this.url }
282
329
  )
283
330
 
284
331
  if (this.showDialogOnUnsavedChanges) {
285
- this.cachedResult = cloneDeep(this.value)
332
+ this.cachedResult = extend(true, {}, this.modelValue)
286
333
  }
287
334
 
288
- this.setErrors()
335
+ this.mx_setErrors()
289
336
  NotifySuccess(response.data.status.text || 'Item salvo com sucesso!')
290
- this.$emit('submit-success', response, this.value)
337
+ this.$emit('submit-success', response, this.modelValue)
291
338
  } catch (error) {
292
- const errors = get(error, 'response.data.errors')
293
- const message = get(error, 'response.data.status.text')
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
- const exception = errors
296
- ? 'Existem erros de validação no formulário.'
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="col-12 gallery">
3
+ <qas-box class="gallery">
3
4
  <div class="q-col-gutter-md row">
4
- <div v-for="(item, index) in initialitems()" :key="index" :class="galleryColumnsClasses">
5
- <q-img class="cursor-pointer rounded-borders" :height="itemHeight" :src="item" @click="toggleCarouselDialog(index)" @error="onError(item)" />
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="itemIndex" animated :arrows="!$_isSmall" control-text-color="primary" :fullscreen="$_isSmall" :height="carouselitemHeight" :next-icon="carouselNextIcon" :prev-icon="carouselPreviousIcon" swipeable :thumbnails="showThumbnails">
20
- <q-carousel-slide v-for="(item, index) in items" :key="index" class="bg-no-repeat bg-size-contain" :img-src="item" :name="index">
21
- <div v-if="$_isSmall" class="full-width justify-end row">
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
- items: {
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
- itemIndex: [],
79
- displayeditems: this.initialLength
81
+ clonedImages: [],
82
+ imageIndex: [],
83
+ displayedImages: this.initialLength
80
84
  }
81
85
  },
82
86
 
83
87
  computed: {
84
- itemHeight () {
85
- if (this.isSingleItem) {
88
+ imageHeight () {
89
+ if (this.isSingleImage) {
86
90
  return this.height || 'auto'
87
91
  }
88
92
 
89
- return this.$_isSmall ? '90px' : '120px'
93
+ return this.mx_isSmall ? '90px' : '120px'
90
94
  },
91
95
 
92
96
  galleryColumnsClasses () {
93
- if (this.isSingleItem) return 'col-12'
97
+ if (this.isSingleImage) return 'col-12'
94
98
 
95
- return this.$_isSmall ? 'col-6' : 'col-2'
99
+ return this.mx_isSmall ? 'col-6' : 'col-2'
96
100
  },
97
101
 
98
102
  hideShowMore () {
99
- return this.items.length <= this.displayeditems
103
+ return this.clonedImages.length <= this.displayedImages
100
104
  },
101
105
 
102
- carouselitemHeight () {
106
+ carouselImageHeight () {
103
107
  return 'calc((500/976) * 100vh)'
104
108
  },
105
109
 
106
110
  showThumbnails () {
107
- return !this.isSingleItem
111
+ return !this.isSingleImage
108
112
  },
109
113
 
110
- isSingleItem () {
111
- return this.items.length === 1
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 (item) {
117
- this.itemIndex = item
129
+ toggleCarouselDialog (image) {
130
+ this.imageIndex = image
118
131
  this.carouselDialog = !this.carouselDialog
119
132
  },
120
133
 
121
134
  showMore () {
122
- this.displayeditems += this.loadLength
135
+ this.displayedImages += this.loadLength
123
136
  },
124
137
 
125
138
  onError (error) {
126
- const index = this.items.findIndex(item => item === error)
139
+ const index = this.clonedImages.findIndex(image => image === error)
127
140
 
128
141
  if (~index) {
129
- this.$delete(this.items, index)
142
+ this.clonedImages.splice(index, 1)
130
143
  this.$forceUpdate()
131
144
  }
132
145
  },
133
146
 
134
- initialitems () {
135
- return this.items.slice(0, this.displayeditems)
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="classes">
3
- <div v-for="(field, key) in formattedFields" :key="key" :class="getFieldClass(key, true)">
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/generator'
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="mask" v-model="model" v-bind="$attrs" bottom-slots :mask="mask" unmasked-value v-on="listeners">
4
- <slot v-for="(slot, key) in $slots" :slot="key" :name="key" />
5
- <template v-for="(slot, key) in $scopedSlots" :slot="key" slot-scope="scope">
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
- value: {
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
- computed: {
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
- listeners () {
35
- const { input, ...listeners } = this.$listeners
36
- return listeners
31
+ computed: {
32
+ hasError () {
33
+ return this.inputReference.hasError
37
34
  },
38
35
 
39
36
  inputReference () {
40
- return this.$refs.mask
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 Object.prototype.hasOwnProperty.call(this.masks, mask)
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.$refs.mask.$refs.input
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
  }