@design.estate/dees-catalog 21.46.1 → 21.47.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 +788 -247
  2. package/dist_bundle/bundle.js.map +1 -1
  3. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-FCUX4QGD.js → chunk-Q5VY4AV7.js} +3 -3
  4. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-LWT7IIPZ.js → chunk-QG5BHDQO.js} +2 -2
  5. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-VJVZHESI.js → chunk-UPDBEHU2.js} +16 -3
  6. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-VJVZHESI.js.map → chunk-UPDBEHU2.js.map} +1 -1
  7. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{de-7PGZC4IF.js → de-E2CUVVOP.js} +16 -3
  8. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-E2CUVVOP.js.map +1 -0
  9. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-VOIWY235.js → dees-modal-YOGT7PSU.js} +3 -3
  10. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-EJRHSZ5F.js → dees-workspace-terminal-ORLONA36.js} +4 -4
  11. package/dist_ts_web/00_commitinfo_data.js +1 -1
  12. package/dist_ts_web/elements/00group-dataview/dees-thread/dees-thread.d.ts +9 -1
  13. package/dist_ts_web/elements/00group-dataview/dees-thread/dees-thread.js +42 -5
  14. package/dist_ts_web/elements/00group-dataview/dees-thread/interfaces.d.ts +11 -0
  15. package/dist_ts_web/elements/00group-harness/dees-harness-question-card/dees-harness-question-card.d.ts +30 -8
  16. package/dist_ts_web/elements/00group-harness/dees-harness-question-card/dees-harness-question-card.js +95 -24
  17. package/dist_ts_web/elements/00group-harness/interfaces.d.ts +14 -3
  18. package/dist_ts_web/elements/00group-kanban/dees-kanban/dees-kanban.d.ts +17 -5
  19. package/dist_ts_web/elements/00group-kanban/dees-kanban/dees-kanban.demo.js +6 -2
  20. package/dist_ts_web/elements/00group-kanban/dees-kanban/dees-kanban.js +76 -20
  21. package/dist_ts_web/elements/00group-kanban/dees-kanban-activity/dees-kanban-activity.js +3 -1
  22. package/dist_ts_web/elements/00group-kanban/dees-kanban-card/dees-kanban-card.d.ts +3 -1
  23. package/dist_ts_web/elements/00group-kanban/dees-kanban-card/dees-kanban-card.js +17 -3
  24. package/dist_ts_web/elements/00group-kanban/dees-kanban-column/dees-kanban-column.d.ts +3 -1
  25. package/dist_ts_web/elements/00group-kanban/dees-kanban-column/dees-kanban-column.js +12 -2
  26. package/dist_ts_web/elements/00group-kanban/dees-kanban-discussion/dees-kanban-discussion.d.ts +41 -5
  27. package/dist_ts_web/elements/00group-kanban/dees-kanban-discussion/dees-kanban-discussion.js +196 -20
  28. package/dist_ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.d.ts +25 -2
  29. package/dist_ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.js +137 -8
  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 +96 -3
  33. package/dist_ts_web/elements/00group-kanban/kanban.demodata.js +119 -3
  34. package/dist_ts_web/elements/00group-kanban/kanban.helpers.d.ts +19 -1
  35. package/dist_ts_web/elements/00group-kanban/kanban.helpers.js +50 -1
  36. package/dist_ts_web/elements/00group-kanban/kanban.styles.js +32 -1
  37. package/dist_ts_web/i18n/de.d.ts +53 -1
  38. package/dist_ts_web/i18n/de.js +15 -2
  39. package/dist_ts_web/i18n/messages.d.ts +53 -1
  40. package/dist_ts_web/i18n/messages.js +15 -2
  41. package/package.json +1 -1
  42. package/readme.md +57 -18
  43. package/ts_web/00_commitinfo_data.ts +1 -1
  44. package/ts_web/elements/00group-dataview/dees-thread/dees-thread.ts +39 -4
  45. package/ts_web/elements/00group-dataview/dees-thread/interfaces.ts +11 -0
  46. package/ts_web/elements/00group-harness/dees-harness-question-card/dees-harness-question-card.ts +83 -21
  47. package/ts_web/elements/00group-harness/interfaces.ts +14 -3
  48. package/ts_web/elements/00group-kanban/dees-kanban/dees-kanban.demo.ts +5 -1
  49. package/ts_web/elements/00group-kanban/dees-kanban/dees-kanban.ts +82 -23
  50. package/ts_web/elements/00group-kanban/dees-kanban-activity/dees-kanban-activity.ts +2 -0
  51. package/ts_web/elements/00group-kanban/dees-kanban-card/dees-kanban-card.ts +11 -2
  52. package/ts_web/elements/00group-kanban/dees-kanban-column/dees-kanban-column.ts +6 -1
  53. package/ts_web/elements/00group-kanban/dees-kanban-discussion/dees-kanban-discussion.ts +199 -21
  54. package/ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.ts +144 -6
  55. package/ts_web/elements/00group-kanban/index.ts +1 -0
  56. package/ts_web/elements/00group-kanban/interfaces.ts +101 -4
  57. package/ts_web/elements/00group-kanban/kanban.demodata.ts +126 -2
  58. package/ts_web/elements/00group-kanban/kanban.helpers.ts +70 -0
  59. package/ts_web/elements/00group-kanban/kanban.styles.ts +31 -0
  60. package/ts_web/i18n/de.ts +14 -1
  61. package/ts_web/i18n/messages.ts +14 -1
  62. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-7PGZC4IF.js.map +0 -1
  63. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-FCUX4QGD.js.map → chunk-Q5VY4AV7.js.map} +0 -0
  64. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-LWT7IIPZ.js.map → chunk-QG5BHDQO.js.map} +0 -0
  65. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-VOIWY235.js.map → dees-modal-YOGT7PSU.js.map} +0 -0
  66. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-EJRHSZ5F.js.map → dees-workspace-terminal-ORLONA36.js.map} +0 -0
@@ -11,6 +11,7 @@ import {
11
11
  import { dcLocalize } from '../../../i18n/localize.js';
12
12
  import type {
13
13
  IKanbanActivity,
14
+ IKanbanAutoLabel,
14
15
  IKanbanBoardSnapshot,
15
16
  IKanbanColumn,
16
17
  IKanbanComment,
@@ -21,8 +22,11 @@ import type {
21
22
  IKanbanPerson,
22
23
  IKanbanProject,
23
24
  IKanbanProvider,
25
+ IKanbanQuestion,
26
+ IKanbanQuestionAnswerInput,
24
27
  IKanbanTicket,
25
28
  IKanbanTicketDraft,
29
+ TKanbanDiscussionItem,
26
30
  TKanbanDraftField,
27
31
  } from '../interfaces.js';
28
32
  import type {
@@ -46,9 +50,11 @@ import { DeesKanbanTicketDetail } from '../dees-kanban-ticket-detail/dees-kanban
46
50
  import { kanbanStyles } from '../kanban.styles.js';
47
51
  import {
48
52
  isKanbanRevisionConflict,
53
+ kanbanAutoLabel,
49
54
  kanbanDraftChanges,
50
55
  kanbanError,
51
56
  kanbanEvent,
57
+ kanbanItemKey,
52
58
  kanbanProjectName,
53
59
  kanbanProjects,
54
60
  kanbanTicketVersion,
@@ -91,6 +97,8 @@ const interactionEvents = [
91
97
  'kanban-ticket-draft',
92
98
  'kanban-comment-draft',
93
99
  'kanban-comment-added',
100
+ 'kanban-question-added',
101
+ 'kanban-question-answered',
94
102
  'kanban-comments-refresh',
95
103
  'kanban-activity-refresh',
96
104
  'kanban-detail-back',
@@ -109,6 +117,8 @@ interface IKanbanInteractionMap {
109
117
  'kanban-ticket-draft': { ticketId: string; draft?: IKanbanTicketDraft };
110
118
  'kanban-comment-draft': { ticketId: string; body: TReferenceContent };
111
119
  'kanban-comment-added': { comment: IKanbanComment; submittedBody: TReferenceContent };
120
+ 'kanban-question-added': { question: IKanbanQuestion; submittedBody: TReferenceContent };
121
+ 'kanban-question-answered': { question: IKanbanQuestion; answer: IKanbanQuestionAnswerInput };
112
122
  'kanban-comments-refresh': { ticketId: string };
113
123
  'kanban-activity-refresh': { ticketId: string };
114
124
  'kanban-detail-back': Record<string, never>;
@@ -123,7 +133,7 @@ type TKanbanInteraction = {
123
133
  }[keyof IKanbanInteractionMap];
124
134
 
125
135
  /** The board's filters in the filter bubble, by their `IKanbanFilterValues` key. */
126
- type TKanbanFilterKey = 'project' | 'epic' | 'assignee' | 'label' | 'mine';
136
+ type TKanbanFilterKey = 'project' | 'epic' | 'assignee' | 'label' | 'autoLabel' | 'mine';
127
137
 
128
138
  /** What narrows the board now, as its active-filter bar shows it. */
129
139
  interface IKanbanActiveFilter {
@@ -164,6 +174,13 @@ export class DeesKanban extends DeesElement {
164
174
  @property({ attribute: false })
165
175
  accessor projects: IKanbanProject[] = [];
166
176
 
177
+ /**
178
+ * How the AutoLabels the tickets carry show, by `label`: name, description, icon and tone. The
179
+ * board names `openQuestion` itself; another label without a definition shows as it is.
180
+ */
181
+ @property({ attribute: false })
182
+ accessor autoLabelDefinitions: IKanbanAutoLabel[] = [];
183
+
167
184
  /**
168
185
  * Every task and epic belongs to a project: the create dialog offers no "No project", says so,
169
186
  * and creates nothing until one is chosen; a subtask still takes its parent's. The provider
@@ -226,7 +243,7 @@ export class DeesKanban extends DeesElement {
226
243
  /** Counts the tickets the board took from its own saves, moves and creations. */
227
244
  private mutationEpoch = 0;
228
245
  private activityCache = new Map<string, IKanbanActivity[]>();
229
- private commentCache = new Map<string, IKanbanComment[]>();
246
+ private commentCache = new Map<string, TKanbanDiscussionItem[]>();
230
247
  private commentRevisions = new Map<string, number>();
231
248
  private commentDrafts = new Map<string, TReferenceContent>();
232
249
  private ticketDrafts = new Map<string, IKanbanTicketDraft>();
@@ -540,6 +557,7 @@ export class DeesKanban extends DeesElement {
540
557
  .tickets=${tasks.filter(ticket => ticket.columnId === column.id)}
541
558
  .allTickets=${this.tickets}
542
559
  .projects=${projects}
560
+ .autoLabelDefinitions=${this.autoLabelDefinitions}
543
561
  .showProjects=${!filters.project && projects.length > 0}
544
562
  .movable=${Boolean(this.provider.moveTicket)}
545
563
  .canCreate=${Boolean(this.provider.createTicket)}
@@ -604,6 +622,7 @@ export class DeesKanban extends DeesElement {
604
622
  ? !ticket.assignee
605
623
  : ticket.assignee?.id === filters.assignee)) &&
606
624
  (!filters.label || Boolean(ticket.labels?.includes(filters.label))) &&
625
+ (!filters.autoLabel || Boolean(ticket.autoLabels?.includes(filters.autoLabel))) &&
607
626
  (!mine || ticket.assignee?.id === this.currentPersonId) &&
608
627
  (!query ||
609
628
  [
@@ -612,6 +631,7 @@ export class DeesKanban extends DeesElement {
612
631
  ticket.project ? kanbanProjectName(this.projects, ticket.project) : '',
613
632
  ticket.assignee?.name,
614
633
  ...ticket.labels ?? [],
634
+ ...(ticket.autoLabels ?? []).map(label => this.autoLabelName(label)),
615
635
  ...this.tickets
616
636
  .filter(child => child.parentId === ticket.id)
617
637
  .map(child => `${child.key} ${child.title}`),
@@ -622,10 +642,15 @@ export class DeesKanban extends DeesElement {
622
642
  );
623
643
  }
624
644
 
645
+ /** An AutoLabel's name, as its chip shows it. */
646
+ private autoLabelName(label: string): string {
647
+ return kanbanAutoLabel(this.t, this.autoLabelDefinitions, label).name;
648
+ }
649
+
625
650
  /**
626
651
  * The filter bubble's fields, as the table's filters: a project, an epic (of that project), an
627
- * assignee and a label, each with an "all" option, and "Assigned to me" while the board knows
628
- * its reader. A field with nothing to choose from is left out; a value set in code that no
652
+ * assignee, a label and an AutoLabel, each with an "all" option, and "Assigned to me" while the
653
+ * board knows its reader. The AutoLabels are the defined ones and those a ticket carries. A field with nothing to choose from is left out; a value set in code that no
629
654
  * ticket has stays a choice.
630
655
  */
631
656
  private filterFields(): ITableFilter[] {
@@ -669,6 +694,12 @@ export class DeesKanban extends DeesElement {
669
694
  ];
670
695
  const labels = [...new Set(this.tickets.flatMap(ticket => ticket.labels ?? []))]
671
696
  .sort((a, b) => a.localeCompare(b));
697
+ const autoLabels = [...new Set([
698
+ ...this.autoLabelDefinitions.map(definition => definition.label),
699
+ ...this.tickets.flatMap(ticket => ticket.autoLabels ?? []),
700
+ ])]
701
+ .map(label => ({ key: label, label: this.autoLabelName(label) }))
702
+ .sort((a, b) => a.label.localeCompare(b.label));
672
703
  const fields = [
673
704
  choices('project', this.t('kanban.project'), this.t('kanban.allProjects'),
674
705
  projects.map(project => ({ key: project.id, label: project.name }))),
@@ -682,6 +713,7 @@ export class DeesKanban extends DeesElement {
682
713
  : []),
683
714
  choices('label', this.t('kanban.label'), this.t('kanban.allLabels'),
684
715
  labels.map(label => ({ key: label, label }))),
716
+ choices('autoLabel', this.t('kanban.autoLabel'), this.t('kanban.allAutoLabels'), autoLabels),
685
717
  ].filter((field): field is ITableFilter => Boolean(field));
686
718
  if (this.currentPersonId)
687
719
  fields.push({
@@ -891,6 +923,7 @@ export class DeesKanban extends DeesElement {
891
923
  this.detail.provider = this.provider;
892
924
  this.detail.searchTickets = this.searchTickets;
893
925
  this.detail.projects = this.projects;
926
+ this.detail.autoLabelDefinitions = this.autoLabelDefinitions;
894
927
  this.detail.comments = this.commentCache.get(this.selectedId) ?? [];
895
928
  this.detail.activity = this.activityCache.get(this.selectedId) ?? [];
896
929
  this.detail.commentDraft = this.commentDrafts.get(this.selectedId) ?? [];
@@ -901,8 +934,8 @@ export class DeesKanban extends DeesElement {
901
934
  if (this.modal) this.modal.heading = this.detail.ticket.key;
902
935
  }
903
936
 
904
- /** Replace a ticket's discussion with an authoritative snapshot (for realtime updates). */
905
- public setComments(ticketId: string, comments: IKanbanComment[]): void {
937
+ /** Replace a ticket's discussion, comments and questions, with an authoritative snapshot (for realtime updates). */
938
+ public setComments(ticketId: string, comments: TKanbanDiscussionItem[]): void {
906
939
  if (comments.some(comment => comment.ticketId !== ticketId))
907
940
  throw new Error('Comment ticket IDs must match.');
908
941
  this.commentCache.set(ticketId, [...comments]);
@@ -910,6 +943,23 @@ export class DeesKanban extends DeesElement {
910
943
  this.syncDetail();
911
944
  }
912
945
 
946
+ /**
947
+ * Takes a comment or question the discussion saved into the ticket's discussion, over its earlier
948
+ * state; the composer's kept text leaves once it is what was posted. The history loads again.
949
+ */
950
+ private keepDiscussionItem(item: TKanbanDiscussionItem, submittedBody?: TReferenceContent): void {
951
+ const key = kanbanItemKey(item);
952
+ const items = this.commentCache.get(item.ticketId) ?? [];
953
+ this.commentCache.set(item.ticketId, [...items.filter(other => kanbanItemKey(other) !== key), item]);
954
+ if (
955
+ submittedBody &&
956
+ JSON.stringify(this.commentDrafts.get(item.ticketId) ?? []) === JSON.stringify(submittedBody)
957
+ )
958
+ this.commentDrafts.delete(item.ticketId);
959
+ this.syncDetail();
960
+ if (item.ticketId === this.selectedId) void this.refreshActivity(item.ticketId, true);
961
+ }
962
+
913
963
  /** Loads a ticket's comments again; `quiet` keeps the shown ones without a loading line meanwhile. */
914
964
  public async refreshComments(ticketId = this.selectedId, quiet = false): Promise<void> {
915
965
  this.commentsAbort?.abort();
@@ -922,7 +972,7 @@ export class DeesKanban extends DeesElement {
922
972
  return;
923
973
  }
924
974
  const revision = this.commentRevisions.get(ticketId) ?? 0;
925
- const existingIds = new Set((this.commentCache.get(ticketId) ?? []).map(comment => comment.id));
975
+ const before = new Map((this.commentCache.get(ticketId) ?? []).map(item => [kanbanItemKey(item), item]));
926
976
  if (this.detail && ticketId === this.selectedId && !quiet) {
927
977
  this.detail.loadingComments = true;
928
978
  this.detail.commentsError = '';
@@ -930,10 +980,18 @@ export class DeesKanban extends DeesElement {
930
980
  try {
931
981
  const comments = await this.provider.loadComments(ticketId, controller.signal);
932
982
  if (!controller.signal.aborted && (this.commentRevisions.get(ticketId) ?? 0) === revision) {
933
- const postedWhileLoading = (this.commentCache.get(ticketId) ?? []).filter(
934
- comment => !existingIds.has(comment.id) && !comments.some(item => item.id === comment.id),
935
- );
936
- this.setComments(ticketId, [...comments, ...postedWhileLoading]);
983
+ // What the board saved meanwhile stays: a comment or question the snapshot lacks, and a
984
+ // question answered since, over the snapshot's open one.
985
+ const loaded = new Set(comments.map(kanbanItemKey));
986
+ const savedWhileLoading = new Map((this.commentCache.get(ticketId) ?? [])
987
+ .filter(item => before.get(kanbanItemKey(item)) !== item)
988
+ .map(item => [kanbanItemKey(item), item]));
989
+ this.setComments(ticketId, [
990
+ ...comments.map(item => before.has(kanbanItemKey(item))
991
+ ? savedWhileLoading.get(kanbanItemKey(item)) ?? item
992
+ : item),
993
+ ...[...savedWhileLoading.values()].filter(item => !loaded.has(kanbanItemKey(item))),
994
+ ]);
937
995
  if (this.detail && ticketId === this.selectedId) this.detail.commentsError = '';
938
996
  }
939
997
  } catch (error) {
@@ -1475,21 +1533,22 @@ export class DeesKanban extends DeesElement {
1475
1533
  break;
1476
1534
  case 'kanban-comment-added': {
1477
1535
  const { comment, submittedBody } = detail;
1478
- const comments = this.commentCache.get(comment.ticketId) ?? [];
1479
- this.commentCache.set(comment.ticketId, [
1480
- ...comments.filter(item => item.id !== comment.id),
1481
- comment,
1482
- ]);
1483
- if (
1484
- JSON.stringify(this.commentDrafts.get(comment.ticketId) ?? []) ===
1485
- JSON.stringify(submittedBody)
1486
- )
1487
- this.commentDrafts.delete(comment.ticketId);
1488
- this.syncDetail();
1489
- if (comment.ticketId === this.selectedId) void this.refreshActivity(comment.ticketId, true);
1536
+ this.keepDiscussionItem(comment, submittedBody);
1490
1537
  kanbanEvent(this, 'kanban-comment-saved', { comment });
1491
1538
  break;
1492
1539
  }
1540
+ case 'kanban-question-added': {
1541
+ const { question, submittedBody } = detail;
1542
+ this.keepDiscussionItem(question, submittedBody);
1543
+ kanbanEvent(this, 'kanban-question-asked', { question });
1544
+ break;
1545
+ }
1546
+ case 'kanban-question-answered': {
1547
+ const { question, answer } = detail;
1548
+ this.keepDiscussionItem(question);
1549
+ kanbanEvent(this, 'kanban-question-answer', { ...answer, question });
1550
+ break;
1551
+ }
1493
1552
  case 'kanban-comments-refresh':
1494
1553
  void this.refreshComments(detail.ticketId);
1495
1554
  break;
@@ -45,6 +45,8 @@ const actionIcons: Record<TKanbanActivityAction, string> = {
45
45
  reordered: 'lucide:ArrowUpDown',
46
46
  commented: 'lucide:MessageSquare',
47
47
  linked: 'lucide:Link',
48
+ asked: 'lucide:MessageCircleQuestionMark',
49
+ answered: 'lucide:MessageCircleReply',
48
50
  };
49
51
 
50
52
  interface IChangeLine {
@@ -1,8 +1,8 @@
1
1
  import { DeesElement, customElement, property, html, css } from '@design.estate/dees-element';
2
2
  import { dcLocalize } from '../../../i18n/localize.js';
3
- import type { IKanbanTicket, IKanbanColumn } from '../interfaces.js';
3
+ import type { IKanbanAutoLabel, IKanbanTicket, IKanbanColumn } from '../interfaces.js';
4
4
  import { kanbanStyles } from '../kanban.styles.js';
5
- import { kanbanEvent, kanbanInitials, kanbanPriorityIcon } from '../kanban.helpers.js';
5
+ import { kanbanEvent, kanbanInitials, kanbanPriorityIcon, renderKanbanAutoLabels } from '../kanban.helpers.js';
6
6
  import '../../00group-button/dees-button/dees-button.js';
7
7
  import '../../00group-utility/dees-icon/dees-icon.js';
8
8
 
@@ -30,6 +30,10 @@ export class DeesKanbanCard extends DeesElement {
30
30
  @property({ attribute: false })
31
31
  accessor columns: IKanbanColumn[] = [];
32
32
 
33
+ /** What the host's AutoLabels are called and how they look; see the board's `autoLabelDefinitions`. */
34
+ @property({ attribute: false })
35
+ accessor autoLabelDefinitions: IKanbanAutoLabel[] = [];
36
+
33
37
  @property({ type: Boolean, reflect: true })
34
38
  accessor movable = false;
35
39
 
@@ -173,6 +177,10 @@ export class DeesKanbanCard extends DeesElement {
173
177
  text-overflow: ellipsis;
174
178
  }
175
179
 
180
+ .badge.auto {
181
+ display: inline-flex;
182
+ }
183
+
176
184
  .assignee {
177
185
  display: flex;
178
186
  align-items: center;
@@ -338,6 +346,7 @@ export class DeesKanbanCard extends DeesElement {
338
346
  aria-hidden="true"
339
347
  ></dees-icon>${this.t('kanban.priority', { priority: ticket.priority })}</span>`
340
348
  : ''}
349
+ ${renderKanbanAutoLabels(this.t, this.autoLabelDefinitions, ticket.autoLabels)}
341
350
  ${ticket.labels?.map(label => html`<span class="badge" title=${label}>${label}</span>`)}
342
351
  <span class="assignee" title=${ticket.assignee?.name ?? this.t('kanban.unassigned')}>
343
352
  <span
@@ -9,7 +9,7 @@ import {
9
9
  } from '@design.estate/dees-element';
10
10
  import { dcLocalize } from '../../../i18n/localize.js';
11
11
  import { ScrollEdgeShadowController, scrollEdgeShadowStyles } from '../../00scrolledges.js';
12
- import type { IKanbanColumn, IKanbanProject, IKanbanTicket } from '../interfaces.js';
12
+ import type { IKanbanAutoLabel, IKanbanColumn, IKanbanProject, IKanbanTicket } from '../interfaces.js';
13
13
  import type { IKanbanMotion } from '../kanban.dragcontroller.js';
14
14
  import { kanbanStyles } from '../kanban.styles.js';
15
15
  import { kanbanEvent, kanbanProjectName, sortKanbanTickets } from '../kanban.helpers.js';
@@ -44,6 +44,10 @@ export class DeesKanbanColumn extends DeesElement {
44
44
  @property({ attribute: false })
45
45
  accessor projects: IKanbanProject[] = [];
46
46
 
47
+ /** The host's AutoLabels, for the cards' chips. */
48
+ @property({ attribute: false })
49
+ accessor autoLabelDefinitions: IKanbanAutoLabel[] = [];
50
+
47
51
  /** Shows each card's project; off while the board shows one project. */
48
52
  @property({ type: Boolean, reflect: true })
49
53
  accessor showProjects = false;
@@ -349,6 +353,7 @@ export class DeesKanbanColumn extends DeesElement {
349
353
  : html`<dees-kanban-card
350
354
  .ticket=${ticket}
351
355
  .columns=${this.columns}
356
+ .autoLabelDefinitions=${this.autoLabelDefinitions}
352
357
  .projectName=${this.showProjects && ticket.project
353
358
  ? kanbanProjectName(this.projects, ticket.project)
354
359
  : ''}
@@ -1,30 +1,46 @@
1
1
  import {
2
2
  DeesElement,
3
3
  customElement,
4
+ directives,
4
5
  property,
6
+ state,
5
7
  html,
6
8
  } from '@design.estate/dees-element';
7
9
  import { dcLocalize } from '../../../i18n/localize.js';
8
- import type { IKanbanComment, IKanbanPerson, IKanbanProvider } from '../interfaces.js';
9
- import { kanbanFeedStyles, kanbanStyles } from '../kanban.styles.js';
10
- import { kanbanEvent } from '../kanban.helpers.js';
11
10
  import type {
12
- TReferenceContent,
13
- TReferenceSearch,
11
+ IKanbanPerson,
12
+ IKanbanProvider,
13
+ IKanbanQuestion,
14
+ IKanbanQuestionAnswerInput,
15
+ TKanbanDiscussionItem,
16
+ } from '../interfaces.js';
17
+ import { kanbanFeedStyles, kanbanStyles } from '../kanban.styles.js';
18
+ import { isKanbanQuestion, kanbanError, kanbanEvent } from '../kanban.helpers.js';
19
+ import {
20
+ referenceText,
21
+ type TReferenceContent,
22
+ type TReferenceSearch,
14
23
  } from '../../00group-input/dees-input-reference/index.js';
15
24
  import {
16
25
  markdownToReferences,
17
26
  referencesToMarkdown,
18
27
  } from '../../00group-input/dees-input-richtext/markdown.js';
19
28
  import type {
29
+ IThreadComposerAction,
20
30
  IThreadDraftDetail,
21
31
  IThreadEntry,
22
32
  IThreadReferenceDetail,
23
33
  IThreadSubmission,
24
34
  TThreadView,
25
35
  } from '../../00group-dataview/dees-thread/interfaces.js';
36
+ import type {
37
+ IHarnessQuestionRequest,
38
+ IHarnessQuestionResponseDetail,
39
+ } from '../../00group-harness/interfaces.js';
40
+ import type { DeesHarnessQuestionCard } from '../../00group-harness/dees-harness-question-card/dees-harness-question-card.js';
26
41
  import '../../00group-button/dees-button/dees-button.js';
27
42
  import '../../00group-dataview/dees-thread/dees-thread.js';
43
+ import '../../00group-harness/dees-harness-question-card/dees-harness-question-card.js';
28
44
 
29
45
  declare global {
30
46
  interface HTMLElementTagNameMap {
@@ -37,6 +53,11 @@ declare global {
37
53
  * reader's avatar. Comments and the draft stay `TReferenceContent`, their text parts Markdown, and
38
54
  * the events and the provider see them so. `view` shows the comments or the composer alone, as the
39
55
  * ticket detail pins the composer under its main column.
56
+ *
57
+ * The ticket's questions stand among the comments as question cards, an unanswered one outlined
58
+ * and never folded away. With `answerQuestion` the reader answers one by its options, in their own
59
+ * words, or both; a refusal shows on the card, which waits for an answer again. With `askQuestion`
60
+ * the composer also posts its text as a question ("Ask as question").
40
61
  */
41
62
  @customElement('dees-kanban-discussion')
42
63
  export class DeesKanbanDiscussion extends DeesElement {
@@ -45,8 +66,9 @@ export class DeesKanbanDiscussion extends DeesElement {
45
66
  @property({ type: String, reflect: true })
46
67
  accessor ticketId = '';
47
68
 
69
+ /** The ticket's comments and questions, in any order. */
48
70
  @property({ attribute: false })
49
- accessor comments: IKanbanComment[] = [];
71
+ accessor comments: TKanbanDiscussionItem[] = [];
50
72
 
51
73
  @property({ attribute: false })
52
74
  accessor draft: TReferenceContent = [];
@@ -65,6 +87,14 @@ export class DeesKanbanDiscussion extends DeesElement {
65
87
  @property({ attribute: false })
66
88
  accessor addComment: IKanbanProvider['addComment'];
67
89
 
90
+ /** Offers "Ask as question" beside the comment button. */
91
+ @property({ attribute: false })
92
+ accessor askQuestion: IKanbanProvider['askQuestion'];
93
+
94
+ /** Lets the reader answer the questions; without it they show read-only. */
95
+ @property({ attribute: false })
96
+ accessor answerQuestion: IKanbanProvider['answerQuestion'];
97
+
68
98
  @property({ type: Boolean, reflect: true })
69
99
  accessor loading = false;
70
100
 
@@ -78,26 +108,100 @@ export class DeesKanbanDiscussion extends DeesElement {
78
108
  @property({ type: Boolean, reflect: true })
79
109
  accessor showHeader = true;
80
110
 
111
+ /** The questions whose answer is being saved, by id. */
112
+ @state()
113
+ private accessor answering: ReadonlySet<string> = new Set();
114
+
81
115
  public static styles = [...kanbanStyles, kanbanFeedStyles];
82
116
 
83
- /** The ticket's comments as the thread's entries, oldest first. */
117
+ /** The ticket's comments and questions as the thread's entries, oldest first. */
84
118
  private threadEntries: IThreadEntry[] = [];
85
119
 
120
+ /** The ticket's questions, oldest first, each with a card in the thread. */
121
+ private questions: IKanbanQuestion[] = [];
122
+
123
+ /** Each question as its card asks it, kept while the question is unchanged. */
124
+ private readonly cardRequests = new WeakMap<IKanbanQuestion, IHarnessQuestionRequest>();
125
+
126
+ private askActions: IThreadComposerAction[] = [];
127
+
86
128
  /** The composer's Markdown the draft was read from, given back while the draft is unchanged. */
87
129
  private draftSource: { draft: TReferenceContent; markdown: string } | undefined;
88
130
 
89
131
  protected override willUpdate(changed: Map<string, unknown>): void {
90
132
  super.willUpdate(changed);
91
- if (!changed.has('comments') && !changed.has('ticketId')) return;
92
- this.threadEntries = this.comments
93
- .filter(comment => comment.ticketId === this.ticketId)
94
- .sort((a, b) => Date.parse(a.createdAt) - Date.parse(b.createdAt))
95
- .map(comment => ({
96
- id: comment.id,
97
- author: { id: comment.author.id, name: comment.author.name },
98
- createdAt: comment.createdAt,
99
- body: referencesToMarkdown(comment.body),
100
- }));
133
+ if (!changed.has('comments') && !changed.has('ticketId') && !changed.has('answering')) return;
134
+ const items = this.comments
135
+ .filter(item => item.ticketId === this.ticketId)
136
+ .sort((a, b) => Date.parse(a.createdAt) - Date.parse(b.createdAt));
137
+ this.questions = items.filter(isKanbanQuestion);
138
+ this.threadEntries = items.map(item => isKanbanQuestion(item)
139
+ ? this.questionEntry(item)
140
+ : {
141
+ id: item.id,
142
+ author: { id: item.author.id, name: item.author.name },
143
+ createdAt: item.createdAt,
144
+ body: referencesToMarkdown(item.body),
145
+ });
146
+ }
147
+
148
+ /** A question as the thread's entry: its card in the body's place, outlined while it waits. */
149
+ private questionEntry(question: IKanbanQuestion): IThreadEntry {
150
+ const answer = question.answer;
151
+ const answeredAt = answer && new Date(answer.answeredAt);
152
+ return {
153
+ id: `question:${question.id}`,
154
+ author: { id: question.author.id, name: question.author.name },
155
+ createdAt: question.createdAt,
156
+ body: question.question,
157
+ slot: `question-${question.id}`,
158
+ attention: answer ? undefined : this.t('kanban.autoLabelOpenQuestion'),
159
+ footnote: this.answering.has(question.id)
160
+ ? this.t('kanban.answerSaving')
161
+ : answer && answeredAt && !Number.isNaN(answeredAt.getTime())
162
+ ? this.t('kanban.answeredBy', {
163
+ name: answer.answeredBy.name,
164
+ when: this.t.format.instant(answeredAt, { date: 'medium', time: 'short' }),
165
+ })
166
+ : undefined,
167
+ };
168
+ }
169
+
170
+ /** A question as its card asks it, with its answer as the card shows one: the options chosen, then the words. */
171
+ private cardRequest(question: IKanbanQuestion): IHarnessQuestionRequest {
172
+ const known = this.cardRequests.get(question);
173
+ if (known) return known;
174
+ const options = question.options ?? [];
175
+ const answer = question.answer;
176
+ const request: IHarnessQuestionRequest = {
177
+ id: question.id,
178
+ kind: 'question',
179
+ question: referenceText(markdownToReferences(question.question)),
180
+ options: options.map(option => ({ id: option.id, label: option.label, description: option.description })),
181
+ multiSelect: question.multiSelect ?? false,
182
+ allowCustom: question.allowCustom ?? true,
183
+ createdAt: Date.parse(question.createdAt),
184
+ };
185
+ if (answer) {
186
+ const chosen = new Set(answer.choices);
187
+ const text = answer.text?.trim();
188
+ request.response = [
189
+ ...options.filter(option => chosen.has(option.id)).map(option => option.label),
190
+ ...text ? [text] : [],
191
+ ];
192
+ request.respondedAt = Date.parse(answer.answeredAt);
193
+ }
194
+ this.cardRequests.set(question, request);
195
+ return request;
196
+ }
197
+
198
+ private composerActions(): IThreadComposerAction[] {
199
+ if (!this.askQuestion) return [];
200
+ const label = this.t('kanban.askQuestion');
201
+ if (this.askActions[0]?.label !== label) {
202
+ this.askActions = [{ key: 'ask', label, iconName: 'lucide:MessageCircleQuestionMark' }];
203
+ }
204
+ return this.askActions;
101
205
  }
102
206
 
103
207
  private threadDraft(): string {
@@ -131,6 +235,7 @@ export class DeesKanbanDiscussion extends DeesElement {
131
235
  .searchReferences=${this.searchTickets}
132
236
  .referenceSearchLabel=${this.t('reference.search')}
133
237
  .view=${this.view}
238
+ .composerActions=${this.composerActions()}
134
239
  .onSubmit=${this.post}
135
240
  .readOnly=${this.readOnly || !this.addComment || !this.ticketId}
136
241
  .readOnlyReason=${this.t('kanban.readOnly')}
@@ -153,7 +258,19 @@ export class DeesKanbanDiscussion extends DeesElement {
153
258
  kanbanEvent(this, 'kanban-comments-refresh', { ticketId: this.ticketId });
154
259
  }}
155
260
  @thread-submit=${(event: Event) => event.stopPropagation()}
156
- ></dees-thread>`;
261
+ >${this.view === 'composer' ? '' : directives.repeat(
262
+ this.questions,
263
+ question => question.id,
264
+ question => html`<dees-harness-question-card
265
+ slot=${`question-${question.id}`}
266
+ frameless
267
+ .request=${this.cardRequest(question)}
268
+ .busy=${this.answering.has(question.id)}
269
+ .readOnly=${!this.answerQuestion || !this.ticketId}
270
+ @harness-question-response=${(event: CustomEvent<IHarnessQuestionResponseDetail>) =>
271
+ this.answer(question, event)}
272
+ ></dees-harness-question-card>`,
273
+ )}</dees-thread>`;
157
274
  }
158
275
 
159
276
  /** Posts the draft as the Comment button would; resolves once the post settled. */
@@ -163,14 +280,75 @@ export class DeesKanbanDiscussion extends DeesElement {
163
280
  await this.shadowRoot?.querySelector('dees-thread')?.submit();
164
281
  }
165
282
 
166
- /** Saves a comment; a refusal or a comment saved to another ticket stays in the composer. */
167
- private readonly post = async ({ body }: IThreadSubmission): Promise<void> => {
283
+ /**
284
+ * Shows a question, unfolding a long discussion to it, and puts the focus on its answer where the
285
+ * reader may answer it; `false` when it is not here or takes no answer.
286
+ */
287
+ public async revealQuestion(questionId: string): Promise<boolean> {
288
+ await this.updateComplete;
289
+ const thread = this.shadowRoot?.querySelector('dees-thread');
290
+ if (!thread || !(await thread.revealEntry(`question:${questionId}`))) return false;
291
+ const card = [...this.shadowRoot?.querySelectorAll<DeesHarnessQuestionCard>('dees-harness-question-card') ?? []]
292
+ .find(element => element.slot === `question-${questionId}`);
293
+ // The thread scrolls the whole question into view; the focus must not cut that short.
294
+ return card ? card.focusAnswer({ preventScroll: true }) : false;
295
+ }
296
+
297
+ /**
298
+ * Saves a comment, or with "Ask as question" a question; a refusal, or a comment or question saved
299
+ * to another ticket, stays in the composer.
300
+ */
301
+ private readonly post = async ({ body, action }: IThreadSubmission): Promise<void> => {
168
302
  const ticketId = this.ticketId;
303
+ if (!ticketId || typeof body !== 'string') return;
304
+ if (action === 'ask') {
305
+ const askQuestion = this.askQuestion;
306
+ if (!askQuestion) return;
307
+ const question = await askQuestion({ ticketId, question: body });
308
+ if (question.ticketId !== ticketId) throw new Error(this.t('kanban.questionMismatch'));
309
+ kanbanEvent(this, 'kanban-question-added', { question, submittedBody: markdownToReferences(body) });
310
+ return;
311
+ }
169
312
  const addComment = this.addComment;
170
- if (!ticketId || !addComment || typeof body !== 'string') return;
313
+ if (!addComment) return;
171
314
  const submittedBody = markdownToReferences(body);
172
315
  const comment = await addComment({ ticketId, body: submittedBody });
173
316
  if (comment.ticketId !== ticketId) throw new Error(this.t('kanban.commentMismatch'));
174
317
  kanbanEvent(this, 'kanban-comment-added', { comment, submittedBody });
175
318
  };
319
+
320
+ /**
321
+ * Saves the answer a card gave; the card shows it while it is saved. A refusal, or a saved
322
+ * question that is another or still open, shows on the card, which waits for an answer again.
323
+ */
324
+ private async answer(question: IKanbanQuestion, event: CustomEvent<IHarnessQuestionResponseDetail>): Promise<void> {
325
+ event.stopPropagation();
326
+ const card = event.currentTarget as DeesHarnessQuestionCard;
327
+ const ticketId = this.ticketId;
328
+ const answerQuestion = this.answerQuestion;
329
+ if (!answerQuestion || question.ticketId !== ticketId || this.answering.has(question.id)) {
330
+ card.rejectResponse();
331
+ return;
332
+ }
333
+ const text = event.detail.text?.trim();
334
+ const input: IKanbanQuestionAnswerInput = {
335
+ ticketId,
336
+ questionId: question.id,
337
+ choices: event.detail.optionIds ?? [],
338
+ ...text ? { text } : {},
339
+ };
340
+ this.answering = new Set([...this.answering, question.id]);
341
+ try {
342
+ const saved = await answerQuestion(input);
343
+ if (saved.ticketId !== ticketId || saved.id !== question.id) throw new Error(this.t('kanban.questionMismatch'));
344
+ if (!saved.answer) throw new Error(this.t('question.answerRefused'));
345
+ kanbanEvent(this, 'kanban-question-answered', { question: saved, answer: input });
346
+ } catch (error) {
347
+ card.rejectResponse({ message: kanbanError(error) });
348
+ } finally {
349
+ const answering = new Set(this.answering);
350
+ answering.delete(question.id);
351
+ this.answering = answering;
352
+ }
353
+ }
176
354
  }