Skip to content

Commit 7926d50

Browse files
authored
Merge pull request #1210 from nextcloud/fix/noid/wfe-component
fix: adjust to workflowengine changes and register web component
2 parents c8365e2 + 39d51ba commit 7926d50

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"dependencies": {
2424
"@nextcloud/l10n": "^3.4.0",
2525
"@nextcloud/vue": "8.28.0",
26+
"@vue/web-component-wrapper": "^1.3.0",
2627
"vue": "^2.7.16"
2728
},
2829
"browserslist": [

src/Tag.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-->
55

66
<template>
7-
<NcSelectTags :value="integerValue" :multiple="false" @input="emitInput" />
7+
<NcSelectTags v-model="integerValue" :multiple="false" @input="emitInput" />
88
</template>
99

1010
<script>
@@ -14,19 +14,21 @@ export default {
1414
name: 'Tag',
1515
components: { NcSelectTags },
1616
props: {
17-
value: {
17+
modelValue: {
1818
type: String,
1919
default: '',
2020
},
2121
},
22+
emits: ['update:model-value'],
2223
computed: {
2324
integerValue() {
24-
return parseInt(this.value)
25+
const val = parseInt(this.modelValue)
26+
return isNaN(val) ? -1 : val
2527
},
2628
},
2729
methods: {
2830
emitInput(value) {
29-
this.$emit('input', '' + value)
31+
this.$emit('update:model-value', '' + value)
3032
},
3133
},
3234
}

src/main.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,26 @@
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 Tag from './Tag.vue'
710

11+
const AutoTaggerComponent = wrap(Vue, Tag)
12+
const customElementId = 'oca-files_automatedtagging-operation-tag'
13+
14+
window.customElements.define(customElementId, AutoTaggerComponent)
15+
16+
// In Vue 2, wrap doesn't support disabling shadow :(
17+
// Disable with a hack
18+
Object.defineProperty(AutoTaggerComponent.prototype, 'attachShadow', { value() { return this } })
19+
Object.defineProperty(AutoTaggerComponent.prototype, 'shadowRoot', { get() { return this } })
20+
821
window.OCA.WorkflowEngine.registerOperator({
922
id: 'OCA\\FilesAutomatedTagging\\Operation',
1023
name: t('files_automatedtagging', 'Tag a file'),
1124
description: t('files_automatedtagging'),
1225
color: 'var(--color-success)',
1326
operation: '',
14-
options: Tag,
27+
element: customElementId,
1528
})

0 commit comments

Comments
 (0)