@bildvitta/quasar-ui-asteroid 3.0.0-beta.7 → 3.0.0

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 (106) hide show
  1. package/dist/api/QasAppBar.json +0 -4
  2. package/dist/api/QasBtn.json +2 -1
  3. package/dist/api/QasCard.json +13 -9
  4. package/dist/api/QasDateTimeInput.json +12 -12
  5. package/dist/api/QasDialog.json +6 -2
  6. package/dist/api/QasFilters.json +4 -4
  7. package/dist/api/QasFormGenerator.json +33 -2
  8. package/dist/api/QasFormView.json +43 -15
  9. package/dist/api/QasGridGenerator.json +5 -4
  10. package/dist/api/QasInput.json +1 -1
  11. package/dist/api/QasListItems.json +18 -17
  12. package/dist/api/QasListView.json +21 -7
  13. package/dist/api/QasNestedFields.json +13 -3
  14. package/dist/api/QasNumericInput.json +10 -10
  15. package/dist/api/QasPasswordInput.json +1 -1
  16. package/dist/api/QasSearchBox.json +85 -3
  17. package/dist/api/QasSelect.json +81 -14
  18. package/dist/api/QasSelectList.json +16 -14
  19. package/dist/api/QasSignaturePad.json +1 -1
  20. package/dist/api/QasSingleView.json +13 -4
  21. package/dist/api/QasTabsGenerator.json +5 -2
  22. package/dist/api/QasUploader.json +5 -0
  23. package/dist/asteroid.cjs.css +1 -1
  24. package/dist/asteroid.cjs.js +1522 -706
  25. package/dist/asteroid.cjs.min.js +2 -2
  26. package/dist/asteroid.esm.css +1 -1
  27. package/dist/asteroid.esm.js +1525 -709
  28. package/dist/asteroid.esm.min.js +2 -2
  29. package/dist/asteroid.umd.css +1 -1
  30. package/dist/asteroid.umd.js +1525 -710
  31. package/dist/asteroid.umd.min.js +2 -2
  32. package/dist/vetur/asteroid-attributes.json +176 -100
  33. package/dist/vetur/asteroid-tags.json +60 -41
  34. package/package.json +1 -1
  35. package/src/components/actions-menu/QasActionsMenu.vue +2 -8
  36. package/src/components/app-bar/QasAppBar.vue +16 -12
  37. package/src/components/app-bar/QasAppBar.yml +0 -4
  38. package/src/components/avatar/QasAvatar.vue +0 -4
  39. package/src/components/btn/QasBtn.vue +5 -8
  40. package/src/components/btn/QasBtn.yml +2 -1
  41. package/src/components/card/QasCard.vue +18 -9
  42. package/src/components/card/QasCard.yml +13 -9
  43. package/src/components/date-time-input/QasDateTimeInput.vue +39 -41
  44. package/src/components/date-time-input/QasDateTimeInput.yml +11 -12
  45. package/src/components/delete/QasDelete.vue +15 -1
  46. package/src/components/dialog/QasDialog.vue +26 -3
  47. package/src/components/dialog/QasDialog.yml +6 -3
  48. package/src/components/dialog-router/QasDialogRouter.vue +1 -1
  49. package/src/components/field/QasField.vue +15 -14
  50. package/src/components/filters/QasFilters.vue +27 -10
  51. package/src/components/filters/QasFilters.yml +4 -4
  52. package/src/components/form-generator/QasFormGenerator.vue +87 -12
  53. package/src/components/form-generator/QasFormGenerator.yml +16 -2
  54. package/src/components/form-view/QasFormView.vue +138 -56
  55. package/src/components/form-view/QasFormView.yml +39 -15
  56. package/src/components/grid-generator/QasGridGenerator.vue +23 -7
  57. package/src/components/grid-generator/QasGridGenerator.yml +5 -4
  58. package/src/components/input/QasInput.vue +37 -21
  59. package/src/components/input/QasInput.yml +1 -1
  60. package/src/components/layout/QasLayout.vue +4 -0
  61. package/src/components/list-items/QasListItems.vue +15 -23
  62. package/src/components/list-items/QasListItems.yml +14 -15
  63. package/src/components/list-view/QasListView.vue +45 -24
  64. package/src/components/list-view/QasListView.yml +19 -7
  65. package/src/components/map/QasMap.vue +5 -5
  66. package/src/components/nested-fields/QasNestedFields.vue +29 -21
  67. package/src/components/nested-fields/QasNestedFields.yml +9 -3
  68. package/src/components/numeric-input/QasNumericInput.vue +14 -14
  69. package/src/components/numeric-input/QasNumericInput.yml +10 -10
  70. package/src/components/page-header/QasPageHeader.vue +14 -11
  71. package/src/components/password-input/QasPasswordInput.vue +17 -16
  72. package/src/components/password-input/QasPasswordInput.yml +1 -1
  73. package/src/components/profile/QasProfile.vue +1 -1
  74. package/src/components/search-box/QasSearchBox.vue +138 -42
  75. package/src/components/search-box/QasSearchBox.yml +69 -2
  76. package/src/components/select/QasSelect.vue +63 -53
  77. package/src/components/select/QasSelect.yml +64 -13
  78. package/src/components/select-list/QasSelectList.vue +11 -27
  79. package/src/components/select-list/QasSelectList.yml +13 -14
  80. package/src/components/signature-pad/QasSignaturePad.yml +1 -1
  81. package/src/components/signature-uploader/QasSignatureUploader.vue +7 -5
  82. package/src/components/single-view/QasSingleView.vue +22 -6
  83. package/src/components/single-view/QasSingleView.yml +11 -4
  84. package/src/components/table-generator/QasTableGenerator.vue +13 -2
  85. package/src/components/tabs-generator/QasTabsGenerator.vue +2 -2
  86. package/src/components/tabs-generator/QasTabsGenerator.yml +2 -2
  87. package/src/components/text-truncate/QasTextTruncate.vue +1 -1
  88. package/src/components/uploader/QasUploader.vue +62 -15
  89. package/src/components/uploader/QasUploader.yml +5 -0
  90. package/src/helpers/camelize-fields-name.js +15 -0
  91. package/src/helpers/filters.js +2 -0
  92. package/src/helpers/get-normalized-options.js +20 -0
  93. package/src/helpers/handle-process.js +13 -0
  94. package/src/helpers/index.js +3 -0
  95. package/src/mixins/generator.js +10 -2
  96. package/src/mixins/index.js +2 -0
  97. package/src/mixins/search-filter.js +227 -0
  98. package/src/mixins/view.js +35 -13
  99. package/src/pages/Forbidden.vue +3 -1
  100. package/src/pages/NotFound.vue +3 -1
  101. package/src/pages/ServerError.vue +3 -1
  102. package/src/pages/Unauthorized.vue +28 -0
  103. package/src/plugins/index.js +4 -2
  104. package/src/plugins/logger/Logger.js +44 -0
  105. package/src/plugins/logger/Logger.yml +9 -0
  106. package/src/vue-plugin.js +6 -3
@@ -4,16 +4,17 @@
4
4
  <slot name="header" />
5
5
  </header>
6
6
 
7
- <q-form ref="form" @submit="submit">
7
+ <q-form ref="form" @submit="submitHandler">
8
8
  <slot />
9
9
 
10
- <slot v-if="!readOnly" name="actions">
10
+ <slot v-if="useActions" 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
- <qas-btn v-close-popup="dialog" class="full-width" :data-cy="`btnCancel-${entity}`" :disable="isCancelButtonDisabled" :label="cancelButton" outline type="button" @click="cancel" />
13
+ <qas-btn v-close-popup class="full-width" :data-cy="`btnCancel-${entity}`" :disable="isCancelButtonDisabled" :label="cancelButtonLabel" outline type="button" @click="cancel" />
14
14
  </div>
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="isSubmitting" type="submit" />
15
+
16
+ <div v-if="useSubmitButton" class="col-12 col-sm-2" :class="submitButtonClass">
17
+ <qas-btn class="full-width" :data-cy="`btnSave-${entity}`" :disable="disable" :label="submitButtonLabel" :loading="isSubmitting" type="submit" />
17
18
  </div>
18
19
  </div>
19
20
  </slot>
@@ -55,7 +56,7 @@ export default {
55
56
  mixins: [viewMixin],
56
57
 
57
58
  props: {
58
- cancelButton: {
59
+ cancelButtonLabel: {
59
60
  default: 'Cancelar',
60
61
  type: String
61
62
  },
@@ -79,16 +80,12 @@ export default {
79
80
  type: String
80
81
  },
81
82
 
82
- readOnly: {
83
- type: Boolean
84
- },
85
-
86
83
  route: {
87
84
  default: () => ({}),
88
85
  type: Object
89
86
  },
90
87
 
91
- showDialogOnUnsavedChanges: {
88
+ useDialogOnUnsavedChanges: {
92
89
  default: true,
93
90
  type: Boolean
94
91
  },
@@ -98,7 +95,7 @@ export default {
98
95
  type: Array
99
96
  },
100
97
 
101
- submitButton: {
98
+ submitButtonLabel: {
102
99
  default: 'Salvar',
103
100
  type: String
104
101
  },
@@ -110,6 +107,26 @@ export default {
110
107
 
111
108
  submitting: {
112
109
  type: Boolean
110
+ },
111
+
112
+ useActions: {
113
+ default: true,
114
+ type: Boolean
115
+ },
116
+
117
+ useCancelButton: {
118
+ default: true,
119
+ type: Boolean
120
+ },
121
+
122
+ useSubmitButton: {
123
+ default: true,
124
+ type: Boolean
125
+ },
126
+
127
+ beforeSubmit: {
128
+ default: null,
129
+ type: Function
113
130
  }
114
131
  },
115
132
 
@@ -126,7 +143,6 @@ export default {
126
143
  data () {
127
144
  return {
128
145
  cachedResult: {},
129
- hasResult: false,
130
146
  isSubmitting: false,
131
147
  showDialog: false,
132
148
  ignoreRouterGuard: false,
@@ -154,7 +170,7 @@ export default {
154
170
  },
155
171
 
156
172
  hasCancelButton () {
157
- return !(typeof this.cancelRoute === 'boolean' && !this.cancelRoute)
173
+ return !(typeof this.cancelRoute === 'boolean' && !this.cancelRoute) && this.useCancelButton
158
174
  },
159
175
 
160
176
  id () {
@@ -173,37 +189,27 @@ export default {
173
189
  return this.$route
174
190
  },
175
191
 
176
- saveButtonClass () {
192
+ submitButtonClass () {
177
193
  return this.$qas.screen.isSmall && 'order-first'
178
194
  },
179
195
 
180
196
  isCancelButtonDisabled () {
181
197
  return this.disable || this.isSubmitting
182
- },
183
-
184
- fieldsNameWithDefaultValue () {
185
- return Object.keys(this.fields).filter(field => 'default' in this.fields[field])
186
198
  }
187
199
  },
188
200
 
189
201
  watch: {
190
- mx_fields (fields) {
191
- const models = { ...this.getModelsByFields(fields), ...this.modelValue }
192
-
193
- if (!this.hasResult && this.showDialogOnUnsavedChanges) {
194
- this.cachedResult = extend(true, {}, models)
195
- }
196
- },
197
-
198
202
  isSubmitting (value) {
199
203
  this.$emit('update:submitting', value)
200
204
  }
201
205
  },
202
206
 
203
207
  created () {
204
- onBeforeRouteLeave(this.beforeRouteLeave)
208
+ this.useDialogOnUnsavedChanges && onBeforeRouteLeave(this.beforeRouteLeave)
209
+
205
210
  window.addEventListener('delete-success', this.setIgnoreRouterGuard)
206
- this.fetch()
211
+
212
+ this.mx_fetchHandler({ form: true, id: this.id, url: this.fetchURL }, this.fetchSingle)
207
213
  },
208
214
 
209
215
  onUnmounted () {
@@ -212,14 +218,32 @@ export default {
212
218
 
213
219
  methods: {
214
220
  beforeRouteLeave (to, from, next) {
221
+ const clonedModelValue = extend(true, {}, this.modelValue)
222
+ const clonedCachedResult = extend(true, {}, this.cachedResult)
223
+
224
+ /**
225
+ * Se a propriedade "useDialogOnUnsavedChanges" for false ou a variável
226
+ * "ignoreRouterGuard" for true, então **não** iremos checar se o usuário
227
+ * alterou algum campo antes de sair da pagina, senão iremos validar pela função isEqualWith
228
+ * e mostrar um dialog antes do usuário sair da página.
229
+ */
215
230
  if (
216
- !this.showDialogOnUnsavedChanges ||
231
+ !this.useDialogOnUnsavedChanges ||
217
232
  this.ignoreRouterGuard ||
218
- isEqualWith(this.modelValue, this.cachedResult, this.handleIgnoreKeysInUnsavedChanges)
233
+ isEqualWith(
234
+ clonedModelValue,
235
+ clonedCachedResult,
236
+ this.handleIgnoreKeysInUnsavedChanges
237
+ )
219
238
  ) {
220
239
  return next()
221
240
  }
222
241
 
242
+ this.$qas.logger.group(
243
+ 'QasFormView - beforeRouteLeave -> dialog chamado, modelValue diferente do cachedResult',
244
+ [{ modelValue: clonedModelValue, cachedResult: clonedCachedResult }]
245
+ )
246
+
223
247
  this.handleDialog(() => {
224
248
  this.ignoreRouterGuard = true
225
249
  next()
@@ -227,41 +251,64 @@ export default {
227
251
  },
228
252
 
229
253
  cancel () {
230
- if (!this.dialog) {
231
- this.handleCancelRoute()
232
- }
254
+ this.handleCancelRoute()
233
255
  },
234
256
 
235
- async fetch (params) {
257
+ async fetchSingle (externalPayload = {}) {
236
258
  this.mx_isFetching = true
237
259
 
238
260
  try {
239
- const response = await this.$store.dispatch(
240
- `${this.entity}/fetchSingle`, { form: true, id: this.id, params, url: this.fetchURL }
261
+ const payload = {
262
+ form: true,
263
+ id: this.id,
264
+ url: this.fetchURL,
265
+ ...externalPayload
266
+ }
267
+
268
+ this.$qas.logger.group(
269
+ `QasFormView - fetchSingle -> payload do parâmetro do ${this.entity}/fetchSingle`, [payload]
241
270
  )
242
271
 
272
+ const response = await this.$store.dispatch(`${this.entity}/fetchSingle`, payload)
273
+
243
274
  const { errors, fields, metadata, result } = response.data
244
275
 
276
+ const modelValue = { ...this.getModelsByFields(fields), ...this.modelValue }
277
+
245
278
  this.mx_setErrors(errors)
246
279
  this.mx_setFields(fields)
247
280
  this.mx_setMetadata(metadata)
248
281
 
249
282
  this.mx_updateModels({
250
- errors: errors,
283
+ errors,
251
284
  fields: this.mx_fields,
252
285
  metadata
253
286
  })
254
287
 
255
- if (result) {
256
- this.hasResult = true
257
- this.$emit('update:modelValue', { ...this.modelValue, ...result })
258
- this.cachedResult = this.showDialogOnUnsavedChanges && extend(true, {}, result)
288
+ result && Object.assign(modelValue, result)
289
+
290
+ this.$qas.logger.group(
291
+ `QasFormView - fetchSingle -> resposta da action ${this.entity}/fetchSingle`, [response]
292
+ )
293
+
294
+ if (this.useDialogOnUnsavedChanges) {
295
+ this.cachedResult = extend(true, {}, result || modelValue)
296
+ this.$qas.logger.group('QasFormView - fetchSingle -> cachedResult', [this.cachedResult])
259
297
  }
260
298
 
299
+ this.$emit('update:modelValue', modelValue)
261
300
  this.$emit('fetch-success', response, this.modelValue)
301
+
302
+ this.$qas.logger.group('QasFormView - fetchSingle -> modelValue', [modelValue])
262
303
  } catch (error) {
263
304
  this.mx_fetchError(error)
264
305
  this.$emit('fetch-error', error)
306
+
307
+ this.$qas.logger.group(
308
+ `QasFormView - fetchSingle -> exceção da action ${this.entity}/fetchSingle`,
309
+ [error],
310
+ { error: true }
311
+ )
265
312
  } finally {
266
313
  this.mx_isFetching = false
267
314
  }
@@ -298,6 +345,7 @@ export default {
298
345
  const { addRoute } = useHistory()
299
346
 
300
347
  this.defaultDialogProps.ok.onClick = () => addRoute(this.$route)
348
+
301
349
  this.defaultDialogProps.cancel.onClick = next
302
350
  },
303
351
 
@@ -307,48 +355,76 @@ export default {
307
355
 
308
356
  // ignora chaves na hora de validar quando usuário está saindo da página
309
357
  handleIgnoreKeysInUnsavedChanges (firstValue, secondValue) {
310
- const toIgnore = [
311
- ...this.fieldsNameWithDefaultValue,
312
- ...this.ignoreKeysInUnsavedChanges
313
- ]
358
+ if (!this.ignoreKeysInUnsavedChanges.length) return
314
359
 
315
- if (!toIgnore.length) return
360
+ this.ignoreKeysInUnsavedChanges.forEach(key => {
361
+ if (!firstValue) return
316
362
 
317
- toIgnore.forEach(key => {
318
363
  delete firstValue[key]
319
364
  delete secondValue[key]
320
365
  })
321
366
  },
322
367
 
323
- async submit (event) {
368
+ /**
369
+ * Se existe a propriedade com callback "beforeSubmit", então o controle de quando e como chamar o método "submit"
370
+ * está sendo controlado fora do QasFormView, se não existir a propriedade "beforeSubmit", então o controle do método
371
+ * submit é feito pelo próprio QasFormView, chamado pelo evento @submit.
372
+ */
373
+ submitHandler (event) {
324
374
  if (event) {
325
375
  event.preventDefault()
326
376
  }
327
377
 
328
- if (this.disable || this.readyOnly) {
329
- return null
378
+ const hasBeforeSubmit = typeof this.beforeSubmit === 'function'
379
+
380
+ if (hasBeforeSubmit) {
381
+ return this.beforeSubmit({
382
+ payload: { id: this.id, payload: this.modelValue, url: this.url },
383
+ resolve: payload => this.submit(payload)
384
+ })
330
385
  }
331
386
 
387
+ this.submit()
388
+ },
389
+
390
+ async submit (externalPayload = {}) {
391
+ if (this.disable) return null
392
+
332
393
  this.isSubmitting = true
333
394
 
334
395
  try {
335
- const response = await this.$store.dispatch(
336
- `${this.entity}/${this.mode}`,
337
- { id: this.id, payload: this.modelValue, url: this.url }
396
+ const payload = {
397
+ id: this.id,
398
+ payload: this.modelValue,
399
+ url: this.url,
400
+ ...externalPayload
401
+ }
402
+
403
+ this.$qas.logger.group(
404
+ `QasFormView - submit -> payload do ${this.entity}/${this.mode}`, [payload]
338
405
  )
339
406
 
340
- if (this.showDialogOnUnsavedChanges) {
407
+ const response = await this.$store.dispatch(`${this.entity}/${this.mode}`, payload)
408
+
409
+ if (this.useDialogOnUnsavedChanges) {
341
410
  this.cachedResult = extend(true, {}, this.modelValue)
342
411
  }
343
412
 
344
413
  this.mx_setErrors()
345
414
  NotifySuccess(response.data.status.text || 'Item salvo com sucesso!')
346
415
  this.$emit('submit-success', response, this.modelValue)
416
+
417
+ this.$qas.logger.group(
418
+ `QasFormView - submit -> resposta da action ${this.entity}/${this.mode}`, [response]
419
+ )
347
420
  } catch (error) {
348
421
  const errors = error?.response?.data?.errors
349
422
  const message = error?.response?.data?.status?.text
350
423
  const exceptionResponse = error?.response?.data?.exception
351
- const exception = errors ? 'Existem erros de validação no formulário.' : exceptionResponse || error.message
424
+
425
+ const exception = errors
426
+ ? 'Existem erros de validação no formulário.'
427
+ : exceptionResponse || error.message
352
428
 
353
429
  this.mx_setErrors(errors)
354
430
  this.$emit('update:errors', this.mx_errors)
@@ -356,6 +432,12 @@ export default {
356
432
  NotifyError(message || 'Ops! Erro ao salvar item.', exception)
357
433
 
358
434
  this.$emit('submit-error', error)
435
+
436
+ this.$qas.logger.group(
437
+ `QasFormView - submit -> exceção da action ${this.entity}/${this.mode}`,
438
+ [error],
439
+ { error: true }
440
+ )
359
441
  } finally {
360
442
  this.isSubmitting = false
361
443
  }
@@ -4,7 +4,19 @@ meta:
4
4
  desc: Componente para C.R.U.D. responsável pela pela criação (Create) e edição (Update).
5
5
 
6
6
  props:
7
- cancel-button:
7
+ before-fetch:
8
+ desc: Callback para controlar como funciona o comportamento do fetch.
9
+ default: null
10
+ type: Function
11
+ examples: ['beforeFetch({ payload, resolve })']
12
+
13
+ before-submit:
14
+ desc: Callback para controlar como funciona o comportamento do submit.
15
+ default: null
16
+ type: Function
17
+ examples: ['beforeSubmit({ payload, resolve })']
18
+
19
+ cancel-button-label:
8
20
  desc: Rótulo do botão "cancelar".
9
21
  default: Cancelar
10
22
  type: String
@@ -25,10 +37,6 @@ props:
25
37
  type: String
26
38
  examples: ['my-custom-id']
27
39
 
28
- dialog:
29
- 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.
30
- type: Boolean
31
-
32
40
  disable:
33
41
  desc: Desabilita o submit.
34
42
  type: Boolean
@@ -84,21 +92,12 @@ props:
84
92
  examples: [v-model="values"]
85
93
  model: true
86
94
 
87
- read-only:
88
- desc: Controla o slot de actions.
89
- type: Boolean
90
-
91
95
  route:
92
96
  desc: Você pode passar uma configuração de rota customizada.
93
97
  default: {}
94
98
  type: Object
95
99
 
96
- show-dialog-on-unsaved-changes:
97
- 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.
98
- default: true
99
- type: Boolean
100
-
101
- submit-button:
100
+ submit-button-label:
102
101
  desc: Rótulo do botão "salvar".
103
102
  default: Salvar
104
103
  type: String
@@ -113,6 +112,31 @@ props:
113
112
  desc: Envia como parâmetro para a action "fetchSingle" do modulo correspondente a "entity".
114
113
  type: String
115
114
 
115
+ use-actions:
116
+ desc: Controla se vai ter ou não o slot de actions.
117
+ default: true
118
+ type: Boolean
119
+
120
+ use-boundary:
121
+ desc: Controla o limite que o FormView terá, quando é "false", a tag pai deixa de ser um "QPage" para ser uma "div" e é removido as classes "container" e "spaced", comumente utilizando quando precisa usar o QasFormView dentro de um dialog.
122
+ default: true
123
+ type: Boolean
124
+
125
+ use-cancel-button:
126
+ desc: Controla se vai ter ou não botão de "cancelar".
127
+ default: true
128
+ type: Boolean
129
+
130
+ use-dialog-on-unsaved-changes:
131
+ 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.
132
+ default: true
133
+ type: Boolean
134
+
135
+ use-submit-button:
136
+ desc: Controla se vai ter ou não botão de submit.
137
+ default: true
138
+ type: Boolean
139
+
116
140
  slots:
117
141
  actions:
118
142
  desc: Slot para acessar a seção onde ficam os botões de ações (salvar e cancelar).
@@ -36,10 +36,6 @@ export default {
36
36
  type: [Array, Object, String]
37
37
  },
38
38
 
39
- hideEmptyResult: {
40
- type: Boolean
41
- },
42
-
43
39
  emptyResultText: {
44
40
  default: '-',
45
41
  type: String
@@ -48,6 +44,11 @@ export default {
48
44
  result: {
49
45
  default: () => ({}),
50
46
  type: Object
47
+ },
48
+
49
+ useEmptyResult: {
50
+ default: true,
51
+ type: Boolean
51
52
  }
52
53
  },
53
54
 
@@ -59,7 +60,12 @@ export default {
59
60
 
60
61
  computed: {
61
62
  formattedFields () {
62
- if (!this.hideEmptyResult) {
63
+ if (this.useEmptyResult) {
64
+ this.$qas.logger.group(
65
+ 'QasGridGenerator - formattedFields -> this.useEmptyResult tem valor "true"',
66
+ [this.fields]
67
+ )
68
+
63
69
  return this.fields
64
70
  }
65
71
 
@@ -77,6 +83,8 @@ export default {
77
83
  }
78
84
  }
79
85
 
86
+ this.$qas.logger.group('QasGridGenerator - formattedFields', [fields])
87
+
80
88
  return fields
81
89
  },
82
90
 
@@ -92,11 +100,19 @@ export default {
92
100
 
93
101
  for (const key in result) {
94
102
  if (this.formattedFields[key]?.type) {
95
- formattedResult[key] = humanize(this.formattedFields[key], result[key]) || this.emptyResultText
96
- this.slotValue[key] = { ...this.formattedFields[key], formattedResult: formattedResult[key] }
103
+ formattedResult[key] = (
104
+ humanize(this.formattedFields[key], result[key]) || this.emptyResultText
105
+ )
106
+
107
+ this.slotValue[key] = {
108
+ ...this.formattedFields[key],
109
+ formattedResult: formattedResult[key]
110
+ }
97
111
  }
98
112
  }
99
113
 
114
+ this.$qas.logger.group('QasGridGenerator - getResultsByFields', [formattedResult])
115
+
100
116
  return formattedResult
101
117
  }
102
118
  }
@@ -37,16 +37,17 @@ props:
37
37
  default: 'text-bold'
38
38
  type: [Array, Object, String]
39
39
 
40
- hide-empty-result:
41
- desc: Se o resultado de algum campo for vazio, ele remove todo o campo.
42
- type: Boolean
43
-
44
40
  result:
45
41
  desc: Resultado contendo todas informações para serem exibidas na tela.
46
42
  default: {}
47
43
  type: Object
48
44
  examples: ["{ 'joah@examples.com' }"]
49
45
 
46
+ use-empty-result:
47
+ desc: Se o resultado de algum campo for vazio e esta propriedade for "false", ele remove todo o campo.
48
+ default: true
49
+ type: Boolean
50
+
50
51
  slots:
51
52
  content:
52
53
  desc: Slot para o conteúdo (content).
@@ -1,11 +1,9 @@
1
1
  <template>
2
- <div>
3
- <q-input ref="input" v-model="model" bottom-slots :error="errorData" v-bind="$attrs" :error-message="errorMessageData" :mask="mask" :outlined="outlined" :unmasked-value="unmaskedValue">
4
- <template v-for="(_, name) in $slots" #[name]="context">
5
- <slot :name="name" v-bind="context || {}" />
6
- </template>
7
- </q-input>
8
- </div>
2
+ <q-input ref="input" v-model="model" bottom-slots :error="errorData" v-bind="$attrs" :error-message="errorMessageData" :mask="mask" :outlined="outlined" :unmasked-value="unmaskedValue" @paste="onPaste">
3
+ <template v-for="(_, name) in $slots" #[name]="context">
4
+ <slot :name="name" v-bind="context || {}" />
5
+ </template>
6
+ </q-input>
9
7
  </template>
10
8
 
11
9
  <script>
@@ -15,32 +13,32 @@ export default {
15
13
  inheritAttrs: false,
16
14
 
17
15
  props: {
16
+ error: {
17
+ type: Boolean
18
+ },
19
+
20
+ errorMessage: {
21
+ type: String,
22
+ default: ''
23
+ },
24
+
18
25
  modelValue: {
19
26
  default: '',
20
27
  type: [String, Number]
21
28
  },
22
29
 
23
- unmaskedValue: {
24
- default: true,
25
- type: Boolean
26
- },
27
-
28
30
  outlined: {
29
31
  default: true,
30
32
  type: Boolean
31
33
  },
32
34
 
33
- removeErrorOnType: {
35
+ unmaskedValue: {
36
+ default: true,
34
37
  type: Boolean
35
38
  },
36
39
 
37
- error: {
40
+ useRemoveErrorOnType: {
38
41
  type: Boolean
39
- },
40
-
41
- errorMessage: {
42
- type: String,
43
- default: ''
44
42
  }
45
43
  },
46
44
 
@@ -85,7 +83,7 @@ export default {
85
83
  },
86
84
 
87
85
  set (value) {
88
- if (this.removeErrorOnType && this.error) {
86
+ if (this.useRemoveErrorOnType && this.error) {
89
87
  this.errorData = false
90
88
  this.errorMessageData = ''
91
89
  }
@@ -97,7 +95,7 @@ export default {
97
95
 
98
96
  watch: {
99
97
  mask () {
100
- const input = this.inputReference.$el?.querySelector('input')
98
+ const input = this.getInput()
101
99
 
102
100
  requestAnimationFrame(() => {
103
101
  input.selectionStart = input.value ? input.value.length : ''
@@ -131,12 +129,30 @@ export default {
131
129
  },
132
130
 
133
131
  toggleMask (first, second) {
132
+ if (!this.modelValue?.length) return
133
+
134
134
  const length = first.split('#').length - 2
135
135
  return this.modelValue?.length > length ? second : first
136
136
  },
137
137
 
138
138
  validate (value) {
139
139
  return this.inputReference.validate(value)
140
+ },
141
+
142
+ onPaste (event) {
143
+ if (!this.mask) return
144
+
145
+ const value = event.clipboardData.getData('text')
146
+ const input = this.getInput()
147
+
148
+ requestAnimationFrame(() => {
149
+ this.$emit('update:modelValue', value)
150
+ input.selectionStart = input.value ? input.value.length : ''
151
+ })
152
+ },
153
+
154
+ getInput () {
155
+ return this.inputReference.$el?.querySelector('input')
140
156
  }
141
157
  }
142
158
  }
@@ -26,7 +26,7 @@ props:
26
26
  default: true
27
27
  type: Boolean
28
28
 
29
- remove-error-on-type:
29
+ use-remove-error-on-type:
30
30
  desc: Limpa os erros do campo caso os mesmos existam toda vez que o model atualiza.
31
31
  type: Boolean
32
32
 
@@ -71,6 +71,10 @@ export default {
71
71
  }
72
72
  },
73
73
 
74
+ mounted () {
75
+ this.menuDrawer = !this.$qas.screen.untilMedium
76
+ },
77
+
74
78
  methods: {
75
79
  toggleMenuDrawer () {
76
80
  this.menuDrawer = !this.menuDrawer