@bildvitta/quasar-ui-asteroid 3.9.0-beta.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.9.0-beta.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",
@@ -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
@@ -74,12 +74,17 @@ export default {
74
74
  type: Boolean
75
75
  },
76
76
 
77
- useRefresh: {
77
+ useFilter: {
78
78
  default: true,
79
79
  type: Boolean
80
80
  },
81
81
 
82
- useFilter: {
82
+ usePagination: {
83
+ default: true,
84
+ type: Boolean
85
+ },
86
+
87
+ useRefresh: {
83
88
  default: true,
84
89
  type: Boolean
85
90
  },
@@ -113,7 +118,7 @@ export default {
113
118
  },
114
119
 
115
120
  hasPages () {
116
- return this.totalPages > 1
121
+ return this.totalPages > 1 && this.usePagination
117
122
  },
118
123
 
119
124
  hasResults () {
@@ -76,6 +76,11 @@ props:
76
76
  default: true
77
77
  type: Boolean
78
78
 
79
+ use-pagination:
80
+ desc: Controla se vai ter ou não paginação.
81
+ default: true
82
+ type: Boolean
83
+
79
84
  use-refresh:
80
85
  desc: Controla o [pull-to-refresh](https://quasar.dev/vue-components/pull-to-refresh#basic).
81
86
  default: true