@design.estate/dees-catalog 21.29.0 → 21.30.0

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.
Files changed (66) hide show
  1. package/dist_bundle/bundle.js +2560 -1290
  2. package/dist_bundle/bundle.js.map +1 -1
  3. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-CJVVAKHG.js → chunk-NKLF624Z.js} +2 -2
  4. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-QFJ7LA5L.js → chunk-Q2W326R5.js} +3 -3
  5. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-YBZRR5YD.js → chunk-W57NRRM4.js} +41 -2
  6. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-YBZRR5YD.js.map → chunk-W57NRRM4.js.map} +1 -1
  7. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{de-ZU5CNY4P.js → de-J7BORZFB.js} +41 -2
  8. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-J7BORZFB.js.map +1 -0
  9. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-NVJRWZKO.js → dees-modal-UURRHHYX.js} +3 -3
  10. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-BSBYG5IX.js → dees-workspace-terminal-ZBGBOINI.js} +4 -4
  11. package/dist_ts_web/00_commitinfo_data.js +1 -1
  12. package/dist_ts_web/elements/00group-dataview/dees-table/filters.d.ts +2 -0
  13. package/dist_ts_web/elements/00group-dataview/dees-table/filters.js +11 -13
  14. package/dist_ts_web/elements/00group-dataview/dees-table/styles.d.ts +6 -0
  15. package/dist_ts_web/elements/00group-dataview/dees-table/styles.js +33 -23
  16. package/dist_ts_web/elements/00group-kanban/dees-kanban/dees-kanban.d.ts +80 -6
  17. package/dist_ts_web/elements/00group-kanban/dees-kanban/dees-kanban.demo.d.ts +1 -0
  18. package/dist_ts_web/elements/00group-kanban/dees-kanban/dees-kanban.demo.js +38 -9
  19. package/dist_ts_web/elements/00group-kanban/dees-kanban/dees-kanban.js +502 -73
  20. package/dist_ts_web/elements/00group-kanban/dees-kanban-activity/dees-kanban-activity.d.ts +40 -0
  21. package/dist_ts_web/elements/00group-kanban/dees-kanban-activity/dees-kanban-activity.js +373 -0
  22. package/dist_ts_web/elements/00group-kanban/dees-kanban-card/dees-kanban-card.d.ts +2 -0
  23. package/dist_ts_web/elements/00group-kanban/dees-kanban-card/dees-kanban-card.js +35 -2
  24. package/dist_ts_web/elements/00group-kanban/dees-kanban-column/dees-kanban-column.d.ts +5 -1
  25. package/dist_ts_web/elements/00group-kanban/dees-kanban-column/dees-kanban-column.js +24 -3
  26. package/dist_ts_web/elements/00group-kanban/dees-kanban-discussion/dees-kanban-discussion.d.ts +2 -0
  27. package/dist_ts_web/elements/00group-kanban/dees-kanban-discussion/dees-kanban-discussion.js +31 -70
  28. package/dist_ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.d.ts +26 -3
  29. package/dist_ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.js +475 -21
  30. package/dist_ts_web/elements/00group-kanban/index.d.ts +1 -0
  31. package/dist_ts_web/elements/00group-kanban/index.js +2 -1
  32. package/dist_ts_web/elements/00group-kanban/interfaces.d.ts +114 -0
  33. package/dist_ts_web/elements/00group-kanban/kanban.demodata.d.ts +9 -3
  34. package/dist_ts_web/elements/00group-kanban/kanban.demodata.js +210 -17
  35. package/dist_ts_web/elements/00group-kanban/kanban.helpers.d.ts +23 -1
  36. package/dist_ts_web/elements/00group-kanban/kanban.helpers.js +57 -1
  37. package/dist_ts_web/elements/00group-kanban/kanban.styles.d.ts +2 -0
  38. package/dist_ts_web/elements/00group-kanban/kanban.styles.js +54 -1
  39. package/dist_ts_web/i18n/de.d.ts +156 -0
  40. package/dist_ts_web/i18n/de.js +40 -1
  41. package/dist_ts_web/i18n/messages.d.ts +156 -0
  42. package/dist_ts_web/i18n/messages.js +40 -1
  43. package/package.json +1 -1
  44. package/readme.md +59 -10
  45. package/ts_web/00_commitinfo_data.ts +1 -1
  46. package/ts_web/elements/00group-dataview/dees-table/filters.ts +14 -12
  47. package/ts_web/elements/00group-dataview/dees-table/styles.ts +33 -22
  48. package/ts_web/elements/00group-kanban/dees-kanban/dees-kanban.demo.ts +43 -8
  49. package/ts_web/elements/00group-kanban/dees-kanban/dees-kanban.ts +521 -60
  50. package/ts_web/elements/00group-kanban/dees-kanban-activity/dees-kanban-activity.ts +328 -0
  51. package/ts_web/elements/00group-kanban/dees-kanban-card/dees-kanban-card.ts +28 -0
  52. package/ts_web/elements/00group-kanban/dees-kanban-column/dees-kanban-column.ts +13 -2
  53. package/ts_web/elements/00group-kanban/dees-kanban-discussion/dees-kanban-discussion.ts +25 -68
  54. package/ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.ts +476 -17
  55. package/ts_web/elements/00group-kanban/index.ts +1 -0
  56. package/ts_web/elements/00group-kanban/interfaces.ts +98 -0
  57. package/ts_web/elements/00group-kanban/kanban.demodata.ts +231 -17
  58. package/ts_web/elements/00group-kanban/kanban.helpers.ts +79 -1
  59. package/ts_web/elements/00group-kanban/kanban.styles.ts +54 -0
  60. package/ts_web/i18n/de.ts +39 -0
  61. package/ts_web/i18n/messages.ts +39 -0
  62. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-ZU5CNY4P.js.map +0 -1
  63. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-CJVVAKHG.js.map → chunk-NKLF624Z.js.map} +0 -0
  64. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-QFJ7LA5L.js.map → chunk-Q2W326R5.js.map} +0 -0
  65. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-NVJRWZKO.js.map → dees-modal-UURRHHYX.js.map} +0 -0
  66. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-BSBYG5IX.js.map → dees-workspace-terminal-ZBGBOINI.js.map} +0 -0
@@ -6,14 +6,19 @@ import {
6
6
  html,
7
7
  css,
8
8
  directives,
9
+ type TemplateResult,
9
10
  } from '@design.estate/dees-element';
10
11
  import { dcLocalize } from '../../../i18n/localize.js';
11
12
  import type {
13
+ IKanbanActivity,
14
+ IKanbanBoardSnapshot,
12
15
  IKanbanColumn,
13
16
  IKanbanComment,
14
17
  IKanbanCreate,
18
+ IKanbanFilterValues,
15
19
  IKanbanMove,
16
20
  IKanbanPerson,
21
+ IKanbanProject,
17
22
  IKanbanProvider,
18
23
  IKanbanTicket,
19
24
  IKanbanTicketDraft,
@@ -22,15 +27,42 @@ import type {
22
27
  TReferenceContent,
23
28
  TReferenceSearch,
24
29
  } from '../../00group-input/dees-input-reference/interfaces.js';
25
- import type { DeesInputText } from '../../00group-input/dees-input-text/dees-input-text.js';
26
30
  import { DeesModal } from '../../00group-overlay/dees-modal/dees-modal.js';
27
31
  import { DeesContextmenu } from '../../00group-overlay/dees-contextmenu/dees-contextmenu.js';
32
+ import type {
33
+ DeesPopover,
34
+ IDeesPopoverCloseDetail,
35
+ } from '../../00group-overlay/dees-popover/dees-popover.js';
36
+ import type { IActionFooterAction } from '../../00group-button/dees-actionfooter/dees-actionfooter.js';
28
37
  import { DeesKanbanTicketDetail } from '../dees-kanban-ticket-detail/dees-kanban-ticket-detail.js';
29
38
  import { kanbanStyles } from '../kanban.styles.js';
30
- import { kanbanError, kanbanEvent, sortKanbanTickets, ticketLabel } from '../kanban.helpers.js';
39
+ import {
40
+ kanbanError,
41
+ kanbanEvent,
42
+ kanbanProjectName,
43
+ kanbanProjects,
44
+ sameKanbanLabels,
45
+ sortKanbanTickets,
46
+ ticketLabel,
47
+ } from '../kanban.helpers.js';
48
+ import {
49
+ renderFilterField,
50
+ tableFilterPanelStyles,
51
+ type ITableFilter,
52
+ type TTableFilterValue,
53
+ } from '../../00group-dataview/dees-table/filters.js';
54
+ import {
55
+ activeFilterBarStyles,
56
+ tableSearchFieldStyles,
57
+ } from '../../00group-dataview/dees-table/styles.js';
58
+ import { actionControlStyles } from '../../00baractions.js';
59
+ import { visuallyHidden } from '../../00visuallyhidden.js';
60
+ import { nextFrame } from '../../00overlay.js';
31
61
  import { demoFunc } from './dees-kanban.demo.js';
32
62
  import { KanbanDragController } from '../kanban.dragcontroller.js';
33
63
  import '../dees-kanban-column/dees-kanban-column.js';
64
+ import '../../00group-overlay/dees-popover/dees-popover.js';
65
+ import '../../00group-utility/dees-icon/dees-icon.js';
34
66
 
35
67
  declare global {
36
68
  interface HTMLElementTagNameMap {
@@ -48,6 +80,7 @@ const interactionEvents = [
48
80
  'kanban-comment-draft',
49
81
  'kanban-comment-added',
50
82
  'kanban-comments-refresh',
83
+ 'kanban-activity-refresh',
51
84
  'kanban-detail-back',
52
85
  ] as const;
53
86
 
@@ -61,6 +94,7 @@ interface IKanbanInteractionMap {
61
94
  'kanban-comment-draft': { ticketId: string; body: TReferenceContent };
62
95
  'kanban-comment-added': { comment: IKanbanComment; submittedBody: TReferenceContent };
63
96
  'kanban-comments-refresh': { ticketId: string };
97
+ 'kanban-activity-refresh': { ticketId: string };
64
98
  'kanban-detail-back': Record<string, never>;
65
99
  }
66
100
 
@@ -68,6 +102,15 @@ type TKanbanInteraction = {
68
102
  [K in keyof IKanbanInteractionMap]: { type: K; detail: IKanbanInteractionMap[K] }
69
103
  }[keyof IKanbanInteractionMap];
70
104
 
105
+ /** The board's filters in the filter bubble, by their `IKanbanFilterValues` key. */
106
+ type TKanbanFilterKey = 'project' | 'epic' | 'assignee' | 'label' | 'mine';
107
+
108
+ /** What narrows the board now, as its active-filter bar shows it. */
109
+ interface IKanbanActiveFilter {
110
+ key: TKanbanFilterKey | 'text';
111
+ label: string;
112
+ }
113
+
71
114
  @customElement('dees-kanban')
72
115
  export class DeesKanban extends DeesElement {
73
116
  public static demo = demoFunc;
@@ -97,14 +140,37 @@ export class DeesKanban extends DeesElement {
97
140
  @property({ type: String, reflect: true })
98
141
  accessor error = '';
99
142
 
143
+ /** The projects tickets belong to, for their names; a project only a ticket names shows by its id. */
144
+ @property({ attribute: false })
145
+ accessor projects: IKanbanProject[] = [];
146
+
147
+ /** The reader's person `id`; set, the filters offer "Assigned to me". */
148
+ @property({ type: String, reflect: true })
149
+ accessor currentPersonId = '';
150
+
151
+ /**
152
+ * The search and the filters that narrow the board's tasks. The reader's choices change it and
153
+ * emit `kanban-filter-change`; a host sets it to start the board filtered.
154
+ */
155
+ @property({ attribute: false })
156
+ accessor filterValues: IKanbanFilterValues = {};
157
+
158
+ /**
159
+ * The revision of the tickets the board shows, as the host set it or `refresh()` loaded it; a
160
+ * board snapshot older than it is dropped.
161
+ */
162
+ @property({ attribute: false })
163
+ accessor revision: number | undefined;
164
+
100
165
  @state()
101
- private accessor query = '';
166
+ private accessor operationError = '';
102
167
 
103
168
  @state()
104
- private accessor epicId = '';
169
+ private accessor filtersOpen = false;
105
170
 
171
+ /** The live region's words: what the last chip or "Clear all" took off the board. */
106
172
  @state()
107
- private accessor operationError = '';
173
+ private accessor filterAnnouncement = '';
108
174
 
109
175
  @state()
110
176
  private accessor pendingTicketId = '';
@@ -119,6 +185,15 @@ export class DeesKanban extends DeesElement {
119
185
  private history: string[] = [];
120
186
  private openAbort?: AbortController;
121
187
  private commentsAbort?: AbortController;
188
+ private activityAbort?: AbortController;
189
+ private boardAbort?: AbortController;
190
+ /** The board load `refresh()` runs, which the calls made meanwhile share. */
191
+ private boardLoad?: Promise<void>;
192
+ /** A `refresh()` came while a load ran: one more load follows it. */
193
+ private boardAgain = false;
194
+ /** Counts the tickets the board took from its own saves, moves and creations. */
195
+ private mutationEpoch = 0;
196
+ private activityCache = new Map<string, IKanbanActivity[]>();
122
197
  private commentCache = new Map<string, IKanbanComment[]>();
123
198
  private commentRevisions = new Map<string, number>();
124
199
  private commentDrafts = new Map<string, TReferenceContent>();
@@ -133,6 +208,10 @@ export class DeesKanban extends DeesElement {
133
208
 
134
209
  public static styles = [
135
210
  ...kanbanStyles,
211
+ actionControlStyles,
212
+ tableSearchFieldStyles,
213
+ tableFilterPanelStyles,
214
+ activeFilterBarStyles,
136
215
  css`
137
216
  :host {
138
217
  padding: 20px 24px;
@@ -177,14 +256,23 @@ export class DeesKanban extends DeesElement {
177
256
  gap: 8px;
178
257
  }
179
258
 
180
- .filters dees-input-text {
181
- width: 230px;
182
- min-width: 140px;
259
+ .filters .searchField {
260
+ width: 260px;
261
+ min-width: 160px;
262
+ }
263
+
264
+ /* Below the header, across the board: the table's bar, rounded on the canvas. */
265
+ .activeFilters {
266
+ margin: -4px 0 16px;
267
+ padding: 6px 10px;
268
+ border: var(--dees-line-width-hairline) solid
269
+ color-mix(in srgb, var(--dees-color-accent-primary) 16%, transparent);
270
+ border-radius: var(--dees-radius-lg);
271
+ corner-shape: var(--dees-corner-shape);
183
272
  }
184
273
 
185
- .filters dees-input-dropdown {
186
- width: 180px;
187
- min-width: 140px;
274
+ .filterStatus {
275
+ ${visuallyHidden}
188
276
  }
189
277
 
190
278
  .actions {
@@ -206,7 +294,7 @@ export class DeesKanban extends DeesElement {
206
294
  order: 3;
207
295
  flex-basis: 100%;
208
296
  }
209
- .filters dees-input-text {
297
+ .filters .searchField {
210
298
  flex: 1;
211
299
  max-width: 320px;
212
300
  }
@@ -229,10 +317,10 @@ export class DeesKanban extends DeesElement {
229
317
  .filters {
230
318
  flex-wrap: wrap;
231
319
  }
232
- .filters dees-input-text,
233
- .filters dees-input-dropdown {
320
+ .filters .searchField {
234
321
  flex: 1;
235
322
  width: auto;
323
+ max-width: none;
236
324
  min-width: 130px;
237
325
  }
238
326
  .columns {
@@ -262,56 +350,74 @@ export class DeesKanban extends DeesElement {
262
350
  public updated(): void {
263
351
  this.syncDetail();
264
352
  this.dragController.sync();
353
+ // The filter bubble points at the button this render drew.
354
+ const button = this.shadowRoot?.querySelector<HTMLElement>('.filterButton') ?? null;
355
+ const bubble = this.filterBubble;
356
+ if (bubble && button && bubble.anchor !== button) bubble.anchor = button;
265
357
  }
266
358
 
267
359
  public render() {
268
- const epics = sortKanbanTickets(this.tickets.filter(ticket => ticket.kind === 'epic'));
269
- const query = this.query.trim().toLocaleLowerCase();
270
- const tasks = this.tickets.filter(ticket =>
271
- ticket.kind === 'task' &&
272
- (!this.epicId || ticket.parentId === this.epicId) &&
273
- (!query ||
274
- [
275
- ticket.key,
276
- ticket.title,
277
- ticket.assignee?.name,
278
- ...ticket.labels ?? [],
279
- ...this.tickets
280
- .filter(child => child.parentId === ticket.id)
281
- .map(child => `${child.key} ${child.title}`),
282
- ]
283
- .join(' ')
284
- .toLocaleLowerCase()
285
- .includes(query)),
286
- );
287
- const epic = epics.find(ticket => ticket.id === this.epicId);
360
+ const filters = this.filterValues;
361
+ const epics = sortKanbanTickets(this.tickets.filter(ticket =>
362
+ ticket.kind === 'epic' && (!filters.project || this.inProject(ticket, filters.project)),
363
+ ));
364
+ const tasks = this.visibleTasks();
365
+ const epic = this.tickets.find(ticket => ticket.kind === 'epic' && ticket.id === filters.epic);
366
+ const fields = this.filterFields();
367
+ const active = this.activeFilters(fields);
368
+ const count = active.filter(filter => filter.key !== 'text').length;
369
+ const filterLabel = count ? this.t('kanban.filtersActive', { count }) : this.t('kanban.filters');
370
+ const projects = kanbanProjects(this.projects, this.tickets);
288
371
  return html`<header class="heading">
289
372
  <div class="identity">
290
373
  <h2>${this.heading || this.t('kanban.board')}</h2>
291
374
  <span class="totals">${this.t('kanban.totals', { tasks: tasks.length, epics: epics.length })}</span>
292
375
  </div>
293
376
  <div class="filters">
294
- <dees-input-text
295
- label=${this.t('kanban.search')}
296
- .labelPosition=${'none'}
297
- placeholder=${this.t('kanban.searchPlaceholder')}
298
- .value=${this.query}
299
- @input=${(event: Event) => {
300
- this.query = String((event.currentTarget as DeesInputText).value ?? '');
301
- }}
302
- ></dees-input-text>
303
- <dees-input-dropdown
304
- label=${this.t('kanban.epic')}
305
- .labelPosition=${'none'}
306
- .value=${{ key: this.epicId, option: epic?.title ?? this.t('kanban.allEpics') }}
307
- .options=${[
308
- { key: '', option: this.t('kanban.allEpics') },
309
- ...epics.map(ticket => ({ key: ticket.id, option: ticket.title })),
310
- ]}
311
- @selectedOption=${(event: CustomEvent<{ key: string }>) => {
312
- this.epicId = event.detail.key;
377
+ <div class="searchField">
378
+ <dees-icon aria-hidden="true" icon="lucide:Search" iconSize="15"></dees-icon>
379
+ <input
380
+ class="searchInput"
381
+ type="search"
382
+ aria-label=${this.t('kanban.search')}
383
+ placeholder=${this.t('kanban.searchPlaceholder')}
384
+ .value=${filters.text ?? ''}
385
+ @input=${(event: Event) =>
386
+ this.setFilterValues({ text: (event.currentTarget as HTMLInputElement).value })}
387
+ />
388
+ <button
389
+ class="searchOptions filterButton control ${count ? 'filtering' : ''}"
390
+ type="button"
391
+ aria-label=${filterLabel}
392
+ title=${filterLabel}
393
+ .ariaHasPopup=${'dialog'}
394
+ .ariaExpanded=${'false'}
395
+ @click=${this.toggleFilters}
396
+ >
397
+ <dees-icon aria-hidden="true" icon="lucide:SlidersHorizontal" iconSize="14"></dees-icon>
398
+ ${count
399
+ ? html`<span class="filterCount" aria-hidden="true">${this.t.format.number(count)}</span>`
400
+ : ''}
401
+ </button>
402
+ </div>
403
+ <dees-popover
404
+ class="filterBubble"
405
+ .label=${this.t('kanban.filters')}
406
+ .open=${this.filtersOpen}
407
+ .dismissOnTab=${false}
408
+ width="min(320px, calc(100vw - 16px))"
409
+ maxHeight="min(70vh, 560px)"
410
+ .actions=${this.filterActions(active.length > 0)}
411
+ @dees-popover-close=${(event: CustomEvent<IDeesPopoverCloseDetail>) => {
412
+ event.stopPropagation();
413
+ this.filtersOpen = false;
313
414
  }}
314
- ></dees-input-dropdown>
415
+ ><div class="filterPanel">
416
+ <div class="filterPanelSection">${fields.map(field =>
417
+ renderFilterField(field, this.filterValue(field), value =>
418
+ this.setFilterValues({ [field.key]: value ?? undefined })),
419
+ )}</div>
420
+ </div></dees-popover>
315
421
  ${epic
316
422
  ? html`<dees-button
317
423
  type="ghost"
@@ -341,13 +447,15 @@ export class DeesKanban extends DeesElement {
341
447
  void this.createTicket({
342
448
  kind: 'task',
343
449
  columnId: this.columns[0].id,
344
- parentId: this.epicId || undefined,
450
+ parentId: epic?.id,
345
451
  });
346
452
  }}
347
453
  ></dees-button>
348
454
  </div>`
349
455
  : ''}
350
456
  </header>
457
+ ${this.renderActiveFilters(active)}
458
+ <p class="filterStatus" role="status">${this.filterAnnouncement}</p>
351
459
  ${this.loading || this.openingTicket
352
460
  ? html`<p class="caption" role="status">${this.loading
353
461
  ? this.t('kanban.loading')
@@ -365,6 +473,8 @@ export class DeesKanban extends DeesElement {
365
473
  .pointerManaged=${true}
366
474
  .tickets=${tasks.filter(ticket => ticket.columnId === column.id)}
367
475
  .allTickets=${this.tickets}
476
+ .projects=${projects}
477
+ .showProjects=${!filters.project && projects.length > 0}
368
478
  .movable=${Boolean(this.provider.moveTicket)}
369
479
  .canCreate=${Boolean(this.provider.createTicket)}
370
480
  .movesDisabled=${Boolean(this.pendingTicketId)}
@@ -373,6 +483,235 @@ export class DeesKanban extends DeesElement {
373
483
  </div>`}`;
374
484
  }
375
485
 
486
+ /**
487
+ * The active-filter bar: below the header, a chip for each filter off its default and for the
488
+ * search, each removing what it names, then "Clear all". Nothing filtered, no bar.
489
+ */
490
+ private renderActiveFilters(active: IKanbanActiveFilter[]): TemplateResult | string {
491
+ if (!active.length) return '';
492
+ return html`<div class="activeFilters" role="group" aria-label=${this.t('kanban.activeFilters')}>
493
+ <dees-icon class="activeFiltersIcon" aria-hidden="true" icon="lucide:ListFilter" iconSize="14"></dees-icon>
494
+ ${active.map((filter, index) => html`<button
495
+ type="button"
496
+ class="activeFilterChip control"
497
+ data-key=${filter.key}
498
+ aria-label=${this.t('kanban.removeFilter', { filter: filter.label })}
499
+ title=${this.t('kanban.removeFilter', { filter: filter.label })}
500
+ @click=${() => this.removeActiveFilter(filter, index)}
501
+ ><span class="activeFilterLabel">${filter.label}</span><dees-icon
502
+ aria-hidden="true"
503
+ icon="lucide:X"
504
+ iconSize="12"
505
+ ></dees-icon></button>`)}
506
+ <button type="button" class="clearAllFilters control" @click=${this.clearAllFilters}
507
+ >${this.t('kanban.clearAll')}</button>
508
+ </div>`;
509
+ }
510
+
511
+ /** Whether a ticket belongs to a project: its own, or for an epic, one of its tasks'. */
512
+ private inProject(ticket: IKanbanTicket, project: string): boolean {
513
+ return ticket.project === project || (
514
+ ticket.kind === 'epic' &&
515
+ this.tickets.some(task => task.parentId === ticket.id && task.project === project)
516
+ );
517
+ }
518
+
519
+ /** The tasks the search and the filters let through, in the board's columns. */
520
+ private visibleTasks(): IKanbanTicket[] {
521
+ const filters = this.filterValues;
522
+ const query = (filters.text ?? '').trim().toLocaleLowerCase();
523
+ const mine = filters.mine && this.currentPersonId;
524
+ return this.tickets.filter(ticket =>
525
+ ticket.kind === 'task' &&
526
+ (!filters.epic || ticket.parentId === filters.epic) &&
527
+ (!filters.project || ticket.project === filters.project) &&
528
+ (!filters.assignee ||
529
+ (filters.assignee === 'none'
530
+ ? !ticket.assignee
531
+ : ticket.assignee?.id === filters.assignee)) &&
532
+ (!filters.label || Boolean(ticket.labels?.includes(filters.label))) &&
533
+ (!mine || ticket.assignee?.id === this.currentPersonId) &&
534
+ (!query ||
535
+ [
536
+ ticket.key,
537
+ ticket.title,
538
+ ticket.project ? kanbanProjectName(this.projects, ticket.project) : '',
539
+ ticket.assignee?.name,
540
+ ...ticket.labels ?? [],
541
+ ...this.tickets
542
+ .filter(child => child.parentId === ticket.id)
543
+ .map(child => `${child.key} ${child.title}`),
544
+ ]
545
+ .join(' ')
546
+ .toLocaleLowerCase()
547
+ .includes(query)),
548
+ );
549
+ }
550
+
551
+ /**
552
+ * The filter bubble's fields, as the table's filters: a project, an epic (of that project), an
553
+ * assignee and a label, each with an "all" option, and "Assigned to me" while the board knows
554
+ * its reader. A field with nothing to choose from is left out; a value set in code that no
555
+ * ticket has stays a choice.
556
+ */
557
+ private filterFields(): ITableFilter[] {
558
+ const filters = this.filterValues;
559
+ const choices = (
560
+ key: TKanbanFilterKey,
561
+ label: string,
562
+ all: string,
563
+ options: { key: string; label: string }[],
564
+ ): ITableFilter | undefined => {
565
+ const value = filters[key];
566
+ if (typeof value === 'string' && value && !options.some(option => option.key === value))
567
+ options.push({ key: value, label: value });
568
+ if (!options.length) return undefined;
569
+ return {
570
+ key,
571
+ label,
572
+ type: 'select',
573
+ default: '',
574
+ options: [{ key: '', label: all }, ...options],
575
+ chip: chosen => this.t('kanban.filterChip', {
576
+ label,
577
+ value: options.find(option => option.key === chosen)?.label ?? String(chosen),
578
+ }),
579
+ };
580
+ };
581
+ const projects = kanbanProjects(this.projects, this.tickets);
582
+ // The project's epics, and the chosen one, by its title, even outside the project.
583
+ const epics = sortKanbanTickets(this.tickets.filter(ticket =>
584
+ ticket.kind === 'epic' &&
585
+ (!filters.project || ticket.id === filters.epic || this.inProject(ticket, filters.project)),
586
+ ));
587
+ const people = [
588
+ ...this.people,
589
+ ...this.tickets
590
+ .map(ticket => ticket.assignee)
591
+ .filter((person): person is IKanbanPerson => Boolean(person))
592
+ .filter((person, index, all) => all.findIndex(item => item.id === person.id) === index)
593
+ .filter(person => !this.people.some(known => known.id === person.id))
594
+ .sort((a, b) => a.name.localeCompare(b.name)),
595
+ ];
596
+ const labels = [...new Set(this.tickets.flatMap(ticket => ticket.labels ?? []))]
597
+ .sort((a, b) => a.localeCompare(b));
598
+ const fields = [
599
+ choices('project', this.t('kanban.project'), this.t('kanban.allProjects'),
600
+ projects.map(project => ({ key: project.id, label: project.name }))),
601
+ choices('epic', this.t('kanban.epic'), this.t('kanban.allEpics'),
602
+ epics.map(ticket => ({ key: ticket.id, label: ticket.title }))),
603
+ choices('assignee', this.t('kanban.assignee'), this.t('kanban.anyone'), people.length
604
+ ? [
605
+ { key: 'none', label: this.t('kanban.unassigned') },
606
+ ...people.map(person => ({ key: person.id, label: person.name })),
607
+ ]
608
+ : []),
609
+ choices('label', this.t('kanban.label'), this.t('kanban.allLabels'),
610
+ labels.map(label => ({ key: label, label }))),
611
+ ].filter((field): field is ITableFilter => Boolean(field));
612
+ if (this.currentPersonId)
613
+ fields.push({
614
+ key: 'mine',
615
+ label: this.t('kanban.mine'),
616
+ type: 'toggle',
617
+ default: false,
618
+ chip: () => this.t('kanban.mine'),
619
+ });
620
+ return fields;
621
+ }
622
+
623
+ private filterValue(field: ITableFilter): TTableFilterValue {
624
+ const value = this.filterValues[field.key as TKanbanFilterKey];
625
+ return value === undefined ? field.default : value;
626
+ }
627
+
628
+ /** What narrows the board now, in the bubble's order, then the search. */
629
+ private activeFilters(fields = this.filterFields()): IKanbanActiveFilter[] {
630
+ const active: IKanbanActiveFilter[] = fields
631
+ .filter(field => {
632
+ const value = this.filterValue(field);
633
+ return (value ?? '') !== (field.default ?? '');
634
+ })
635
+ .map(field => ({
636
+ key: field.key as TKanbanFilterKey,
637
+ label: field.chip!(this.filterValue(field)),
638
+ }));
639
+ const text = this.filterValues.text?.trim();
640
+ if (text) active.push({ key: 'text', label: this.t('kanban.searchChip', { query: text }) });
641
+ return active;
642
+ }
643
+
644
+ /** Takes the reader's change into `filterValues` and tells the host; empty values leave it. */
645
+ private setFilterValues(change: IKanbanFilterValues): void {
646
+ const next: Record<string, unknown> = { ...this.filterValues, ...change };
647
+ for (const [key, value] of Object.entries(next))
648
+ if (value === undefined || value === '' || value === false) delete next[key];
649
+ this.filterValues = next as IKanbanFilterValues;
650
+ kanbanEvent(this, 'kanban-filter-change', { filterValues: this.filterValues });
651
+ }
652
+
653
+ /**
654
+ * The filter bubble's action, as the table's (`tableFilterActions`): "Clear filters" in its action
655
+ * footer, no primary, unavailable while nothing narrows the board.
656
+ */
657
+ private filterActions(filtering: boolean): IActionFooterAction[] {
658
+ return [{
659
+ name: this.t('kanban.clearFilters'),
660
+ primary: false,
661
+ disabled: !filtering,
662
+ action: async () => this.clearFilters(),
663
+ }];
664
+ }
665
+
666
+ /** Clears the search and every filter. */
667
+ public clearFilters(): void {
668
+ this.filterValues = {};
669
+ kanbanEvent(this, 'kanban-filter-change', { filterValues: this.filterValues });
670
+ void this.announceFilters(this.t('kanban.filtersCleared'));
671
+ }
672
+
673
+ /** Says a change of the filters through the live region; emptied first, so the same words twice are said twice. */
674
+ private async announceFilters(text: string): Promise<void> {
675
+ this.filterAnnouncement = '';
676
+ await this.updateComplete;
677
+ this.filterAnnouncement = text;
678
+ }
679
+
680
+ /** A chip's press: its filter leaves, and the focus moves to the chip now in its place, else the one before. */
681
+ private async removeActiveFilter(filter: IKanbanActiveFilter, index: number): Promise<void> {
682
+ this.setFilterValues({ [filter.key]: undefined });
683
+ void this.announceFilters(this.t('kanban.filterRemoved', { filter: filter.label }));
684
+ await this.updateComplete;
685
+ const chips = [...this.shadowRoot?.querySelectorAll<HTMLElement>('.activeFilterChip') ?? []];
686
+ const next = chips[index] ?? chips[index - 1];
687
+ if (next) next.focus();
688
+ else this.shadowRoot?.querySelector<HTMLInputElement>('.searchInput')?.focus();
689
+ }
690
+
691
+ private clearAllFilters = async (): Promise<void> => {
692
+ this.clearFilters();
693
+ await this.updateComplete;
694
+ this.shadowRoot?.querySelector<HTMLInputElement>('.searchInput')?.focus();
695
+ };
696
+
697
+ private get filterBubble(): DeesPopover | null {
698
+ return this.shadowRoot?.querySelector<DeesPopover>('.filterBubble') ?? null;
699
+ }
700
+
701
+ private toggleFilters = async (): Promise<void> => {
702
+ if (this.filtersOpen) {
703
+ // Closes the bubble and gives the focus back to the button.
704
+ this.filterBubble?.close();
705
+ return;
706
+ }
707
+ this.filtersOpen = true;
708
+ await this.updateComplete;
709
+ // The bubble shows itself once it is placed, a frame on; hidden until then, it takes no focus.
710
+ await nextFrame();
711
+ await nextFrame();
712
+ if (this.filtersOpen) this.filterBubble?.querySelector<HTMLElement>('.filterField')?.focus();
713
+ };
714
+
376
715
  private findTicket(id: string): IKanbanTicket | undefined {
377
716
  return this.tickets.find(ticket => ticket.id === id) ?? this.resolvedTickets.get(id);
378
717
  }
@@ -437,13 +776,14 @@ export class DeesKanban extends DeesElement {
437
776
  this.selectedId = '';
438
777
  this.history = [];
439
778
  this.commentsAbort?.abort();
779
+ this.activityAbort?.abort();
440
780
  this.openAbort?.abort();
441
781
  }, { once: true });
442
782
  } else if (this.modalOpening) await this.modalOpening;
443
783
  this.syncDetail();
444
784
  if (controller.signal.aborted) return;
445
785
  kanbanEvent(this, 'kanban-ticket-opened', { ticketId: id });
446
- await this.refreshComments(id);
786
+ await Promise.all([this.refreshComments(id), this.refreshActivity(id)]);
447
787
  } catch (error) {
448
788
  if (!controller.signal.aborted) this.reportError(error);
449
789
  } finally {
@@ -467,7 +807,9 @@ export class DeesKanban extends DeesElement {
467
807
  this.detail.people = this.people;
468
808
  this.detail.provider = this.provider;
469
809
  this.detail.searchTickets = this.searchTickets;
810
+ this.detail.projects = this.projects;
470
811
  this.detail.comments = this.commentCache.get(this.selectedId) ?? [];
812
+ this.detail.activity = this.activityCache.get(this.selectedId) ?? [];
471
813
  this.detail.commentDraft = this.commentDrafts.get(this.selectedId) ?? [];
472
814
  this.detail.draft = this.ticketDrafts.get(this.selectedId);
473
815
  this.detail.canGoBack = this.history.length > 0;
@@ -484,7 +826,8 @@ export class DeesKanban extends DeesElement {
484
826
  this.syncDetail();
485
827
  }
486
828
 
487
- public async refreshComments(ticketId = this.selectedId): Promise<void> {
829
+ /** Loads a ticket's comments again; `quiet` keeps the shown ones without a loading line meanwhile. */
830
+ public async refreshComments(ticketId = this.selectedId, quiet = false): Promise<void> {
488
831
  this.commentsAbort?.abort();
489
832
  const controller = this.commentsAbort = new AbortController();
490
833
  if (!ticketId || !this.provider.loadComments) {
@@ -496,7 +839,7 @@ export class DeesKanban extends DeesElement {
496
839
  }
497
840
  const revision = this.commentRevisions.get(ticketId) ?? 0;
498
841
  const existingIds = new Set((this.commentCache.get(ticketId) ?? []).map(comment => comment.id));
499
- if (this.detail && ticketId === this.selectedId) {
842
+ if (this.detail && ticketId === this.selectedId && !quiet) {
500
843
  this.detail.loadingComments = true;
501
844
  this.detail.commentsError = '';
502
845
  }
@@ -507,6 +850,7 @@ export class DeesKanban extends DeesElement {
507
850
  comment => !existingIds.has(comment.id) && !comments.some(item => item.id === comment.id),
508
851
  );
509
852
  this.setComments(ticketId, [...comments, ...postedWhileLoading]);
853
+ if (this.detail && ticketId === this.selectedId) this.detail.commentsError = '';
510
854
  }
511
855
  } catch (error) {
512
856
  if (!controller.signal.aborted && this.detail && ticketId === this.selectedId)
@@ -517,7 +861,101 @@ export class DeesKanban extends DeesElement {
517
861
  }
518
862
  }
519
863
 
864
+ /** Loads a ticket's history again; `quiet` keeps the shown one without a loading line meanwhile. */
865
+ public async refreshActivity(ticketId = this.selectedId, quiet = false): Promise<void> {
866
+ this.activityAbort?.abort();
867
+ const controller = this.activityAbort = new AbortController();
868
+ if (!ticketId || !this.provider.loadActivity) {
869
+ if (this.detail) {
870
+ this.detail.loadingActivity = false;
871
+ this.detail.activityError = '';
872
+ }
873
+ return;
874
+ }
875
+ if (this.detail && ticketId === this.selectedId && !quiet) {
876
+ this.detail.loadingActivity = true;
877
+ this.detail.activityError = '';
878
+ }
879
+ try {
880
+ const activity = await this.provider.loadActivity(ticketId, controller.signal);
881
+ if (controller.signal.aborted) return;
882
+ if (activity.some(entry => entry.ticketId !== ticketId))
883
+ throw new Error(this.t('kanban.activityMismatch'));
884
+ this.activityCache.set(ticketId, [...activity]);
885
+ if (this.detail && ticketId === this.selectedId) this.detail.activityError = '';
886
+ this.syncDetail();
887
+ } catch (error) {
888
+ if (!controller.signal.aborted && this.detail && ticketId === this.selectedId)
889
+ this.detail.activityError = kanbanError(error);
890
+ } finally {
891
+ if (!controller.signal.aborted && this.detail && ticketId === this.selectedId)
892
+ this.detail.loadingActivity = false;
893
+ }
894
+ }
895
+
896
+ /**
897
+ * Loads the board again through the provider's `loadBoard` and shows it in place, as a live
898
+ * update does: the open ticket stays open with its unsaved changes and its comment draft, its
899
+ * comments and history load again quietly, and the filters and the scroll stay. Calls made
900
+ * while a load runs share it, and one more load follows it; a snapshot older than `revision`, or
901
+ * loaded while the board saved a change of its own, is not shown.
902
+ */
903
+ public refresh(): Promise<void> {
904
+ if (!this.provider.loadBoard) return Promise.resolve();
905
+ if (this.boardLoad) {
906
+ this.boardAgain = true;
907
+ return this.boardLoad;
908
+ }
909
+ const load = this.boardLoad = this.loadBoard().finally(() => {
910
+ this.boardLoad = undefined;
911
+ // A call that came after the last load had begun answering.
912
+ if (this.boardAgain && this.isConnected) void this.refresh();
913
+ });
914
+ return load;
915
+ }
916
+
917
+ private async loadBoard(): Promise<void> {
918
+ do {
919
+ this.boardAgain = false;
920
+ const controller = this.boardAbort = new AbortController();
921
+ const epoch = this.mutationEpoch;
922
+ let snapshot: IKanbanBoardSnapshot;
923
+ try {
924
+ snapshot = await this.provider.loadBoard!(controller.signal);
925
+ } catch (error) {
926
+ if (!controller.signal.aborted) this.reportError(error);
927
+ return;
928
+ }
929
+ if (controller.signal.aborted || !this.isConnected) return;
930
+ if (this.mutationEpoch !== epoch) {
931
+ this.boardAgain = true;
932
+ continue;
933
+ }
934
+ if (
935
+ snapshot.revision !== undefined &&
936
+ this.revision !== undefined &&
937
+ snapshot.revision < this.revision
938
+ )
939
+ continue;
940
+ this.applySnapshot(snapshot);
941
+ } while (this.boardAgain);
942
+ }
943
+
944
+ private applySnapshot(snapshot: IKanbanBoardSnapshot): void {
945
+ this.tickets = [...snapshot.tickets];
946
+ if (snapshot.columns) this.columns = [...snapshot.columns];
947
+ if (snapshot.revision !== undefined) this.revision = snapshot.revision;
948
+ for (const ticket of snapshot.tickets)
949
+ if (this.resolvedTickets.has(ticket.id)) this.resolvedTickets.set(ticket.id, ticket);
950
+ this.syncDetail();
951
+ if (this.modal && this.selectedId) {
952
+ void this.refreshComments(this.selectedId, true);
953
+ void this.refreshActivity(this.selectedId, true);
954
+ }
955
+ }
956
+
520
957
  private mergeTickets(tickets: IKanbanTicket[], addToBoard = false): void {
958
+ this.mutationEpoch++;
521
959
  for (const ticket of tickets) this.resolvedTickets.set(ticket.id, ticket);
522
960
  this.tickets = this.tickets.map(ticket => tickets.find(item => item.id === ticket.id) ?? ticket);
523
961
  if (addToBoard)
@@ -526,6 +964,8 @@ export class DeesKanban extends DeesElement {
526
964
  ...tickets.filter(ticket => !this.tickets.some(item => item.id === ticket.id)),
527
965
  ];
528
966
  this.syncDetail();
967
+ if (this.modal && tickets.some(ticket => ticket.id === this.selectedId))
968
+ void this.refreshActivity(this.selectedId, true);
529
969
  kanbanEvent(this, 'kanban-change', { tickets });
530
970
  }
531
971
 
@@ -621,6 +1061,12 @@ export class DeesKanban extends DeesElement {
621
1061
  priority: draft.priority,
622
1062
  assignee: assignee ?? null,
623
1063
  parentId: ticket.kind === 'epic' ? null : draft.parentId || null,
1064
+ ...draft.labels && !sameKanbanLabels(draft.labels, ticket.labels ?? [])
1065
+ ? { labels: [...draft.labels] }
1066
+ : {},
1067
+ ...draft.project && draft.project !== (ticket.project ?? '')
1068
+ ? { project: draft.project }
1069
+ : {},
624
1070
  },
625
1071
  });
626
1072
  if (saved.id !== ticketId)
@@ -647,13 +1093,22 @@ export class DeesKanban extends DeesElement {
647
1093
  )
648
1094
  return;
649
1095
  const parentId =
650
- input.parentId ?? (input.kind === 'task' ? this.epicId || undefined : undefined);
1096
+ input.parentId ?? (input.kind === 'task' ? this.filterValues.epic || undefined : undefined);
1097
+ const project =
1098
+ input.project ||
1099
+ this.filterValues.project ||
1100
+ (parentId ? this.findTicket(parentId)?.project : undefined);
651
1101
  await DeesModal.prompt({
652
1102
  heading: this.t('kanban.newTicket', { kind: input.kind }),
653
1103
  label: this.t('kanban.ticketTitle'),
654
1104
  i18n: this.t.i18n,
655
1105
  onConfirm: async title => {
656
- const ticket = await this.provider.createTicket!({ ...input, parentId, title });
1106
+ const ticket = await this.provider.createTicket!({
1107
+ ...input,
1108
+ parentId,
1109
+ title,
1110
+ ...project ? { project } : {},
1111
+ });
657
1112
  this.mergeTickets([ticket], true);
658
1113
  },
659
1114
  });
@@ -760,12 +1215,16 @@ export class DeesKanban extends DeesElement {
760
1215
  )
761
1216
  this.commentDrafts.delete(comment.ticketId);
762
1217
  this.syncDetail();
1218
+ if (comment.ticketId === this.selectedId) void this.refreshActivity(comment.ticketId, true);
763
1219
  kanbanEvent(this, 'kanban-comment-saved', { comment });
764
1220
  break;
765
1221
  }
766
1222
  case 'kanban-comments-refresh':
767
1223
  void this.refreshComments(detail.ticketId);
768
1224
  break;
1225
+ case 'kanban-activity-refresh':
1226
+ void this.refreshActivity(detail.ticketId);
1227
+ break;
769
1228
  case 'kanban-detail-back': {
770
1229
  const previous = this.history.pop();
771
1230
  if (previous) void this.openTicket(previous, false);
@@ -783,6 +1242,8 @@ export class DeesKanban extends DeesElement {
783
1242
  }
784
1243
  this.openAbort?.abort();
785
1244
  this.commentsAbort?.abort();
1245
+ this.activityAbort?.abort();
1246
+ this.boardAbort?.abort();
786
1247
  void this.modal?.destroy();
787
1248
  await super.disconnectedCallback();
788
1249
  }