@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
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
<footer v-if="!isInfoDialog">
|
|
23
23
|
<slot name="actions">
|
|
24
|
-
<qas-actions v-bind="
|
|
24
|
+
<qas-actions v-bind="formattedActionsProps">
|
|
25
25
|
<template v-if="hasOk" #primary>
|
|
26
26
|
<qas-btn v-close-popup="!useForm" class="full-width" variant="primary" v-bind="defaultOk" @click="submitHandler" />
|
|
27
27
|
</template>
|
|
@@ -172,6 +172,20 @@ export default {
|
|
|
172
172
|
|
|
173
173
|
isInfoDialog () {
|
|
174
174
|
return !this.hasOk && !this.hasCancel
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
formattedActionsProps () {
|
|
178
|
+
const { useFullWidth, useEqualWidth } = this.actionsProps
|
|
179
|
+
|
|
180
|
+
if (useFullWidth || useEqualWidth) {
|
|
181
|
+
return this.actionsProps
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return {
|
|
185
|
+
useFullWidth: this.hasSingleAction,
|
|
186
|
+
useEqualWidth: this.hasAllActions,
|
|
187
|
+
...this.actionsProps
|
|
188
|
+
}
|
|
175
189
|
}
|
|
176
190
|
},
|
|
177
191
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<q-input ref="input" v-model="model" bottom-slots :error="errorData" v-bind="$attrs" :error-message="
|
|
2
|
+
<q-input ref="input" v-model="model" bottom-slots :error="errorData" v-bind="$attrs" :error-message="errorMessage" :mask="mask" :outlined="outlined" :unmasked-value="unmaskedValue" @paste="onPaste">
|
|
3
3
|
<template v-for="(_, name) in $slots" #[name]="context">
|
|
4
4
|
<slot :name="name" v-bind="context || {}" />
|
|
5
5
|
</template>
|
|
@@ -47,7 +47,6 @@ export default {
|
|
|
47
47
|
data () {
|
|
48
48
|
return {
|
|
49
49
|
errorData: false,
|
|
50
|
-
messageErrorData: '',
|
|
51
50
|
mask: ''
|
|
52
51
|
}
|
|
53
52
|
},
|
|
@@ -107,14 +106,6 @@ export default {
|
|
|
107
106
|
this.errorData = value
|
|
108
107
|
},
|
|
109
108
|
|
|
110
|
-
immediate: true
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
errorMessage: {
|
|
114
|
-
handler (value) {
|
|
115
|
-
this.errorMessageData = value
|
|
116
|
-
},
|
|
117
|
-
|
|
118
109
|
immediate: true
|
|
119
110
|
}
|
|
120
111
|
},
|
|
@@ -156,7 +147,6 @@ export default {
|
|
|
156
147
|
handleErrors () {
|
|
157
148
|
if (this.useRemoveErrorOnType && this.error) {
|
|
158
149
|
this.errorData = false
|
|
159
|
-
this.errorMessageData = ''
|
|
160
150
|
}
|
|
161
151
|
},
|
|
162
152
|
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<div>
|
|
12
12
|
<div class="flex items-center justify-between q-py-md">
|
|
13
13
|
<qas-label v-if="!useSingleLabel" :label="getRowLabel(index)" />
|
|
14
|
-
<qas-actions-menu v-if="hasBlockActions(row)" :list="getActionsList(index, row)"
|
|
14
|
+
<qas-actions-menu v-if="hasBlockActions(row)" v-bind="actionsMenuProps" :list="getActionsList(index, row)" />
|
|
15
15
|
</div>
|
|
16
16
|
|
|
17
17
|
<div ref="formGenerator" class="col-12 justify-between q-col-gutter-x-md row">
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
</slot>
|
|
25
25
|
|
|
26
26
|
<div v-if="hasInlineActions(row)" class="flex items-center qas-nested-fields__actions">
|
|
27
|
-
<qas-actions-menu :list="getActionsList(index, row)"
|
|
27
|
+
<qas-actions-menu v-bind="actionsMenuProps" :list="getActionsList(index, row)" />
|
|
28
28
|
</div>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<qas-input v-model="model" :bottom-
|
|
2
|
+
<qas-input v-model="model" class="qas-password-input" :hide-bottom-space="hideBottomSpace" v-bind="$attrs" :type="type" use-remove-error-on-type>
|
|
3
|
+
<template #prepend>
|
|
4
|
+
<q-icon color="grey-8" name="sym_r_lock" />
|
|
5
|
+
</template>
|
|
6
|
+
|
|
3
7
|
<template #append>
|
|
4
|
-
<
|
|
8
|
+
<qas-btn color="primary" :icon="icon" variant="tertiary" @click="toggle" />
|
|
5
9
|
</template>
|
|
6
10
|
|
|
7
11
|
<template v-for="(_, name) in $slots" #[name]="context">
|
|
@@ -9,7 +13,7 @@
|
|
|
9
13
|
</template>
|
|
10
14
|
|
|
11
15
|
<template v-if="hasStrengthChecker" #hint>
|
|
12
|
-
<qas-password-strength-checker v-bind="strengthCheckerProps" :password="model" />
|
|
16
|
+
<qas-password-strength-checker v-bind="strengthCheckerProps" :password="model" @update:current-level="updateCurrentLevel" />
|
|
13
17
|
</template>
|
|
14
18
|
</qas-input>
|
|
15
19
|
</template>
|
|
@@ -37,18 +41,13 @@ export default {
|
|
|
37
41
|
type: Boolean
|
|
38
42
|
},
|
|
39
43
|
|
|
40
|
-
iconColor: {
|
|
41
|
-
type: String,
|
|
42
|
-
default: 'primary'
|
|
43
|
-
},
|
|
44
|
-
|
|
45
44
|
modelValue: {
|
|
46
45
|
type: String,
|
|
47
46
|
default: ''
|
|
48
47
|
}
|
|
49
48
|
},
|
|
50
49
|
|
|
51
|
-
emits: ['update:modelValue'],
|
|
50
|
+
emits: ['update:modelValue', 'update:currentLevel'],
|
|
52
51
|
|
|
53
52
|
data () {
|
|
54
53
|
return {
|
|
@@ -72,7 +71,12 @@ export default {
|
|
|
72
71
|
},
|
|
73
72
|
|
|
74
73
|
strengthCheckerProps () {
|
|
75
|
-
const {
|
|
74
|
+
const {
|
|
75
|
+
modelValue,
|
|
76
|
+
useStrengthChecker,
|
|
77
|
+
...props
|
|
78
|
+
} = this.$props
|
|
79
|
+
|
|
76
80
|
return props
|
|
77
81
|
},
|
|
78
82
|
|
|
@@ -86,12 +90,20 @@ export default {
|
|
|
86
90
|
|
|
87
91
|
hasStrengthChecker () {
|
|
88
92
|
return this.useStrengthChecker && this.hasBottomSlots
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
hideBottomSpace () {
|
|
96
|
+
return this.$attrs.error || !!this.model.length
|
|
89
97
|
}
|
|
90
98
|
},
|
|
91
99
|
|
|
92
100
|
methods: {
|
|
93
101
|
toggle () {
|
|
94
102
|
this.toggleType = !this.toggleType
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
updateCurrentLevel (currentLevel) {
|
|
106
|
+
this.$emit('update:currentLevel', currentLevel)
|
|
95
107
|
}
|
|
96
108
|
}
|
|
97
109
|
}
|
|
@@ -7,10 +7,11 @@ mixins:
|
|
|
7
7
|
- '@bildvitta/quasar-ui-asteroid/dist/api/QasInput.json'
|
|
8
8
|
- quasar/dist/api/QInput.json
|
|
9
9
|
props:
|
|
10
|
-
|
|
11
|
-
desc:
|
|
12
|
-
default:
|
|
13
|
-
type:
|
|
10
|
+
current-level:
|
|
11
|
+
desc: model que tem o valor atual do level.
|
|
12
|
+
default: 0
|
|
13
|
+
type: Number
|
|
14
|
+
model: true
|
|
14
15
|
|
|
15
16
|
levels:
|
|
16
17
|
desc: Níveis de força da senha, é um objeto de objeto.
|
|
@@ -101,3 +102,10 @@ events:
|
|
|
101
102
|
value:
|
|
102
103
|
desc: Novo valor do v-model
|
|
103
104
|
type: Boolean
|
|
105
|
+
|
|
106
|
+
'@update:current-level -> function (level)':
|
|
107
|
+
desc: Dispara toda vez que o level (score) é atualizado.
|
|
108
|
+
params:
|
|
109
|
+
level:
|
|
110
|
+
desc: Novo valor do v-model:currentLevel
|
|
111
|
+
type: Boolean
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div v-if="length">
|
|
3
3
|
<slot :level="level">
|
|
4
|
-
<q-linear-progress :color="level.color" :track-color="trackColor" :value="level.progress" />
|
|
5
|
-
<div class="text-
|
|
4
|
+
<q-linear-progress :color="level.color" rounded :track-color="trackColor" :value="level.progress" />
|
|
5
|
+
<div class="q-mt-sm text-subtitle2" :class="level.textClass">{{ level.label }}</div>
|
|
6
6
|
</slot>
|
|
7
7
|
</div>
|
|
8
8
|
</template>
|
|
@@ -16,18 +16,13 @@ export default {
|
|
|
16
16
|
mixins: [passwordMixin],
|
|
17
17
|
|
|
18
18
|
props: {
|
|
19
|
-
modelValue: {
|
|
20
|
-
default: false,
|
|
21
|
-
type: Boolean
|
|
22
|
-
},
|
|
23
|
-
|
|
24
19
|
password: {
|
|
25
20
|
default: '',
|
|
26
21
|
type: String
|
|
27
22
|
}
|
|
28
23
|
},
|
|
29
24
|
|
|
30
|
-
emits: ['update:modelValue'],
|
|
25
|
+
emits: ['update:modelValue', 'update:currentLevel'],
|
|
31
26
|
|
|
32
27
|
computed: {
|
|
33
28
|
length () {
|
|
@@ -64,18 +59,12 @@ export default {
|
|
|
64
59
|
},
|
|
65
60
|
|
|
66
61
|
watch: {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
created () {
|
|
73
|
-
this.emitValue()
|
|
74
|
-
},
|
|
62
|
+
score: {
|
|
63
|
+
handler (score) {
|
|
64
|
+
this.$emit('update:currentLevel', score)
|
|
65
|
+
},
|
|
75
66
|
|
|
76
|
-
|
|
77
|
-
emitValue () {
|
|
78
|
-
this.$emit('update:modelValue', this.score === 4)
|
|
67
|
+
immediate: true
|
|
79
68
|
}
|
|
80
69
|
}
|
|
81
70
|
}
|
|
@@ -4,6 +4,12 @@ meta:
|
|
|
4
4
|
desc: Componente para checar nível de força da senha.
|
|
5
5
|
|
|
6
6
|
props:
|
|
7
|
+
current-level:
|
|
8
|
+
desc: model que tem o valor atual do level.
|
|
9
|
+
default: 0
|
|
10
|
+
type: Number
|
|
11
|
+
model: true
|
|
12
|
+
|
|
7
13
|
levels:
|
|
8
14
|
desc: Níveis de força da senha, é um objeto de objeto.
|
|
9
15
|
type: [Object, Boolean]
|
|
@@ -44,12 +50,6 @@ props:
|
|
|
44
50
|
desc: Senha para ser usado nas validações.
|
|
45
51
|
type: String
|
|
46
52
|
|
|
47
|
-
model-value:
|
|
48
|
-
desc: Model do componente, retorna se passou ou não na validação de senha.
|
|
49
|
-
type: Boolean
|
|
50
|
-
examples: [v-model="value"]
|
|
51
|
-
model: true
|
|
52
|
-
|
|
53
53
|
minlength:
|
|
54
54
|
desc: Número mínimo de caracteres.
|
|
55
55
|
default: 8
|
|
@@ -95,9 +95,9 @@ slots:
|
|
|
95
95
|
type: Object
|
|
96
96
|
|
|
97
97
|
events:
|
|
98
|
-
'@update:
|
|
99
|
-
desc: Dispara toda vez que o
|
|
98
|
+
'@update:current-level -> function (level)':
|
|
99
|
+
desc: Dispara toda vez que o level (score) é atualizado.
|
|
100
100
|
params:
|
|
101
|
-
|
|
102
|
-
desc: Novo valor do v-model
|
|
101
|
+
level:
|
|
102
|
+
desc: Novo valor do v-model:currentLevel
|
|
103
103
|
type: Boolean
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<qas-box class="q-px-lg q-py-md">
|
|
3
3
|
<q-table ref="table" class="bg-white qas-table-generator text-grey-8" :class="tableClass" v-bind="attributes">
|
|
4
|
-
<template v-for="(_, name) in
|
|
5
|
-
<slot
|
|
4
|
+
<template v-for="(_, name) in slots" #[name]="context">
|
|
5
|
+
<slot :name="name" v-bind="context" />
|
|
6
|
+
</template>
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
<template v-for="(fieldName, index) in bodyCellNameSlots" :key="index" #[`body-cell-${fieldName}`]="context">
|
|
9
|
+
<q-td>
|
|
10
|
+
<component :is="tdChildComponent" v-bind="getTdChildComponentProps(context.row)">
|
|
11
|
+
<slot :name="`body-cell-${fieldName}`" v-bind="context || {}">
|
|
12
|
+
{{ context.row?.[fieldName] }}
|
|
13
|
+
</slot>
|
|
14
|
+
</component>
|
|
9
15
|
</q-td>
|
|
10
16
|
</template>
|
|
11
17
|
</q-table>
|
|
@@ -26,6 +32,11 @@ export default {
|
|
|
26
32
|
type: Array
|
|
27
33
|
},
|
|
28
34
|
|
|
35
|
+
rowRouteFn: {
|
|
36
|
+
type: Function,
|
|
37
|
+
default: undefined
|
|
38
|
+
},
|
|
39
|
+
|
|
29
40
|
fields: {
|
|
30
41
|
default: () => ({}),
|
|
31
42
|
type: [Array, Object]
|
|
@@ -50,6 +61,10 @@ export default {
|
|
|
50
61
|
useScrollOnGrab: {
|
|
51
62
|
type: Boolean,
|
|
52
63
|
default: true
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
useExternalLink: {
|
|
67
|
+
type: Boolean
|
|
53
68
|
}
|
|
54
69
|
},
|
|
55
70
|
|
|
@@ -63,6 +78,36 @@ export default {
|
|
|
63
78
|
},
|
|
64
79
|
|
|
65
80
|
computed: {
|
|
81
|
+
tdChildComponent () {
|
|
82
|
+
if (this.useExternalLink) return 'a'
|
|
83
|
+
|
|
84
|
+
return this.rowRouteFn ? 'router-link' : 'span'
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
bodyCellNameSlots () {
|
|
88
|
+
if (this.hasBodyCellSlot) return []
|
|
89
|
+
|
|
90
|
+
return this.columns.length
|
|
91
|
+
? this.columns.map(column => typeof column === 'object' ? column.name : column)
|
|
92
|
+
: Object.keys(this.fields)
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
slots () {
|
|
96
|
+
const slots = {}
|
|
97
|
+
|
|
98
|
+
for (const slotKey in this.$slots) {
|
|
99
|
+
if (slotKey.includes('body-cell-')) continue
|
|
100
|
+
|
|
101
|
+
slots[slotKey] = this.$slots[slotKey]
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return slots
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
hasBodyCellSlot () {
|
|
108
|
+
return !!this.$slots['body-cell']
|
|
109
|
+
},
|
|
110
|
+
|
|
66
111
|
attributes () {
|
|
67
112
|
const attributes = {
|
|
68
113
|
columns: this.columnsByFields,
|
|
@@ -123,14 +168,6 @@ export default {
|
|
|
123
168
|
return columns
|
|
124
169
|
},
|
|
125
170
|
|
|
126
|
-
hasBodySlot () {
|
|
127
|
-
return !!this.$slots.body
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
hasTbodySlot () {
|
|
131
|
-
return !!this.$slots.tbody
|
|
132
|
-
},
|
|
133
|
-
|
|
134
171
|
hasFields () {
|
|
135
172
|
return Object.keys(this.fields).length
|
|
136
173
|
},
|
|
@@ -164,6 +201,10 @@ export default {
|
|
|
164
201
|
|
|
165
202
|
hasScrollOnGrab () {
|
|
166
203
|
return !!Object.keys(this.scrollOnGrab).length
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
isScrolling () {
|
|
207
|
+
return this.hasScrollOnGrab && this.scrollOnGrab.haveMoved()
|
|
167
208
|
}
|
|
168
209
|
},
|
|
169
210
|
|
|
@@ -223,11 +264,6 @@ export default {
|
|
|
223
264
|
}
|
|
224
265
|
},
|
|
225
266
|
|
|
226
|
-
onRowClick () {
|
|
227
|
-
if (this.hasScrollOnGrab && this.scrollOnGrab.haveMoved()) return
|
|
228
|
-
this.$attrs.onRowClick(...arguments)
|
|
229
|
-
},
|
|
230
|
-
|
|
231
267
|
setObserver () {
|
|
232
268
|
this.elementToObserve = this.getTableElement()
|
|
233
269
|
this.resizeObserver = new ResizeObserver(entries => {
|
|
@@ -239,6 +275,27 @@ export default {
|
|
|
239
275
|
|
|
240
276
|
destroyObserver () {
|
|
241
277
|
this.resizeObserver.unobserve(this.elementToObserve)
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
getTdChildComponentProps (row) {
|
|
281
|
+
if (!this.rowRouteFn) return
|
|
282
|
+
|
|
283
|
+
return {
|
|
284
|
+
class: 'text-no-decoration text-grey-8 flex full-width items-center full-height',
|
|
285
|
+
[this.useExternalLink ? 'href' : 'to']: this.rowRouteFn(row),
|
|
286
|
+
onClick: this.onRowClickHandler,
|
|
287
|
+
...(this.useExternalLink && { target: '_blank' })
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
|
|
291
|
+
onRowClickHandler (event) {
|
|
292
|
+
if (this.isScrolling) return event.preventDefault()
|
|
293
|
+
},
|
|
294
|
+
|
|
295
|
+
onRowClick () {
|
|
296
|
+
if (this.isScrolling) return
|
|
297
|
+
|
|
298
|
+
this.$attrs.onRowClick(...arguments)
|
|
242
299
|
}
|
|
243
300
|
}
|
|
244
301
|
}
|
|
@@ -36,6 +36,16 @@ props:
|
|
|
36
36
|
default: true
|
|
37
37
|
type: Boolean
|
|
38
38
|
|
|
39
|
+
row-route-fn:
|
|
40
|
+
desc: Usado quando há a necessidade de alteração de rota ao clicar em um item da tabela(a linha passa ser um <a> habilitando a opção de abrir em uma nova aba).
|
|
41
|
+
type: Function
|
|
42
|
+
examples: ["() => ({ name: 'UsersList' })"]
|
|
43
|
+
|
|
44
|
+
use-external-link:
|
|
45
|
+
desc: Usado em conjunto com a prop "row-route-fn" quando há a necessidade da rota ser um link externo.
|
|
46
|
+
default: false
|
|
47
|
+
type: Boolean
|
|
48
|
+
|
|
39
49
|
slots:
|
|
40
50
|
body:
|
|
41
51
|
desc: Acesso direto dentro do `tbody`.
|
package/src/mixins/password.js
CHANGED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Dialog, NotifySuccess, NotifyError } from 'asteroid'
|
|
2
|
+
import { Loading } from 'quasar'
|
|
3
|
+
import { getAction } from '@bildvitta/store-adapter'
|
|
4
|
+
import { useHistory } from '../../composables'
|
|
5
|
+
|
|
6
|
+
export default function (config = {}) {
|
|
7
|
+
const {
|
|
8
|
+
dialogProps = {},
|
|
9
|
+
deleteActionParams = {},
|
|
10
|
+
useAutoDeleteRoute,
|
|
11
|
+
|
|
12
|
+
// callbacks
|
|
13
|
+
onDelete = () => {},
|
|
14
|
+
onDeleteError = () => {},
|
|
15
|
+
onDeleteSuccess = () => {},
|
|
16
|
+
deleteAction
|
|
17
|
+
} = config
|
|
18
|
+
|
|
19
|
+
const { entity, id, url } = deleteActionParams
|
|
20
|
+
|
|
21
|
+
const defaultDialogProps = {
|
|
22
|
+
card: { description: 'Tem certeza que deseja excluir este item?' },
|
|
23
|
+
|
|
24
|
+
ok: { label: 'Excluir', onClick: () => destroy.call(this) },
|
|
25
|
+
|
|
26
|
+
...dialogProps
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const defaultNotifyMessages = {
|
|
30
|
+
error: 'Não conseguimos excluir as informações. Por favor, tente novamente em alguns minutos.',
|
|
31
|
+
success: 'Informações excluídas com sucesso.'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function destroy () {
|
|
35
|
+
Loading.show()
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
onDelete(true)
|
|
39
|
+
|
|
40
|
+
const hasDeleteAction = typeof deleteAction === 'function'
|
|
41
|
+
|
|
42
|
+
const payload = { id, url }
|
|
43
|
+
const destroyActionParams = { entity, key: 'destroy', payload }
|
|
44
|
+
|
|
45
|
+
const response = hasDeleteAction
|
|
46
|
+
? await deleteAction(payload)
|
|
47
|
+
: await getAction.call(this, destroyActionParams)
|
|
48
|
+
|
|
49
|
+
NotifySuccess(defaultNotifyMessages.success)
|
|
50
|
+
|
|
51
|
+
if (useAutoDeleteRoute) {
|
|
52
|
+
const { destroyRoutes, history } = useHistory()
|
|
53
|
+
|
|
54
|
+
// remove todas rotas que possuem o id do item excluído.
|
|
55
|
+
const routesToBeDeleted = getRoutesToBeDeletedById(history.list)
|
|
56
|
+
destroyRoutes(routesToBeDeleted)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// cria um evento para notificar que o item foi excluído no "window".
|
|
60
|
+
createDeleteSuccessEvent()
|
|
61
|
+
|
|
62
|
+
onDeleteSuccess(response)
|
|
63
|
+
} catch (error) {
|
|
64
|
+
onDeleteError(error)
|
|
65
|
+
|
|
66
|
+
NotifyError(defaultNotifyMessages.error)
|
|
67
|
+
} finally {
|
|
68
|
+
onDelete(false)
|
|
69
|
+
|
|
70
|
+
Loading.hide()
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function getRoutesToBeDeletedById (routes = []) {
|
|
75
|
+
return routes.filter(({ params }) => params.id === id)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function createDeleteSuccessEvent () {
|
|
79
|
+
const event = new CustomEvent('delete-success', {
|
|
80
|
+
bubbles: false,
|
|
81
|
+
cancelable: false,
|
|
82
|
+
detail: deleteActionParams
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
window.dispatchEvent(event)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
Dialog(defaultDialogProps)
|
|
89
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
type: component
|
|
2
|
+
|
|
3
|
+
meta:
|
|
4
|
+
desc: Plugin que implementa a action `destroy` do `StoreModule` adicionando comportamento de confirmação antes de excluir, este mesmo plugin é utilizado no componente `QasDelete`.
|
|
5
|
+
|
|
6
|
+
inject:
|
|
7
|
+
'this.$qas.delete(config)':
|
|
8
|
+
params:
|
|
9
|
+
config:
|
|
10
|
+
type: Object
|
|
11
|
+
desc: Objeto de configuração do plugin.
|
|
12
|
+
params:
|
|
13
|
+
dialogProps:
|
|
14
|
+
type: Object
|
|
15
|
+
desc: Propriedades repassadas para o "QasDialog".
|
|
16
|
+
|
|
17
|
+
deleteActionParams:
|
|
18
|
+
type: Object
|
|
19
|
+
desc: Propriedades de configuração da action destroy.
|
|
20
|
+
params:
|
|
21
|
+
entity:
|
|
22
|
+
type: String
|
|
23
|
+
desc: entidade da store.
|
|
24
|
+
default: ''
|
|
25
|
+
|
|
26
|
+
id:
|
|
27
|
+
type: String
|
|
28
|
+
desc: Identificador (id, uuid, slug) do item a ser deletado.
|
|
29
|
+
default: ''
|
|
30
|
+
|
|
31
|
+
url:
|
|
32
|
+
type: String
|
|
33
|
+
desc: URL do endpoint do item a ser deletado.
|
|
34
|
+
default: ''
|
|
35
|
+
|
|
36
|
+
'onDelete -> function (isDeleting)':
|
|
37
|
+
type: Function
|
|
38
|
+
desc: Este callback é chamado quando inicializa a ação de deleção e quando finaliza, independente se der erro ou sucesso.
|
|
39
|
+
params:
|
|
40
|
+
isDeleting:
|
|
41
|
+
type: Boolean
|
|
42
|
+
desc: Retorna "true" caso esteja ocorrendo a ação de deleção e "false" quando finalizada.
|
|
43
|
+
default: false
|
|
44
|
+
|
|
45
|
+
'onDeleteError -> function (error)':
|
|
46
|
+
type: Function
|
|
47
|
+
desc: Este callback é chamado quando a ação de deleção é finalizada com erro.
|
|
48
|
+
params:
|
|
49
|
+
error:
|
|
50
|
+
type: Object
|
|
51
|
+
desc: Objeto de retorno de erro
|
|
52
|
+
default: {}
|
|
53
|
+
|
|
54
|
+
'onDeleteSuccess -> function (response)':
|
|
55
|
+
type: Function
|
|
56
|
+
desc: Este callback é chamado quando a ação de deleção é finalizada com sucesso.
|
|
57
|
+
params:
|
|
58
|
+
error:
|
|
59
|
+
type: Object
|
|
60
|
+
desc: Objeto de resposta da API
|
|
61
|
+
default: {}
|
|
62
|
+
|
|
63
|
+
'deleteAction -> function (deleteActionParams) || undefined':
|
|
64
|
+
type: [Function, undefined]
|
|
65
|
+
desc: Quando utilizado este plugin fora de componentes vue, não temos acesso ao contexto "this", neste caso é necessário passar a action "destroy" que deseja executar, é neste momento que o callback é chamado / utilizado, caso esteja dentro do componente vue, não repasse esse callback.
|
|
66
|
+
params:
|
|
67
|
+
error:
|
|
68
|
+
type: Object
|
|
69
|
+
desc: Objeto deleteActionParams enviado anteriormente como configuração do plugin Delete.
|
|
70
|
+
default: {}
|
|
71
|
+
examples: ["{ ..., deleteAction: params => useUsers.destroy(params) }"]
|
package/src/plugins/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Delete from './delete/Delete.js'
|
|
1
2
|
import Dialog from './dialog/Dialog.js'
|
|
2
3
|
import Logger from './logger/Logger.js'
|
|
3
4
|
import NotifyError from './notify-error/NotifyError.js'
|
|
@@ -5,6 +6,7 @@ import NotifySuccess from './notify-success/NotifySuccess.js'
|
|
|
5
6
|
import Screen from './screen/Screen.js'
|
|
6
7
|
|
|
7
8
|
export {
|
|
9
|
+
Delete,
|
|
8
10
|
Dialog,
|
|
9
11
|
Logger,
|
|
10
12
|
NotifyError,
|