@haiiro/docuflow 0.0.8 → 0.0.9
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 +7 -0
- package/manifest.json +32 -7
- package/package.json +1 -1
- package/src/front-components/docflow-documents.front-component.mjs +26 -26
- package/src/front-components/docflow-documents.front-component.tsx +24 -8
- package/src/front-components/docflow-processes.front-component.mjs +23 -23
- package/src/front-components/docflow-processes.front-component.tsx +25 -2
- package/src/front-components/docflow-tasks.front-component.mjs +32 -32
- package/src/front-components/docflow-tasks.front-component.tsx +16 -4
- package/src/front-components/process-steps.front-component.mjs +21 -21
- package/src/front-components/process-steps.front-component.tsx +27 -1
|
@@ -4,7 +4,7 @@ import { AppPath, enqueueSnackbar, openSidePanelPage } from 'twenty-sdk/front-co
|
|
|
4
4
|
import { Button } from 'twenty-ui/primitives/input';
|
|
5
5
|
import { useTheme } from 'twenty-ui/theme';
|
|
6
6
|
|
|
7
|
-
import { createRecord, getErrorMessage, listRecords } from 'src/front/api';
|
|
7
|
+
import { createRecord, deleteRecord, getErrorMessage, listRecords } from 'src/front/api';
|
|
8
8
|
import {
|
|
9
9
|
DOCUMENT_TYPE_LABELS,
|
|
10
10
|
formatDate,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
TextField,
|
|
20
20
|
Toolbar,
|
|
21
21
|
} from 'src/front/ui/components';
|
|
22
|
-
import { restAnd, restEq, restIlike, restIn, restOr } from 'src/shared/api/rest-filter.util';
|
|
22
|
+
import { restAnd, restEq, restIlike, restIn, restIsNotNull, restOr } from 'src/shared/api/rest-filter.util';
|
|
23
23
|
import { DOCUMENT_OBJECT_NAME, PAGE_SIZE } from 'src/shared/docflow.constants';
|
|
24
24
|
import { logDocflow, logDocflowError } from 'src/shared/log.util';
|
|
25
25
|
import { DOCUMENTS_FRONT_COMPONENT_UNIVERSAL_IDENTIFIER } from 'src/universal-identifiers';
|
|
@@ -27,7 +27,7 @@ import { DOCUMENTS_FRONT_COMPONENT_UNIVERSAL_IDENTIFIER } from 'src/universal-id
|
|
|
27
27
|
const LIST_POLL_INTERVAL_MS = 3000;
|
|
28
28
|
const LIST_POLL_DURATION_MS = 10 * 60 * 1000;
|
|
29
29
|
|
|
30
|
-
type DocumentFilter = 'all' | 'collected' | 'DRAFT' | 'IN_REVIEW' | 'APPROVED' | 'ARCHIVED';
|
|
30
|
+
type DocumentFilter = 'all' | 'collected' | 'DRAFT' | 'IN_REVIEW' | 'APPROVED' | 'ARCHIVED' | 'deleted';
|
|
31
31
|
|
|
32
32
|
const SEARCH_DEBOUNCE_MS = 300;
|
|
33
33
|
const FOLDERS_LIMIT = 500;
|
|
@@ -65,7 +65,10 @@ const buildFilter = ({
|
|
|
65
65
|
}) =>
|
|
66
66
|
restAnd(
|
|
67
67
|
folderId !== ALL_FOLDERS ? restEq('folderId', folderId) : undefined,
|
|
68
|
-
|
|
68
|
+
// Deleted = in the Twenty trash, restored from the document's own card
|
|
69
|
+
documentFilter === 'deleted'
|
|
70
|
+
? restIsNotNull('deletedAt')
|
|
71
|
+
: documentFilter === 'collected'
|
|
69
72
|
? restIn('origin', ['RECORD', 'PROCESS'])
|
|
70
73
|
: documentFilter !== 'all'
|
|
71
74
|
? restEq('status', documentFilter)
|
|
@@ -180,6 +183,17 @@ const DocflowDocuments = () => {
|
|
|
180
183
|
}
|
|
181
184
|
};
|
|
182
185
|
|
|
186
|
+
const handleDeleteDocument = async (documentId: string) => {
|
|
187
|
+
try {
|
|
188
|
+
await deleteRecord('smbDocuments', documentId);
|
|
189
|
+
await enqueueSnackbar({ message: 'Документ удалён: он в фильтре «Удалённые»', variant: 'success' });
|
|
190
|
+
await reload();
|
|
191
|
+
} catch (deleteError) {
|
|
192
|
+
logDocflowError('documents: delete failed', deleteError, { documentId });
|
|
193
|
+
await enqueueSnackbar({ message: getErrorMessage(deleteError, 'Не удалось удалить документ'), variant: 'error' });
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
183
197
|
const handleCreateFolder = async () => {
|
|
184
198
|
const folderName = newFolderName.trim();
|
|
185
199
|
|
|
@@ -257,6 +271,7 @@ const DocflowDocuments = () => {
|
|
|
257
271
|
{ value: 'IN_REVIEW', label: 'На согласовании' },
|
|
258
272
|
{ value: 'APPROVED', label: 'Согласованные' },
|
|
259
273
|
{ value: 'ARCHIVED', label: 'В архиве' },
|
|
274
|
+
{ value: 'deleted', label: 'Удалённые' },
|
|
260
275
|
]}
|
|
261
276
|
onChange={(value) => {
|
|
262
277
|
setDocumentFilter(value);
|
|
@@ -279,14 +294,15 @@ const DocflowDocuments = () => {
|
|
|
279
294
|
{documents.length > 0 && (
|
|
280
295
|
<DataTable
|
|
281
296
|
columns={[
|
|
282
|
-
{ key: 'name', label: 'Название', width: '
|
|
283
|
-
{ key: 'type', label: 'Тип', width: '
|
|
284
|
-
{ key: 'number', label: 'Номер', width: '
|
|
285
|
-
{ key: 'source', label: 'Где загружен', width: '
|
|
297
|
+
{ key: 'name', label: 'Название', width: '30%' },
|
|
298
|
+
{ key: 'type', label: 'Тип', width: '12%' },
|
|
299
|
+
{ key: 'number', label: 'Номер', width: '10%' },
|
|
300
|
+
{ key: 'source', label: 'Где загружен', width: '22%' },
|
|
286
301
|
{ key: 'createdAt', label: 'Добавлен' },
|
|
287
302
|
]}
|
|
288
303
|
selectedRowId={openedDocumentId}
|
|
289
304
|
onRowClick={(documentId) => void openDocument(documentId)}
|
|
305
|
+
onDeleteRow={documentFilter === 'deleted' ? undefined : handleDeleteDocument}
|
|
290
306
|
rows={documents.map((document) => ({
|
|
291
307
|
id: document.id,
|
|
292
308
|
cells: {
|