Skip to content

Commit 7bdb354

Browse files
committed
vue 3 upgrade
1 parent 6a2016d commit 7bdb354

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

ui/field/AdminField.vue

+10-6
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,37 @@
1717
</template>
1818

1919
<script>
20-
import { get } from 'lodash'
20+
import { get, isEmpty } from 'lodash'
2121
import Multiselect from '@/Adaptcms/Base/ui/components/Form/Multiselect'
2222
2323
export default {
2424
props: [
25-
'value',
25+
'modelValue',
2626
'field',
2727
'errors',
2828
'formMeta',
2929
'model',
3030
'action'
3131
],
3232
33+
emits: [
34+
'update:modelValue'
35+
],
36+
3337
components: {
3438
Multiselect
3539
},
3640
3741
watch: {
38-
value (newVal, oldVal) {
39-
if (newVal !== oldVal) {
42+
modelValue (newVal, oldVal) {
43+
if (!isEmpty(newVal) && newVal !== oldVal) {
4044
this.selected = newVal
4145
}
4246
},
4347
4448
selected (newVal, oldVal) {
4549
if (newVal !== oldVal) {
46-
this.$emit('input', newVal)
50+
this.$emit('update:modelValue', newVal)
4751
}
4852
}
4953
},
@@ -68,7 +72,7 @@ export default {
6872
6973
mounted () {
7074
if (!this.selected) {
71-
this.selected = JSON.parse(this.value)
75+
this.selected = this.modelValue
7276
}
7377
}
7478
}

ui/field/AdminOptions.vue

+11-9
Original file line numberDiff line numberDiff line change
@@ -26,40 +26,42 @@ import { get } from 'lodash'
2626
2727
export default {
2828
props: [
29-
'value',
29+
'modelValue',
3030
'field',
3131
'package',
3232
'errors',
3333
'fields'
3434
],
3535
36+
emits: [
37+
'update:modelValue'
38+
],
39+
3640
watch: {
37-
value (newVal, oldVal) {
41+
modelValue (newVal, oldVal) {
3842
if ((newVal !== oldVal) && get(newVal, 'options', null)) {
3943
this.options = newVal.options
4044
}
4145
},
4246
4347
options (newVal, oldVal) {
4448
if (newVal !== oldVal) {
45-
this.$emit('input', { options: newVal })
49+
this.$emit('update:modelValue', { options: newVal })
4650
}
4751
}
4852
},
4953
5054
computed: {
5155
hasError () {
5256
let key = 'meta.options'
53-
let errors = get(this.$page, 'props.errors')
5457
55-
return (typeof errors[key] !== 'undefined')
58+
return (typeof this.errors[key] !== 'undefined')
5659
},
5760
5861
errorsList () {
5962
let key = 'meta.options'
60-
let errors = get(this.$page, 'props.errors')
6163
62-
return (typeof errors[key] !== 'undefined' ? errors[key] : [])
64+
return (typeof this.errors[key] !== 'undefined' ? this.errors[key].messages : [])
6365
}
6466
},
6567
@@ -70,8 +72,8 @@ export default {
7072
},
7173
7274
mounted () {
73-
if (get(this.value, 'options', null)) {
74-
this.options = this.value.options
75+
if (get(this.modelValue, 'options', null)) {
76+
this.options = this.modelValue.options
7577
}
7678
}
7779
}

0 commit comments

Comments
 (0)