@bildvitta/quasar-ui-asteroid 3.7.0-beta.1 → 3.7.0-beta.3
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 +1 -1
- package/src/components/actions/QasActions.vue +1 -1
- package/src/components/actions-menu/QasActionsMenu.vue +111 -64
- package/src/components/actions-menu/QasActionsMenu.yml +11 -14
- package/src/components/btn/QasBtn.vue +16 -1
- package/src/components/btn/QasBtn.yml +8 -0
- package/src/components/btn-dropdown/QasBtnDropdown.vue +120 -0
- package/src/components/btn-dropdown/QasBtnDropdown.yml +42 -0
- package/src/components/delete/QasDelete.vue +15 -101
- package/src/components/dialog/QasDialog.vue +15 -1
- package/src/components/input/QasInput.vue +1 -11
- package/src/components/nested-fields/QasNestedFields.vue +2 -2
- package/src/components/numeric-input/QasNumericInput.vue +0 -1
- package/src/components/numeric-input/QasNumericInput.yml +1 -1
- package/src/components/password-input/QasPasswordInput.vue +22 -10
- package/src/components/password-input/QasPasswordInput.yml +12 -4
- package/src/components/password-strength-checker/QasPasswordStrengthChecker.vue +8 -19
- package/src/components/password-strength-checker/QasPasswordStrengthChecker.yml +10 -10
- package/src/components/table-generator/QasTableGenerator.vue +74 -17
- package/src/components/table-generator/QasTableGenerator.yml +10 -0
- package/src/css/components/button.scss +1 -0
- package/src/css/variables/index.scss +1 -0
- package/src/css/variables/separator.scss +2 -0
- package/src/mixins/password.js +5 -0
- package/src/plugins/delete/Delete.js +89 -0
- package/src/plugins/delete/Delete.yml +71 -0
- package/src/plugins/dialog/Dialog.yml +1 -1
- package/src/plugins/index.js +2 -0
- package/src/vue-plugin.js +5 -0
package/package.json
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div v-if="hasActions">
|
|
3
|
-
<component :is="component.is" v-bind="component.props"
|
|
4
|
-
<q-
|
|
5
|
-
<
|
|
6
|
-
<
|
|
7
|
-
<
|
|
8
|
-
<q-item
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
</q-list>
|
|
18
|
-
</q-menu>
|
|
2
|
+
<div v-if="hasActions" class="qas-actions-menu">
|
|
3
|
+
<component :is="component.is" v-bind="component.props" variant="tertiary">
|
|
4
|
+
<q-list v-if="isBtnDropdown">
|
|
5
|
+
<slot v-for="(item, key) in actions" :item="item" :name="key">
|
|
6
|
+
<q-item v-bind="item.props" :key="key" clickable @click="onClick(item)">
|
|
7
|
+
<q-item-section avatar>
|
|
8
|
+
<q-icon :name="item.icon" />
|
|
9
|
+
</q-item-section>
|
|
10
|
+
|
|
11
|
+
<q-item-section>
|
|
12
|
+
<div>{{ item.label }}</div>
|
|
13
|
+
</q-item-section>
|
|
14
|
+
</q-item>
|
|
15
|
+
</slot>
|
|
16
|
+
</q-list>
|
|
19
17
|
|
|
20
18
|
<q-tooltip v-if="hasTooltip" class="text-caption">
|
|
21
19
|
{{ tooltipLabel }}
|
|
@@ -26,28 +24,18 @@
|
|
|
26
24
|
|
|
27
25
|
<script>
|
|
28
26
|
import QasBtn from '../btn/QasBtn.vue'
|
|
29
|
-
import
|
|
27
|
+
import QasBtnDropdown from '../btn-dropdown/QasBtnDropdown.vue'
|
|
30
28
|
|
|
31
29
|
export default {
|
|
32
30
|
name: 'QasActionsMenu',
|
|
33
31
|
|
|
34
32
|
components: {
|
|
35
33
|
QasBtn,
|
|
36
|
-
|
|
34
|
+
QasBtnDropdown
|
|
37
35
|
},
|
|
38
36
|
|
|
39
37
|
props: {
|
|
40
|
-
|
|
41
|
-
default: '',
|
|
42
|
-
type: String
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
icon: {
|
|
46
|
-
default: 'sym_r_more_vert',
|
|
47
|
-
type: String
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
list: {
|
|
38
|
+
buttonProps: {
|
|
51
39
|
default: () => ({}),
|
|
52
40
|
type: Object
|
|
53
41
|
},
|
|
@@ -67,54 +55,63 @@ export default {
|
|
|
67
55
|
type: Object
|
|
68
56
|
},
|
|
69
57
|
|
|
70
|
-
|
|
71
|
-
default:
|
|
72
|
-
type:
|
|
58
|
+
dropdownIcon: {
|
|
59
|
+
default: 'sym_r_more_vert',
|
|
60
|
+
type: String
|
|
73
61
|
},
|
|
74
62
|
|
|
75
|
-
|
|
63
|
+
list: {
|
|
64
|
+
default: () => ({}),
|
|
65
|
+
type: Object
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
splitName: {
|
|
69
|
+
type: String,
|
|
70
|
+
default: ''
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
useLabel: {
|
|
74
|
+
default: true,
|
|
76
75
|
type: Boolean
|
|
77
76
|
}
|
|
78
77
|
},
|
|
79
78
|
|
|
80
79
|
computed: {
|
|
81
80
|
actions () {
|
|
81
|
+
const list = { ...this.fullList }
|
|
82
|
+
|
|
83
|
+
if (this.hasSplit && list[this.splitName] && this.isBtnDropdown) {
|
|
84
|
+
this.isSmall
|
|
85
|
+
? Object.assign(list, { [this.splitName]: list[this.splitName] })
|
|
86
|
+
: delete list[this.splitName]
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return list
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
fullList () {
|
|
82
93
|
return {
|
|
83
94
|
...this.list,
|
|
84
95
|
...(this.hasDelete && {
|
|
85
96
|
delete: {
|
|
97
|
+
color: 'grey-9',
|
|
86
98
|
icon: this.deleteIcon,
|
|
87
99
|
label: this.deleteLabel,
|
|
88
|
-
|
|
89
|
-
...this.deleteProps,
|
|
90
|
-
tag: this.hasMoreThanOneAction ? 'q-item' : 'qas-btn'
|
|
91
|
-
}
|
|
100
|
+
handler: () => this.$qas.delete(this.deleteProps)
|
|
92
101
|
}
|
|
93
102
|
})
|
|
94
103
|
}
|
|
95
104
|
},
|
|
96
105
|
|
|
97
106
|
component () {
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
// TODO: solução do color é temporária até ser definido o novo QasBtn.
|
|
101
|
-
if (this.hasMoreThanOneAction) {
|
|
102
|
-
props.color = this.color || 'grey-9'
|
|
103
|
-
props.iconRight = this.icon
|
|
104
|
-
props.label = this.useLabel ? 'Opções' : ''
|
|
105
|
-
} else {
|
|
106
|
-
const { color, icon } = this.actions[this.firstItemKey] || {}
|
|
107
|
-
|
|
108
|
-
props.color = color || this.color || 'primary'
|
|
109
|
-
props.icon = icon
|
|
110
|
-
props.label = this.useLabel ? this.tooltipLabel : ''
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
this.hasDelete && Object.assign(props, this.deleteProps)
|
|
107
|
+
const is = this.isBtnDropdown ? 'qas-btn-dropdown' : 'qas-btn'
|
|
114
108
|
|
|
115
109
|
return {
|
|
116
|
-
is
|
|
117
|
-
props
|
|
110
|
+
is,
|
|
111
|
+
props: {
|
|
112
|
+
...(this.isBtnDropdown ? this.btnDropdownProps : this.btnProps),
|
|
113
|
+
...(this.hasDelete && this.deleteProps)
|
|
114
|
+
}
|
|
118
115
|
}
|
|
119
116
|
},
|
|
120
117
|
|
|
@@ -130,26 +127,76 @@ export default {
|
|
|
130
127
|
return !!Object.keys(this.deleteProps).length
|
|
131
128
|
},
|
|
132
129
|
|
|
133
|
-
|
|
134
|
-
return
|
|
130
|
+
hasSplit () {
|
|
131
|
+
return !!this.splitName
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
isBtnDropdown () {
|
|
135
|
+
return Object.keys(this.fullList || {}).length > 1
|
|
135
136
|
},
|
|
136
137
|
|
|
137
138
|
hasTooltip () {
|
|
138
|
-
return !this.
|
|
139
|
+
return !this.isBtnDropdown && !this.useLabel
|
|
139
140
|
},
|
|
140
141
|
|
|
141
142
|
tooltipLabel () {
|
|
142
143
|
return this.actions[this.firstItemKey]?.label
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
defaultButtonProps () {
|
|
147
|
+
const { label, variant, ...buttonProps } = this.buttonProps
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
useHoverOnWhiteColor: true,
|
|
151
|
+
useLabelOnSmallScreen: false,
|
|
152
|
+
...buttonProps
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
btnDropdownProps () {
|
|
157
|
+
const { icon, label } = this.fullList[this.splitName] || {}
|
|
158
|
+
|
|
159
|
+
const {
|
|
160
|
+
icon: defaultIcon,
|
|
161
|
+
...defaultButtonProps
|
|
162
|
+
} = this.defaultButtonProps
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
buttonProps: {
|
|
166
|
+
...(this.useLabel && { label: this.hasSplit ? label : 'Opções' }),
|
|
167
|
+
...defaultButtonProps,
|
|
168
|
+
icon: icon || defaultIcon
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
dropdownIcon: this.dropdownIcon,
|
|
172
|
+
useSplit: this.hasSplit,
|
|
173
|
+
|
|
174
|
+
// evento
|
|
175
|
+
onClick: () => this.onClick(this.fullList[this.splitName])
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
btnProps () {
|
|
180
|
+
const { color, icon } = this.actions[this.firstItemKey] || {}
|
|
181
|
+
const { color: defaultColor, ...defaultButtonProps } = this.defaultButtonProps
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
color: color || defaultColor,
|
|
185
|
+
icon,
|
|
186
|
+
label: this.useLabel ? this.tooltipLabel : '',
|
|
187
|
+
onClick: this.onClick,
|
|
188
|
+
...defaultButtonProps
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
isSmall () {
|
|
193
|
+
return this.$qas.screen.isSmall
|
|
143
194
|
}
|
|
144
195
|
},
|
|
145
196
|
|
|
146
197
|
methods: {
|
|
147
|
-
getComponent (key) {
|
|
148
|
-
return key === 'delete' ? 'qas-delete' : 'q-item'
|
|
149
|
-
},
|
|
150
|
-
|
|
151
198
|
onClick (item = {}) {
|
|
152
|
-
if (!this.
|
|
199
|
+
if (!this.isBtnDropdown) {
|
|
153
200
|
item = this.actions[this.firstItemKey]
|
|
154
201
|
}
|
|
155
202
|
|
|
@@ -4,9 +4,11 @@ meta:
|
|
|
4
4
|
desc: Componente para abrir um menu de ação a partir de um botão, muito utilizado em tela de edição.
|
|
5
5
|
|
|
6
6
|
props:
|
|
7
|
-
|
|
8
|
-
desc:
|
|
9
|
-
|
|
7
|
+
button-props:
|
|
8
|
+
desc: Propriedades repassadas para o "QasBtn" caso esteja em modo de botão (apenas um item na prop "list"), caso esteja em modo de dropdown (mais de 1 item na prop "list") é enviado para a propriedade buttonProps do "QasBtnDropdown".
|
|
9
|
+
default: {}
|
|
10
|
+
type: Object
|
|
11
|
+
examples: ["{ color: 'white', icon: 'sym_r_person', useLabelOnSmallScreen: false }"]
|
|
10
12
|
|
|
11
13
|
delete-icon:
|
|
12
14
|
desc: Ícone do botão de deletar.
|
|
@@ -23,19 +25,13 @@ props:
|
|
|
23
25
|
default: {}
|
|
24
26
|
type: Object
|
|
25
27
|
|
|
26
|
-
icon:
|
|
27
|
-
desc: Ícone do botão.
|
|
28
|
-
default: sym_r_more_vert
|
|
29
|
-
type: String
|
|
30
|
-
examples: [start, end, between, around, center]
|
|
31
|
-
|
|
32
28
|
list:
|
|
33
29
|
desc: Lista de items que vão ser criados dentro do menu de ações.
|
|
34
30
|
default: '{}'
|
|
35
31
|
type: Object
|
|
36
32
|
examples: [
|
|
37
33
|
"{
|
|
38
|
-
|
|
34
|
+
visibility: {
|
|
39
35
|
icon: 'sym_r_visibility',
|
|
40
36
|
label: 'Visualizar',
|
|
41
37
|
handler: () => alert('handler ativado')
|
|
@@ -43,10 +39,11 @@ props:
|
|
|
43
39
|
}"
|
|
44
40
|
]
|
|
45
41
|
|
|
46
|
-
|
|
47
|
-
desc:
|
|
48
|
-
default:
|
|
49
|
-
type:
|
|
42
|
+
split-name:
|
|
43
|
+
desc: propriedade para definir o useSplit, habilita 2 ações diferentes no mesmo componente, separando o mesmo por uma barra, o valor deve ser alguma chave (key) existente na propriedade "list".
|
|
44
|
+
default: ''
|
|
45
|
+
type: String
|
|
46
|
+
examples: [visibility]
|
|
50
47
|
|
|
51
48
|
use-label:
|
|
52
49
|
desc: Habilita ou não o label no botão.
|
|
@@ -21,6 +21,16 @@ export default {
|
|
|
21
21
|
validator: value => ['grey-9', 'primary', 'white'].includes(value)
|
|
22
22
|
},
|
|
23
23
|
|
|
24
|
+
icon: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: undefined
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
iconRight: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: undefined
|
|
32
|
+
},
|
|
33
|
+
|
|
24
34
|
useLabelOnSmallScreen: {
|
|
25
35
|
default: true,
|
|
26
36
|
type: Boolean
|
|
@@ -76,12 +86,17 @@ export default {
|
|
|
76
86
|
...(this.showLabel && { label: this.label }),
|
|
77
87
|
|
|
78
88
|
...attributes,
|
|
89
|
+
icon: this.icon,
|
|
90
|
+
iconRight: this.iconRight,
|
|
79
91
|
class: [this.classes, externalClass]
|
|
80
92
|
}
|
|
81
93
|
},
|
|
82
94
|
|
|
83
95
|
hasIconOnly () {
|
|
84
|
-
return (
|
|
96
|
+
return (
|
|
97
|
+
(!this.label || !this.showLabel) &&
|
|
98
|
+
((this.icon && !this.iconRight) || (this.iconRight && !this.icon))
|
|
99
|
+
)
|
|
85
100
|
},
|
|
86
101
|
|
|
87
102
|
classes () {
|
|
@@ -13,6 +13,14 @@ props:
|
|
|
13
13
|
type: String
|
|
14
14
|
examples: ['grey-9', 'primary', 'white']
|
|
15
15
|
|
|
16
|
+
icon:
|
|
17
|
+
desc: Ícone a esquerda.
|
|
18
|
+
type: String
|
|
19
|
+
|
|
20
|
+
icon-right:
|
|
21
|
+
desc: Ícone a direita.
|
|
22
|
+
type: String
|
|
23
|
+
|
|
16
24
|
use-hover-on-white-color:
|
|
17
25
|
desc: Quando usamos a cor branca para contrast, em alguns casos podemos não querer ter um hover de outra cor justamente por conta do contraste, esta propriedade só funciona com variante "tertiary" e cor "white", para remover o hover sete o valor para "false".
|
|
18
26
|
default: true
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="flex inline items-center qas-btn-dropdown">
|
|
3
|
+
<div v-if="hasLeftButton" :class="leftSideClasses">
|
|
4
|
+
<slot name="left-button">
|
|
5
|
+
<qas-btn variant="tertiary" v-bind="defaultButtonProps" @click="$emit('click', $event)">
|
|
6
|
+
<q-menu v-if="hasMenuOnLeftSide" anchor="bottom right" auto-close self="top right">
|
|
7
|
+
<div :class="menuContentClasses">
|
|
8
|
+
<slot />
|
|
9
|
+
</div>
|
|
10
|
+
</q-menu>
|
|
11
|
+
</qas-btn>
|
|
12
|
+
</slot>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<q-separator v-if="hasSeparator" class="q-mr-sm qas-btn-dropdown__separator self-center" dark vertical />
|
|
16
|
+
|
|
17
|
+
<div v-if="useSplit">
|
|
18
|
+
<qas-btn color="grey-9" :icon="dropdownIcon" variant="tertiary">
|
|
19
|
+
<q-menu v-if="hasDefaultSlot" anchor="bottom right" auto-close self="top right">
|
|
20
|
+
<div :class="menuContentClasses">
|
|
21
|
+
<slot />
|
|
22
|
+
</div>
|
|
23
|
+
</q-menu>
|
|
24
|
+
</qas-btn>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script>
|
|
30
|
+
export default {
|
|
31
|
+
name: 'QasBtnDropdown',
|
|
32
|
+
|
|
33
|
+
inheritAttrs: false,
|
|
34
|
+
|
|
35
|
+
props: {
|
|
36
|
+
buttonProps: {
|
|
37
|
+
default: () => ({}),
|
|
38
|
+
type: Object
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
dropdownIcon: {
|
|
42
|
+
default: 'sym_r_more_vert',
|
|
43
|
+
type: String
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
useSplit: {
|
|
47
|
+
type: Boolean
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
useMenuPadding: {
|
|
51
|
+
type: Boolean
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
emits: ['click'],
|
|
56
|
+
|
|
57
|
+
computed: {
|
|
58
|
+
leftSideClasses () {
|
|
59
|
+
return {
|
|
60
|
+
'q-mr-sm': this.useSplit
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
menuContentClasses () {
|
|
65
|
+
return {
|
|
66
|
+
'q-pa-md': this.useMenuPadding
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
hasDefaultSlot () {
|
|
71
|
+
return !!this.$slots.default
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
hasMenuOnLeftSide () {
|
|
75
|
+
return this.hasDefaultSlot && !this.useSplit
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
defaultButtonProps () {
|
|
79
|
+
const {
|
|
80
|
+
icon,
|
|
81
|
+
iconRight,
|
|
82
|
+
color,
|
|
83
|
+
...defaultProps
|
|
84
|
+
} = this.buttonProps
|
|
85
|
+
|
|
86
|
+
const defaultIconRight = iconRight || this.dropdownIcon
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
useLabelOnSmallScreen: false,
|
|
90
|
+
|
|
91
|
+
...defaultProps,
|
|
92
|
+
|
|
93
|
+
color: color || (!this.useSplit ? 'grey-9' : 'primary'),
|
|
94
|
+
...(!this.useSplit && { iconRight: defaultIconRight }),
|
|
95
|
+
...(this.useSplit && { icon })
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
isSmall () {
|
|
100
|
+
return this.$qas.screen.isSmall
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
hasLeftButton () {
|
|
104
|
+
return !this.isSmall || !this.useSplit
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
hasSeparator () {
|
|
108
|
+
return !this.isSmall && this.useSplit
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
</script>
|
|
113
|
+
|
|
114
|
+
<style lang="scss">
|
|
115
|
+
.qas-btn-dropdown {
|
|
116
|
+
&__separator {
|
|
117
|
+
height: 18px;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
</style>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
type: component
|
|
2
|
+
|
|
3
|
+
meta:
|
|
4
|
+
desc: Componente semelhante ao QBtnDropdown porém utilizando o QasBtn e QSeparator para aplicar estilos padrões do Design System.
|
|
5
|
+
|
|
6
|
+
props:
|
|
7
|
+
button-props:
|
|
8
|
+
desc: Propriedades repassadas para o QasBtn.
|
|
9
|
+
default: {}
|
|
10
|
+
type: Object
|
|
11
|
+
examples: ["{ color: 'white', icon: 'sym_r_person' }"]
|
|
12
|
+
|
|
13
|
+
dropdown-icon:
|
|
14
|
+
desc: Ícone a direita do dropdown.
|
|
15
|
+
default: sym_r_more_vert
|
|
16
|
+
type: String
|
|
17
|
+
|
|
18
|
+
use-split:
|
|
19
|
+
desc: Divide o componente em 2 ações, o primeiro (direita) é um botão padrão, o segundo (esquerda) é um botão com ícone que abre o dropdown, criando uma separação com o QSeparator.
|
|
20
|
+
default: false
|
|
21
|
+
type: Boolean
|
|
22
|
+
|
|
23
|
+
use-menu-padding:
|
|
24
|
+
desc: Habilita o espaçamento dentro do menu de 16px (q-pa-md).
|
|
25
|
+
default: false
|
|
26
|
+
type: Boolean
|
|
27
|
+
|
|
28
|
+
slots:
|
|
29
|
+
default:
|
|
30
|
+
desc: Slot para passar o conteúdo do dropdown (menu)
|
|
31
|
+
|
|
32
|
+
left-button:
|
|
33
|
+
desc: Slot para substituir o botão a esquerda.
|
|
34
|
+
|
|
35
|
+
events:
|
|
36
|
+
'click':
|
|
37
|
+
desc: Caso não tenha "useSplit", o evento é disparado ao clicar no componente como um todo, caso tenha "useSplit", o evento é disparado ao clicar no botão a esquerda.
|
|
38
|
+
params:
|
|
39
|
+
event:
|
|
40
|
+
desc: Evento nativo de click.
|
|
41
|
+
type: Object
|
|
42
|
+
|
|
@@ -1,28 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<component v-bind="attributes" :is="tag" @click.stop="
|
|
2
|
+
<component v-bind="attributes" :is="tag" @click.stop="onDelete">
|
|
3
3
|
<template v-for="(_, name) in $slots" #[name]="context">
|
|
4
4
|
<slot :name="name" v-bind="context || {}" />
|
|
5
5
|
</template>
|
|
6
6
|
</component>
|
|
7
|
-
|
|
8
|
-
<qas-dialog v-model="showDialog" v-bind="defaultDialogProps" />
|
|
9
7
|
</template>
|
|
10
8
|
|
|
11
9
|
<script>
|
|
12
|
-
import { Loading } from 'quasar'
|
|
13
|
-
import { getAction } from '@bildvitta/store-adapter'
|
|
14
|
-
import { NotifyError, NotifySuccess } from '../../plugins'
|
|
15
|
-
import { useHistory } from '../../composables'
|
|
16
|
-
|
|
17
10
|
import QasBtn from '../btn/QasBtn.vue'
|
|
18
|
-
import QasDialog from '../dialog/QasDialog.vue'
|
|
19
11
|
|
|
20
12
|
export default {
|
|
21
13
|
name: 'QasDelete',
|
|
22
14
|
|
|
23
15
|
components: {
|
|
24
|
-
QasBtn
|
|
25
|
-
QasDialog
|
|
16
|
+
QasBtn
|
|
26
17
|
},
|
|
27
18
|
|
|
28
19
|
inheritAttrs: false,
|
|
@@ -69,12 +60,6 @@ export default {
|
|
|
69
60
|
'update:deleting'
|
|
70
61
|
],
|
|
71
62
|
|
|
72
|
-
data () {
|
|
73
|
-
return {
|
|
74
|
-
showDialog: false
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
|
|
78
63
|
computed: {
|
|
79
64
|
attributes () {
|
|
80
65
|
return {
|
|
@@ -83,106 +68,35 @@ export default {
|
|
|
83
68
|
}
|
|
84
69
|
},
|
|
85
70
|
|
|
86
|
-
defaultDialogProps () {
|
|
87
|
-
return {
|
|
88
|
-
card: {
|
|
89
|
-
description: 'Tem certeza que deseja excluir este item?'
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
ok: {
|
|
93
|
-
label: 'Excluir',
|
|
94
|
-
onClick: this.destroy
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
...this.dialogProps
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
|
|
101
71
|
id () {
|
|
102
72
|
return this.customId || this.$route.params.id
|
|
103
73
|
},
|
|
104
74
|
|
|
105
|
-
defaultNotifyMessages () {
|
|
106
|
-
return {
|
|
107
|
-
error: 'Não conseguimos excluir as informações. Por favor, tente novamente em alguns minutos.',
|
|
108
|
-
success: 'Informações excluídas com sucesso.'
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
|
|
112
75
|
isButton () {
|
|
113
76
|
return this.tag === 'qas-btn'
|
|
114
77
|
}
|
|
115
78
|
},
|
|
116
79
|
|
|
117
80
|
methods: {
|
|
118
|
-
|
|
119
|
-
this.
|
|
120
|
-
|
|
81
|
+
onDelete () {
|
|
82
|
+
this.$qas.delete({
|
|
83
|
+
deleteActionParams: {
|
|
84
|
+
entity: this.entity,
|
|
85
|
+
id: this.id,
|
|
86
|
+
url: this.url
|
|
87
|
+
},
|
|
121
88
|
|
|
122
|
-
|
|
123
|
-
Loading.show()
|
|
124
|
-
this.$emit('update:deleting', true)
|
|
89
|
+
dialogProps: this.dialogProps,
|
|
125
90
|
|
|
126
|
-
|
|
127
|
-
const payload = { id: this.id, url: this.url }
|
|
91
|
+
useAutoDeleteRoute: this.useAutoDeleteRoute,
|
|
128
92
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
)
|
|
93
|
+
// callbacks
|
|
94
|
+
onDelete: isDeleting => this.$emit('update:deleting', isDeleting),
|
|
132
95
|
|
|
133
|
-
|
|
134
|
-
entity: this.entity,
|
|
135
|
-
key: 'destroy',
|
|
136
|
-
payload
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
NotifySuccess(this.defaultNotifyMessages.success)
|
|
140
|
-
|
|
141
|
-
if (this.useAutoDeleteRoute) {
|
|
142
|
-
const { destroyRoutes, history } = useHistory()
|
|
143
|
-
|
|
144
|
-
// remove todas rotas que possuem o id do item excluído.
|
|
145
|
-
const routesToBeDeleted = this.getRoutesToBeDeletedById(history.list)
|
|
146
|
-
destroyRoutes(routesToBeDeleted)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// cria um evento para notificar que o item foi excluído no "window".
|
|
150
|
-
this.createDeleteSuccessEvent()
|
|
151
|
-
|
|
152
|
-
this.$emit('success')
|
|
153
|
-
|
|
154
|
-
this.$qas.logger.info('QasDelete - destroy -> item deletado com sucesso!')
|
|
155
|
-
} catch (error) {
|
|
156
|
-
NotifyError(this.defaultNotifyMessages.error)
|
|
157
|
-
this.$emit('error', error)
|
|
158
|
-
|
|
159
|
-
this.$qas.logger.group(
|
|
160
|
-
`QasDelete - destroy -> exceção da action ${this.entity}/destroy`,
|
|
161
|
-
[error],
|
|
162
|
-
{ error: true }
|
|
163
|
-
)
|
|
164
|
-
} finally {
|
|
165
|
-
Loading.hide()
|
|
166
|
-
this.$emit('update:deleting', false)
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
|
|
170
|
-
getRoutesToBeDeletedById (routes = []) {
|
|
171
|
-
return routes.filter(({ params }) => params.id === this.id)
|
|
172
|
-
},
|
|
96
|
+
onDeleteError: error => this.$emit('error', error),
|
|
173
97
|
|
|
174
|
-
|
|
175
|
-
const event = new CustomEvent('delete-success', {
|
|
176
|
-
bubbles: false,
|
|
177
|
-
cancelable: false,
|
|
178
|
-
detail: {
|
|
179
|
-
entity: this.entity,
|
|
180
|
-
url: this.url,
|
|
181
|
-
id: this.id
|
|
182
|
-
}
|
|
98
|
+
onDeleteSuccess: response => this.$emit('success', response)
|
|
183
99
|
})
|
|
184
|
-
|
|
185
|
-
window.dispatchEvent(event)
|
|
186
100
|
}
|
|
187
101
|
}
|
|
188
102
|
}
|