@bildvitta/quasar-ui-asteroid 3.8.0 → 3.9.0-beta.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bildvitta/quasar-ui-asteroid",
3
3
  "description": "Asteroid",
4
- "version": "3.8.0",
4
+ "version": "3.9.0-beta.1",
5
5
  "author": "Bild & Vitta <systemteam@bild.com.br>",
6
6
  "license": "MIT",
7
7
  "main": "dist/asteroid.cjs.min.js",
@@ -73,6 +73,10 @@ export default {
73
73
  useLabel: {
74
74
  default: true,
75
75
  type: Boolean
76
+ },
77
+
78
+ useTooltip: {
79
+ type: Boolean
76
80
  }
77
81
  },
78
82
 
@@ -136,7 +140,7 @@ export default {
136
140
  },
137
141
 
138
142
  hasTooltip () {
139
- return !this.isBtnDropdown && !this.useLabel
143
+ return !this.isBtnDropdown && !this.useLabel && this.useTooltip
140
144
  },
141
145
 
142
146
  tooltipLabel () {
@@ -45,6 +45,9 @@ props:
45
45
  type: String
46
46
  examples: [visibility]
47
47
 
48
+ use-tooltip:
49
+ desc: Controla se vai ter o tooltip caso passe nas regras de exibição de tooltip
50
+
48
51
  use-label:
49
52
  desc: Habilita ou não o label no botão.
50
53
  default: true
@@ -11,8 +11,8 @@
11
11
  </router-link>
12
12
  </q-toolbar-title>
13
13
 
14
- <slot v-if="hasUser" name="user" :user="user">
15
- <qas-app-user :menu-props="appUserMenuProps" :user="user" @sign-out="signOut" />
14
+ <slot v-if="hasUser" name="user">
15
+ <qas-app-user v-bind="defaultAppUserProps" />
16
16
  </slot>
17
17
  </q-toolbar>
18
18
  </q-header>
@@ -31,6 +31,12 @@ export default {
31
31
  },
32
32
 
33
33
  props: {
34
+ appUserProps: {
35
+ type: Object,
36
+ required: true,
37
+ default: () => ({})
38
+ },
39
+
34
40
  brand: {
35
41
  default: '',
36
42
  type: String
@@ -44,12 +50,6 @@ export default {
44
50
  title: {
45
51
  required: true,
46
52
  type: String
47
- },
48
-
49
- user: {
50
- default: () => ({}),
51
- require: true,
52
- type: Object
53
53
  }
54
54
  },
55
55
 
@@ -70,6 +70,19 @@ export default {
70
70
  }
71
71
  },
72
72
 
73
+ defaultAppUserProps () {
74
+ return {
75
+ menuProps: {
76
+ anchor: 'bottom end',
77
+ offset: [0, 5],
78
+ self: 'top end'
79
+ },
80
+
81
+ onSignOut: this.signOut,
82
+ ...this.appUserProps
83
+ }
84
+ },
85
+
73
86
  developmentBadgeLabel () {
74
87
  const hosts = {
75
88
  localhost: 'Local',
@@ -92,7 +105,7 @@ export default {
92
105
  },
93
106
 
94
107
  hasUser () {
95
- return !!Object.keys(this.user).length
108
+ return !!Object.keys(this.defaultAppUserProps.user || {}).length
96
109
  },
97
110
 
98
111
  rootRoute () {
@@ -4,6 +4,12 @@ meta:
4
4
  desc: Gerencia a barra superior da aplicação
5
5
 
6
6
  props:
7
+ app-user-props:
8
+ desc: Props repassadas para o QasAppUser.
9
+ default: {}
10
+ type: Object
11
+ required: true
12
+
7
13
  brand:
8
14
  desc: Path do logotipo.
9
15
  type: String
@@ -18,20 +24,6 @@ props:
18
24
  required: true
19
25
  type: String
20
26
 
21
- user:
22
- desc: Informações do usuário.
23
- type: Object
24
- default: {}
25
- examples: [
26
- "
27
- {
28
- photo: 'minha-img',
29
- name: 'Eduardo Lima',
30
- email: 'eduardolima@gmail.com'
31
- }
32
- "
33
- ]
34
-
35
27
  slots:
36
28
  user:
37
29
  desc: Slot para acessar o menu de usuário.
@@ -76,8 +76,8 @@
76
76
  </div>
77
77
 
78
78
  <!-- User -->
79
- <div v-if="showUser" class="full-width q-pb-lg q-px-lg">
80
- <qas-app-user v-bind="appUserProps" />
79
+ <div v-if="showAppUser" class="full-width q-pb-lg q-px-lg">
80
+ <qas-app-user v-bind="defaultAppUserProps" />
81
81
  </div>
82
82
  </div>
83
83
  </q-drawer>
@@ -102,6 +102,12 @@ export default {
102
102
  inheritAttrs: false,
103
103
 
104
104
  props: {
105
+ appUserProps: {
106
+ type: Object,
107
+ required: true,
108
+ default: () => ({})
109
+ },
110
+
105
111
  brand: {
106
112
  default: '',
107
113
  required: true,
@@ -137,12 +143,6 @@ export default {
137
143
  title: {
138
144
  default: '',
139
145
  type: String
140
- },
141
-
142
- user: {
143
- default: () => ({}),
144
- require: true,
145
- type: Object
146
146
  }
147
147
  },
148
148
 
@@ -168,20 +168,6 @@ export default {
168
168
  }
169
169
  },
170
170
 
171
- appUserProps () {
172
- return {
173
- avatarSize: '40px',
174
- user: this.user,
175
-
176
- menuProps: {
177
- 'onUpdate:modelValue': this.setHasOpenedMenu
178
- },
179
-
180
- // eventos
181
- onSignOut: this.signOut
182
- }
183
- },
184
-
185
171
  behavior () {
186
172
  return this.isUntilLarge ? 'mobile' : 'desktop'
187
173
  },
@@ -213,6 +199,20 @@ export default {
213
199
  return this.defaultModules.find(module => module?.value.includes(hostname))?.value
214
200
  },
215
201
 
202
+ defaultAppUserProps () {
203
+ return {
204
+ avatarSize: '40px',
205
+
206
+ menuProps: {
207
+ 'onUpdate:modelValue': this.setHasOpenedMenu
208
+ },
209
+
210
+ // eventos
211
+ onSignOut: this.signOut,
212
+ ...this.appUserProps
213
+ }
214
+ },
215
+
216
216
  defaultModules () {
217
217
  if (!isLocalDevelopment()) return this.modules
218
218
 
@@ -289,7 +289,7 @@ export default {
289
289
  return this.$router.hasRoute('Root') ? { name: 'Root' } : { path: '/' }
290
290
  },
291
291
 
292
- showUser () {
292
+ showAppUser () {
293
293
  return this.hasUser && !this.isUntilLarge
294
294
  },
295
295
 
@@ -339,7 +339,7 @@ export default {
339
339
  },
340
340
 
341
341
  hasUser () {
342
- return !!Object.keys(this.user).length
342
+ return !!Object.keys(this.defaultAppUserProps.user || {}).length
343
343
  },
344
344
 
345
345
  isActive ({ to }) {
@@ -4,6 +4,12 @@ meta:
4
4
  desc: Menu lateral.
5
5
 
6
6
  props:
7
+ app-user-props:
8
+ desc: Props repassadas para o QasAppUser.
9
+ default: {}
10
+ type: Object
11
+ required: true
12
+
7
13
  brand:
8
14
  desc: Logotipo quando menu esta aberto.
9
15
  type: String
@@ -38,20 +44,6 @@ props:
38
44
  desc: Título que vai ficar no label do select de módulos.
39
45
  type: String
40
46
 
41
- user:
42
- desc: Informações do usuário.
43
- type: Object
44
- default: {}
45
- examples: [
46
- "
47
- {
48
- photo: 'minha-img',
49
- name: 'Eduardo Lima',
50
- email: 'eduardolima@gmail.com'
51
- }
52
- "
53
- ]
54
-
55
47
  slots:
56
48
  user:
57
49
  desc: Slot para acessar o menu de usuário.
@@ -17,6 +17,8 @@
17
17
  <div class="ellipsis qas-app-user__menu-name">{{ userName }}</div>
18
18
  <div class="ellipsis">{{ user.email }}</div>
19
19
 
20
+ <qas-select v-if="hasCompaniesSelect" v-model="companiesModel" class="q-my-md" label="Vínculo" :loading="loading" :options="companiesOptions" @update:model-value="setCompanies" />
21
+
20
22
  <q-list class="q-mt-md">
21
23
  <q-item v-close-popup :active="false" class="qas-app-user__menu-item" clickable :to="user.to">
22
24
  <q-item-section avatar>
@@ -67,6 +69,16 @@ export default {
67
69
  type: String
68
70
  },
69
71
 
72
+ companiesOptions: {
73
+ type: Array,
74
+ default: () => []
75
+ },
76
+
77
+ currentCompany: {
78
+ type: String,
79
+ default: ''
80
+ },
81
+
70
82
  menuProps: {
71
83
  default: () => ({}),
72
84
  type: Object
@@ -86,6 +98,13 @@ export default {
86
98
 
87
99
  emits: ['sign-out'],
88
100
 
101
+ data () {
102
+ return {
103
+ companiesModel: '',
104
+ loading: false
105
+ }
106
+ },
107
+
89
108
  computed: {
90
109
  hasNotifications () {
91
110
  return !!Object.keys(this.notifications).length
@@ -93,12 +112,43 @@ export default {
93
112
 
94
113
  userName () {
95
114
  return this.user.name || this.user.givenName
115
+ },
116
+
117
+ hasCompaniesSelect () {
118
+ return this.companiesOptions.length > 1
119
+ }
120
+ },
121
+
122
+ watch: {
123
+ currentCompany: {
124
+ handler (value) {
125
+ this.companiesModel = value
126
+ },
127
+
128
+ immediate: true
96
129
  }
97
130
  },
98
131
 
99
132
  methods: {
100
133
  signOut () {
101
134
  this.$emit('sign-out')
135
+ },
136
+
137
+ async setCompanies (value) {
138
+ this.loading = true
139
+
140
+ try {
141
+ await this.$axios.patch('users/me', { companies: value })
142
+
143
+ this.$qas.success('Vínculo alterado com sucesso.')
144
+
145
+ setTimeout(() => location.reload(), 1500)
146
+ } catch {
147
+ this.companiesModel = this.currentCompany
148
+ this.$qas.error('Falha ao alterar vínculo.')
149
+ } finally {
150
+ this.loading = false
151
+ }
102
152
  }
103
153
  }
104
154
  }
@@ -4,6 +4,26 @@ meta:
4
4
  desc: Exibe o avatar e o nome do usuário, ao clicar abre um menu com as opções.
5
5
 
6
6
  props:
7
+ avatar-size:
8
+ desc: Define o tamanho do avatar.
9
+ default: 36px
10
+ type: String
11
+
12
+ companies-options:
13
+ desc: Opções para o select de vínculo de empresas.
14
+ default: []
15
+ type: Array
16
+
17
+ current-company:
18
+ desc: Empresa atual vinculada
19
+ default: ''
20
+ type: String
21
+
22
+ menu-props:
23
+ desc: Repassa props pro QMenu.
24
+ default: {}
25
+ type: Object
26
+
7
27
  notifications:
8
28
  desc: Lista com as notificações do usuário.
9
29
  type: Object
@@ -3,23 +3,11 @@
3
3
  <div class="qas-gallery">
4
4
  <div class="q-col-gutter-md row">
5
5
  <div v-for="(image, index) in getInitialImages()" :key="index" :class="galleryColumnsClasses" :data-cy="`gallery-image-${index}`">
6
- <div class="bg-white q-pa-md rounded-borders shadow-2">
7
- <div class="flat items-center justify-between no-wrap q-mb-xs row text-grey-9">
8
- <div class="ellipsis q-mr-xs qas-gallery__name">
9
- <slot v-if="image.name" :image="image" :index="index" name="header">
10
- {{ image.name }}
11
- </slot>
12
- </div>
13
-
14
- <div v-if="useDestroy">
15
- <slot :destroy="onDestroy" :image="image" :index="index" name="destroy">
16
- <qas-btn color="grey-9" :disabled="isDestroyDisabled(image)" icon="sym_r_delete" variant="tertiary" @click="onDestroy(image, index)" />
17
- </slot>
18
- </div>
19
- </div>
20
-
21
- <q-img class="cursor-pointer rounded-borders" height="150px" :src="image.url" @click="toggleCarouselDialog(index)" @error="onError(image.url)" />
22
- </div>
6
+ <qas-gallery-card v-bind="getGalleryCardProps({ image, index })">
7
+ <template v-for="(_, name) in $slots" #[name]="context">
8
+ <slot v-bind="context" :image="image" :index="index" :name="name" />
9
+ </template>
10
+ </qas-gallery-card>
23
11
  </div>
24
12
 
25
13
  <slot>
@@ -64,6 +52,11 @@ export default {
64
52
  default: 'sym_r_chevron_left'
65
53
  },
66
54
 
55
+ galleryCardProps: {
56
+ type: Object,
57
+ default: () => ({})
58
+ },
59
+
67
60
  initialSize: {
68
61
  type: Number,
69
62
  default: 4,
@@ -184,6 +177,46 @@ export default {
184
177
  }
185
178
  },
186
179
 
180
+ getGalleryCardProps ({ image, index }) {
181
+ return {
182
+ card: image,
183
+ imageProps: this.getImageProps({ image, index }),
184
+ actionsMenuProps: this.getActionsMenuProps({ image, index }),
185
+ ...this.galleryCardProps
186
+ }
187
+ },
188
+
189
+ getActionsMenuProps ({ image, index }) {
190
+ if (!this.useDestroy) return {}
191
+
192
+ return {
193
+ useLabel: false,
194
+
195
+ buttonProps: {
196
+ disable: this.isDestroyDisabled(image)
197
+ },
198
+
199
+ list: {
200
+ destroy: {
201
+ label: 'Excluir',
202
+ color: 'grey-9',
203
+ icon: 'sym_r_delete',
204
+
205
+ handler: () => this.onDestroy(image, index)
206
+ }
207
+ }
208
+ }
209
+ },
210
+
211
+ getImageProps ({ image, index }) {
212
+ return {
213
+ class: 'cursor-pointer',
214
+
215
+ onClick: () => this.toggleCarouselDialog(index),
216
+ onError: () => this.onError(image.url)
217
+ }
218
+ },
219
+
187
220
  getInitialImages () {
188
221
  return this.useLoadAll
189
222
  ? this.normalizedImages
@@ -230,13 +263,3 @@ export default {
230
263
  }
231
264
  }
232
265
  </script>
233
-
234
- <!-- TODO rever tipografia -->
235
- <style lang="scss">
236
- .qas-gallery {
237
- &__name {
238
- font-size: 16px;
239
- font-weight: 600;
240
- }
241
- }
242
- </style>
@@ -21,6 +21,11 @@ props:
21
21
  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" (utilizado para remover imagem).
22
22
  type: String
23
23
 
24
+ gallery-card-props:
25
+ desc: Propriedades repassadas para o QasGalleryCard
26
+ default: {}
27
+ type: Object
28
+
24
29
  initial-size:
25
30
  desc: Quantidade de imagens iniciais.
26
31
  default: 6
@@ -61,17 +66,39 @@ props:
61
66
  type: Boolean
62
67
 
63
68
  slots:
69
+ actions:
70
+ desc: Slot para ações do cabeçalho.
71
+ scope:
72
+ index:
73
+ desc: index atual.
74
+ default: 0
75
+ type: Number
76
+
77
+ image:
78
+ desc: imagem atual.
79
+ default: {}
80
+ type: Object
81
+
82
+ bottom:
83
+ desc: Slot para acessar o conteúdo abaixo da imagem.
84
+ scope:
85
+ index:
86
+ desc: index atual.
87
+ default: 0
88
+ type: Number
89
+
90
+ image:
91
+ desc: imagem atual.
92
+ default: {}
93
+ type: Object
94
+
95
+
64
96
  default:
65
97
  desc: Slot para todo conteúdo onde fica o botão "mostrar mais".
66
98
 
67
- destroy:
68
- desc: Slot para o ícone de remover.
99
+ image:
100
+ desc: Slot para acessar o conteúdo da imagem (onde fica o QasGridGenerator).
69
101
  scope:
70
- destroy:
71
- desc: Função para remover e atualizar o model.
72
- default: undefined
73
- type: Function
74
-
75
102
  index:
76
103
  desc: index atual.
77
104
  default: 0
@@ -83,7 +110,20 @@ slots:
83
110
  type: Object
84
111
 
85
112
  header:
86
- desc: Slot para o header.
113
+ desc: Slot para acessar o conteúdo do cabeçalho.
114
+ scope:
115
+ index:
116
+ desc: index atual.
117
+ default: 0
118
+ type: Number
119
+
120
+ image:
121
+ desc: imagem atual.
122
+ default: {}
123
+ type: Object
124
+
125
+ name:
126
+ desc: Slot para acessar o conteúdo do nome, acima da imagem.
87
127
  scope:
88
128
  index:
89
129
  desc: index atual.
@@ -1,16 +1,17 @@
1
- <!-- TODO: componente adaptado somente para o uso do QasUploader, precisa ser revisitado para ser implementado no QasGallery -->
2
1
  <template>
3
2
  <div class="bg-white q-pa-md qas-gallery-card rounded-borders shadow-2" :class="classes">
4
- <header class="flat items-center no-wrap q-mb-md row" :class="headerClasses">
3
+ <header class="flat items-center no-wrap row" :class="headerClasses">
5
4
  <slot name="header">
6
- <div class="ellipsis q-mr-xs qas-gallery__name">
5
+ <div class="ellipsis q-mr-xs qas-gallery__name text-subtitle1">
7
6
  <slot v-if="card.name" name="name">
8
7
  {{ card.name }}
9
8
  </slot>
10
9
  </div>
11
10
 
12
- <div v-if="hasActionsMenu">
13
- <qas-actions-menu v-bind="defaultActionsMenuProps" />
11
+ <div v-if="hasActions">
12
+ <slot name="actions">
13
+ <qas-actions-menu v-bind="defaultActionsMenuProps" />
14
+ </slot>
14
15
  </div>
15
16
  </slot>
16
17
  </header>
@@ -84,8 +85,12 @@ export default {
84
85
  }
85
86
  },
86
87
 
87
- hasActionsMenu () {
88
- return !!Object.keys(this.actionsMenuProps).length
88
+ hasActions () {
89
+ return !!Object.keys(this.actionsMenuProps).length || this.hasActionsSlot
90
+ },
91
+
92
+ hasActionsSlot () {
93
+ return !!this.$slots.actions
89
94
  },
90
95
 
91
96
  hasBottom () {
@@ -100,7 +105,8 @@ export default {
100
105
  return {
101
106
  'justify-between': this.card.name,
102
107
  'justify-right': !this.card.name,
103
- 'text-grey-9': !this.disable
108
+ 'text-grey-9': !this.disable,
109
+ 'q-mb-md': this.hasActions || this.card.name
104
110
  }
105
111
  }
106
112
  }
@@ -29,6 +29,9 @@ props:
29
29
  type: Object
30
30
 
31
31
  slots:
32
+ actions:
33
+ desc: Slot para ações do cabeçalho.
34
+
32
35
  bottom:
33
36
  desc: Slot para acessar o conteúdo abaixo da imagem.
34
37
 
@@ -70,8 +70,7 @@ export default {
70
70
  type: Boolean
71
71
  },
72
72
 
73
- useRefresh: {
74
- default: true,
73
+ useAutoRefetchOnDelete: {
75
74
  type: Boolean
76
75
  },
77
76
 
@@ -80,6 +79,16 @@ export default {
80
79
  type: Boolean
81
80
  },
82
81
 
82
+ usePagination: {
83
+ default: true,
84
+ type: Boolean
85
+ },
86
+
87
+ useRefresh: {
88
+ default: true,
89
+ type: Boolean
90
+ },
91
+
83
92
  useResultsAreaOnly: {
84
93
  type: Boolean
85
94
  }
@@ -100,12 +109,16 @@ export default {
100
109
  },
101
110
 
102
111
  computed: {
112
+ hasDeleteEventListener () {
113
+ return this.useAutoHandleOnDelete || this.useAutoRefetchOnDelete
114
+ },
115
+
103
116
  hasHeaderSlot () {
104
117
  return !!this.$slots.header
105
118
  },
106
119
 
107
120
  hasPages () {
108
- return this.totalPages > 1
121
+ return this.totalPages > 1 && this.usePagination
109
122
  },
110
123
 
111
124
  hasResults () {
@@ -153,13 +166,13 @@ export default {
153
166
  },
154
167
 
155
168
  mounted () {
156
- if (!this.useAutoHandleOnDelete) return
169
+ if (!this.hasDeleteEventListener) return
157
170
 
158
171
  window.addEventListener('delete-success', this.onDeleteResult)
159
172
  },
160
173
 
161
174
  unmounted () {
162
- if (!this.useAutoHandleOnDelete) return
175
+ if (!this.hasDeleteEventListener) return
163
176
 
164
177
  window.removeEventListener('delete-success', this.onDeleteResult)
165
178
  },
@@ -235,7 +248,7 @@ export default {
235
248
  this.page = parseInt(this.$route.query.page || 1)
236
249
  },
237
250
 
238
- onDeleteResult ({ detail: { entity } }) {
251
+ onAutoHandleDelete ({ detail: { entity } }) {
239
252
  const { page } = this.mx_context
240
253
 
241
254
  /*
@@ -269,6 +282,15 @@ export default {
269
282
  * ex: estou na pagina 2 e existem 3 paginas, removo um item da pagina 2, então chamo o método fetchList
270
283
  */
271
284
  this.mx_fetchHandler({ ...this.mx_context, url: this.url }, this.fetchList)
285
+ },
286
+
287
+ onDeleteResult (event) {
288
+ if (this.useAutoRefetchOnDelete) {
289
+ this.mx_fetchHandler({ ...this.mx_context, url: this.url }, this.fetchList)
290
+ return
291
+ }
292
+
293
+ this.onAutoHandleDelete(event)
272
294
  }
273
295
  }
274
296
  }
@@ -62,6 +62,10 @@ props:
62
62
  desc: Controla se o componente vai lidar automaticamente quando acontecer algum delete compatível com a listagem.
63
63
  type: Boolean
64
64
 
65
+ use-auto-refetch-on-delete:
66
+ desc: Controla se o componente vai fazer o fetch novamente quando acontecer algum delete compatível com a listagem.
67
+ type: Boolean
68
+
65
69
  use-boundary:
66
70
  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.
67
71
  default: true
@@ -72,6 +76,11 @@ props:
72
76
  default: true
73
77
  type: Boolean
74
78
 
79
+ use-pagination:
80
+ desc: Controla se vai ter ou não paginação.
81
+ default: true
82
+ type: Boolean
83
+
75
84
  use-refresh:
76
85
  desc: Controla o [pull-to-refresh](https://quasar.dev/vue-components/pull-to-refresh#basic).
77
86
  default: true
@@ -6,9 +6,9 @@ export default async (text, onLoading = () => {}) => {
6
6
 
7
7
  try {
8
8
  await copyToClipboard(text)
9
- NotifySuccess('Copiado!', text)
9
+ NotifySuccess('Item copiado com sucesso.')
10
10
  } catch {
11
- NotifyError('Não foi possível copiar.', text)
11
+ NotifyError('Não foi possível copiar o item.')
12
12
  } finally {
13
13
  setTimeout(() => { onLoading(false) }, 500)
14
14
  }