Allow selecting other event types (fix #18510)

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2019-12-23 10:25:42 +01:00
parent a0d786769d
commit b8779eed36
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
1 changed files with 15 additions and 1 deletions

View File

@ -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)
},
},