@dxos/plugin-kanban 0.8.4-main.9735255 → 0.8.4-main.abd8ff62ef
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/dist/lib/browser/blueprints/index.mjs +23 -4
- package/dist/lib/browser/blueprints/index.mjs.map +4 -4
- package/dist/lib/browser/chunk-T32TEM55.mjs +105 -0
- package/dist/lib/browser/chunk-T32TEM55.mjs.map +7 -0
- package/dist/lib/browser/delete-card-7OSCNCW2.mjs +24 -0
- package/dist/lib/browser/delete-card-7OSCNCW2.mjs.map +7 -0
- package/dist/lib/browser/delete-card-field-NSB2RE3Z.mjs +42 -0
- package/dist/lib/browser/delete-card-field-NSB2RE3Z.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +20 -89
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operations/index.mjs +13 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/restore-card-FO3WERIE.mjs +21 -0
- package/dist/lib/browser/restore-card-FO3WERIE.mjs.map +7 -0
- package/dist/lib/browser/restore-card-field-U5XYEEOW.mjs +40 -0
- package/dist/lib/browser/restore-card-field-U5XYEEOW.mjs.map +7 -0
- package/dist/lib/browser/translations.mjs +44 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +154 -8
- package/dist/lib/browser/types/index.mjs.map +4 -4
- package/dist/lib/node-esm/blueprints/index.mjs +23 -4
- package/dist/lib/node-esm/blueprints/index.mjs.map +4 -4
- package/dist/lib/node-esm/chunk-W2RNFBMZ.mjs +106 -0
- package/dist/lib/node-esm/chunk-W2RNFBMZ.mjs.map +7 -0
- package/dist/lib/node-esm/delete-card-ZIREL6HN.mjs +25 -0
- package/dist/lib/node-esm/delete-card-ZIREL6HN.mjs.map +7 -0
- package/dist/lib/node-esm/delete-card-field-IPTEGVPP.mjs +43 -0
- package/dist/lib/node-esm/delete-card-field-IPTEGVPP.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +20 -89
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operations/index.mjs +14 -0
- package/dist/lib/node-esm/operations/index.mjs.map +7 -0
- package/dist/lib/node-esm/restore-card-WJJ4YB7K.mjs +22 -0
- package/dist/lib/node-esm/restore-card-WJJ4YB7K.mjs.map +7 -0
- package/dist/lib/node-esm/restore-card-field-L24WJXAW.mjs +41 -0
- package/dist/lib/node-esm/restore-card-field-L24WJXAW.mjs.map +7 -0
- package/dist/lib/node-esm/translations.mjs +45 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +154 -8
- package/dist/lib/node-esm/types/index.mjs.map +4 -4
- package/dist/types/src/KanbanPlugin.d.ts +1 -0
- package/dist/types/src/KanbanPlugin.d.ts.map +1 -1
- package/dist/types/src/KanbanPlugin.node.d.ts +4 -0
- package/dist/types/src/KanbanPlugin.node.d.ts.map +1 -0
- package/dist/types/src/KanbanPlugin.test.d.ts +2 -0
- package/dist/types/src/KanbanPlugin.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/index.d.ts +1 -1
- package/dist/types/src/blueprints/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/kanban-blueprint.d.ts +3 -21
- package/dist/types/src/blueprints/kanban-blueprint.d.ts.map +1 -1
- package/dist/types/src/capabilities/{artifact-definition/artifact-definition.d.ts → artifact-definition.d.ts} +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts +6 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +7 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/migrations.d.ts +5 -0
- package/dist/types/src/capabilities/migrations.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/undo-mappings.d.ts +5 -0
- package/dist/types/src/capabilities/undo-mappings.d.ts.map +1 -0
- package/dist/types/src/components/KanbanBoard/KanbanBoard.d.ts +57 -0
- package/dist/types/src/components/KanbanBoard/KanbanBoard.d.ts.map +1 -0
- package/dist/types/src/components/KanbanBoard/KanbanBoard.stories.d.ts +72 -0
- package/dist/types/src/components/KanbanBoard/KanbanBoard.stories.d.ts.map +1 -0
- package/dist/types/src/components/KanbanBoard/KanbanCard.d.ts +10 -0
- package/dist/types/src/components/KanbanBoard/KanbanCard.d.ts.map +1 -0
- package/dist/types/src/components/KanbanBoard/KanbanColumn.d.ts +9 -0
- package/dist/types/src/components/KanbanBoard/KanbanColumn.d.ts.map +1 -0
- package/dist/types/src/components/KanbanBoard/index.d.ts +2 -0
- package/dist/types/src/components/KanbanBoard/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/KanbanContainer/KanbanContainer.d.ts +6 -0
- package/dist/types/src/containers/KanbanContainer/KanbanContainer.d.ts.map +1 -0
- package/dist/types/src/containers/KanbanContainer/KanbanContainer.stories.d.ts +79 -0
- package/dist/types/src/containers/KanbanContainer/KanbanContainer.stories.d.ts.map +1 -0
- package/dist/types/src/containers/KanbanContainer/index.d.ts +2 -0
- package/dist/types/src/containers/KanbanContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/KanbanSettings/KanbanSettings.d.ts +13 -0
- package/dist/types/src/containers/KanbanSettings/KanbanSettings.d.ts.map +1 -0
- package/dist/types/src/containers/KanbanSettings/index.d.ts +2 -0
- package/dist/types/src/containers/KanbanSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +4 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +7 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useEchoChangeCallback.d.ts +13 -0
- package/dist/types/src/hooks/useEchoChangeCallback.d.ts.map +1 -0
- package/dist/types/src/hooks/useItemsProjection.d.ts +10 -0
- package/dist/types/src/hooks/useItemsProjection.d.ts.map +1 -0
- package/dist/types/src/hooks/useKanbanBoardModel.browser.test.d.ts +2 -0
- package/dist/types/src/hooks/useKanbanBoardModel.browser.test.d.ts.map +1 -0
- package/dist/types/src/hooks/useKanbanBoardModel.d.ts +16 -0
- package/dist/types/src/hooks/useKanbanBoardModel.d.ts.map +1 -0
- package/dist/types/src/hooks/useKanbanColumnEventHandler.d.ts +22 -0
- package/dist/types/src/hooks/useKanbanColumnEventHandler.d.ts.map +1 -0
- package/dist/types/src/hooks/useKanbanItemEventHandler.d.ts +19 -0
- package/dist/types/src/hooks/useKanbanItemEventHandler.d.ts.map +1 -0
- package/dist/types/src/hooks/useProjectionModel.d.ts +15 -0
- package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/operations/definitions.d.ts +52 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/delete-card-field.d.ts +5 -0
- package/dist/types/src/operations/delete-card-field.d.ts.map +1 -0
- package/dist/types/src/operations/delete-card.d.ts +5 -0
- package/dist/types/src/operations/delete-card.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/restore-card-field.d.ts +5 -0
- package/dist/types/src/operations/restore-card-field.d.ts.map +1 -0
- package/dist/types/src/operations/restore-card.d.ts +5 -0
- package/dist/types/src/operations/restore-card.d.ts.map +1 -0
- package/dist/types/src/playwright/board-manager.d.ts +5 -0
- package/dist/types/src/playwright/board-manager.d.ts.map +1 -0
- package/dist/types/src/playwright/playwright.config.d.ts +3 -0
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
- package/dist/types/src/playwright/smoke.spec.d.ts +2 -0
- package/dist/types/src/playwright/smoke.spec.d.ts.map +1 -0
- package/dist/types/src/testing/KanbanCardTileSimple.d.ts +7 -0
- package/dist/types/src/testing/KanbanCardTileSimple.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +48 -32
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Kanban.d.ts +109 -0
- package/dist/types/src/types/Kanban.d.ts.map +1 -0
- package/dist/types/src/types/constants.d.ts +6 -0
- package/dist/types/src/types/constants.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/migrations.test.d.ts +2 -0
- package/dist/types/src/types/migrations.test.d.ts.map +1 -0
- package/dist/types/src/types/schema.d.ts +15 -104
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +28 -0
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/util/arrangement.d.ts +72 -0
- package/dist/types/src/util/arrangement.d.ts.map +1 -0
- package/dist/types/src/util/arrangement.test.d.ts +2 -0
- package/dist/types/src/util/arrangement.test.d.ts.map +1 -0
- package/dist/types/src/util/index.d.ts +2 -0
- package/dist/types/src/util/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +74 -52
- package/src/KanbanPlugin.node.ts +55 -0
- package/src/KanbanPlugin.test.ts +31 -0
- package/src/KanbanPlugin.tsx +42 -24
- package/src/blueprints/index.ts +1 -1
- package/src/blueprints/kanban-blueprint.ts +12 -9
- package/src/capabilities/{artifact-definition/artifact-definition.ts → artifact-definition.ts} +11 -10
- package/src/capabilities/blueprint-definition.ts +19 -0
- package/src/capabilities/index.ts +12 -3
- package/src/capabilities/migrations.ts +35 -0
- package/src/capabilities/operation-handler.ts +14 -0
- package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +31 -22
- package/src/capabilities/undo-mappings.ts +34 -0
- package/src/components/KanbanBoard/KanbanBoard.stories.tsx +146 -0
- package/src/components/KanbanBoard/KanbanBoard.tsx +198 -0
- package/src/components/KanbanBoard/KanbanCard.tsx +98 -0
- package/src/components/KanbanBoard/KanbanColumn.tsx +71 -0
- package/src/components/KanbanBoard/index.ts +5 -0
- package/src/components/index.ts +1 -2
- package/src/{components → containers/KanbanContainer}/KanbanContainer.stories.tsx +85 -96
- package/src/containers/KanbanContainer/KanbanContainer.tsx +178 -0
- package/src/containers/KanbanContainer/index.ts +5 -0
- package/src/containers/KanbanSettings/KanbanSettings.tsx +94 -0
- package/src/containers/KanbanSettings/index.ts +5 -0
- package/src/containers/index.ts +8 -0
- package/src/hooks/index.ts +10 -0
- package/src/hooks/useEchoChangeCallback.ts +30 -0
- package/src/hooks/useItemsProjection.ts +44 -0
- package/src/hooks/useKanbanBoardModel.browser.test.ts +235 -0
- package/src/hooks/useKanbanBoardModel.ts +157 -0
- package/src/hooks/useKanbanColumnEventHandler.ts +106 -0
- package/src/hooks/useKanbanItemEventHandler.ts +133 -0
- package/src/hooks/useProjectionModel.ts +58 -0
- package/src/index.ts +6 -2
- package/src/meta.ts +1 -1
- package/src/operations/definitions.ts +63 -0
- package/src/operations/delete-card-field.ts +47 -0
- package/src/operations/delete-card.ts +23 -0
- package/src/operations/index.ts +12 -0
- package/src/operations/restore-card-field.ts +41 -0
- package/src/operations/restore-card.ts +21 -0
- package/src/playwright/board-manager.ts +13 -0
- package/src/playwright/playwright.config.ts +19 -0
- package/src/playwright/smoke.spec.ts +107 -0
- package/src/testing/KanbanCardTileSimple.tsx +82 -0
- package/src/testing/index.ts +5 -0
- package/src/translations.ts +26 -18
- package/src/types/Kanban.ts +151 -0
- package/src/types/constants.ts +9 -0
- package/src/types/index.ts +2 -0
- package/src/types/migrations.test.ts +83 -0
- package/src/types/schema.ts +19 -77
- package/src/types/types.ts +35 -0
- package/src/util/arrangement.test.ts +218 -0
- package/src/util/arrangement.ts +177 -0
- package/src/util/index.ts +5 -0
- package/dist/lib/browser/blueprint-definition-T2544VMJ.mjs +0 -17
- package/dist/lib/browser/blueprint-definition-T2544VMJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-L6N4ZDZ7.mjs +0 -35
- package/dist/lib/browser/chunk-L6N4ZDZ7.mjs.map +0 -7
- package/dist/lib/browser/chunk-XYQO4VL7.mjs +0 -150
- package/dist/lib/browser/chunk-XYQO4VL7.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-UEJHX42A.mjs +0 -162
- package/dist/lib/browser/operation-resolver-UEJHX42A.mjs.map +0 -7
- package/dist/lib/browser/react-surface-LFUJAPRL.mjs +0 -236
- package/dist/lib/browser/react-surface-LFUJAPRL.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-APJQFSHJ.mjs +0 -18
- package/dist/lib/node-esm/blueprint-definition-APJQFSHJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NN6JMKIT.mjs +0 -152
- package/dist/lib/node-esm/chunk-NN6JMKIT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZHRMUKTF.mjs +0 -36
- package/dist/lib/node-esm/chunk-ZHRMUKTF.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-5RPWHZCF.mjs +0 -163
- package/dist/lib/node-esm/operation-resolver-5RPWHZCF.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-7TSGBRJL.mjs +0 -237
- package/dist/lib/node-esm/react-surface-7TSGBRJL.mjs.map +0 -7
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/artifact-definition/index.d.ts +0 -3
- package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +0 -9
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +0 -3
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/KanbanContainer.d.ts +0 -6
- package/dist/types/src/components/KanbanContainer.d.ts.map +0 -1
- package/dist/types/src/components/KanbanContainer.stories.d.ts +0 -75
- package/dist/types/src/components/KanbanContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/KanbanViewEditor.d.ts +0 -8
- package/dist/types/src/components/KanbanViewEditor.d.ts.map +0 -1
- package/src/capabilities/artifact-definition/index.ts +0 -7
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +0 -23
- package/src/capabilities/blueprint-definition/index.ts +0 -7
- package/src/capabilities/operation-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -133
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/components/KanbanContainer.tsx +0 -86
- package/src/components/KanbanViewEditor.tsx +0 -59
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { Annotation, Obj, Ref, Type } from '@dxos/echo';
|
|
8
|
+
import { View } from '@dxos/echo';
|
|
9
|
+
import { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';
|
|
10
|
+
import { ViewAnnotation } from '@dxos/schema';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Per-column entry: ordered card ids plus an optional `hidden` flag that
|
|
14
|
+
* removes the column from the rendered board (and from the model's column
|
|
15
|
+
* list). Today only the uncategorized column is exposed in settings, but
|
|
16
|
+
* the data structure supports per-column hiding generally.
|
|
17
|
+
*/
|
|
18
|
+
const ArrangementColumnEntry = Schema.Struct({
|
|
19
|
+
ids: Schema.Array(Obj.ID),
|
|
20
|
+
hidden: Schema.Boolean.pipe(Schema.optional),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
/** Keyed by columnValue. */
|
|
24
|
+
const ArrangementColumns = Schema.Record({
|
|
25
|
+
key: Schema.String,
|
|
26
|
+
value: ArrangementColumnEntry,
|
|
27
|
+
}).pipe(FormInputAnnotation.set(false));
|
|
28
|
+
|
|
29
|
+
/** Column order and per-column card ids. */
|
|
30
|
+
export const Arrangement = Schema.Struct({
|
|
31
|
+
order: Schema.Array(Schema.String).pipe(FormInputAnnotation.set(false)),
|
|
32
|
+
columns: ArrangementColumns,
|
|
33
|
+
}).pipe(FormInputAnnotation.set(false));
|
|
34
|
+
|
|
35
|
+
export type Arrangement = Schema.Schema.Type<typeof Arrangement>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* v1: pre-existing Kanban shape. Retained as the source for the v1→v2 migration.
|
|
39
|
+
*/
|
|
40
|
+
export const KanbanV1 = Schema.Struct({
|
|
41
|
+
name: Schema.String.pipe(Schema.optional),
|
|
42
|
+
view: Ref.Ref(View.View).pipe(FormInputAnnotation.set(false)),
|
|
43
|
+
arrangement: Arrangement,
|
|
44
|
+
}).pipe(
|
|
45
|
+
Type.object({
|
|
46
|
+
typename: 'org.dxos.type.kanban',
|
|
47
|
+
version: '0.1.0',
|
|
48
|
+
}),
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
//
|
|
52
|
+
// v2 — `spec` is a discriminated union of how items are sourced.
|
|
53
|
+
//
|
|
54
|
+
// Mirrors the canonical DXOS pattern (see `Trigger.Spec` in
|
|
55
|
+
// `@dxos/functions/src/types/Trigger.ts` and `Sequence.Source` in
|
|
56
|
+
// `@dxos/plugin-zen`): the `Type.object` schema is a flat `Schema.Struct`,
|
|
57
|
+
// and the discriminated union lives one level down as a single field whose
|
|
58
|
+
// variants are tagged with a `kind` literal.
|
|
59
|
+
//
|
|
60
|
+
|
|
61
|
+
/** View-variant: items come from running the View's query (the original behaviour). */
|
|
62
|
+
export const KanbanViewSpec = Schema.Struct({
|
|
63
|
+
kind: Schema.Literal('view').pipe(FormInputAnnotation.set(false)),
|
|
64
|
+
view: Ref.Ref(View.View).pipe(FormInputAnnotation.set(false)),
|
|
65
|
+
});
|
|
66
|
+
export type KanbanViewSpec = Schema.Schema.Type<typeof KanbanViewSpec>;
|
|
67
|
+
|
|
68
|
+
/** Items-variant: kanban owns its items as an explicit ref array (used by externally-synced kanbans). */
|
|
69
|
+
export const KanbanItemsSpec = Schema.Struct({
|
|
70
|
+
kind: Schema.Literal('items').pipe(FormInputAnnotation.set(false)),
|
|
71
|
+
/** Property path on each item that drives column membership (e.g. `'listName'`). */
|
|
72
|
+
pivotField: Schema.String,
|
|
73
|
+
/** Items owned directly by the kanban. */
|
|
74
|
+
items: Schema.Array(Ref.Ref(Obj.Unknown)).pipe(FormInputAnnotation.set(false)),
|
|
75
|
+
});
|
|
76
|
+
export type KanbanItemsSpec = Schema.Schema.Type<typeof KanbanItemsSpec>;
|
|
77
|
+
|
|
78
|
+
/** Discriminated union of source specs. Distinguished by `kind`. */
|
|
79
|
+
export const KanbanSpec = Schema.Union(KanbanViewSpec, KanbanItemsSpec);
|
|
80
|
+
export type KanbanSpec = Schema.Schema.Type<typeof KanbanSpec>;
|
|
81
|
+
|
|
82
|
+
export const Kanban = Schema.Struct({
|
|
83
|
+
name: Schema.String.pipe(Schema.optional),
|
|
84
|
+
arrangement: Arrangement,
|
|
85
|
+
/** How this kanban sources its items. Discriminated by `spec.kind`. */
|
|
86
|
+
spec: KanbanSpec,
|
|
87
|
+
}).pipe(
|
|
88
|
+
Type.object({
|
|
89
|
+
typename: 'org.dxos.type.kanban',
|
|
90
|
+
version: '0.2.0',
|
|
91
|
+
}),
|
|
92
|
+
LabelAnnotation.set(['name']),
|
|
93
|
+
ViewAnnotation.set(['spec', 'view']),
|
|
94
|
+
Annotation.IconAnnotation.set({
|
|
95
|
+
icon: 'ph--kanban--regular',
|
|
96
|
+
hue: 'green',
|
|
97
|
+
}),
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
/** Instance type; narrow on `kanban.spec.kind` (or use the guards below). */
|
|
101
|
+
export interface Kanban extends Schema.Schema.Type<typeof Kanban> {}
|
|
102
|
+
|
|
103
|
+
/** Narrowed view-variant kanban. */
|
|
104
|
+
export type KanbanView = Kanban & { spec: KanbanViewSpec };
|
|
105
|
+
|
|
106
|
+
/** Narrowed items-variant kanban. */
|
|
107
|
+
export type KanbanItems = Kanban & { spec: KanbanItemsSpec };
|
|
108
|
+
|
|
109
|
+
export const isKanbanView = (kanban: Kanban): kanban is KanbanView => kanban.spec.kind === 'view';
|
|
110
|
+
export const isKanbanItems = (kanban: Kanban): kanban is KanbanItems => kanban.spec.kind === 'items';
|
|
111
|
+
|
|
112
|
+
type MakeViewProps = {
|
|
113
|
+
name?: string;
|
|
114
|
+
view: View.View;
|
|
115
|
+
arrangement?: Arrangement;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Make a view-variant kanban (items sourced via the View's query).
|
|
120
|
+
*/
|
|
121
|
+
export const make = (props: MakeViewProps): Kanban => {
|
|
122
|
+
const { name, view, arrangement } = props;
|
|
123
|
+
const order = arrangement?.order ?? [];
|
|
124
|
+
const columns = arrangement?.columns ?? {};
|
|
125
|
+
return Obj.make(Kanban, {
|
|
126
|
+
name,
|
|
127
|
+
arrangement: { order, columns },
|
|
128
|
+
spec: { kind: 'view' as const, view: Ref.make(view) },
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
type MakeItemsProps = {
|
|
133
|
+
name?: string;
|
|
134
|
+
arrangement?: Arrangement;
|
|
135
|
+
pivotField: string;
|
|
136
|
+
items?: ReadonlyArray<Ref.Ref<Obj.Unknown>>;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Make an items-variant kanban (items list owned by the kanban itself, e.g. populated by a sync integration).
|
|
141
|
+
*/
|
|
142
|
+
export const makeItems = (props: MakeItemsProps): Kanban => {
|
|
143
|
+
const { name, arrangement, pivotField, items = [] } = props;
|
|
144
|
+
const order = arrangement?.order ?? [];
|
|
145
|
+
const columns = arrangement?.columns ?? {};
|
|
146
|
+
return Obj.make(Kanban, {
|
|
147
|
+
name,
|
|
148
|
+
arrangement: { order, columns },
|
|
149
|
+
spec: { kind: 'items' as const, pivotField, items },
|
|
150
|
+
});
|
|
151
|
+
};
|
package/src/types/index.ts
CHANGED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import { afterEach, beforeEach, describe, test } from 'vitest';
|
|
7
|
+
|
|
8
|
+
import { defineObjectMigration } from '@dxos/client/echo';
|
|
9
|
+
import { Filter, JsonSchema, Obj, Query, Ref, Type, View } from '@dxos/echo';
|
|
10
|
+
import { EchoTestBuilder } from '@dxos/echo-db/testing';
|
|
11
|
+
import { ViewModel } from '@dxos/schema';
|
|
12
|
+
|
|
13
|
+
import { Kanban } from './Kanban';
|
|
14
|
+
import { KanbanV1 } from './Kanban';
|
|
15
|
+
|
|
16
|
+
const TestCardSchema = Schema.Struct({ id: Schema.String }).pipe(
|
|
17
|
+
Type.object({ typename: 'com.example/TestCard', version: '0.1.0' }),
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* v0.1.0 → v0.2.0 migration: nests `view` under `spec: { kind: 'view', view }`.
|
|
22
|
+
*
|
|
23
|
+
* Mirrors the migration registered in `capabilities/migrations.ts`. Running it
|
|
24
|
+
* here against a real ECHO database verifies that the transform produces a
|
|
25
|
+
* v0.2.0-shaped object that's queryable as `Kanban.Kanban`.
|
|
26
|
+
*/
|
|
27
|
+
describe('Kanban migration v1 → v2', () => {
|
|
28
|
+
let builder: EchoTestBuilder;
|
|
29
|
+
|
|
30
|
+
beforeEach(async () => {
|
|
31
|
+
builder = await new EchoTestBuilder().open();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
afterEach(async () => {
|
|
35
|
+
await builder.close();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const migration = defineObjectMigration({
|
|
39
|
+
from: KanbanV1,
|
|
40
|
+
to: Kanban,
|
|
41
|
+
transform: async (from) => ({
|
|
42
|
+
name: from.name,
|
|
43
|
+
arrangement: from.arrangement,
|
|
44
|
+
spec: { kind: 'view' as const, view: from.view },
|
|
45
|
+
}),
|
|
46
|
+
onMigration: async () => {},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('migrates a v1 Kanban into the v2 view-variant shape', async ({ expect }) => {
|
|
50
|
+
const { db, graph } = await builder.createDatabase();
|
|
51
|
+
await graph.schemaRegistry.register([KanbanV1, Kanban, View.View]);
|
|
52
|
+
|
|
53
|
+
// Build a real View object so the v1 Kanban has a valid ref to migrate.
|
|
54
|
+
const view = ViewModel.make({
|
|
55
|
+
query: Query.select(Filter.type(TestCardSchema)),
|
|
56
|
+
jsonSchema: JsonSchema.toJsonSchema(TestCardSchema),
|
|
57
|
+
});
|
|
58
|
+
db.add(view);
|
|
59
|
+
|
|
60
|
+
db.add(
|
|
61
|
+
Obj.make(KanbanV1, {
|
|
62
|
+
name: 'My Board',
|
|
63
|
+
view: Ref.make(view),
|
|
64
|
+
arrangement: { order: ['todo'], columns: { todo: { ids: [] } } },
|
|
65
|
+
}),
|
|
66
|
+
);
|
|
67
|
+
await db.flush();
|
|
68
|
+
|
|
69
|
+
await db.runMigrations([migration]);
|
|
70
|
+
|
|
71
|
+
const results = await db.query(Filter.type(Kanban)).run();
|
|
72
|
+
expect(results).toHaveLength(1);
|
|
73
|
+
|
|
74
|
+
const migrated = results[0];
|
|
75
|
+
expect(migrated.name).toBe('My Board');
|
|
76
|
+
expect(migrated.arrangement.order).toEqual(['todo']);
|
|
77
|
+
expect(migrated.spec.kind).toBe('view');
|
|
78
|
+
if (migrated.spec.kind === 'view') {
|
|
79
|
+
expect(migrated.spec.view.dxn.toString()).toBe(Ref.make(view).dxn.toString());
|
|
80
|
+
}
|
|
81
|
+
expect(Type.getVersion(Obj.getSchema(migrated)!)).toBe('0.2.0');
|
|
82
|
+
});
|
|
83
|
+
});
|
package/src/types/schema.ts
CHANGED
|
@@ -4,12 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import { Capability } from '@dxos/app-framework';
|
|
8
|
-
import { Operation } from '@dxos/operation';
|
|
9
7
|
import { TypeInputOptionsAnnotation } from '@dxos/plugin-space/types';
|
|
10
|
-
import { FieldSchema, View } from '@dxos/schema';
|
|
11
|
-
|
|
12
|
-
import { meta } from '../meta';
|
|
13
8
|
|
|
14
9
|
/**
|
|
15
10
|
* Kanban data model.
|
|
@@ -23,10 +18,28 @@ import { meta } from '../meta';
|
|
|
23
18
|
// TODO(wittjosiah): Factor out?
|
|
24
19
|
export const PivotColumnAnnotationId = Symbol.for('@dxos/plugin-kanban/annotation/PivotColumn');
|
|
25
20
|
|
|
26
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Settings common to every Kanban (view or items). Rendered as form fields
|
|
23
|
+
* by `KanbanSettings`.
|
|
24
|
+
*/
|
|
25
|
+
export const KanbanSettingsSchema = Schema.Struct({
|
|
26
|
+
hideUncategorized: Schema.Boolean.annotations({
|
|
27
|
+
title: 'Hide uncategorized column',
|
|
28
|
+
description: 'When enabled, items without a pivot value won’t be shown as a column.',
|
|
29
|
+
}).pipe(Schema.optional),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Settings for view-variant Kanbans only. Spreads {@link KanbanSettingsSchema}'s
|
|
34
|
+
* fields and adds a column-field picker that binds the View’s pivot field.
|
|
35
|
+
* Items-variant kanbans use a hardcoded `spec.pivotField` and don’t expose
|
|
36
|
+
* this control.
|
|
37
|
+
*/
|
|
38
|
+
export const KanbanViewSettingsSchema = Schema.Struct({
|
|
27
39
|
columnFieldId: Schema.String.annotations({
|
|
28
40
|
title: 'Column field',
|
|
29
41
|
}),
|
|
42
|
+
...KanbanSettingsSchema.fields,
|
|
30
43
|
});
|
|
31
44
|
|
|
32
45
|
export const CreateKanbanSchema = Schema.Struct({
|
|
@@ -37,7 +50,6 @@ export const CreateKanbanSchema = Schema.Struct({
|
|
|
37
50
|
TypeInputOptionsAnnotation.set({
|
|
38
51
|
location: ['database', 'runtime'],
|
|
39
52
|
kind: ['user'],
|
|
40
|
-
registered: ['registered'],
|
|
41
53
|
}),
|
|
42
54
|
Schema.optional,
|
|
43
55
|
),
|
|
@@ -48,73 +60,3 @@ export const CreateKanbanSchema = Schema.Struct({
|
|
|
48
60
|
}),
|
|
49
61
|
),
|
|
50
62
|
});
|
|
51
|
-
|
|
52
|
-
const KANBAN_OPERATION = `${meta.id}/operation`;
|
|
53
|
-
|
|
54
|
-
export namespace KanbanOperation {
|
|
55
|
-
export const DeleteCardFieldOutput = Schema.Struct({
|
|
56
|
-
field: FieldSchema.annotations({ description: 'The deleted field schema.' }),
|
|
57
|
-
props: Schema.Any.annotations({ description: 'The deleted field properties.' }),
|
|
58
|
-
index: Schema.Number.annotations({ description: 'The index the field was at.' }),
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
export type DeleteCardFieldOutput = Schema.Schema.Type<typeof DeleteCardFieldOutput>;
|
|
62
|
-
|
|
63
|
-
export const DeleteCardField = Operation.make({
|
|
64
|
-
meta: { key: `${KANBAN_OPERATION}/delete-card-field`, name: 'Delete Card Field' },
|
|
65
|
-
services: [Capability.Service],
|
|
66
|
-
schema: {
|
|
67
|
-
input: Schema.Struct({
|
|
68
|
-
view: View.View,
|
|
69
|
-
fieldId: Schema.String,
|
|
70
|
-
}),
|
|
71
|
-
output: DeleteCardFieldOutput,
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
export const DeleteCardOutput = Schema.Struct({
|
|
76
|
-
card: Schema.Any.annotations({ description: 'The deleted card.' }),
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
export type DeleteCardOutput = Schema.Schema.Type<typeof DeleteCardOutput>;
|
|
80
|
-
|
|
81
|
-
export const DeleteCard = Operation.make({
|
|
82
|
-
meta: { key: `${KANBAN_OPERATION}/delete-card`, name: 'Delete Card' },
|
|
83
|
-
schema: {
|
|
84
|
-
input: Schema.Struct({
|
|
85
|
-
card: Schema.Any,
|
|
86
|
-
}),
|
|
87
|
-
output: DeleteCardOutput,
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Restore a deleted card field (inverse of DeleteCardField).
|
|
93
|
-
*/
|
|
94
|
-
export const RestoreCardField = Operation.make({
|
|
95
|
-
meta: { key: `${KANBAN_OPERATION}/restore-card-field`, name: 'Restore Card Field' },
|
|
96
|
-
services: [Capability.Service],
|
|
97
|
-
schema: {
|
|
98
|
-
input: Schema.Struct({
|
|
99
|
-
view: View.View.annotations({ description: 'The view to restore the field to.' }),
|
|
100
|
-
field: FieldSchema.annotations({ description: 'The field schema to restore.' }),
|
|
101
|
-
props: Schema.Any.annotations({ description: 'The field properties to restore.' }),
|
|
102
|
-
index: Schema.Number.annotations({ description: 'The index to restore the field at.' }),
|
|
103
|
-
}),
|
|
104
|
-
output: Schema.Void,
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Restore a deleted card (inverse of DeleteCard).
|
|
110
|
-
*/
|
|
111
|
-
export const RestoreCard = Operation.make({
|
|
112
|
-
meta: { key: `${KANBAN_OPERATION}/restore-card`, name: 'Restore Card' },
|
|
113
|
-
schema: {
|
|
114
|
-
input: Schema.Struct({
|
|
115
|
-
card: Schema.Any.annotations({ description: 'The card to restore.' }),
|
|
116
|
-
}),
|
|
117
|
-
output: Schema.Void,
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
}
|
package/src/types/types.ts
CHANGED
|
@@ -2,6 +2,41 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { type Obj } from '@dxos/echo';
|
|
6
|
+
|
|
7
|
+
import { type Kanban } from './Kanban';
|
|
8
|
+
|
|
5
9
|
export type Location = {
|
|
6
10
|
idx?: number;
|
|
7
11
|
};
|
|
12
|
+
|
|
13
|
+
/** Snapshot shape used when reading kanban arrangement from atoms. */
|
|
14
|
+
export type KanbanArrangementSnapshot = Kanban | Obj.Snapshot<Kanban>;
|
|
15
|
+
|
|
16
|
+
/** Minimal item shape for arrangement; Obj.Unknown satisfies this. */
|
|
17
|
+
export type BaseKanbanItem = { id: string };
|
|
18
|
+
|
|
19
|
+
/** Column structure without cards; used for board model column type and derived atoms. */
|
|
20
|
+
export type ColumnStructure = {
|
|
21
|
+
columnValue: string;
|
|
22
|
+
ids: string[];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type KanbanColumn<T extends BaseKanbanItem = BaseKanbanItem> = {
|
|
26
|
+
columnValue: string;
|
|
27
|
+
cards: T[];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type ArrangedCards<T extends BaseKanbanItem = BaseKanbanItem> = KanbanColumn<T>[];
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Callback type for wrapping mutations in Obj.update().
|
|
34
|
+
* Contains separate callbacks for kanban object and item mutations.
|
|
35
|
+
*/
|
|
36
|
+
export type KanbanChangeCallback<T extends BaseKanbanItem> = {
|
|
37
|
+
/** Callback to wrap kanban object mutations. */
|
|
38
|
+
kanban: (mutate: (mutableKanban: Obj.Mutable<Kanban>) => void) => void;
|
|
39
|
+
|
|
40
|
+
/** Sets a field on an item, wrapping in Obj.update() if needed. */
|
|
41
|
+
setItemField: (item: T, field: string, value: unknown) => void;
|
|
42
|
+
};
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import { beforeEach, describe, test } from 'vitest';
|
|
7
|
+
|
|
8
|
+
import { Filter, JsonSchema, Query, Type } from '@dxos/echo';
|
|
9
|
+
import { type View } from '@dxos/echo';
|
|
10
|
+
import { ObjectId } from '@dxos/keys';
|
|
11
|
+
import { ViewModel } from '@dxos/schema';
|
|
12
|
+
|
|
13
|
+
import { Kanban, UNCATEGORIZED_VALUE } from '#types';
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
computeColumnStructure,
|
|
17
|
+
computeItemArrangement,
|
|
18
|
+
getOrderByColumnFromArrangement,
|
|
19
|
+
getOrderFromArrangement,
|
|
20
|
+
} from './arrangement';
|
|
21
|
+
|
|
22
|
+
const selectOptions = [
|
|
23
|
+
{ id: UNCATEGORIZED_VALUE, title: 'Uncategorized', color: 'neutral' },
|
|
24
|
+
{ id: 'a', title: 'A', color: 'blue' },
|
|
25
|
+
{ id: 'b', title: 'B', color: 'green' },
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
const MinimalSchema = Schema.Struct({ id: Schema.String }).pipe(
|
|
29
|
+
Type.object({ typename: 'test/Minimal', version: '0.1.0' }),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
describe('arrangement utils', () => {
|
|
33
|
+
let view: View.View;
|
|
34
|
+
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
view = ViewModel.make({
|
|
37
|
+
query: Query.select(Filter.type(MinimalSchema)),
|
|
38
|
+
jsonSchema: JsonSchema.toJsonSchema(MinimalSchema),
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe('getOrderFromArrangement', () => {
|
|
43
|
+
test('returns copy of order when present', ({ expect }) => {
|
|
44
|
+
const arrangement = { order: ['a', 'b'], columns: {} };
|
|
45
|
+
expect(getOrderFromArrangement(arrangement)).toEqual(['a', 'b']);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('returns copy of order from kanban arrangement', ({ expect }) => {
|
|
49
|
+
const kanban = Kanban.make({
|
|
50
|
+
view,
|
|
51
|
+
arrangement: { order: ['b', 'a'], columns: {} },
|
|
52
|
+
});
|
|
53
|
+
const order = getOrderFromArrangement(kanban.arrangement);
|
|
54
|
+
expect(order).toEqual(['b', 'a']);
|
|
55
|
+
order.push('x');
|
|
56
|
+
expect(getOrderFromArrangement(kanban.arrangement)).toEqual(['b', 'a']);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('returns empty when arrangement or order missing or empty', ({ expect }) => {
|
|
60
|
+
expect(getOrderFromArrangement(undefined)).toEqual([]);
|
|
61
|
+
expect(getOrderFromArrangement({ order: [], columns: {} })).toEqual([]);
|
|
62
|
+
const kanbanEmptyOrder = Kanban.make({
|
|
63
|
+
view,
|
|
64
|
+
arrangement: { order: [], columns: {} },
|
|
65
|
+
});
|
|
66
|
+
expect(getOrderFromArrangement(kanbanEmptyOrder.arrangement)).toEqual([]);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('getOrderByColumnFromArrangement', () => {
|
|
71
|
+
test('returns per-column data with mutable id arrays', ({ expect }) => {
|
|
72
|
+
const arrangement = {
|
|
73
|
+
order: [],
|
|
74
|
+
columns: { a: { ids: ['i1'] } },
|
|
75
|
+
};
|
|
76
|
+
const byColumn = getOrderByColumnFromArrangement(arrangement);
|
|
77
|
+
expect(byColumn.a.ids).toEqual(['i1']);
|
|
78
|
+
byColumn.a.ids.push('i2');
|
|
79
|
+
expect(getOrderByColumnFromArrangement(arrangement).a.ids).toEqual(['i1']);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('returns per-column ids and preserves hidden from kanban arrangement', ({ expect }) => {
|
|
83
|
+
const id1 = ObjectId.random();
|
|
84
|
+
const id2 = ObjectId.random();
|
|
85
|
+
const id3 = ObjectId.random();
|
|
86
|
+
const kanban = Kanban.make({
|
|
87
|
+
view,
|
|
88
|
+
arrangement: {
|
|
89
|
+
order: [],
|
|
90
|
+
columns: {
|
|
91
|
+
a: { ids: [id1, id2], hidden: true },
|
|
92
|
+
b: { ids: [id3] },
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
const byColumn = getOrderByColumnFromArrangement(kanban.arrangement);
|
|
97
|
+
expect(byColumn.a).toEqual({ ids: [id1, id2], hidden: true });
|
|
98
|
+
expect(byColumn.b).toEqual({ ids: [id3] });
|
|
99
|
+
expect(byColumn.b.hidden).toBeUndefined();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('treats non-array ids as empty (Automerge / corrupt layout)', ({ expect }) => {
|
|
103
|
+
const arrangement = {
|
|
104
|
+
order: [],
|
|
105
|
+
columns: { a: { ids: {} as unknown as string[] }, b: { ids: ['ok'] } },
|
|
106
|
+
};
|
|
107
|
+
const byColumn = getOrderByColumnFromArrangement(arrangement);
|
|
108
|
+
expect(byColumn.a.ids).toEqual([]);
|
|
109
|
+
expect(byColumn.b.ids).toEqual(['ok']);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test('returns mutable copies', ({ expect }) => {
|
|
113
|
+
const idX = ObjectId.random();
|
|
114
|
+
const kanban = Kanban.make({
|
|
115
|
+
view,
|
|
116
|
+
arrangement: { order: [], columns: { a: { ids: [idX] } } },
|
|
117
|
+
});
|
|
118
|
+
const byColumn = getOrderByColumnFromArrangement(kanban.arrangement);
|
|
119
|
+
byColumn.a.ids.push(ObjectId.random());
|
|
120
|
+
expect(getOrderByColumnFromArrangement(kanban.arrangement).a.ids).toEqual([idX]);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test('returns empty object when arrangement or columns missing', ({ expect }) => {
|
|
124
|
+
expect(getOrderByColumnFromArrangement(undefined)).toEqual({});
|
|
125
|
+
expect(getOrderByColumnFromArrangement({ order: [], columns: {} })).toEqual({});
|
|
126
|
+
const kanbanEmpty = Kanban.make({
|
|
127
|
+
view,
|
|
128
|
+
arrangement: { order: [], columns: {} },
|
|
129
|
+
});
|
|
130
|
+
expect(getOrderByColumnFromArrangement(kanbanEmpty.arrangement)).toEqual({});
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
describe('computeColumnStructure', () => {
|
|
135
|
+
test('uncategorized first, then effectiveOrder, then missing selectOptions', ({ expect }) => {
|
|
136
|
+
const effectiveOrder = ['b'];
|
|
137
|
+
const effectiveByColumn = { [UNCATEGORIZED_VALUE]: { ids: ['x'] }, b: { ids: ['y'] } };
|
|
138
|
+
const result = computeColumnStructure(effectiveOrder, effectiveByColumn, selectOptions);
|
|
139
|
+
expect(result.map((col) => col.columnValue)).toEqual([UNCATEGORIZED_VALUE, 'b', 'a']);
|
|
140
|
+
expect(result[0].ids).toEqual(['x']);
|
|
141
|
+
expect(result[1].ids).toEqual(['y']);
|
|
142
|
+
expect(result[2].ids).toEqual([]);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test('does not duplicate uncategorized when already in effectiveOrder', ({ expect }) => {
|
|
146
|
+
const effectiveOrder = [UNCATEGORIZED_VALUE, 'a'];
|
|
147
|
+
const effectiveByColumn = {};
|
|
148
|
+
const result = computeColumnStructure(effectiveOrder, effectiveByColumn, selectOptions);
|
|
149
|
+
expect(result.map((col) => col.columnValue)).toEqual([UNCATEGORIZED_VALUE, 'a', 'b']);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
describe('computeItemArrangement', () => {
|
|
154
|
+
test('distributes items by pivotPath and preserves saved order within column', ({ expect }) => {
|
|
155
|
+
const idUc1 = ObjectId.random();
|
|
156
|
+
const idA1 = ObjectId.random();
|
|
157
|
+
const idA2 = ObjectId.random();
|
|
158
|
+
const idA3 = ObjectId.random();
|
|
159
|
+
const kanban = Kanban.make({
|
|
160
|
+
view,
|
|
161
|
+
arrangement: {
|
|
162
|
+
order: ['a', 'b'],
|
|
163
|
+
columns: {
|
|
164
|
+
[UNCATEGORIZED_VALUE]: { ids: [idUc1] },
|
|
165
|
+
a: { ids: [idA2, idA1] },
|
|
166
|
+
b: { ids: [] },
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
const items = [{ id: idA1, status: 'a' }, { id: idA2, status: 'a' }, { id: idA3, status: 'a' }, { id: idUc1 }];
|
|
171
|
+
const result = computeItemArrangement({
|
|
172
|
+
object: kanban,
|
|
173
|
+
items,
|
|
174
|
+
pivotPath: 'status',
|
|
175
|
+
selectOptions,
|
|
176
|
+
});
|
|
177
|
+
const colUncat = result.find((c) => c.columnValue === UNCATEGORIZED_VALUE);
|
|
178
|
+
const colA = result.find((c) => c.columnValue === 'a');
|
|
179
|
+
const colB = result.find((c) => c.columnValue === 'b');
|
|
180
|
+
expect(colUncat?.cards.map((c) => c.id)).toEqual([idUc1]);
|
|
181
|
+
expect(colA?.cards.map((c) => c.id)).toEqual([idA2, idA1, idA3]);
|
|
182
|
+
expect(colB?.cards.map((c) => c.id)).toEqual([]);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
test('when pivotPath undefined all items go to uncategorized', ({ expect }) => {
|
|
186
|
+
const kanban = Kanban.make({
|
|
187
|
+
view,
|
|
188
|
+
arrangement: { order: ['a', 'b'], columns: { a: { ids: [] }, b: { ids: [] } } },
|
|
189
|
+
});
|
|
190
|
+
const items = [
|
|
191
|
+
{ id: '1', status: 'a' },
|
|
192
|
+
{ id: '2', status: 'b' },
|
|
193
|
+
];
|
|
194
|
+
const result = computeItemArrangement({
|
|
195
|
+
object: kanban,
|
|
196
|
+
items,
|
|
197
|
+
selectOptions,
|
|
198
|
+
});
|
|
199
|
+
const colUncat = result.find((c) => c.columnValue === UNCATEGORIZED_VALUE);
|
|
200
|
+
const colA = result.find((c) => c.columnValue === 'a');
|
|
201
|
+
expect(colUncat?.cards.length).toBe(2);
|
|
202
|
+
expect(colA?.cards.length).toBe(0);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
test('column order is uncategorized then selectOptions', ({ expect }) => {
|
|
206
|
+
const kanban = Kanban.make({
|
|
207
|
+
view,
|
|
208
|
+
arrangement: { order: ['a', 'b'], columns: {} },
|
|
209
|
+
});
|
|
210
|
+
const result = computeItemArrangement({
|
|
211
|
+
object: kanban,
|
|
212
|
+
items: [],
|
|
213
|
+
selectOptions,
|
|
214
|
+
});
|
|
215
|
+
expect(result.map((c) => c.columnValue)).toEqual([UNCATEGORIZED_VALUE, 'a', 'b']);
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
});
|