From 7449bb77fb25d33f0e8b0394e914cd31e00a9c60 Mon Sep 17 00:00:00 2001
From: Arthur Schiwon <blizzz@arthur-schiwon.de>
Date: Mon, 31 Mar 2025 17:45:39 +0200
Subject: fix(workflowengine): adapt check operator RequestUserGroup to use web
 component

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
---
 .../src/components/Checks/RequestUserGroup.vue     | 34 +++++++++++++++++-----
 1 file changed, 27 insertions(+), 7 deletions(-)

(limited to 'apps/workflowengine/src/components/Checks/RequestUserGroup.vue')

diff --git a/apps/workflowengine/src/components/Checks/RequestUserGroup.vue b/apps/workflowengine/src/components/Checks/RequestUserGroup.vue
index 4ea53295162..e53a8309b47 100644
--- a/apps/workflowengine/src/components/Checks/RequestUserGroup.vue
+++ b/apps/workflowengine/src/components/Checks/RequestUserGroup.vue
@@ -10,10 +10,11 @@
 			:loading="status.isLoading && groups.length === 0"
 			:placeholder="t('workflowengine', 'Type to search for group …')"
 			:options="groups"
-			:value="currentValue"
+		    :model-value="currentValue"
 			label="displayname"
 			@search="searchAsync"
-			@input="(value) => $emit('input', value.id)" />
+		    @input="update"
+			/>
 	</div>
 </template>
 
@@ -35,7 +36,7 @@ export default {
 		NcSelect,
 	},
 	props: {
-		value: {
+		modelValue: {
 			type: String,
 			default: '',
 		},
@@ -48,11 +49,17 @@ export default {
 		return {
 			groups,
 			status,
+			newValue: '',
 		}
 	},
 	computed: {
-		currentValue() {
-			return this.groups.find(group => group.id === this.value) || null
+		currentValue: {
+			get: function () {
+				return this.groups.find(group => group.id === this.newValue) || null
+			},
+			set: function (value) {
+				this.newValue = value
+			}
 		},
 	},
 	async mounted() {
@@ -61,10 +68,16 @@ export default {
 			await this.searchAsync('')
 		}
 		// If a current group is set but not in our list of groups then search for that group
-		if (this.currentValue === null && this.value) {
-			await this.searchAsync(this.value)
+		if (this.currentValue === null && this.newValue) {
+			await this.searchAsync(this.newValue)
 		}
 	},
+	emits: ['update:model-value'],
+	watch: {
+		modelValue() {
+			this.updateInternalValue()
+		},
+	},
 	methods: {
 		t,
 
@@ -86,12 +99,19 @@ export default {
 				console.error('Error while loading group list', error.response)
 			})
 		},
+		updateInternalValue() {
+			this.newValue = this.modelValue
+		},
 		addGroup(group) {
 			const index = this.groups.findIndex((item) => item.id === group.id)
 			if (index === -1) {
 				this.groups.push(group)
 			}
 		},
+		update(value) {
+			this.newValue = value.id
+			this.$emit('update:model-value', this.newValue)
+		}
 	},
 }
 </script>
-- 
cgit v1.2.3

