9
9
:options="roomOptions"
10
10
:aria-label-combobox="t('spreed', 'Select a conversation')"
11
11
label="displayName"
12
- @input="( newValue) => newValue !== null && $emit('input', JSON.stringify({'m': currentMode.id, 't': newValue.token }) )" />
12
+ @input="newValue => emitEvents( currentMode.id, newValue.token)" />
13
13
14
14
<NcSelect :model-value="currentMode"
15
15
:options="modeOptions"
16
16
:aria-label-combobox="t('spreed', 'Select a mode')"
17
17
label="text"
18
- @input="( newValue) => newValue !== null && $emit('input', JSON.stringify({'m': newValue.id, 't': currentRoom.token }) )" />
18
+ @input="newValue => emitEvents( newValue.id, currentRoom.token)" />
19
19
</div>
20
20
</template>
21
21
@@ -35,13 +35,18 @@ export default {
35
35
name: 'FlowPostToConversation',
36
36
components: { NcSelect },
37
37
props: {
38
+ modelValue: {
39
+ default: '',
40
+ type: String,
41
+ },
42
+ // keep "value" for backwards compatibility, up to NC 31
38
43
value: {
39
44
default: JSON.stringify({ m: '0', t: '' }),
40
45
type: String,
41
46
},
42
47
},
43
48
44
- emits: ['input'],
49
+ emits: ['input', 'update:model-value' ],
45
50
46
51
data() {
47
52
return {
@@ -64,21 +69,21 @@ export default {
64
69
},
65
70
computed: {
66
71
currentRoom() {
67
- if (this.value === '') {
72
+ if (this.modelValue === '' && this. value === '') {
68
73
return ''
69
74
}
70
- const selectedRoom = JSON.parse(this.value).t
75
+ const selectedRoom = JSON.parse(this.modelValue || this. value).t
71
76
const newValue = this.roomOptions.find(option => option.token === selectedRoom)
72
77
if (typeof newValue === 'undefined') {
73
78
return ''
74
79
}
75
80
return newValue
76
81
},
77
82
currentMode() {
78
- if (this.value === '') {
83
+ if (this.modelValue === '' && this. value === '') {
79
84
return this.modeOptions[0]
80
85
}
81
- const selectedMode = JSON.parse(this.value).m
86
+ const selectedMode = JSON.parse(this.modelValue || this. value).m
82
87
const newValue = this.modeOptions.find(option => option.id === selectedMode)
83
88
if (typeof newValue === 'undefined') {
84
89
return this.modeOptions[0]
@@ -100,6 +105,13 @@ export default {
100
105
})
101
106
})
102
107
},
108
+ emitEvents(mode, token) {
109
+ if (mode === null || token === null) {
110
+ return
111
+ }
112
+ this.$emit('input', JSON.stringify({ m: mode, t: token }))
113
+ this.$emit('update:model-value', JSON.stringify({ m: mode, t: token }))
114
+ }
103
115
},
104
116
}
105
117
0 commit comments