@bildvitta/quasar-ui-asteroid 2.14.0 → 3.0.0-alpha.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/dist/api/QasBox.json +16 -0
- package/dist/api/QasBreakline.json +32 -0
- package/dist/api/QasBtn.json +15 -0
- package/dist/api/QasDebugger.json +13 -0
- package/dist/asteroid.cjs.css +1 -1
- package/dist/asteroid.cjs.js +6762 -1400
- package/dist/asteroid.cjs.min.js +2 -2
- package/dist/asteroid.esm.css +1 -1
- package/dist/asteroid.esm.js +6764 -1405
- package/dist/asteroid.esm.min.js +2 -2
- package/dist/asteroid.umd.css +1 -1
- package/dist/asteroid.umd.js +6760 -1405
- package/dist/asteroid.umd.min.js +2 -2
- package/dist/vetur/asteroid-attributes.json +16 -0
- package/dist/vetur/asteroid-tags.json +19 -0
- package/package.json +41 -56
- package/src/assets/logo-modular.svg +1 -1
- package/src/asteroid.js +1 -0
- package/src/components/actions/QasActions.vue +45 -0
- package/src/components/actions-menu/QasActionsMenu.vue +8 -19
- package/src/components/alert/QasAlert.vue +90 -0
- package/src/components/app-bar/QasAppBar.vue +16 -13
- package/src/components/app-menu/QasAppMenu.vue +10 -7
- package/src/components/avatar/QasAvatar.vue +7 -3
- package/src/components/box/QasBox.vue +12 -4
- package/src/components/box/QasBox.yml +13 -0
- package/src/components/breakline/QasBreakline.vue +37 -0
- package/src/components/breakline/QasBreakline.yml +25 -0
- package/src/components/btn/QasBtn.vue +27 -24
- package/src/components/btn/QasBtn.yml +12 -0
- package/src/components/card/QasCard.vue +29 -21
- package/src/components/checkbox-group/QasCheckboxGroup.vue +31 -17
- package/src/components/copy/QasCopy.vue +22 -11
- package/src/components/date-time-input/QasDateTimeInput.vue +16 -26
- package/src/components/debugger/QasDebugger.vue +2 -0
- package/src/components/debugger/QasDebugger.yml +10 -0
- package/src/components/delete/QasDelete.vue +28 -15
- package/src/components/dialog/QasDialog.vue +71 -67
- package/src/components/dialog-router/QasDialogRouter.vue +12 -4
- package/src/components/field/QasField.vue +16 -19
- package/src/components/filters/QasFilters.vue +31 -24
- package/src/components/form-generator/QasFormGenerator.vue +13 -15
- package/src/components/form-view/QasFormView.vue +117 -66
- package/src/components/gallery/QasGallery.vue +39 -26
- package/src/components/grid-generator/QasGridGenerator.vue +12 -6
- package/src/components/index.js +0 -0
- package/src/components/input/QasInput.vue +38 -36
- package/src/components/label/QasLabel.vue +14 -15
- package/src/components/layout/QasLayout.vue +13 -21
- package/src/components/list-items/QasListItems.vue +16 -8
- package/src/components/list-view/QasListView.vue +31 -28
- package/src/components/map/QasMap.vue +15 -25
- package/src/components/nested-fields/QasNestedFields.vue +39 -36
- package/src/components/numeric-input/QasNumericInput.vue +24 -21
- package/src/components/page-header/QasPageHeader.vue +19 -10
- package/src/components/password-input/QasPasswordInput.vue +20 -18
- package/src/components/password-strength-checker/QasPasswordStrengthChecker.vue +52 -31
- package/src/components/profile/QasProfile.vue +14 -12
- package/src/components/resizer/QasResizer.vue +1 -1
- package/src/components/search-box/QasSearchBox.vue +36 -20
- package/src/components/select/QasSelect.vue +41 -44
- package/src/components/select-list/QasSelectList.vue +64 -51
- package/src/components/signature-pad/QasSignaturePad.vue +57 -41
- package/src/components/signature-uploader/QasSignatureUploader.vue +15 -13
- package/src/components/single-view/QasSingleView.vue +31 -17
- package/src/components/sortable/QasSortable.vue +45 -27
- package/src/components/table-generator/QasTableGenerator.vue +95 -22
- package/src/components/tabs-generator/QasTabsGenerator.vue +36 -24
- package/src/components/text-truncate/QasTextTruncate.vue +25 -17
- package/src/components/transfer/QasTransfer.vue +57 -53
- package/src/components/uploader/QasUploader.vue +169 -48
- package/src/css/background.scss +1 -1
- package/src/css/border.scss +7 -6
- package/src/css/design-system.scss +0 -43
- package/src/css/fonts.scss +2 -28
- package/src/css/opacity.scss +0 -4
- package/src/css/set-brand.scss +15 -0
- package/src/css/transitions.scss +1 -1
- package/src/helpers/add-counter-suffix.js +3 -0
- package/src/helpers/{base64ToBlob.js → base-64-to-blob.js} +0 -0
- package/src/helpers/{constructObject.js → construct-object.js} +0 -0
- package/src/helpers/filter-object.js +8 -6
- package/src/helpers/filters.js +2 -3
- package/src/helpers/get-slot-children-text.js +15 -0
- package/src/helpers/{greatestCommonDivisor.js → greatest-common-divisor.js} +0 -0
- package/src/helpers/images.js +28 -0
- package/src/helpers/index.js +11 -59
- package/src/helpers/{isLocalDevelopment.js → is-local-development.js} +0 -0
- package/src/helpers/scroll-on-grap.js +61 -0
- package/src/index.cjs.js +1 -0
- package/src/index.esm.js +4 -0
- package/src/index.scss +19 -21
- package/src/index.umd.js +2 -0
- package/src/mixins/context.js +1 -1
- package/src/mixins/dialog-router.js +17 -0
- package/src/mixins/form.js +4 -12
- package/src/mixins/generator.js +14 -14
- package/src/mixins/index.js +2 -8
- package/src/mixins/password.js +73 -11
- package/src/mixins/screen.js +8 -6
- package/src/mixins/view.js +57 -20
- package/src/plugins/Dialog.js +14 -0
- package/src/plugins/NotifySuccess.js +3 -3
- package/src/plugins/index.js +4 -2
- package/src/store/history.js +43 -0
- package/src/store/index.js +1 -0
- package/src/vue-plugin.js +185 -0
- package/.babelrc +0 -12
- package/.storybook/main.js +0 -35
- package/.storybook/preview.js +0 -26
- package/debug.log +0 -1
- package/index.js +0 -4
- package/jest-setup.js +0 -1
- package/jest.config.json +0 -22
- package/postcss.config.js +0 -5
- package/src/components/Introduction.stories.mdx +0 -12
- package/src/components/actions-menu/QasActionsMenu.stories.js +0 -73
- package/src/components/app-bar/QasAppBar.stories.js +0 -84
- package/src/components/app-menu/QasAppMenu.stories.js +0 -66
- package/src/components/apps-menu/QasAppsMenu.spec.js +0 -58
- package/src/components/apps-menu/QasAppsMenu.stories.js +0 -54
- package/src/components/apps-menu/QasAppsMenu.vue +0 -48
- package/src/components/avatar/QasAvatar.spec.js +0 -14
- package/src/components/avatar/QasAvatar.stories.js +0 -52
- package/src/components/box/QasBox.spec.js +0 -18
- package/src/components/box/QasBox.stories.js +0 -35
- package/src/components/break-line/QasBreakLine.stories.js +0 -57
- package/src/components/break-line/QasBreakLine.vue +0 -52
- package/src/components/btn/QasBtn.stories.js +0 -45
- package/src/components/btn-actions/QasBtnActions.stories.js +0 -77
- package/src/components/btn-actions/QasBtnActions.vue +0 -54
- package/src/components/card/QasCard.stories.js +0 -126
- package/src/components/checkbox-group/QasCheckboxGroup.stories.js +0 -59
- package/src/components/copy/QasCopy.stories.js +0 -41
- package/src/components/date-time-input/QasDateTimeInput.stories.js +0 -67
- package/src/components/debugger/QasDebugger.stories.js +0 -33
- package/src/components/delete/QasDelete.stories.js +0 -80
- package/src/components/dialog/QasDialog.stories.js +0 -139
- package/src/components/dialog-router/QasDialogRouter.stories.js +0 -38
- package/src/components/field/QasField.stories.js +0 -181
- package/src/components/filters/QasFilters.stories.js +0 -121
- package/src/components/form-generator/QasFormGenerator.stories.js +0 -115
- package/src/components/form-view/QasFormView.stories.js +0 -236
- package/src/components/gallery/QasGallery.stories.js +0 -91
- package/src/components/grid-generator/QasGridGenerator.stories.js +0 -138
- package/src/components/input/QasInput.stories.js +0 -78
- package/src/components/label/QasLabel.stories.js +0 -60
- package/src/components/layout/QasLayout.stories.js +0 -104
- package/src/components/list-items/QasListItems.stories.js +0 -130
- package/src/components/list-view/QasListView.stories.js +0 -168
- package/src/components/map/QasMap.stories.js +0 -75
- package/src/components/nested-fields/QasNestedFields.stories.js +0 -255
- package/src/components/numeric-input/QasNumericInput.stories.js +0 -92
- package/src/components/page-header/QasPageHeader.stories.js +0 -61
- package/src/components/password-input/QasPasswordInput.stories.js +0 -76
- package/src/components/password-strength-checker/QasPasswordStrengthChecker.stories.js +0 -54
- package/src/components/profile/QasProfile.stories.js +0 -131
- package/src/components/resizer/QasResizer.stories.js +0 -43
- package/src/components/search-box/QasSearchBox.stories.js +0 -111
- package/src/components/select/QasSelect.stories.js +0 -113
- package/src/components/select-list/QasSelectList.stories.js +0 -153
- package/src/components/signature-pad/QasSignaturePad.stories.js +0 -51
- package/src/components/signature-uploader/QasSignatureUploader.stories.js +0 -69
- package/src/components/single-view/QasSingleView.stories.js +0 -130
- package/src/components/sortable/QasSortable.stories.js +0 -80
- package/src/components/table-generator/QasTableGenerator.stories.js +0 -116
- package/src/components/tabs-generator/QasTabsGenerator.stories.js +0 -145
- package/src/components/text-truncate/QasTextTruncate.stories.js +0 -55
- package/src/components/tip/QasTip.stories.js +0 -57
- package/src/components/tip/QasTip.vue +0 -68
- package/src/components/tooltip/QasTooltip.stories.js +0 -63
- package/src/components/tooltip/QasTooltip.vue +0 -81
- package/src/components/transfer/QasTransfer.stories.js +0 -118
- package/src/components/uploader/QasCustomUploader.vue +0 -121
- package/src/components/uploader/QasUploader.stories.js +0 -139
- package/src/directives/Test.js +0 -13
- package/src/helpers/historyHandler.js +0 -52
- package/src/helpers/label.js +0 -3
- package/src/index.js +0 -249
- package/src/mixins/map-markers.js +0 -26
- package/src/mixins/unsaved-changes.js +0 -24
- package/src/mixins/uploader.js +0 -30
- package/src/mocks/json/user.json +0 -27
- package/src/mocks/json/users-new.json +0 -23
- package/src/mocks/json/users.json +0 -97
- package/src/mocks/storeModule.js +0 -71
- package/src/pages/Forbidden.vue +0 -6
- package/src/pages/NotFound.vue +0 -6
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<q-dialog ref="dialog"
|
|
2
|
+
<q-dialog ref="dialog" :persistent="persistent" v-bind="dialogProps" @hide="onDialogHide" @update:model-value="updateModelValue">
|
|
3
3
|
<q-card v-bind="cardProps" class="q-pa-sm" :style="style">
|
|
4
4
|
<q-card-section>
|
|
5
5
|
<slot name="header">
|
|
6
|
-
<div class="
|
|
6
|
+
<div class="justify-between row">
|
|
7
|
+
<div class="text-bold text-h6">{{ card.title }}</div>
|
|
8
|
+
<qas-btn v-if="useCloseIcon" v-close-popup dense flat icon="o_close" rounded />
|
|
9
|
+
</div>
|
|
7
10
|
</slot>
|
|
8
11
|
</q-card-section>
|
|
9
12
|
|
|
@@ -17,14 +20,15 @@
|
|
|
17
20
|
|
|
18
21
|
<q-card-section>
|
|
19
22
|
<slot name="actions">
|
|
20
|
-
<qas-
|
|
23
|
+
<qas-actions v-bind="btnActionsProps">
|
|
21
24
|
<template #primary>
|
|
22
|
-
<qas-btn v-if="ok" v-close-popup="!useForm" class="full-width" v-bind="defaultOk
|
|
25
|
+
<qas-btn v-if="ok" v-close-popup="!useForm" class="full-width" v-bind="defaultOk" @click="submitHandler" />
|
|
23
26
|
</template>
|
|
27
|
+
|
|
24
28
|
<template #secondary>
|
|
25
|
-
<qas-btn v-if="cancel" v-close-popup class="full-width" v-bind="defaultCancel
|
|
29
|
+
<qas-btn v-if="cancel" v-close-popup class="full-width" v-bind="defaultCancel" />
|
|
26
30
|
</template>
|
|
27
|
-
</qas-
|
|
31
|
+
</qas-actions>
|
|
28
32
|
</slot>
|
|
29
33
|
</q-card-section>
|
|
30
34
|
</q-card>
|
|
@@ -33,23 +37,29 @@
|
|
|
33
37
|
|
|
34
38
|
<script>
|
|
35
39
|
import QasBtn from '../btn/QasBtn.vue'
|
|
36
|
-
import
|
|
40
|
+
import QasActions from '../actions/QasActions.vue'
|
|
41
|
+
|
|
42
|
+
import screenMixin from '../../mixins/screen'
|
|
37
43
|
|
|
38
44
|
export default {
|
|
45
|
+
name: 'QasDialog',
|
|
46
|
+
|
|
39
47
|
components: {
|
|
40
48
|
QasBtn,
|
|
41
|
-
|
|
49
|
+
QasActions
|
|
42
50
|
},
|
|
43
51
|
|
|
52
|
+
mixins: [screenMixin],
|
|
53
|
+
|
|
44
54
|
props: {
|
|
45
|
-
|
|
55
|
+
btnActionsProps: {
|
|
46
56
|
default: () => ({}),
|
|
47
57
|
type: Object
|
|
48
58
|
},
|
|
49
59
|
|
|
50
60
|
cancel: {
|
|
51
61
|
default: () => ({}),
|
|
52
|
-
type: [
|
|
62
|
+
type: [Object, Boolean]
|
|
53
63
|
},
|
|
54
64
|
|
|
55
65
|
card: {
|
|
@@ -74,7 +84,7 @@ export default {
|
|
|
74
84
|
|
|
75
85
|
ok: {
|
|
76
86
|
default: () => ({}),
|
|
77
|
-
type: [
|
|
87
|
+
type: [Object, Boolean]
|
|
78
88
|
},
|
|
79
89
|
|
|
80
90
|
persistent: {
|
|
@@ -86,91 +96,85 @@ export default {
|
|
|
86
96
|
type: Boolean
|
|
87
97
|
},
|
|
88
98
|
|
|
89
|
-
|
|
99
|
+
modelValue: {
|
|
90
100
|
type: Boolean
|
|
91
|
-
}
|
|
92
|
-
},
|
|
101
|
+
},
|
|
93
102
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
show: null,
|
|
101
|
-
toggle: null
|
|
102
|
-
}
|
|
103
|
+
usePlugin: {
|
|
104
|
+
type: Boolean
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
useCloseIcon: {
|
|
108
|
+
type: Boolean
|
|
103
109
|
}
|
|
104
110
|
},
|
|
105
111
|
|
|
112
|
+
emits: [
|
|
113
|
+
'update:modelValue',
|
|
114
|
+
'validate',
|
|
115
|
+
'ok',
|
|
116
|
+
'hide',
|
|
117
|
+
'update:open'
|
|
118
|
+
],
|
|
119
|
+
|
|
106
120
|
computed: {
|
|
107
121
|
defaultCancel () {
|
|
108
122
|
return {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
props
|
|
112
|
-
label: 'Cancelar',
|
|
113
|
-
outline: true,
|
|
114
|
-
...this.cancel?.props
|
|
115
|
-
}
|
|
123
|
+
label: 'Cancelar',
|
|
124
|
+
outline: true,
|
|
125
|
+
...this.cancel?.props
|
|
116
126
|
}
|
|
117
127
|
},
|
|
118
128
|
|
|
119
|
-
defaultDialogMethods () {
|
|
120
|
-
return this.dialogMethods
|
|
121
|
-
},
|
|
122
|
-
|
|
123
129
|
defaultOk () {
|
|
124
130
|
return {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
props
|
|
128
|
-
label: 'Ok',
|
|
129
|
-
type: this.ok?.props.type || this.useForm ? 'submit' : 'button',
|
|
130
|
-
...this.ok?.props
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
isSmallScreen () {
|
|
136
|
-
return this.$q.screen.xs
|
|
137
|
-
},
|
|
138
|
-
|
|
139
|
-
model: {
|
|
140
|
-
get () {
|
|
141
|
-
return this.value
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
set (value) {
|
|
145
|
-
return this.$emit('input', value)
|
|
131
|
+
label: 'Ok',
|
|
132
|
+
type: this.ok?.props?.type || this.useForm ? 'submit' : 'button',
|
|
133
|
+
...this.ok?.props
|
|
146
134
|
}
|
|
147
135
|
},
|
|
148
136
|
|
|
149
137
|
style () {
|
|
150
138
|
return {
|
|
151
|
-
maxWidth: this.maxWidth || (this.
|
|
152
|
-
minWidth: this.minWidth || (this.
|
|
139
|
+
maxWidth: this.maxWidth || (this.mx_isSmall ? '' : '600px'),
|
|
140
|
+
minWidth: this.minWidth || (this.mx_isSmall ? '' : '400px')
|
|
153
141
|
}
|
|
154
142
|
},
|
|
155
143
|
|
|
156
144
|
componentTag () {
|
|
157
145
|
return this.useForm ? 'q-form' : 'div'
|
|
158
|
-
}
|
|
159
|
-
},
|
|
146
|
+
},
|
|
160
147
|
|
|
161
|
-
|
|
162
|
-
|
|
148
|
+
dialogProps () {
|
|
149
|
+
return {
|
|
150
|
+
...(!this.usePlugin && { modelValue: this.modelValue }),
|
|
151
|
+
...this.$attrs
|
|
152
|
+
}
|
|
153
|
+
}
|
|
163
154
|
},
|
|
164
155
|
|
|
165
156
|
methods: {
|
|
166
|
-
setDialogMethods () {
|
|
167
|
-
for (const key in this.dialogMethods) {
|
|
168
|
-
this.dialogMethods[key] = this.$refs.dialog[key]
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
|
|
172
157
|
async submitHandler () {
|
|
173
158
|
this.useForm && this.$emit('validate', await this.$refs.form.validate())
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
// metodo para funcionar como plugin
|
|
162
|
+
show () {
|
|
163
|
+
this.$refs.dialog.show()
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
// metodo para funcionar como plugin
|
|
167
|
+
hide () {
|
|
168
|
+
this.$refs.dialog.hide()
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
// metodo para funcionar como plugin
|
|
172
|
+
onDialogHide () {
|
|
173
|
+
this.$emit('hide')
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
updateModelValue (value) {
|
|
177
|
+
this.$emit('update:modelValue', value)
|
|
174
178
|
}
|
|
175
179
|
}
|
|
176
180
|
}
|
|
@@ -9,10 +9,15 @@
|
|
|
9
9
|
</template>
|
|
10
10
|
|
|
11
11
|
<script>
|
|
12
|
-
import {
|
|
12
|
+
import { markRaw } from 'vue'
|
|
13
|
+
import { Loading, extend } from 'quasar'
|
|
13
14
|
import { NotifyError } from '../../plugins'
|
|
14
15
|
|
|
15
16
|
export default {
|
|
17
|
+
name: 'QasDialogRouter',
|
|
18
|
+
|
|
19
|
+
emits: ['error', 'hide'],
|
|
20
|
+
|
|
16
21
|
data () {
|
|
17
22
|
return {
|
|
18
23
|
component: null,
|
|
@@ -39,7 +44,7 @@ export default {
|
|
|
39
44
|
},
|
|
40
45
|
|
|
41
46
|
resolveRoute (path) {
|
|
42
|
-
return this.$router.resolve(path)
|
|
47
|
+
return this.$router.resolve(path)
|
|
43
48
|
},
|
|
44
49
|
|
|
45
50
|
async show (route) {
|
|
@@ -52,9 +57,12 @@ export default {
|
|
|
52
57
|
|
|
53
58
|
try {
|
|
54
59
|
Loading.show()
|
|
55
|
-
const component = [...this.route.matched].pop().components.default
|
|
56
60
|
|
|
57
|
-
|
|
61
|
+
const component = markRaw(
|
|
62
|
+
extend(true, {}, [...this.route.matched].pop().components.default)
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
if (typeof component.value !== 'function') {
|
|
58
66
|
this.component = component
|
|
59
67
|
this.$refs.dialog.show()
|
|
60
68
|
} else {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<component :is="component.is" v-bind="component" :data-cy="field.name" :value="formattedValue"
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
<slot :name="key" v-bind="scope" />
|
|
3
|
+
<component :is="component.is" v-bind="component" :data-cy="field.name" :model-value="formattedValue" @update:model-value="updateModel">
|
|
4
|
+
<template v-for="(_, name) in $slots" #[name]="context">
|
|
5
|
+
<slot :name="name" v-bind="context || {}" />
|
|
7
6
|
</template>
|
|
8
7
|
</component>
|
|
9
8
|
</div>
|
|
@@ -47,9 +46,16 @@ export default {
|
|
|
47
46
|
default: () => ({}),
|
|
48
47
|
required: true,
|
|
49
48
|
type: Object
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
modelValue: {
|
|
52
|
+
default: undefined,
|
|
53
|
+
type: [Object, Array, String, Number, Boolean]
|
|
50
54
|
}
|
|
51
55
|
},
|
|
52
56
|
|
|
57
|
+
emits: ['update:modelValue'],
|
|
58
|
+
|
|
53
59
|
computed: {
|
|
54
60
|
component () {
|
|
55
61
|
const {
|
|
@@ -148,11 +154,6 @@ export default {
|
|
|
148
154
|
return Array.isArray(this.error) ? this.error.join(' ') : this.error
|
|
149
155
|
},
|
|
150
156
|
|
|
151
|
-
events () {
|
|
152
|
-
const { input, ...events } = this.$listeners
|
|
153
|
-
return events
|
|
154
|
-
},
|
|
155
|
-
|
|
156
157
|
// This computed will change the key name when the server sends different key.
|
|
157
158
|
formatedField () {
|
|
158
159
|
const field = {}
|
|
@@ -165,17 +166,15 @@ export default {
|
|
|
165
166
|
},
|
|
166
167
|
|
|
167
168
|
formattedValue () {
|
|
168
|
-
const { value } = this.$attrs
|
|
169
|
-
|
|
170
169
|
if (!this.isBoolean) {
|
|
171
|
-
return
|
|
170
|
+
return this.modelValue
|
|
172
171
|
}
|
|
173
172
|
|
|
174
173
|
if (this.isEmptyValue) {
|
|
175
|
-
return !!
|
|
174
|
+
return !!this.modelValue
|
|
176
175
|
}
|
|
177
176
|
|
|
178
|
-
return JSON.parse(
|
|
177
|
+
return JSON.parse(this.modelValue)
|
|
179
178
|
},
|
|
180
179
|
|
|
181
180
|
hasError () {
|
|
@@ -187,13 +186,11 @@ export default {
|
|
|
187
186
|
},
|
|
188
187
|
|
|
189
188
|
isEmptyValue () {
|
|
190
|
-
const { value } = this.$attrs
|
|
191
|
-
|
|
192
189
|
if (!this.isBoolean) {
|
|
193
190
|
return false
|
|
194
191
|
}
|
|
195
192
|
|
|
196
|
-
return !this.
|
|
193
|
+
return !this.modelValue && (this.modelValue === undefined || typeof this.modelValue === 'string')
|
|
197
194
|
},
|
|
198
195
|
|
|
199
196
|
isNumberType () {
|
|
@@ -202,8 +199,8 @@ export default {
|
|
|
202
199
|
},
|
|
203
200
|
|
|
204
201
|
methods: {
|
|
205
|
-
|
|
206
|
-
this.$emit('
|
|
202
|
+
updateModel (value) {
|
|
203
|
+
this.$emit('update:modelValue', this.isNumberType ? Number(value) : value)
|
|
207
204
|
}
|
|
208
205
|
}
|
|
209
206
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<div v-if="showFilters" class="q-gutter-x-md row">
|
|
4
4
|
<div v-if="showSearch" class="col">
|
|
5
5
|
<slot :filter="filter" name="search">
|
|
6
|
-
<q-form v-if="
|
|
6
|
+
<q-form v-if="useSearch" @submit.prevent="filter()">
|
|
7
7
|
<q-input v-model="search" :debounce="debounce" dense :placeholder="searchPlaceholder" type="search">
|
|
8
8
|
<template #append>
|
|
9
9
|
<q-btn v-if="hasSearch" icon="o_clear" unelevated @click="clearSearch" />
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
</div>
|
|
16
16
|
|
|
17
17
|
<slot v-if="showFilterButton" :filter="filter" name="filter-button">
|
|
18
|
-
<q-btn v-if="
|
|
18
|
+
<q-btn v-if="useFilterButton" :color="filterButtonColor" flat icon="o_filter_list" :label="filterButtonLabel">
|
|
19
19
|
<q-menu @before-show="fetchFilters">
|
|
20
20
|
<div v-if="isFetching" class="q-pa-xl text-center">
|
|
21
21
|
<q-spinner color="grey" size="2em" />
|
|
@@ -40,29 +40,32 @@
|
|
|
40
40
|
</slot>
|
|
41
41
|
</div>
|
|
42
42
|
|
|
43
|
-
<div v-if="
|
|
43
|
+
<div v-if="useBadges && hasActiveFilters" class="q-mt-md">
|
|
44
44
|
<q-chip v-for="(filterItem, key) in activeFilters" :key="key" color="grey-4" dense removable size="md" text-color="grey-8" @remove="removeFilter(filterItem)">{{ filterItem.label }} = "{{ getChipValue(filterItem.value) }}"</q-chip>
|
|
45
45
|
</div>
|
|
46
46
|
|
|
47
|
-
<slot :context="
|
|
47
|
+
<slot :context="mx_context" :filter="filter" :filters="activeFilters" :remove-filter="removeFilter" />
|
|
48
48
|
</section>
|
|
49
49
|
</template>
|
|
50
50
|
|
|
51
51
|
<script>
|
|
52
|
-
import QasField from '../field/QasField'
|
|
52
|
+
import QasField from '../field/QasField.vue'
|
|
53
53
|
|
|
54
54
|
import { camelize, camelizeKeys } from 'humps'
|
|
55
|
-
import { humanize, parseValue } from '../../helpers/filters'
|
|
56
|
-
import contextMixin from '../../mixins/context'
|
|
55
|
+
import { humanize, parseValue } from '../../helpers/filters.js'
|
|
56
|
+
import contextMixin from '../../mixins/context.js'
|
|
57
57
|
|
|
58
58
|
export default {
|
|
59
|
+
name: 'QasFilters',
|
|
60
|
+
|
|
59
61
|
components: {
|
|
60
62
|
QasField
|
|
61
63
|
},
|
|
62
64
|
|
|
63
65
|
mixins: [contextMixin],
|
|
66
|
+
|
|
64
67
|
props: {
|
|
65
|
-
|
|
68
|
+
useBadges: {
|
|
66
69
|
default: true,
|
|
67
70
|
type: Boolean
|
|
68
71
|
},
|
|
@@ -72,13 +75,13 @@ export default {
|
|
|
72
75
|
type: String
|
|
73
76
|
},
|
|
74
77
|
|
|
75
|
-
|
|
76
|
-
default:
|
|
78
|
+
useFilterButton: {
|
|
79
|
+
default: true,
|
|
77
80
|
type: Boolean
|
|
78
81
|
},
|
|
79
82
|
|
|
80
|
-
|
|
81
|
-
default:
|
|
83
|
+
useSearch: {
|
|
84
|
+
default: true,
|
|
82
85
|
type: Boolean
|
|
83
86
|
},
|
|
84
87
|
|
|
@@ -98,6 +101,8 @@ export default {
|
|
|
98
101
|
}
|
|
99
102
|
},
|
|
100
103
|
|
|
104
|
+
emits: ['fetch-success', 'fetch-error'],
|
|
105
|
+
|
|
101
106
|
data () {
|
|
102
107
|
return {
|
|
103
108
|
filters: {},
|
|
@@ -116,7 +121,7 @@ export default {
|
|
|
116
121
|
const activeFilters = {}
|
|
117
122
|
|
|
118
123
|
const fields = Object.keys(this.fields)
|
|
119
|
-
const filters = camelizeKeys(this.
|
|
124
|
+
const filters = camelizeKeys(this.mx_context.filters)
|
|
120
125
|
|
|
121
126
|
for (const key in filters) {
|
|
122
127
|
const hasField = fields.includes(key)
|
|
@@ -161,22 +166,24 @@ export default {
|
|
|
161
166
|
},
|
|
162
167
|
|
|
163
168
|
showFilterButton () {
|
|
164
|
-
return !!this.$
|
|
169
|
+
return !!this.$slots.filterButton || this.useFilterButton
|
|
165
170
|
},
|
|
166
171
|
|
|
167
172
|
showFilters () {
|
|
168
|
-
return this.
|
|
173
|
+
return this.useFilterButton || this.showSearch
|
|
169
174
|
},
|
|
170
175
|
|
|
171
176
|
showSearch () {
|
|
172
|
-
return !!this.$
|
|
177
|
+
return !!this.$slots.search || this.useSearch
|
|
173
178
|
}
|
|
174
179
|
},
|
|
175
180
|
|
|
176
181
|
watch: {
|
|
177
|
-
$route () {
|
|
178
|
-
|
|
179
|
-
|
|
182
|
+
$route (to, from) {
|
|
183
|
+
if (to.name === from.name) {
|
|
184
|
+
this.fetchFilters()
|
|
185
|
+
this.updateValues()
|
|
186
|
+
}
|
|
180
187
|
},
|
|
181
188
|
|
|
182
189
|
search () {
|
|
@@ -193,7 +200,7 @@ export default {
|
|
|
193
200
|
|
|
194
201
|
methods: {
|
|
195
202
|
clearFilters () {
|
|
196
|
-
const { filters, ...query } = this.
|
|
203
|
+
const { filters, ...query } = this.mx_context
|
|
197
204
|
|
|
198
205
|
if (this.hasFields) {
|
|
199
206
|
const fields = Object.keys(this.fields)
|
|
@@ -220,7 +227,7 @@ export default {
|
|
|
220
227
|
},
|
|
221
228
|
|
|
222
229
|
async fetchFilters () {
|
|
223
|
-
if (this.hasFields || this.
|
|
230
|
+
if (this.hasFields || !this.useFilterButton) {
|
|
224
231
|
return null
|
|
225
232
|
}
|
|
226
233
|
|
|
@@ -239,7 +246,7 @@ export default {
|
|
|
239
246
|
},
|
|
240
247
|
|
|
241
248
|
filter (external) {
|
|
242
|
-
const { filters, page, ...context } = this.
|
|
249
|
+
const { filters, page, ...context } = this.mx_context
|
|
243
250
|
|
|
244
251
|
const query = {
|
|
245
252
|
...filters,
|
|
@@ -266,11 +273,11 @@ export default {
|
|
|
266
273
|
},
|
|
267
274
|
|
|
268
275
|
updateValues () {
|
|
269
|
-
const { filters, search } = this.
|
|
276
|
+
const { filters, search } = this.mx_context
|
|
270
277
|
this.search = search || ''
|
|
271
278
|
|
|
272
279
|
for (const key in filters) {
|
|
273
|
-
this
|
|
280
|
+
this.filters[key] = parseValue(this.normalizeValues(filters[key], this.fields[key]?.multiple))
|
|
274
281
|
}
|
|
275
282
|
},
|
|
276
283
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<div :class="
|
|
4
|
-
<div v-for="(field, key) in groupedFields.visible" :key="key" :class="
|
|
3
|
+
<div :class="mx_classes">
|
|
4
|
+
<div v-for="(field, key) in groupedFields.visible" :key="key" :class="mx_getFieldClass(key)">
|
|
5
5
|
<slot :field="field" :name="`field-${field.name}`">
|
|
6
|
-
<qas-field v-bind="fieldsProps[field.name]" :error="errors[key]" :field="field" :value="
|
|
6
|
+
<qas-field v-bind="fieldsProps[field.name]" :error="errors[key]" :field="field" :model-value="modelValue[field.name]" @update:model-value="updateModelValue(field.name, $event)" />
|
|
7
7
|
</slot>
|
|
8
8
|
</div>
|
|
9
9
|
</div>
|
|
10
10
|
|
|
11
11
|
<div v-for="(field, key) in groupedFields.hidden" :key="key">
|
|
12
12
|
<slot :field="field" :name="`field-${field.name}`">
|
|
13
|
-
<qas-field v-bind="fieldsProps[field.name]" :field="field" :value="
|
|
13
|
+
<qas-field v-bind="fieldsProps[field.name]" :field="field" :model-value="modelValue[field.name]" @update:model-value="updateModelValue(field.name, $event)" />
|
|
14
14
|
</slot>
|
|
15
15
|
</div>
|
|
16
16
|
</div>
|
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
|
|
19
19
|
<script>
|
|
20
20
|
import generatorMixin from '../../mixins/generator'
|
|
21
|
-
|
|
22
|
-
import QasField from '../field/QasField'
|
|
21
|
+
import QasField from '../field/QasField.vue'
|
|
23
22
|
|
|
24
23
|
export default {
|
|
24
|
+
name: 'QasFormGenerator',
|
|
25
|
+
|
|
25
26
|
components: {
|
|
26
27
|
QasField
|
|
27
28
|
},
|
|
@@ -34,11 +35,6 @@ export default {
|
|
|
34
35
|
type: Object
|
|
35
36
|
},
|
|
36
37
|
|
|
37
|
-
fieldsEvents: {
|
|
38
|
-
default: () => ({}),
|
|
39
|
-
type: Object
|
|
40
|
-
},
|
|
41
|
-
|
|
42
38
|
fieldsProps: {
|
|
43
39
|
default: () => ({}),
|
|
44
40
|
type: Object
|
|
@@ -49,13 +45,15 @@ export default {
|
|
|
49
45
|
type: Array
|
|
50
46
|
},
|
|
51
47
|
|
|
52
|
-
|
|
48
|
+
modelValue: {
|
|
53
49
|
default: () => ({}),
|
|
54
50
|
required: true,
|
|
55
51
|
type: Object
|
|
56
52
|
}
|
|
57
53
|
},
|
|
58
54
|
|
|
55
|
+
emits: ['update:modelValue'],
|
|
56
|
+
|
|
59
57
|
computed: {
|
|
60
58
|
groupedFields () {
|
|
61
59
|
const fields = { hidden: {}, visible: {} }
|
|
@@ -80,11 +78,11 @@ export default {
|
|
|
80
78
|
},
|
|
81
79
|
|
|
82
80
|
methods: {
|
|
83
|
-
|
|
84
|
-
const models = { ...this.
|
|
81
|
+
updateModelValue (key, value) {
|
|
82
|
+
const models = { ...this.modelValue }
|
|
85
83
|
models[key] = value
|
|
86
84
|
|
|
87
|
-
this.$emit('
|
|
85
|
+
this.$emit('update:modelValue', models)
|
|
88
86
|
}
|
|
89
87
|
}
|
|
90
88
|
}
|