Skip to content

[stable31] fix: adjust to workflowengine changes and register web component #1213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: stable31
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"dependencies": {
"@nextcloud/l10n": "^3.1.0",
"@nextcloud/vue": "8.22.0",
"@vue/web-component-wrapper": "^1.3.0",
"vue": "^2.7.16"
},
"browserslist": [
Expand Down
10 changes: 6 additions & 4 deletions src/Tag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
-->

<template>
<NcSelectTags :value="integerValue" :multiple="false" @input="emitInput" />
<NcSelectTags v-model="integerValue" :multiple="false" @input="emitInput" />
</template>

<script>
Expand All @@ -14,19 +14,21 @@ export default {
name: 'Tag',
components: { NcSelectTags },
props: {
value: {
modelValue: {
type: String,
default: '',
},
},
emits: ['update:model-value'],
computed: {
integerValue() {
return parseInt(this.value)
const val = parseInt(this.modelValue)
return isNaN(val) ? -1 : val
},
},
methods: {
emitInput(value) {
this.$emit('input', '' + value)
this.$emit('update:model-value', '' + value)
},
},
}
Expand Down
15 changes: 14 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,26 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import wrap from '@vue/web-component-wrapper'
import Vue from 'vue'

import Tag from './Tag.vue'

const AutoTaggerComponent = wrap(Vue, Tag)
const customElementId = 'oca-files_automatedtagging-operation-tag'

window.customElements.define(customElementId, AutoTaggerComponent)

// In Vue 2, wrap doesn't support disabling shadow :(
// Disable with a hack
Object.defineProperty(AutoTaggerComponent.prototype, 'attachShadow', { value() { return this } })
Object.defineProperty(AutoTaggerComponent.prototype, 'shadowRoot', { get() { return this } })

window.OCA.WorkflowEngine.registerOperator({
id: 'OCA\\FilesAutomatedTagging\\Operation',
name: t('files_automatedtagging', 'Tag a file'),
description: t('files_automatedtagging'),
color: 'var(--color-success)',
operation: '',
options: Tag,
element: customElementId,
})