@haiiro/docuflow 0.0.5 → 0.0.7

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.
@@ -1,6 +1,6 @@
1
1
  import { useState } from 'react';
2
2
  import { defineFrontComponent } from 'twenty-sdk/define';
3
- import { enqueueSnackbar } from 'twenty-sdk/front-component';
3
+ import { AppPath, enqueueSnackbar, openSidePanelPage } from 'twenty-sdk/front-component';
4
4
  import { Button } from 'twenty-ui/primitives/input';
5
5
  import { Tag } from 'twenty-ui/primitives/data-display';
6
6
  import { useTheme } from 'twenty-ui/theme';
@@ -27,6 +27,7 @@ import {
27
27
  restAnd,
28
28
  restEq,
29
29
  restIlike,
30
+ restIsNotNull,
30
31
  restIsNull,
31
32
  restLt,
32
33
  restNeq,
@@ -37,7 +38,7 @@ import { type FormField } from 'src/shared/form/form-field.type';
37
38
  import { getFormFieldsError } from 'src/shared/form/form-fields.util';
38
39
  import { TASKS_FRONT_COMPONENT_UNIVERSAL_IDENTIFIER } from 'src/universal-identifiers';
39
40
 
40
- type TaskFilter = 'open' | 'mine' | 'overdue' | 'done';
41
+ type TaskFilter = 'open' | 'mine' | 'overdue' | 'done' | 'archived';
41
42
  type TaskSort = 'newest' | 'oldest' | 'dueSoon' | 'nameAsc';
42
43
  type Panel = { kind: 'closed' } | { kind: 'create' } | { kind: 'task'; taskId: string };
43
44
 
@@ -53,6 +54,15 @@ const ORDER_BY: Record<TaskSort, string> = {
53
54
 
54
55
  const OPEN_FILTER = restOr(restNeq('status', TASK_DONE_STATUS), restIsNull('status'));
55
56
 
57
+ // An archived task opens in its standard card: Twenty shows it as deleted
58
+ // there and offers to restore it.
59
+ const openArchivedTask = (taskId: string) =>
60
+ openSidePanelPage({
61
+ to: AppPath.RecordShowPage,
62
+ params: { objectNameSingular: 'task', objectRecordId: taskId },
63
+ pageTitle: 'Задание',
64
+ });
65
+
56
66
  // The list is filtered by the server, so a long history of tasks never
57
67
  // travels to the browser.
58
68
  const buildFilter = ({
@@ -68,7 +78,12 @@ const buildFilter = ({
68
78
  }) =>
69
79
  restAnd(
70
80
  restEq('smbSection', DOCFLOW_SECTION),
71
- taskFilter === 'done' ? restEq('status', TASK_DONE_STATUS) : OPEN_FILTER,
81
+ // Archived = deleted in Twenty (kept in its trash): any status
82
+ taskFilter === 'archived'
83
+ ? restIsNotNull('deletedAt')
84
+ : taskFilter === 'done'
85
+ ? restEq('status', TASK_DONE_STATUS)
86
+ : OPEN_FILTER,
72
87
  taskFilter === 'mine'
73
88
  ? currentMemberId !== undefined
74
89
  ? restEq('assigneeId', currentMemberId)
@@ -224,6 +239,7 @@ const DocflowTasks = () => {
224
239
  { value: 'mine', label: 'Мои' },
225
240
  { value: 'overdue', label: 'Просроченные' },
226
241
  { value: 'done', label: 'Выполненные' },
242
+ { value: 'archived', label: 'Архив' },
227
243
  ]}
228
244
  onChange={(value) => {
229
245
  setTaskFilter(value);
@@ -263,7 +279,11 @@ const DocflowTasks = () => {
263
279
  { key: 'status', label: 'Статус' },
264
280
  ]}
265
281
  selectedRowId={panel.kind === 'task' ? panel.taskId : undefined}
266
- onRowClick={(taskId) => setPanel({ kind: 'task', taskId })}
282
+ onRowClick={(taskId) =>
283
+ taskFilter === 'archived'
284
+ ? void openArchivedTask(taskId)
285
+ : setPanel({ kind: 'task', taskId })
286
+ }
267
287
  rows={tasks.map((task) => ({
268
288
  id: task.id,
269
289
  cells: {