@haiiro/docuflow 0.0.0-stage → 0.0.2
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/.nvmrc +1 -0
- package/.oxlintrc.json +37 -0
- package/.yarnrc.yml +1 -0
- package/README.md +127 -2
- package/package.json +60 -4
- package/public/cover.svg +15 -0
- package/public/logo.svg +9 -0
- package/src/application-config.ts +58 -0
- package/src/fields/company-documents.field.ts +29 -0
- package/src/fields/document-author.field.ts +32 -0
- package/src/fields/document-counterparty.field.ts +32 -0
- package/src/fields/document-folder-child-folders.field.ts +23 -0
- package/src/fields/document-folder-documents.field.ts +24 -0
- package/src/fields/document-folder-parent-folder.field.ts +31 -0
- package/src/fields/document-folder.field.ts +32 -0
- package/src/fields/document-responsible.field.ts +32 -0
- package/src/fields/member-authored-documents.field.ts +29 -0
- package/src/fields/member-responsible-documents.field.ts +29 -0
- package/src/fields/task-form-schema.field.ts +21 -0
- package/src/fields/task-form-values.field.ts +21 -0
- package/src/fields/task-instruction.field.ts +21 -0
- package/src/fields/task-section.field.ts +36 -0
- package/src/fields/task-workflow-run-id.field.ts +21 -0
- package/src/fields/task-workflow-step-id.field.ts +21 -0
- package/src/fields/task-workflow-thread-id.field.ts +21 -0
- package/src/fields/workflow-launch-fields.field.ts +21 -0
- package/src/fields/workflow-section.field.ts +36 -0
- package/src/front/api.ts +56 -0
- package/src/front/format.ts +60 -0
- package/src/front/hooks/use-async.ts +54 -0
- package/src/front/hooks/use-workspace-members.ts +22 -0
- package/src/front/types.ts +48 -0
- package/src/front/ui/components.tsx +436 -0
- package/src/front/ui/form-field-inputs.tsx +187 -0
- package/src/front/ui/form-fields-builder.tsx +183 -0
- package/src/front/ui/task-work-panel.tsx +218 -0
- package/src/front-components/docflow-documents.front-component.tsx +516 -0
- package/src/front-components/docflow-processes.front-component.tsx +266 -0
- package/src/front-components/docflow-tasks.front-component.tsx +303 -0
- package/src/front-components/process-steps.front-component.tsx +286 -0
- package/src/front-components/task-form.front-component.tsx +29 -0
- package/src/logic-functions/bitrix-app.logic-function.ts +143 -0
- package/src/logic-functions/bitrix-event.logic-function.ts +54 -0
- package/src/logic-functions/bitrix-install.logic-function.ts +81 -0
- package/src/logic-functions/capture-file.logic-function.ts +32 -0
- package/src/logic-functions/complete-task.logic-function.ts +46 -0
- package/src/logic-functions/hand-out-form-step.logic-function.ts +30 -0
- package/src/logic-functions/health-check.ts +31 -0
- package/src/logic-functions/launch-parameters-step.logic-function.ts +33 -0
- package/src/logic-functions/launch-process.logic-function.ts +96 -0
- package/src/logic-functions/notify-bitrix-assignee.logic-function.ts +85 -0
- package/src/logic-functions/on-attachment-created.logic-function.ts +67 -0
- package/src/logic-functions/on-task-updated.logic-function.ts +71 -0
- package/src/logic-functions/on-workflow-run-updated.logic-function.ts +70 -0
- package/src/logic-functions/save-launch-fields.logic-function.ts +73 -0
- package/src/logic-functions/save-step-settings.logic-function.ts +90 -0
- package/src/logic-functions/save-task-form.logic-function.ts +62 -0
- package/src/navigation-menu-items/docflow.navigation-menu-item.ts +15 -0
- package/src/objects/document-folder.object.ts +80 -0
- package/src/objects/document.object.ts +312 -0
- package/src/page-layouts/docflow.page-layout.ts +86 -0
- package/src/page-layouts/task-docflow.page-layout-tab.ts +36 -0
- package/src/page-layouts/workflow-steps.page-layout-tab.ts +37 -0
- package/src/roles/default-role.ts +21 -0
- package/src/roles/docflow-member.role.ts +23 -0
- package/src/server/bitrix-page.ts +52 -0
- package/src/server/bitrix-portal.ts +67 -0
- package/src/server/document-capture.ts +102 -0
- package/src/server/http-response.ts +18 -0
- package/src/server/launch-step.ts +166 -0
- package/src/server/process-tasks.ts +116 -0
- package/src/server/records.ts +132 -0
- package/src/server/task-completion.ts +100 -0
- package/src/server/workflow-engine.ts +105 -0
- package/src/shared/api/core-graphql.util.ts +98 -0
- package/src/shared/api/object-summaries.ts +79 -0
- package/src/shared/api/rest-filter.util.ts +37 -0
- package/src/shared/api/rest-response.util.ts +43 -0
- package/src/shared/bitrix/bitrix-client.ts +114 -0
- package/src/shared/bitrix/bitrix.type.ts +25 -0
- package/src/shared/bitrix/bitrix.util.ts +139 -0
- package/src/shared/docflow.constants.ts +31 -0
- package/src/shared/documents/attachment-target.util.ts +64 -0
- package/src/shared/engine.ts +11 -0
- package/src/shared/form/form-field-builder.util.ts +122 -0
- package/src/shared/form/form-field.type.ts +23 -0
- package/src/shared/form/form-fields.util.ts +138 -0
- package/src/shared/form/step-settings.util.ts +104 -0
- package/src/shared/workflow/launch-step.util.ts +56 -0
- package/src/shared/workflow/run-target-record.util.ts +70 -0
- package/src/shared/workflow/workflow-run.type.ts +35 -0
- package/src/shared/workflow/workflow-run.util.ts +174 -0
- package/src/universal-identifiers.ts +199 -0
- package/src/views/all-document-folders.view.ts +50 -0
- package/src/views/all-documents.view.ts +91 -0
- package/src/views/documents-by-status.view.ts +76 -0
- package/tsconfig.json +37 -0
- package/tsconfig.spec.json +9 -0
- package/vitest.unit.config.ts +14 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { Button } from 'twenty-ui/primitives/input';
|
|
3
|
+
import { useTheme } from 'twenty-ui/theme';
|
|
4
|
+
|
|
5
|
+
import { CheckboxField, Message, SelectField, TextField, VariableChip } from 'src/front/ui/components';
|
|
6
|
+
import { FormFieldInputs } from 'src/front/ui/form-field-inputs';
|
|
7
|
+
import { type FormField } from 'src/shared/form/form-field.type';
|
|
8
|
+
import {
|
|
9
|
+
applyBuilderFieldKind,
|
|
10
|
+
BUILDER_FIELD_KINDS,
|
|
11
|
+
type BuilderFieldKind,
|
|
12
|
+
buildNewBuilderField,
|
|
13
|
+
buildUniqueFieldName,
|
|
14
|
+
getBuilderFieldKind,
|
|
15
|
+
setFieldRequired,
|
|
16
|
+
} from 'src/shared/form/form-field-builder.util';
|
|
17
|
+
import { isFormFieldRequired } from 'src/shared/form/form-fields.util';
|
|
18
|
+
|
|
19
|
+
// Fields are built here instead of written as JSON. A field keeps its name
|
|
20
|
+
// once saved: later steps of a process read it as {{step.name}}, so renaming
|
|
21
|
+
// the label must not break them. A new field takes its name from the label.
|
|
22
|
+
export const FormFieldsBuilder = ({
|
|
23
|
+
fields,
|
|
24
|
+
onChange,
|
|
25
|
+
variablePrefix,
|
|
26
|
+
disabled = false,
|
|
27
|
+
}: {
|
|
28
|
+
fields: FormField[];
|
|
29
|
+
onChange: (fields: FormField[]) => void;
|
|
30
|
+
variablePrefix?: string;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
}) => {
|
|
33
|
+
const theme = useTheme();
|
|
34
|
+
const [savedFieldIds] = useState(() => new Set(fields.map(({ id }) => id)));
|
|
35
|
+
const [isPreviewShown, setIsPreviewShown] = useState(false);
|
|
36
|
+
|
|
37
|
+
const updateField = (fieldId: string, update: (field: FormField) => FormField) =>
|
|
38
|
+
onChange(fields.map((field) => (field.id === fieldId ? update(field) : field)));
|
|
39
|
+
|
|
40
|
+
const renameField = (field: FormField, label: string): FormField =>
|
|
41
|
+
savedFieldIds.has(field.id) || label.trim().length === 0
|
|
42
|
+
? { ...field, label }
|
|
43
|
+
: {
|
|
44
|
+
...field,
|
|
45
|
+
label,
|
|
46
|
+
name: buildUniqueFieldName(
|
|
47
|
+
label,
|
|
48
|
+
fields.filter(({ id }) => id !== field.id).map(({ name }) => name),
|
|
49
|
+
),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const moveField = (index: number, offset: -1 | 1) => {
|
|
53
|
+
const target = index + offset;
|
|
54
|
+
|
|
55
|
+
if (target < 0 || target >= fields.length) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const reordered = [...fields];
|
|
60
|
+
|
|
61
|
+
[reordered[index], reordered[target]] = [reordered[target], reordered[index]];
|
|
62
|
+
onChange(reordered);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: theme.spacing[2] }}>
|
|
67
|
+
{fields.length === 0 && <Message tone="hint">Полей нет.</Message>}
|
|
68
|
+
{fields.map((field, index) => {
|
|
69
|
+
const kind = getBuilderFieldKind(field);
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<div
|
|
73
|
+
key={field.id}
|
|
74
|
+
style={{
|
|
75
|
+
background: theme.background.transparent.lighter,
|
|
76
|
+
borderRadius: theme.border.radius.md,
|
|
77
|
+
display: 'flex',
|
|
78
|
+
flexDirection: 'column',
|
|
79
|
+
gap: theme.spacing[2],
|
|
80
|
+
padding: theme.spacing[2],
|
|
81
|
+
}}
|
|
82
|
+
>
|
|
83
|
+
<div style={{ display: 'flex', flexWrap: 'wrap', gap: theme.spacing[2] }}>
|
|
84
|
+
<div style={{ flex: '2 1 180px' }}>
|
|
85
|
+
<TextField
|
|
86
|
+
label="Название"
|
|
87
|
+
placeholder="Например, Сумма договора"
|
|
88
|
+
value={field.label}
|
|
89
|
+
disabled={disabled}
|
|
90
|
+
onChange={(label) => updateField(field.id, (current) => renameField(current, label))}
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
<div style={{ flex: '1 1 120px' }}>
|
|
94
|
+
{kind !== undefined ? (
|
|
95
|
+
<SelectField<BuilderFieldKind>
|
|
96
|
+
label="Тип"
|
|
97
|
+
value={kind}
|
|
98
|
+
disabled={disabled}
|
|
99
|
+
options={BUILDER_FIELD_KINDS.map(({ value, label }) => ({ value, label }))}
|
|
100
|
+
onChange={(nextKind) =>
|
|
101
|
+
updateField(field.id, (current) => applyBuilderFieldKind(current, nextKind))
|
|
102
|
+
}
|
|
103
|
+
/>
|
|
104
|
+
) : (
|
|
105
|
+
<TextField label="Тип" value={field.type} disabled onChange={() => undefined} />
|
|
106
|
+
)}
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
<div style={{ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: theme.spacing[2] }}>
|
|
110
|
+
<CheckboxField
|
|
111
|
+
label="Обязательное"
|
|
112
|
+
checked={isFormFieldRequired(field)}
|
|
113
|
+
disabled={disabled}
|
|
114
|
+
onChange={(isRequired) =>
|
|
115
|
+
updateField(field.id, (current) => setFieldRequired(current, isRequired))
|
|
116
|
+
}
|
|
117
|
+
/>
|
|
118
|
+
{variablePrefix !== undefined && (
|
|
119
|
+
<VariableChip>{`{{${variablePrefix}.${field.name}}}`}</VariableChip>
|
|
120
|
+
)}
|
|
121
|
+
<div style={{ display: 'flex', gap: theme.spacing[1], marginLeft: 'auto' }}>
|
|
122
|
+
<Button
|
|
123
|
+
variant="ghost"
|
|
124
|
+
size="sm"
|
|
125
|
+
title="Выше"
|
|
126
|
+
aria-label={`Поднять поле ${field.label}`}
|
|
127
|
+
disabled={disabled || index === 0}
|
|
128
|
+
onClick={() => moveField(index, -1)}
|
|
129
|
+
>
|
|
130
|
+
↑
|
|
131
|
+
</Button>
|
|
132
|
+
<Button
|
|
133
|
+
variant="ghost"
|
|
134
|
+
size="sm"
|
|
135
|
+
title="Ниже"
|
|
136
|
+
aria-label={`Опустить поле ${field.label}`}
|
|
137
|
+
disabled={disabled || index === fields.length - 1}
|
|
138
|
+
onClick={() => moveField(index, 1)}
|
|
139
|
+
>
|
|
140
|
+
↓
|
|
141
|
+
</Button>
|
|
142
|
+
<Button
|
|
143
|
+
variant="ghost"
|
|
144
|
+
size="sm"
|
|
145
|
+
disabled={disabled}
|
|
146
|
+
onClick={() => onChange(fields.filter(({ id }) => id !== field.id))}
|
|
147
|
+
>
|
|
148
|
+
Удалить
|
|
149
|
+
</Button>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
);
|
|
154
|
+
})}
|
|
155
|
+
<div style={{ display: 'flex', flexWrap: 'wrap', gap: theme.spacing[2] }}>
|
|
156
|
+
<Button
|
|
157
|
+
variant="outline"
|
|
158
|
+
size="sm"
|
|
159
|
+
disabled={disabled}
|
|
160
|
+
onClick={() => onChange([...fields, buildNewBuilderField(fields, () => crypto.randomUUID())])}
|
|
161
|
+
>
|
|
162
|
+
Добавить поле
|
|
163
|
+
</Button>
|
|
164
|
+
{fields.length > 0 && (
|
|
165
|
+
<Button variant="ghost" size="sm" onClick={() => setIsPreviewShown((current) => !current)}>
|
|
166
|
+
{isPreviewShown ? 'Скрыть предпросмотр' : 'Как увидит исполнитель'}
|
|
167
|
+
</Button>
|
|
168
|
+
)}
|
|
169
|
+
</div>
|
|
170
|
+
{isPreviewShown && fields.length > 0 && (
|
|
171
|
+
<div
|
|
172
|
+
style={{
|
|
173
|
+
borderRadius: theme.border.radius.md,
|
|
174
|
+
boxShadow: `inset 0 0 0 1px ${theme.border.color.light}`,
|
|
175
|
+
padding: theme.spacing[3],
|
|
176
|
+
}}
|
|
177
|
+
>
|
|
178
|
+
<FormFieldInputs fields={fields} values={{}} disabled onChange={() => undefined} />
|
|
179
|
+
</div>
|
|
180
|
+
)}
|
|
181
|
+
</div>
|
|
182
|
+
);
|
|
183
|
+
};
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { enqueueSnackbar } from 'twenty-sdk/front-component';
|
|
3
|
+
import { Button } from 'twenty-ui/primitives/input';
|
|
4
|
+
import { Tag } from 'twenty-ui/primitives/data-display';
|
|
5
|
+
import { useTheme } from 'twenty-ui/theme';
|
|
6
|
+
|
|
7
|
+
import { callAppRoute, getErrorMessage, getRecord } from 'src/front/api';
|
|
8
|
+
import { formatDate, formatMemberName, isOverdue, TASK_STATUS_LABELS } from 'src/front/format';
|
|
9
|
+
import { useAsync } from 'src/front/hooks/use-async';
|
|
10
|
+
import { useWorkspaceMembers } from 'src/front/hooks/use-workspace-members';
|
|
11
|
+
import { type DocflowTask } from 'src/front/types';
|
|
12
|
+
import { Details, Message, SectionTitle } from 'src/front/ui/components';
|
|
13
|
+
import { FormFieldInputs } from 'src/front/ui/form-field-inputs';
|
|
14
|
+
import { FormFieldsBuilder } from 'src/front/ui/form-fields-builder';
|
|
15
|
+
import { TASK_DONE_STATUS } from 'src/shared/docflow.constants';
|
|
16
|
+
import { type FormField, type FormValues } from 'src/shared/form/form-field.type';
|
|
17
|
+
import { getFormFieldsError, parseFormFields, parseFormValues } from 'src/shared/form/form-fields.util';
|
|
18
|
+
|
|
19
|
+
// The one-off fields of a task: the author builds them, the worker fills them.
|
|
20
|
+
const TaskFieldsEditor = ({
|
|
21
|
+
initialFields,
|
|
22
|
+
onSave,
|
|
23
|
+
onCancel,
|
|
24
|
+
}: {
|
|
25
|
+
initialFields: FormField[];
|
|
26
|
+
onSave: (fields: FormField[]) => Promise<void>;
|
|
27
|
+
onCancel: () => void;
|
|
28
|
+
}) => {
|
|
29
|
+
const theme = useTheme();
|
|
30
|
+
const [fields, setFields] = useState(initialFields);
|
|
31
|
+
const [isSaving, setIsSaving] = useState(false);
|
|
32
|
+
const [errorMessage, setErrorMessage] = useState<string | undefined>();
|
|
33
|
+
|
|
34
|
+
const save = async () => {
|
|
35
|
+
const fieldsError = getFormFieldsError(fields);
|
|
36
|
+
|
|
37
|
+
if (fieldsError !== undefined) {
|
|
38
|
+
setErrorMessage(fieldsError);
|
|
39
|
+
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
setIsSaving(true);
|
|
44
|
+
setErrorMessage(undefined);
|
|
45
|
+
await onSave(fields).finally(() => setIsSaving(false));
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: theme.spacing[2] }}>
|
|
50
|
+
<FormFieldsBuilder fields={fields} onChange={setFields} disabled={isSaving} />
|
|
51
|
+
{errorMessage !== undefined && <Message tone="danger">{errorMessage}</Message>}
|
|
52
|
+
<div style={{ display: 'flex', flexWrap: 'wrap', gap: theme.spacing[2] }}>
|
|
53
|
+
<Button variant="solid" size="sm" loading={isSaving} onClick={() => void save()}>
|
|
54
|
+
Сохранить поля
|
|
55
|
+
</Button>
|
|
56
|
+
<Button variant="ghost" size="sm" onClick={onCancel}>
|
|
57
|
+
Отмена
|
|
58
|
+
</Button>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const TaskWorkPanel = ({
|
|
65
|
+
taskId,
|
|
66
|
+
onChanged,
|
|
67
|
+
}: {
|
|
68
|
+
taskId: string;
|
|
69
|
+
onChanged?: () => void;
|
|
70
|
+
}) => {
|
|
71
|
+
const theme = useTheme();
|
|
72
|
+
const { members } = useWorkspaceMembers();
|
|
73
|
+
const { data: task, loading, error, reload } = useAsync(
|
|
74
|
+
() => getRecord<DocflowTask>('tasks', taskId),
|
|
75
|
+
[taskId],
|
|
76
|
+
);
|
|
77
|
+
const [draftValues, setDraftValues] = useState<FormValues | undefined>();
|
|
78
|
+
const [isEditingFields, setIsEditingFields] = useState(false);
|
|
79
|
+
const [isBusy, setIsBusy] = useState(false);
|
|
80
|
+
const [errorMessage, setErrorMessage] = useState<string | undefined>();
|
|
81
|
+
|
|
82
|
+
if (task === undefined) {
|
|
83
|
+
return loading ? (
|
|
84
|
+
<Message>Загрузка…</Message>
|
|
85
|
+
) : (
|
|
86
|
+
<Message tone="danger">{getErrorMessage(error, 'Задание не найдено или нет доступа.')}</Message>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const fields = parseFormFields(task.smbFormSchema);
|
|
91
|
+
const values = draftValues ?? parseFormValues(task.smbFormValues);
|
|
92
|
+
const isProcessTask = typeof task.smbWorkflowThreadId === 'string' && task.smbWorkflowThreadId.length > 0;
|
|
93
|
+
const isDone = task.status === TASK_DONE_STATUS;
|
|
94
|
+
const assignee = members.find((member) => member.id === task.assigneeId);
|
|
95
|
+
|
|
96
|
+
const runAction = async (action: () => Promise<unknown>, successMessage: string, failureMessage: string) => {
|
|
97
|
+
setIsBusy(true);
|
|
98
|
+
setErrorMessage(undefined);
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
await action();
|
|
102
|
+
await enqueueSnackbar({ message: successMessage, variant: 'success' });
|
|
103
|
+
setDraftValues(undefined);
|
|
104
|
+
await reload();
|
|
105
|
+
onChanged?.();
|
|
106
|
+
} catch (actionError) {
|
|
107
|
+
setErrorMessage(getErrorMessage(actionError, failureMessage));
|
|
108
|
+
} finally {
|
|
109
|
+
setIsBusy(false);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: theme.spacing[3] }}>
|
|
115
|
+
<strong style={{ fontSize: theme.font.size.lg }}>{task.title?.trim() || 'Без названия'}</strong>
|
|
116
|
+
<Details
|
|
117
|
+
rows={[
|
|
118
|
+
{
|
|
119
|
+
label: 'Статус',
|
|
120
|
+
value: <Tag color={isDone ? 'green' : 'gray'}>{TASK_STATUS_LABELS[task.status ?? ''] ?? task.status ?? 'Без статуса'}</Tag>,
|
|
121
|
+
},
|
|
122
|
+
{ label: 'Исполнитель', value: formatMemberName(assignee) },
|
|
123
|
+
{
|
|
124
|
+
label: 'Срок',
|
|
125
|
+
value: task.dueAt && (
|
|
126
|
+
<span style={{ color: isOverdue(task.dueAt, task.status, new Date()) ? theme.font.color.danger : undefined }}>
|
|
127
|
+
{formatDate(task.dueAt)}
|
|
128
|
+
</span>
|
|
129
|
+
),
|
|
130
|
+
},
|
|
131
|
+
{ label: 'Процесс', value: isProcessTask ? 'Задание шага процесса' : undefined },
|
|
132
|
+
]}
|
|
133
|
+
/>
|
|
134
|
+
{typeof task.smbInstruction === 'string' && task.smbInstruction.trim().length > 0 && (
|
|
135
|
+
<section
|
|
136
|
+
aria-label="Инструкция"
|
|
137
|
+
style={{
|
|
138
|
+
background: theme.background.transparent.lighter,
|
|
139
|
+
borderRadius: theme.border.radius.md,
|
|
140
|
+
padding: theme.spacing[3],
|
|
141
|
+
whiteSpace: 'pre-wrap',
|
|
142
|
+
}}
|
|
143
|
+
>
|
|
144
|
+
<div style={{ color: theme.font.color.tertiary, fontSize: theme.font.size.sm, marginBottom: theme.spacing[1] }}>
|
|
145
|
+
Инструкция
|
|
146
|
+
</div>
|
|
147
|
+
{task.smbInstruction}
|
|
148
|
+
</section>
|
|
149
|
+
)}
|
|
150
|
+
<SectionTitle
|
|
151
|
+
action={
|
|
152
|
+
!isProcessTask &&
|
|
153
|
+
!isEditingFields &&
|
|
154
|
+
!isDone && (
|
|
155
|
+
<Button variant="ghost" size="sm" onClick={() => setIsEditingFields(true)}>
|
|
156
|
+
{fields.length > 0 ? 'Изменить поля' : 'Добавить поля'}
|
|
157
|
+
</Button>
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
>
|
|
161
|
+
{isProcessTask ? 'Поля задаёт шаг процесса' : 'Поля задания'}
|
|
162
|
+
</SectionTitle>
|
|
163
|
+
{isEditingFields ? (
|
|
164
|
+
<TaskFieldsEditor
|
|
165
|
+
initialFields={fields}
|
|
166
|
+
onCancel={() => setIsEditingFields(false)}
|
|
167
|
+
onSave={(nextFields) =>
|
|
168
|
+
runAction(
|
|
169
|
+
async () => {
|
|
170
|
+
await callAppRoute('/docflow/tasks/form', { taskId, fields: nextFields });
|
|
171
|
+
setIsEditingFields(false);
|
|
172
|
+
},
|
|
173
|
+
'Поля сохранены',
|
|
174
|
+
'Не удалось сохранить поля',
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
/>
|
|
178
|
+
) : (
|
|
179
|
+
<FormFieldInputs fields={fields} values={values} disabled={isBusy || isDone} onChange={setDraftValues} />
|
|
180
|
+
)}
|
|
181
|
+
{errorMessage !== undefined && <Message tone="danger">{errorMessage}</Message>}
|
|
182
|
+
<div style={{ display: 'flex', flexWrap: 'wrap', gap: theme.spacing[2] }}>
|
|
183
|
+
{!isDone && (
|
|
184
|
+
<Button
|
|
185
|
+
variant="solid"
|
|
186
|
+
size="sm"
|
|
187
|
+
loading={isBusy}
|
|
188
|
+
onClick={() =>
|
|
189
|
+
runAction(
|
|
190
|
+
() => callAppRoute('/docflow/tasks/complete', { taskId, values }),
|
|
191
|
+
'Задание выполнено',
|
|
192
|
+
'Не удалось выполнить задание',
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
>
|
|
196
|
+
Выполнить
|
|
197
|
+
</Button>
|
|
198
|
+
)}
|
|
199
|
+
{!isDone && draftValues !== undefined && (
|
|
200
|
+
<Button
|
|
201
|
+
variant="outline"
|
|
202
|
+
size="sm"
|
|
203
|
+
disabled={isBusy}
|
|
204
|
+
onClick={() =>
|
|
205
|
+
runAction(
|
|
206
|
+
() => callAppRoute('/docflow/tasks/form', { taskId, values }),
|
|
207
|
+
'Сохранено',
|
|
208
|
+
'Не удалось сохранить',
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
>
|
|
212
|
+
Сохранить
|
|
213
|
+
</Button>
|
|
214
|
+
)}
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
);
|
|
218
|
+
};
|