Skip to content

Commit da3ea35

Browse files
committed
fix(Flow): adapt to registration fixes at workflowengine
- fixes compatibility issues with newer nextcloud-vue Signed-off-by: Arthur Schiwon <[email protected]>
1 parent 9c74699 commit da3ea35

File tree

4 files changed

+46
-8
lines changed

4 files changed

+46
-8
lines changed

package-lock.json

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"@nextcloud/sharing": "^0.2.4",
4444
"@nextcloud/upload": "^1.8.0",
4545
"@nextcloud/vue": "^8.23.1",
46+
"@vue/web-component-wrapper": "^1.3.0",
4647
"@vueuse/components": "^11.3.0",
4748
"@vueuse/core": "^11.2.0",
4849
"base64-js": "^1.5.1",

src/flow.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,24 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6+
import wrap from '@vue/web-component-wrapper'
7+
import Vue from 'vue'
8+
69
import FlowPostToConversation from './views/FlowPostToConversation.vue'
710

11+
const FlowPostToConversationComponent = wrap(Vue, FlowPostToConversation)
12+
const webComponentId = 'oca-spreed-flow_post_to_conversation'
13+
window.customElements.define(webComponentId, FlowPostToConversationComponent)
14+
15+
// In Vue 2, wrap doesn't support disabling shadow :(
16+
// Disable with a hack
17+
Object.defineProperty(FlowPostToConversationComponent.prototype, 'attachShadow', { value() { return this } })
18+
Object.defineProperty(FlowPostToConversationComponent.prototype, 'shadowRoot', { get() { return this } })
19+
820
window.OCA.WorkflowEngine.registerOperator({
921
id: 'OCA\\Talk\\Flow\\Operation',
1022
color: '#0082c9',
1123
operation: '',
12-
options: FlowPostToConversation,
24+
component: webComponentId,
25+
options: FlowPostToConversation // backward "compatibility"
1326
})

src/views/FlowPostToConversation.vue

+19-7
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
:options="roomOptions"
1010
:aria-label-combobox="t('spreed', 'Select a conversation')"
1111
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)" />
1313

1414
<NcSelect :model-value="currentMode"
1515
:options="modeOptions"
1616
:aria-label-combobox="t('spreed', 'Select a mode')"
1717
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)" />
1919
</div>
2020
</template>
2121

@@ -35,13 +35,18 @@ export default {
3535
name: 'FlowPostToConversation',
3636
components: { NcSelect },
3737
props: {
38+
modelValue: {
39+
default: '',
40+
type: String,
41+
},
42+
// keep "value" for backwards compatibility, up to NC 31
3843
value: {
3944
default: JSON.stringify({ m: '0', t: '' }),
4045
type: String,
4146
},
4247
},
4348

44-
emits: ['input'],
49+
emits: ['input', 'update:model-value'],
4550

4651
data() {
4752
return {
@@ -64,21 +69,21 @@ export default {
6469
},
6570
computed: {
6671
currentRoom() {
67-
if (this.value === '') {
72+
if (this.modelValue === '' && this.value === '') {
6873
return ''
6974
}
70-
const selectedRoom = JSON.parse(this.value).t
75+
const selectedRoom = JSON.parse(this.modelValue || this.value).t
7176
const newValue = this.roomOptions.find(option => option.token === selectedRoom)
7277
if (typeof newValue === 'undefined') {
7378
return ''
7479
}
7580
return newValue
7681
},
7782
currentMode() {
78-
if (this.value === '') {
83+
if (this.modelValue === '' && this.value === '') {
7984
return this.modeOptions[0]
8085
}
81-
const selectedMode = JSON.parse(this.value).m
86+
const selectedMode = JSON.parse(this.modelValue || this.value).m
8287
const newValue = this.modeOptions.find(option => option.id === selectedMode)
8388
if (typeof newValue === 'undefined') {
8489
return this.modeOptions[0]
@@ -100,6 +105,13 @@ export default {
100105
})
101106
})
102107
},
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+
}
103115
},
104116
}
105117

0 commit comments

Comments
 (0)