@afeefa/vue-app 0.0.205 → 0.0.207
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/.afeefa/package/release/version.txt +1 -1
- package/package.json +1 -1
- package/src/components/ACheckboxGroup.vue +112 -0
- package/src/components/form/fields/FormFieldCheckboxGroup.vue +30 -0
- package/src/components/index.js +2 -0
- package/src-admin/components/detail/EditableDetailProperty.vue +5 -2
- package/src-admin/components/list/ListView.vue +3 -0
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.207
|
package/package.json
CHANGED
@@ -0,0 +1,112 @@
|
|
1
|
+
<template>
|
2
|
+
<div>
|
3
|
+
<v-label v-if="$attrs.label">
|
4
|
+
{{ $attrs.label }}
|
5
|
+
</v-label>
|
6
|
+
|
7
|
+
<a-row
|
8
|
+
:vertical="vertical"
|
9
|
+
:gap="vertical ? 0 : 4"
|
10
|
+
>
|
11
|
+
<a-checkbox
|
12
|
+
v-for="option in options_"
|
13
|
+
:key="option.itemValue"
|
14
|
+
:label="option.itemText"
|
15
|
+
:value="isChecked(option.itemValue)"
|
16
|
+
hide-details
|
17
|
+
@input="checked(option.itemValue, $event)"
|
18
|
+
>
|
19
|
+
<template #label>
|
20
|
+
<div v-html="option.itemText" />
|
21
|
+
</template>
|
22
|
+
</a-checkbox>
|
23
|
+
</a-row>
|
24
|
+
|
25
|
+
<div
|
26
|
+
v-if="errorMessages.length"
|
27
|
+
class="mt-1 error--text v-messages"
|
28
|
+
>
|
29
|
+
{{ errorMessages[0] }}
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
</template>
|
33
|
+
|
34
|
+
|
35
|
+
<script>
|
36
|
+
import { Component, Vue, Watch, Inject } from '@a-vue'
|
37
|
+
|
38
|
+
@Component({
|
39
|
+
props: ['value', 'options', 'validator', {vertical: false}]
|
40
|
+
})
|
41
|
+
export default class ACheckboxGroup extends Vue {
|
42
|
+
value_ = []
|
43
|
+
options_ = []
|
44
|
+
errorMessages = []
|
45
|
+
hasError = false
|
46
|
+
|
47
|
+
@Inject({ from: 'form', default: null }) form
|
48
|
+
|
49
|
+
created () {
|
50
|
+
this.form && this.form.register(this)
|
51
|
+
this.value_ = this.value || []
|
52
|
+
this.init()
|
53
|
+
}
|
54
|
+
|
55
|
+
checked (key, value) {
|
56
|
+
if (value) {
|
57
|
+
if (!this.isChecked(key)) {
|
58
|
+
this.value_.push(key)
|
59
|
+
}
|
60
|
+
} else {
|
61
|
+
this.value_ = this.value_.filter(v => v !== key)
|
62
|
+
}
|
63
|
+
this.$emit('input', this.value_)
|
64
|
+
this.validate()
|
65
|
+
}
|
66
|
+
|
67
|
+
isChecked (key) {
|
68
|
+
return this.value_.includes(key)
|
69
|
+
}
|
70
|
+
|
71
|
+
@Watch('options')
|
72
|
+
optionsChanged () {
|
73
|
+
this.init()
|
74
|
+
}
|
75
|
+
|
76
|
+
@Watch('value')
|
77
|
+
valueChanged (value) {
|
78
|
+
this.value_ = value || []
|
79
|
+
}
|
80
|
+
|
81
|
+
async init () {
|
82
|
+
const options = typeof this.options === 'function' ? this.options() : this.options
|
83
|
+
|
84
|
+
if (options instanceof Promise) {
|
85
|
+
this.options_ = await options
|
86
|
+
} else {
|
87
|
+
this.options_ = options
|
88
|
+
}
|
89
|
+
|
90
|
+
this.$nextTick(() => {
|
91
|
+
this.validate()
|
92
|
+
})
|
93
|
+
}
|
94
|
+
|
95
|
+
validate () {
|
96
|
+
this.errorMessages = []
|
97
|
+
if (this.validator) {
|
98
|
+
const rules = this.validator.getRules(this.$attrs.label)
|
99
|
+
for (const rule of rules) {
|
100
|
+
const message = rule(this.value_)
|
101
|
+
if (typeof message === 'string') {
|
102
|
+
this.errorMessages.push(message)
|
103
|
+
break
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
this.hasError = !!this.errorMessages.length // VForm will watch the hasError prop
|
109
|
+
return !this.errorMessages.length
|
110
|
+
}
|
111
|
+
}
|
112
|
+
</script>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<template>
|
2
|
+
<a-checkbox-group
|
3
|
+
v-model="model[name]"
|
4
|
+
:label="label || name"
|
5
|
+
:options="_options"
|
6
|
+
:validator="validator"
|
7
|
+
v-bind="$attrs"
|
8
|
+
v-on="$listeners"
|
9
|
+
/>
|
10
|
+
</template>
|
11
|
+
|
12
|
+
<script>
|
13
|
+
import { Component, Mixins } from '@a-vue'
|
14
|
+
import { FormFieldMixin } from '../FormFieldMixin'
|
15
|
+
|
16
|
+
@Component
|
17
|
+
export default class FormFieldCheckboxGroup extends Mixins(FormFieldMixin) {
|
18
|
+
options = null
|
19
|
+
|
20
|
+
created () {
|
21
|
+
if (this.fieldHasOptionsRequest() || this.fieldHasOptions()) {
|
22
|
+
this.options = this.getSelectOptions()
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
get _options () {
|
27
|
+
return this.$attrs.options || this.options || []
|
28
|
+
}
|
29
|
+
}
|
30
|
+
</script>
|
package/src/components/index.js
CHANGED
@@ -4,6 +4,7 @@ import EditForm from './form/EditForm'
|
|
4
4
|
import EditModal from './form/EditModal'
|
5
5
|
import FormFieldCategory from './form/fields/FormFieldCategory'
|
6
6
|
import FormFieldCheckbox from './form/fields/FormFieldCheckbox'
|
7
|
+
import FormFieldCheckboxGroup from './form/fields/FormFieldCheckboxGroup'
|
7
8
|
import FormFieldDate from './form/fields/FormFieldDate'
|
8
9
|
import FormFieldRadioGroup from './form/fields/FormFieldRadioGroup'
|
9
10
|
import FormFieldRichTextArea from './form/fields/FormFieldRichTextArea'
|
@@ -26,6 +27,7 @@ Vue.component('FormFieldText', FormFieldText)
|
|
26
27
|
Vue.component('FormFieldTextArea', FormFieldTextArea)
|
27
28
|
Vue.component('FormFieldRichTextArea', FormFieldRichTextArea)
|
28
29
|
Vue.component('FormFieldRadioGroup', FormFieldRadioGroup)
|
30
|
+
Vue.component('FormFieldCheckboxGroup', FormFieldCheckboxGroup)
|
29
31
|
Vue.component('FormFieldCategory', FormFieldCategory)
|
30
32
|
Vue.component('FormFieldCheckbox', FormFieldCheckbox)
|
31
33
|
Vue.component('FormFieldDate', FormFieldDate)
|
@@ -21,6 +21,7 @@
|
|
21
21
|
<slot
|
22
22
|
name="models"
|
23
23
|
:models="models_"
|
24
|
+
:filters="filters"
|
24
25
|
/>
|
25
26
|
</template>
|
26
27
|
|
@@ -53,6 +54,7 @@
|
|
53
54
|
name="model-table"
|
54
55
|
:model="model"
|
55
56
|
:index="index"
|
57
|
+
:filters="filters"
|
56
58
|
/>
|
57
59
|
</a-table-row>
|
58
60
|
</a-table>
|
@@ -67,6 +69,7 @@
|
|
67
69
|
<slot
|
68
70
|
name="model"
|
69
71
|
:model="model"
|
72
|
+
:filters="filters"
|
70
73
|
/>
|
71
74
|
</div>
|
72
75
|
</template>
|