@haiiro/docuflow 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -8
- package/manifest.json +99 -13
- package/package.json +6 -3
- package/public/app/docflow-app.css +2 -0
- package/public/app/docflow-app.js +94 -0
- package/src/front-components/docflow-documents.front-component.mjs +3 -3
- package/src/front-components/docflow-processes.front-component.mjs +19 -19
- package/src/front-components/docflow-processes.front-component.tsx +18 -2
- package/src/front-components/docflow-tasks.front-component.mjs +3 -3
- package/src/front-components/launch-process.front-component.mjs +75 -0
- package/src/front-components/launch-process.front-component.tsx +270 -0
- package/src/front-components/process-steps.front-component.mjs +24 -24
- package/src/front-components/process-steps.front-component.tsx +54 -9
- package/src/front-components/task-form.front-component.mjs +21 -21
- package/src/logic-functions/bitrix-app.logic-function.mjs +160 -87
- package/src/logic-functions/bitrix-app.logic-function.ts +22 -59
- package/src/logic-functions/bitrix-install.logic-function.mjs +0 -11
- package/src/logic-functions/bitrix-install.logic-function.ts +0 -3
- package/src/logic-functions/docflow-app-session.logic-function.mjs +60043 -0
- package/src/logic-functions/docflow-app-session.logic-function.ts +54 -0
- package/src/logic-functions/docflow-app.logic-function.mjs +60122 -0
- package/src/logic-functions/docflow-app.logic-function.ts +37 -0
- package/src/logic-functions/launch-process.logic-function.mjs +113 -29
- package/src/logic-functions/launch-process.logic-function.ts +83 -22
- package/src/logic-functions/save-launch-fields.logic-function.mjs +176 -9
- package/src/logic-functions/save-launch-fields.logic-function.ts +24 -6
|
@@ -24,21 +24,32 @@ import {
|
|
|
24
24
|
VariableChip,
|
|
25
25
|
} from 'src/front/ui/components';
|
|
26
26
|
import { FormFieldsBuilder } from 'src/front/ui/form-fields-builder';
|
|
27
|
+
import { listLaunchObjects } from 'src/shared/api/object-summaries';
|
|
27
28
|
import { restAnd, restEq } from 'src/shared/api/rest-filter.util';
|
|
28
|
-
import { LAUNCH_TRIGGER_NAME, TRIGGER_STEP_ID } from 'src/shared/docflow.constants';
|
|
29
|
+
import { LAUNCH_RECORD_KEY, LAUNCH_TRIGGER_NAME, TRIGGER_STEP_ID } from 'src/shared/docflow.constants';
|
|
29
30
|
import { type FormField } from 'src/shared/form/form-field.type';
|
|
30
31
|
import { getFillableFormFields, getFormFieldsError, parseFormFields } from 'src/shared/form/form-fields.util';
|
|
31
32
|
import { readStepSettings, type StepSettings } from 'src/shared/form/step-settings.util';
|
|
32
|
-
import { parseLaunchFields } from 'src/shared/workflow/launch-step.util';
|
|
33
|
+
import { parseLaunchFields, parseLaunchObject } from 'src/shared/workflow/launch-step.util';
|
|
33
34
|
import { type WorkflowStep } from 'src/shared/workflow/workflow-run.type';
|
|
34
35
|
import { getFormStepFields, isFormStep } from 'src/shared/workflow/workflow-run.util';
|
|
35
36
|
import { logDocflow, logDocflowError } from 'src/shared/log.util';
|
|
36
37
|
import { PROCESS_STEPS_FRONT_COMPONENT_UNIVERSAL_IDENTIFIER } from 'src/universal-identifiers';
|
|
37
38
|
|
|
38
39
|
const NO_ASSIGNEE = '';
|
|
40
|
+
const NO_LAUNCH_OBJECT = '';
|
|
41
|
+
// Objects of the workflows themselves: a process is not launched on them
|
|
42
|
+
const WORKFLOW_OBJECTS = ['workflow', 'workflowVersion', 'workflowRun', 'workflowAutomatedTrigger'];
|
|
39
43
|
|
|
40
44
|
type DraftVersion = { id: string; steps?: WorkflowStep[] | null };
|
|
41
|
-
type ProcessRecord = { id: string; smbLaunchFields?: unknown };
|
|
45
|
+
type ProcessRecord = { id: string; smbLaunchFields?: unknown; smbLaunchObject?: string | null };
|
|
46
|
+
type LaunchObjectOption = { value: string; label: string };
|
|
47
|
+
|
|
48
|
+
const loadLaunchObjectOptions = async (): Promise<LaunchObjectOption[]> =>
|
|
49
|
+
(await listLaunchObjects())
|
|
50
|
+
.filter(({ nameSingular }) => !WORKFLOW_OBJECTS.includes(nameSingular))
|
|
51
|
+
.map(({ nameSingular, labelSingular }) => ({ value: nameSingular, label: labelSingular }))
|
|
52
|
+
.sort((left, right) => left.label.localeCompare(right.label, 'ru'));
|
|
42
53
|
|
|
43
54
|
const sectionStyle = { display: 'flex', flexDirection: 'column' as const };
|
|
44
55
|
|
|
@@ -64,14 +75,18 @@ const reopenWorkflowEditor = async (workflowId: string) => {
|
|
|
64
75
|
const LaunchParametersEditor = ({
|
|
65
76
|
workflowId,
|
|
66
77
|
initialFields,
|
|
78
|
+
initialLaunchObject,
|
|
67
79
|
onSaved,
|
|
68
80
|
}: {
|
|
69
81
|
workflowId: string;
|
|
70
82
|
initialFields: FormField[];
|
|
83
|
+
initialLaunchObject: string | undefined;
|
|
71
84
|
onSaved: () => void;
|
|
72
85
|
}) => {
|
|
73
86
|
const theme = useTheme();
|
|
74
87
|
const [fields, setFields] = useState(initialFields);
|
|
88
|
+
const [launchObject, setLaunchObject] = useState(initialLaunchObject ?? NO_LAUNCH_OBJECT);
|
|
89
|
+
const { data: objectOptions, error: objectsError } = useAsync(loadLaunchObjectOptions, []);
|
|
75
90
|
const [isSaving, setIsSaving] = useState(false);
|
|
76
91
|
const [errorMessage, setErrorMessage] = useState<string | undefined>();
|
|
77
92
|
|
|
@@ -86,15 +101,19 @@ const LaunchParametersEditor = ({
|
|
|
86
101
|
|
|
87
102
|
setIsSaving(true);
|
|
88
103
|
setErrorMessage(undefined);
|
|
89
|
-
logDocflow('process: save launch fields', { workflowId, fields });
|
|
104
|
+
logDocflow('process: save launch fields', { workflowId, fields, launchObject });
|
|
90
105
|
|
|
91
106
|
try {
|
|
92
|
-
const result = await callAppRoute('/docflow/processes/launch-fields', {
|
|
107
|
+
const result = await callAppRoute('/docflow/processes/launch-fields', {
|
|
108
|
+
workflowId,
|
|
109
|
+
fields,
|
|
110
|
+
launchObject: launchObject === NO_LAUNCH_OBJECT ? null : launchObject,
|
|
111
|
+
});
|
|
93
112
|
|
|
94
113
|
logDocflow('process: launch fields saved', result);
|
|
95
114
|
await enqueueSnackbar({
|
|
96
115
|
message:
|
|
97
|
-
fields.length > 0
|
|
116
|
+
fields.length > 0 || launchObject !== NO_LAUNCH_OBJECT
|
|
98
117
|
? `Параметры сохранены: процесс начинается с «${LAUNCH_TRIGGER_NAME}», опубликуйте его`
|
|
99
118
|
: 'Параметры убраны',
|
|
100
119
|
variant: 'success',
|
|
@@ -113,10 +132,35 @@ const LaunchParametersEditor = ({
|
|
|
113
132
|
<section style={{ ...sectionStyle, gap: theme.spacing[2] }} aria-label="Параметры запуска">
|
|
114
133
|
<SectionTitle>Параметры запуска</SectionTitle>
|
|
115
134
|
<Message tone="hint">
|
|
116
|
-
Что человек заполняет перед
|
|
117
|
-
в следующих шагах значения выбираются как его
|
|
118
|
-
|
|
135
|
+
Что человек заполняет перед запуском и на какой записи запускает процесс. Первым блоком процесса
|
|
136
|
+
становится «{LAUNCH_TRIGGER_NAME}»: в следующих шагах значения и запись выбираются как его
|
|
137
|
+
переменные, например сотрудник — в поле «Исполнитель». Запускают процесс командой «Запустить
|
|
138
|
+
процесс» в меню (Cmd+K) или на выбранных записях. Без параметров и записи процесс начинается с
|
|
139
|
+
обычного «Запуск вручную».
|
|
119
140
|
</Message>
|
|
141
|
+
<SelectField
|
|
142
|
+
label="Где запускать"
|
|
143
|
+
value={launchObject}
|
|
144
|
+
disabled={isSaving}
|
|
145
|
+
options={[
|
|
146
|
+
{ value: NO_LAUNCH_OBJECT, label: 'Откуда угодно, без записи' },
|
|
147
|
+
// The saved object stays offered while the list loads
|
|
148
|
+
...(objectOptions ??
|
|
149
|
+
(launchObject !== NO_LAUNCH_OBJECT ? [{ value: launchObject, label: launchObject }] : [])),
|
|
150
|
+
].map((option) =>
|
|
151
|
+
option.value === NO_LAUNCH_OBJECT ? option : { ...option, label: `На записи: ${option.label}` },
|
|
152
|
+
)}
|
|
153
|
+
onChange={setLaunchObject}
|
|
154
|
+
/>
|
|
155
|
+
{objectsError !== undefined && (
|
|
156
|
+
<Message tone="danger">{getErrorMessage(objectsError, 'Не удалось прочитать объекты')}</Message>
|
|
157
|
+
)}
|
|
158
|
+
{launchObject !== NO_LAUNCH_OBJECT && (
|
|
159
|
+
<div style={{ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: theme.spacing[2] }}>
|
|
160
|
+
<Message tone="hint">Запись, на которой запустили процесс:</Message>
|
|
161
|
+
<VariableChip>{`{{${TRIGGER_STEP_ID}.${LAUNCH_RECORD_KEY}}}`}</VariableChip>
|
|
162
|
+
</div>
|
|
163
|
+
)}
|
|
120
164
|
<FormFieldsBuilder
|
|
121
165
|
fields={fields}
|
|
122
166
|
onChange={setFields}
|
|
@@ -285,6 +329,7 @@ const ProcessSteps = () => {
|
|
|
285
329
|
key={`${workflowId}:${launchEditorKey}`}
|
|
286
330
|
workflowId={workflowId}
|
|
287
331
|
initialFields={parseLaunchFields(data.process.smbLaunchFields)}
|
|
332
|
+
initialLaunchObject={parseLaunchObject(data.process.smbLaunchObject)}
|
|
288
333
|
onSaved={() => {
|
|
289
334
|
void reload().then(() => setLaunchEditorKey((current) => current + 1));
|
|
290
335
|
}}
|