Skip to content

Commit b91a184

Browse files
committed
Use entity/event definitions from backend
Signed-off-by: Julius Härtl <jus@bitgrid.net>
1 parent c671b26 commit b91a184

6 files changed

Lines changed: 141 additions & 121 deletions

File tree

apps/workflowengine/src/components/Check.vue

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
</template>
1616

1717
<script>
18+
import { Checks } from '../services/Operation';
1819
import { Multiselect, Actions, ActionButton } from 'nextcloud-vue'
1920
import ClickOutside from 'vue-click-outside';
2021
@@ -43,13 +44,8 @@
4344
}
4445
},
4546
mounted() {
46-
this.options = Object.values(OCA.WorkflowEngine.Plugins).map((plugin) => {
47-
if (plugin.component) {
48-
return {...plugin.getCheck(), component: plugin.component}
49-
}
50-
return plugin.getCheck()
51-
})
52-
this.currentOption = this.options.find((option) => option.class === this.check.class)
47+
this.options = Object.values(Checks)
48+
this.currentOption = Checks[this.check.class]
5349
this.currentOperator = this.operators.find((operator) => operator.operator === this.check.operator)
5450
this.$nextTick(() => {
5551
this.$refs.checkSelector.$el.focus()
@@ -59,12 +55,12 @@
5955
operators() {
6056
if (!this.currentOption)
6157
return []
62-
return this.options.find((item) => item.class === this.currentOption.class).operators
58+
return Checks[this.currentOption.class].operators
6359
},
6460
currentComponent() {
6561
if (!this.currentOption)
6662
return []
67-
let currentComponent = this.options.find((item) => item.class === this.currentOption.class).component
63+
let currentComponent = Checks[this.currentOption.class].component
6864
return currentComponent && currentComponent()
6965
}
7066
},
@@ -101,4 +97,4 @@
10197
::placeholder {
10298
font-size: 10px;
10399
}
104-
</style>
100+
</style>

apps/workflowengine/src/components/Event.vue

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<div>
33
<Multiselect :value="currentEvent" :options="allEvents" label="name" track-by="id" :allow-empty="false" :disabled="allEvents.length <= 1" @input="updateEvent">
44
<template slot="singleLabel" slot-scope="props">
5-
<span class="option__icon" :class="props.option.icon"></span>
5+
<img class="option__icon" :src="props.option.icon" />
66
<span class="option__title option__title_single">{{ props.option.name }}</span>
77
</template>
88
<template slot="option" slot-scope="props">
9-
<span class="option__icon" :class="props.option.icon"></span>
9+
<img class="option__icon" :src="props.option.icon" />
1010
<span class="option__title">{{ props.option.name }}</span>
1111
</template>
1212
</Multiselect>
@@ -15,7 +15,7 @@
1515

1616
<script>
1717
import { Multiselect } from 'nextcloud-vue'
18-
import { eventService, operationService } from '../services/Operation'
18+
import { Entities, operationService } from '../services/Operation'
1919
2020
export default {
2121
name: "Event",
@@ -36,7 +36,21 @@
3636
return this.allEvents.find(event => event.id === this.rule.event)
3737
},
3838
allEvents() {
39-
return this.operation.events.map((eventName) => eventService.get(eventName))
39+
return this.operation.events.map((entityEventName) => {
40+
const parts = entityEventName.split('::')
41+
const entityId = parts[0]
42+
const eventName = parts[1]
43+
const Entity = Entities.find((entity) => entity.id === entityId)
44+
const Event = Entity.events.find((event) => event.eventName === eventName)
45+
return {
46+
entity: entityId,
47+
id: entityEventName,
48+
event: eventName,
49+
name: Event.displayName,
50+
icon: Entity.icon,
51+
checks: Entity.checks,
52+
}
53+
})
4054
},
4155
operation() {
4256
return operationService.get(this.rule.class)
@@ -81,4 +95,4 @@
8195
.option__title_single {
8296
font-weight: 900;
8397
}
84-
</style>
98+
</style>

apps/workflowengine/src/components/Operation.vue

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
margin-left: -1px;
4040
padding: 10px;
4141
border-radius: var(--border-radius-large);
42-
max-width: 230px;
4342
margin-right: 20px;
43+
margin-bottom: 20px;
4444
}
4545
.icon {
4646
display: block;
@@ -64,20 +64,21 @@
6464
small {
6565
font-size: 10pt;
6666
}
67-
.icon-block {
68-
background-image: url(/apps-extra/files_accesscontrol/img/app-dark.svg);
69-
}
70-
71-
.icon-convert-pdf {
72-
background-image: url(/apps-extra/workflow_pdf_converter/img/app-dark.svg);
73-
}
7467
7568
.colored {
76-
.icon {
77-
filter: invert(1);
78-
}
7969
* {
8070
color: var(--color-primary-text)
8171
}
8272
}
83-
</style>
73+
74+
/* TODO: those should be provided by the backend, remove once ready */
75+
.icon-block {
76+
background-image: url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8' standalone='no'%3F%3E%3Csvg xmlns='http://www.w3.org/2000/svg' height='32' width='32' version='1.1' viewBox='0 0 32 32'%3E%3Cpath fill='%23fff' d='m10.203 2-8.203 8.203v11.594l8.203 8.203h11.594l8.203-8.203v-11.594l-8.203-8.203h-11.594zm11.097 5.3092 3.345 3.3448-5.346 5.346 5.346 5.346-3.299 3.299-5.346-5.346-5.346 5.346-3.2992-3.299 5.3462-5.346-5.3462-5.346 3.2992-3.2992 5.346 5.3462 5.3-5.3918z'/%3E%3C/svg%3E");
77+
}
78+
.icon-convert-pdf {
79+
background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' version='1.1' viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23fff'%3E%3Cpath d='m7.0624 2.9056c-0.20526 0-0.36653 0.14989-0.36653 0.34066v8.8571c0 0.19077 0.16127 0.34066 0.36653 0.34066h8.0637c0.20526 0 0.36653-0.14989 0.36653-0.34066v-7.1538l-2.1992-2.044zm4.2518 2.6571s0.05132 0.64725-0.10996 1.567c0.52414 1.3987 1.0996 1.5875 1.3562 1.7033 0.54247-0.040873 1.1472-0.068129 1.6861 0.2044 0.36653 0.19486 0.65536 1.022-0.21992 1.022-0.39586-0.023161-1.1267-0.23574-1.6494-0.47692-0.78145 0.081762-1.752 0.21802-2.5657 0.54505-0.91633 1.4308-1.3268 1.6352-1.6494 1.6352-0.89067-0.21802-0.41052-1.3149-0.073304-1.4989 0.40319-0.32022 0.87601-0.50417 1.0263-0.54505 0.065969-0.10221 1.0146-1.8327 1.2462-2.5549-0.21992-0.69767-0.27123-1.4349-0.14661-1.8736 0.57179-0.69358 1.0996-0.23846 1.0996 0.27253zm-0.51315 2.1121c-0.19793 0.72015-0.98817 2.1012-0.95299 2.044 0.81004-0.33044 1.5394-0.42923 2.3458-0.54505-0.38559-0.16011-0.84009-0.17033-1.3928-1.4989z' stroke-width='.70672'/%3E%3Cpath d='m16.246-9.7651c-2.05e-4 0.0144-6e-3 0.027629-6e-3 0.042066-0.0044 2.2592 2.0761 3.742 4.0564 3.6477v1.2349l2.3737-2.2265-2.3377-2.3407-3e-3 1.2289c-1.0287 0.1337-1.8811-0.66867-1.8659-1.5414 2.9e-4 -0.016152 0.0083-0.029062 9e-3 -0.045071z' stroke-width='.67694'/%3E%3Cpath d='m3.2734 5.1094v1.4492h-2.7676v2.5h2.7246l-0.0019532 1.4629 3.0996-2.6387-3.0547-2.7734z'/%3E%3Cpath d='m8.334-11.356c-0.78035-0.78051-1.9205-1.0863-2.9866-0.80073a0.51533 0.51533 0 1 0 0.26293 0.99405c0.71208-0.19075 1.4702 0.01747 1.9914 0.53876 0.46076 0.46083 0.65567 1.1026 0.56688 1.7376a0.61838 0.61838 0 1 0-0.87225 0.87442l0.8687 0.86886a0.61838 0.61838 0 0 0 0.86992 7.91e-5l0.86886-0.8687a0.61838 0.61838 0 0 0 0.0011543-0.88702 0.61838 0.61838 0 0 0-0.67634-0.12303c0.04094-0.86013-0.27221-1.7117-0.89472-2.3343zm-3.3067 1.0814a0.61838 0.61838 0 0 0-0.015967-0.01364l-0.86984-0.87a0.61838 0.61838 0 0 0-0.042126-0.04213 0.61838 0.61838 0 0 0-0.82551 0.04205l-0.87 0.86984a0.61838 0.61838 0 0 0 0.66145 1.0237c-0.024276 0.84049 0.29182 1.6675 0.90045 2.2762 0.78035 0.78052 1.9205 1.0863 2.9866 0.80073a0.51533 0.51533 0 1 0-0.27202-0.99408c-0.71208 0.19075-1.4669-0.011716-1.988-0.53306-0.45484-0.45491-0.65183-1.0905-0.57258-1.7183l0.018216 0.018221a0.61843 0.61843 0 0 0 0.88935-0.85959z' stroke-width='.68342'/%3E%3Cpath d='m31.219 0.33675v0.00113h-6.9286v1.3295l6.9286 0.036145c0.0026-1.821e-4 0.0053 2.074e-4 0.0079 0 0.0053-4.166e-4 0.01058-0.00137 0.01581-0.00113 0.65203-0.00106 1.1749 0.44619 1.1867 1.0392 0.0108 0.5673-0.60099 1.0888-1.3381 1.0019l-0.0013-0.79858-1.6753 1.5203 1.7016 1.4481-0.0013-0.8031c1.419 0.06127 2.9112-0.90236 2.9081-2.3709-0.0029-1.3197-1.2547-2.4007-2.7961-2.4014-0.0023-1e-6 -0.0043-0.00113-0.0066-0.00113z' stroke-width='.462'/%3E%3Crect x='31.116' y='-1.6777' width='4.3279' height='7.5909'/%3E%3C/g%3E%3C/svg%3E");
80+
}
81+
.icon-invert {
82+
filter: invert(1);
83+
}
84+
</style>

apps/workflowengine/src/components/Rule.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,12 @@
163163
164164
.rule {
165165
display: flex;
166+
flex-wrap: wrap;
167+
166168
.trigger, .action {
167169
flex-grow: 1;
168170
min-height: 100px;
169-
width: 50%;
171+
flex-basis: 50%;
170172
}
171173
.action {
172174
position: relative;
@@ -177,6 +179,8 @@
177179
}
178180
.icon-confirm {
179181
background-position: right center;
182+
padding-right: 20px;
183+
margin-right: 20px;
180184
}
181185
}
182186
.trigger p, .action p {
@@ -206,4 +210,4 @@
206210
text-align: left;
207211
font-size: 1em;
208212
}
209-
</style>
213+
</style>

apps/workflowengine/src/components/Workflow.vue

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@
1414
{{ showMoreOperations ? t('workflowengine', 'Show less') : t('workflowengine', 'Show more') }}
1515
</button>
1616
</div>
17-
<transition name="slide">
18-
<div class="actions" v-if="!hasUnsavedRule && showMoreOperations && hasMoreOperations">
19-
<Operation v-for="operation in getMoreOperations" :key="operation.class" :icon="operation.icon" :title="operation.title" :description="operation.description"
20-
@click.native="createNewRule(operation)"></Operation>
21-
</div>
22-
</transition>
2317
</div>
2418

2519
<transition-group name="slide">
@@ -59,6 +53,9 @@
5953
return Object.keys(this.operations.getAll()).length > ACTION_LIMIT
6054
},
6155
getMainOperations() {
56+
if (this.showMoreOperations) {
57+
return Object.values(this.operations.getAll())
58+
}
6259
return Object.values(this.operations.getAll()).slice(0, ACTION_LIMIT)
6360
},
6461
getMoreOperations() {
@@ -95,10 +92,16 @@
9592
</script>
9693

9794
<style scoped lang="scss">
95+
.section {
96+
max-width: 100vw;
97+
}
9898
.actions {
9999
display: flex;
100-
.action__item {
101-
border: 1px solid var(--color-border);
100+
flex-wrap: wrap;
101+
.actions__item {
102+
max-width: 300px;
103+
min-width: 200px;
104+
flex-basis: 200px;
102105
}
103106
}
104107
@@ -143,4 +146,4 @@
143146
overflow: hidden;
144147
max-height: 0;
145148
}
146-
</style>
149+
</style>

0 commit comments

Comments
 (0)