Skip to content

Commit 7f69a4c

Browse files
authored
Fix processes (#9014)
1 parent 0e0c38b commit 7f69a4c

File tree

9 files changed

+119
-148
lines changed

9 files changed

+119
-148
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"MODEL_JSON": "${workspaceRoot}/models/all/bundle/model.json",
9898
// "SERVER_PROVIDER":"uweb"
9999
"SERVER_PROVIDER": "ws",
100-
"MODEL_VERSION": "0.7.75",
100+
"MODEL_VERSION": "0.7.110",
101101
// "VERSION": "0.6.289",
102102
"ELASTIC_INDEX_NAME": "local_storage_index",
103103
"UPLOAD_URL": "/files",

plugins/process-resources/src/components/settings/AsideTransitionEditor.svelte

Lines changed: 80 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
<script lang="ts">
2+
import { Doc } from '@hcengineering/core'
23
import presentation, { getClient } from '@hcengineering/presentation'
3-
import { Process, Transition } from '@hcengineering/process'
4+
import { Process, Step, StepId, Transition } from '@hcengineering/process'
45
import { clearSettingsStore } from '@hcengineering/setting-resources'
5-
import { ButtonIcon, Component, IconDelete, Label, Modal } from '@hcengineering/ui'
6+
import {
7+
Button,
8+
ButtonIcon,
9+
Component,
10+
DropdownIntlItem,
11+
DropdownLabelsPopupIntl,
12+
getEventPositionElement,
13+
IconAdd,
14+
IconDelete,
15+
Label,
16+
Modal,
17+
showPopup
18+
} from '@hcengineering/ui'
619
import plugin from '../../plugin'
20+
import { initState } from '../../utils'
21+
import ActionPresenter from './ActionPresenter.svelte'
22+
import StepEditor from './StepEditor.svelte'
723
import TransitionPresenter from './TransitionPresenter.svelte'
824
925
export let readonly: boolean
@@ -14,11 +30,8 @@
1430
1531
const client = getClient()
1632
17-
const from = client.getModel().findObject(transition.from)
18-
const to = transition.to === null ? null : client.getModel().findObject(transition.to)
19-
2033
async function save (): Promise<void> {
21-
await client.update(transition, { triggerParams: params })
34+
await client.update(transition, { triggerParams: params, actions: transition.actions })
2235
clearSettingsStore()
2336
}
2437
@@ -31,7 +44,28 @@
3144
params = e.detail
3245
}
3346
47+
function addAction (e: MouseEvent): void {
48+
const items: DropdownIntlItem[] = client
49+
.getModel()
50+
.findAllSync(plugin.class.Method, {})
51+
.map((x) => ({
52+
id: x._id,
53+
label: x.label
54+
}))
55+
56+
showPopup(DropdownLabelsPopupIntl, { items }, getEventPositionElement(e), async (res) => {
57+
if (res !== undefined) {
58+
const step = await initState(res)
59+
transition.actions.push(step)
60+
transition.actions = transition.actions
61+
await client.update(transition, { actions: transition.actions })
62+
}
63+
})
64+
}
65+
3466
$: trigger = client.getModel().findObject(transition.trigger)
67+
68+
let expanded = new Set<StepId>()
3569
</script>
3670

3771
<Modal
@@ -48,19 +82,47 @@
4882
<ButtonIcon icon={IconDelete} size={'small'} kind={'tertiary'} on:click={remove} />
4983
{/if}
5084
</svelte:fragment>
51-
{#if trigger !== undefined}
52-
<div class="content clear-mins">
53-
<div class="header">
54-
<div class="fs-title title text-xl">
55-
<Label label={trigger.label} />
56-
</div>
85+
<div class="content clear-mins">
86+
<div class="header">
87+
<div class="fs-title title text-xl">
5788
<TransitionPresenter {transition} />
5889
</div>
90+
</div>
91+
{#if trigger !== undefined}
92+
<div class="flex-col-center text-lg">
93+
<Label label={trigger.label} />
94+
</div>
5995
{#if trigger.editor !== undefined}
6096
<Component is={trigger.editor} props={{ process, params, readonly }} on:change={change} />
6197
{/if}
98+
{/if}
99+
<div class="divider" />
100+
<div class="flex-col flex-gap-2">
101+
{#each transition.actions as action}
102+
<Button
103+
justify="left"
104+
size="large"
105+
kind="regular"
106+
width="100%"
107+
on:click={() => {
108+
if (readonly) return
109+
expanded.has(action._id) ? expanded.delete(action._id) : expanded.add(action._id)
110+
expanded = expanded
111+
}}
112+
>
113+
<svelte:fragment slot="content">
114+
<ActionPresenter {action} {process} {readonly} />
115+
</svelte:fragment>
116+
</Button>
117+
{#if expanded.has(action._id)}
118+
<StepEditor bind:step={action} {process} withoutHeader />
119+
{/if}
120+
{/each}
121+
{#if !readonly}
122+
<Button kind={'ghost'} width={'100%'} icon={IconAdd} label={plugin.string.AddAction} on:click={addAction} />
123+
{/if}
62124
</div>
63-
{/if}
125+
</div>
64126
</Modal>
65127

66128
<style lang="scss">
@@ -71,4 +133,9 @@
71133
.title {
72134
padding-bottom: 1rem;
73135
}
136+
137+
.divider {
138+
border-bottom: 1px solid var(--theme-divider-color);
139+
margin: 1rem 0;
140+
}
74141
</style>

plugins/process-resources/src/components/settings/ParamsEditor.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
{key}
4747
{allowRemove}
4848
object={params}
49-
on:update={(e) => {
49+
on:change={(e) => {
5050
change(e, key)
5151
}}
5252
on:remove

plugins/process-resources/src/components/settings/ProcessAttributeEditor.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import { AnySvelteComponent } from '@hcengineering/ui'
2020
import { getContext } from '../../utils'
2121
import ProcessAttribute from '../ProcessAttribute.svelte'
22+
import { createEventDispatcher } from 'svelte'
2223
2324
export let process: Process
2425
export let _class: Ref<Class<Doc>>
@@ -28,6 +29,7 @@
2829
2930
const client = getClient()
3031
const hierarchy = client.getHierarchy()
32+
const dispatch = createEventDispatcher()
3133
3234
function onChange (value: any | undefined): void {
3335
if (value === undefined) {
@@ -36,6 +38,7 @@
3638
} else {
3739
;(object as any)[key] = value
3840
}
41+
dispatch('change', { value })
3942
}
4043
4144
$: value = object[key]

plugins/process-resources/src/components/settings/StepEditor.svelte

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
2323
export let step: Step<Doc>
2424
export let process: Process
25+
export let withoutHeader: boolean = false
2526
2627
const client = getClient()
2728
const dispatch = createEventDispatcher()
@@ -44,16 +45,18 @@
4445

4546
{#if method !== undefined}
4647
<div class="content clear-mins">
47-
<div class="header">
48-
<div class="fs-title title text-xl">
49-
<Label label={method.label} />
50-
</div>
51-
{#if method.description}
52-
<div class="descr">
53-
<Label label={method.description} />
48+
{#if !withoutHeader}
49+
<div class="header">
50+
<div class="fs-title title text-xl">
51+
<Label label={method.label} />
5452
</div>
55-
{/if}
56-
</div>
53+
{#if method.description}
54+
<div class="descr">
55+
<Label label={method.description} />
56+
</div>
57+
{/if}
58+
</div>
59+
{/if}
5760
{#if method.editor !== undefined}
5861
<Component is={method.editor} props={{ step, process }} on:change={change} />
5962
{/if}

plugins/process-resources/src/components/settings/TransitionEditor.svelte

Lines changed: 9 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,14 @@
1313
// limitations under the License.
1414
-->
1515
<script lang="ts">
16-
import { createQuery, getClient, MessageBox } from '@hcengineering/presentation'
17-
import { Process, Step, Transition } from '@hcengineering/process'
18-
import {
19-
Button,
20-
ButtonIcon,
21-
DropdownIntlItem,
22-
DropdownLabelsPopupIntl,
23-
eventToHTMLElement,
24-
Icon,
25-
IconAdd,
26-
IconMoreV,
27-
Label,
28-
Menu,
29-
showPopup
30-
} from '@hcengineering/ui'
31-
import view from '@hcengineering/view'
32-
import plugin from '../../plugin'
33-
import { initState } from '../../utils'
34-
import ActionPresenter from './ActionPresenter.svelte'
35-
import TriggerPresenter from './TriggerPresenter.svelte'
36-
import AsideStepEditor from './AsideStepEditor.svelte'
37-
import { Doc } from '@hcengineering/core'
16+
import { createQuery, getClient } from '@hcengineering/presentation'
17+
import { Process, Transition } from '@hcengineering/process'
3818
import { settingsStore } from '@hcengineering/setting-resources'
19+
import { Button, Icon } from '@hcengineering/ui'
20+
import plugin from '../../plugin'
3921
import AsideTransitionEditor from './AsideTransitionEditor.svelte'
4022
import TransitionPresenter from './TransitionPresenter.svelte'
23+
import TriggerPresenter from './TriggerPresenter.svelte'
4124
4225
export let transition: Transition
4326
export let process: Process
@@ -46,8 +29,6 @@
4629
4730
const client = getClient()
4831
49-
let collapsed: boolean = true
50-
5132
let from = client.getModel().findObject(transition.from)
5233
let to = transition.to === null ? null : client.getModel().findObject(transition.to)
5334
@@ -57,114 +38,27 @@
5738
to = transition.to === null ? null : client.getModel().findObject(transition.to)
5839
})
5940
60-
function editAction (step: Step<Doc>): void {
61-
$settingsStore = {
62-
id: transition._id,
63-
component: AsideStepEditor,
64-
props: { readonly, process, step, _id: transition._id }
65-
}
66-
}
67-
68-
let hovered: boolean = false
69-
70-
async function onMenuClick (ev: MouseEvent): Promise<void> {
71-
const actions = [
72-
{
73-
label: view.string.Delete,
74-
icon: view.icon.Delete,
75-
action: async () => {
76-
showPopup(MessageBox, {
77-
label: plugin.string.DeleteTransition,
78-
message: plugin.string.DeleteTransitionConfirm,
79-
action: async () => {
80-
await client.remove(transition)
81-
}
82-
})
83-
}
84-
}
85-
]
86-
hovered = true
87-
showPopup(Menu, { actions }, eventToHTMLElement(ev), () => {
88-
hovered = false
89-
})
90-
}
91-
92-
function add (e: MouseEvent): void {
93-
const items: DropdownIntlItem[] = client
94-
.getModel()
95-
.findAllSync(plugin.class.Method, {})
96-
.map((x) => ({
97-
id: x._id,
98-
label: x.label
99-
}))
100-
101-
showPopup(DropdownLabelsPopupIntl, { items }, eventToHTMLElement(e), async (res) => {
102-
if (res !== undefined) {
103-
const step = await initState(res)
104-
const length = transition.actions.push(step)
105-
await client.update(transition, { actions: transition.actions })
106-
editAction(step)
107-
}
108-
})
109-
}
110-
11141
function edit (): void {
11242
$settingsStore = { id: transition._id, component: AsideTransitionEditor, props: { readonly, process, transition } }
11343
}
11444
</script>
11545

116-
<div class="w-full container" class:hovered>
117-
<div class:expand={!collapsed} class="innerContainer">
46+
<div class="w-full container">
47+
<div class="innerContainer">
11848
<Button on:click={edit} kind="ghost" width={'100%'} padding={'0'} size="small">
11949
<div class="flex-between w-full" slot="content">
12050
<div class="flex-row-center flex-gap-2">
12151
<TriggerPresenter {process} value={transition.trigger} params={transition.triggerParams} />
12252
<TransitionPresenter {transition} {direction} />
12353
</div>
12454
<div class="flex-row-center">
125-
{#if !readonly}
126-
<div class="tool">
127-
<ButtonIcon kind="tertiary" icon={IconMoreV} size={'min'} on:click={onMenuClick} />
128-
</div>
129-
{/if}
13055
{#if transition.to !== null}
131-
<Button
132-
on:click={() => {
133-
collapsed = !collapsed
134-
}}
135-
padding={'0.25rem'}
136-
kind="ghost"
137-
size="small"
138-
>
139-
<div class="flex-row-center" slot="content">
140-
<Icon icon={plugin.icon.Process} size="small" />
141-
{transition.actions.length}
142-
</div>
143-
</Button>
56+
<Icon icon={plugin.icon.Process} size="small" />
57+
{transition.actions.length}
14458
{/if}
14559
</div>
14660
</div>
14761
</Button>
148-
{#if !collapsed}
149-
{#each transition.actions as action}
150-
<Button
151-
justify="left"
152-
kind="ghost"
153-
width="100%"
154-
on:click={() => {
155-
if (readonly) return
156-
editAction(action)
157-
}}
158-
>
159-
<svelte:fragment slot="content">
160-
<ActionPresenter {action} {process} {readonly} />
161-
</svelte:fragment>
162-
</Button>
163-
{/each}
164-
{#if !readonly}
165-
<Button label={plugin.string.AddAction} icon={IconAdd} kind={'ghost'} width={'100%'} on:click={add} />
166-
{/if}
167-
{/if}
16862
</div>
16963
</div>
17064

0 commit comments

Comments
 (0)