From b8779eed3680be88155750e2564465c462007f54 Mon Sep 17 00:00:00 2001
From: Julius Härtl <jus@bitgrid.net>
Date: Mon, 23 Dec 2019 10:25:42 +0100
Subject: Allow selecting other event types (fix #18510)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Julius Härtl <jus@bitgrid.net>
---
 apps/workflowengine/src/components/Event.vue | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

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

diff --git a/apps/workflowengine/src/components/Event.vue b/apps/workflowengine/src/components/Event.vue
index 9883a8cf93c..bf8e06e5df1 100644
--- a/apps/workflowengine/src/components/Event.vue
+++ b/apps/workflowengine/src/components/Event.vue
@@ -56,7 +56,21 @@ export default {
 	},
 	methods: {
 		updateEvent(events) {
-			this.$set(this.rule, 'events', events.map(event => event.eventName))
+			if (events.length === 0) {
+				window.OCP.Toast.warning(t('workflowengine', 'At least one event must be selected'))
+				return
+			}
+			const existingEntity = this.rule.entity
+			const newEntities = events.map(event => event.entity.id).filter((value, index, self) => self.indexOf(value) === index)
+			let newEntity = null
+			if (newEntities.length > 1) {
+				newEntity = newEntities.filter(entity => entity !== existingEntity)[0]
+			} else {
+				newEntity = newEntities[0]
+			}
+
+			this.$set(this.rule, 'entity', newEntity)
+			this.$set(this.rule, 'events', events.filter(event => event.entity.id === newEntity).map(event => event.eventName))
 			this.$emit('update', this.rule)
 		},
 	},
-- 
cgit v1.2.3

