@design.estate/dees-catalog 21.46.0 → 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 (69) hide show
  1. package/dist_bundle/bundle.js +825 -259
  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-table/dees-table.d.ts +24 -7
  13. package/dist_ts_web/elements/00group-dataview/dees-table/dees-table.js +53 -18
  14. package/dist_ts_web/elements/00group-dataview/dees-thread/dees-thread.d.ts +9 -1
  15. package/dist_ts_web/elements/00group-dataview/dees-thread/dees-thread.js +42 -5
  16. package/dist_ts_web/elements/00group-dataview/dees-thread/interfaces.d.ts +11 -0
  17. package/dist_ts_web/elements/00group-harness/dees-harness-question-card/dees-harness-question-card.d.ts +30 -8
  18. package/dist_ts_web/elements/00group-harness/dees-harness-question-card/dees-harness-question-card.js +95 -24
  19. package/dist_ts_web/elements/00group-harness/interfaces.d.ts +14 -3
  20. package/dist_ts_web/elements/00group-kanban/dees-kanban/dees-kanban.d.ts +17 -5
  21. package/dist_ts_web/elements/00group-kanban/dees-kanban/dees-kanban.demo.js +6 -2
  22. package/dist_ts_web/elements/00group-kanban/dees-kanban/dees-kanban.js +76 -20
  23. package/dist_ts_web/elements/00group-kanban/dees-kanban-activity/dees-kanban-activity.js +3 -1
  24. package/dist_ts_web/elements/00group-kanban/dees-kanban-card/dees-kanban-card.d.ts +3 -1
  25. package/dist_ts_web/elements/00group-kanban/dees-kanban-card/dees-kanban-card.js +17 -3
  26. package/dist_ts_web/elements/00group-kanban/dees-kanban-column/dees-kanban-column.d.ts +3 -1
  27. package/dist_ts_web/elements/00group-kanban/dees-kanban-column/dees-kanban-column.js +12 -2
  28. package/dist_ts_web/elements/00group-kanban/dees-kanban-discussion/dees-kanban-discussion.d.ts +41 -5
  29. package/dist_ts_web/elements/00group-kanban/dees-kanban-discussion/dees-kanban-discussion.js +196 -20
  30. package/dist_ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.d.ts +25 -2
  31. package/dist_ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.js +137 -8
  32. package/dist_ts_web/elements/00group-kanban/index.d.ts +1 -0
  33. package/dist_ts_web/elements/00group-kanban/index.js +2 -1
  34. package/dist_ts_web/elements/00group-kanban/interfaces.d.ts +96 -3
  35. package/dist_ts_web/elements/00group-kanban/kanban.demodata.js +119 -3
  36. package/dist_ts_web/elements/00group-kanban/kanban.helpers.d.ts +19 -1
  37. package/dist_ts_web/elements/00group-kanban/kanban.helpers.js +50 -1
  38. package/dist_ts_web/elements/00group-kanban/kanban.styles.js +32 -1
  39. package/dist_ts_web/i18n/de.d.ts +53 -1
  40. package/dist_ts_web/i18n/de.js +15 -2
  41. package/dist_ts_web/i18n/messages.d.ts +53 -1
  42. package/dist_ts_web/i18n/messages.js +15 -2
  43. package/package.json +1 -1
  44. package/readme.md +58 -19
  45. package/ts_web/00_commitinfo_data.ts +1 -1
  46. package/ts_web/elements/00group-dataview/dees-table/dees-table.ts +54 -17
  47. package/ts_web/elements/00group-dataview/dees-thread/dees-thread.ts +39 -4
  48. package/ts_web/elements/00group-dataview/dees-thread/interfaces.ts +11 -0
  49. package/ts_web/elements/00group-harness/dees-harness-question-card/dees-harness-question-card.ts +83 -21
  50. package/ts_web/elements/00group-harness/interfaces.ts +14 -3
  51. package/ts_web/elements/00group-kanban/dees-kanban/dees-kanban.demo.ts +5 -1
  52. package/ts_web/elements/00group-kanban/dees-kanban/dees-kanban.ts +82 -23
  53. package/ts_web/elements/00group-kanban/dees-kanban-activity/dees-kanban-activity.ts +2 -0
  54. package/ts_web/elements/00group-kanban/dees-kanban-card/dees-kanban-card.ts +11 -2
  55. package/ts_web/elements/00group-kanban/dees-kanban-column/dees-kanban-column.ts +6 -1
  56. package/ts_web/elements/00group-kanban/dees-kanban-discussion/dees-kanban-discussion.ts +199 -21
  57. package/ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.ts +144 -6
  58. package/ts_web/elements/00group-kanban/index.ts +1 -0
  59. package/ts_web/elements/00group-kanban/interfaces.ts +101 -4
  60. package/ts_web/elements/00group-kanban/kanban.demodata.ts +126 -2
  61. package/ts_web/elements/00group-kanban/kanban.helpers.ts +70 -0
  62. package/ts_web/elements/00group-kanban/kanban.styles.ts +31 -0
  63. package/ts_web/i18n/de.ts +14 -1
  64. package/ts_web/i18n/messages.ts +14 -1
  65. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-7PGZC4IF.js.map +0 -1
  66. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-FCUX4QGD.js.map → chunk-Q5VY4AV7.js.map} +0 -0
  67. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-LWT7IIPZ.js.map → chunk-QG5BHDQO.js.map} +0 -0
  68. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-VOIWY235.js.map → dees-modal-YOGT7PSU.js.map} +0 -0
  69. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-EJRHSZ5F.js.map → dees-workspace-terminal-ORLONA36.js.map} +0 -0
@@ -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
  }
@@ -13,15 +13,18 @@ import { visuallyHidden } from '../../00visuallyhidden.js';
13
13
  import { insetInlineStyles } from '../../00theme.js';
14
14
  import type {
15
15
  IKanbanActivity,
16
+ IKanbanAutoLabel,
16
17
  IKanbanColumn,
17
- IKanbanComment,
18
18
  IKanbanEditConflict,
19
19
  IKanbanPerson,
20
20
  IKanbanProject,
21
21
  IKanbanProvider,
22
+ IKanbanQuestion,
22
23
  IKanbanSource,
23
24
  IKanbanTicket,
24
25
  IKanbanTicketDraft,
26
+ TKanbanActivityAction,
27
+ TKanbanDiscussionItem,
25
28
  TKanbanDraftField,
26
29
  TKanbanLink,
27
30
  TKanbanPriority,
@@ -32,6 +35,7 @@ import type {
32
35
  } from '../../00group-input/dees-input-reference/interfaces.js';
33
36
  import { kanbanStyles } from '../kanban.styles.js';
34
37
  import {
38
+ isKanbanQuestion,
35
39
  kanbanDraftFields,
36
40
  kanbanEvent,
37
41
  kanbanHref,
@@ -43,12 +47,14 @@ import {
43
47
  kanbanProjectName,
44
48
  kanbanProjects,
45
49
  kanbanShortSha,
50
+ renderKanbanAutoLabels,
46
51
  sortKanbanTickets,
47
52
  ticketDraft,
48
53
  ticketLabel,
49
54
  } from '../kanban.helpers.js';
50
55
  import type { DeesInputText } from '../../00group-input/dees-input-text/dees-input-text.js';
51
56
  import type { DeesInputTextarea } from '../../00group-input/dees-input-textarea/dees-input-textarea.js';
57
+ import type { DeesKanbanDiscussion } from '../dees-kanban-discussion/dees-kanban-discussion.js';
52
58
  import '../../00group-input/dees-input-text/dees-input-text.js';
53
59
  import '../../00group-input/dees-input-textarea/dees-input-textarea.js';
54
60
  import '../../00group-input/dees-input-dropdown/dees-input-dropdown.js';
@@ -60,6 +66,9 @@ import '../../00group-feedback/dees-hint/dees-hint.js';
60
66
  import '../dees-kanban-discussion/dees-kanban-discussion.js';
61
67
  import '../dees-kanban-activity/dees-kanban-activity.js';
62
68
 
69
+ /** What the discussion shows, so the history leaves it out. */
70
+ const discussionActions: ReadonlySet<TKanbanActivityAction> = new Set(['commented', 'asked', 'answered']);
71
+
63
72
  declare global {
64
73
  interface HTMLElementTagNameMap {
65
74
  'dees-kanban-ticket-detail': DeesKanbanTicketDetail;
@@ -95,8 +104,13 @@ export class DeesKanbanTicketDetail extends DeesElement {
95
104
  @property({ attribute: false })
96
105
  accessor commentDraft: TReferenceContent = [];
97
106
 
107
+ /** The ticket's comments and questions. */
108
+ @property({ attribute: false })
109
+ accessor comments: TKanbanDiscussionItem[] = [];
110
+
111
+ /** What the host's AutoLabels are called and how they look; see the board's `autoLabelDefinitions`. */
98
112
  @property({ attribute: false })
99
- accessor comments: IKanbanComment[] = [];
113
+ accessor autoLabelDefinitions: IKanbanAutoLabel[] = [];
100
114
 
101
115
  @property({ attribute: false })
102
116
  accessor searchTickets: TReferenceSearch | undefined;
@@ -154,6 +168,13 @@ export class DeesKanbanTicketDetail extends DeesElement {
154
168
  @state()
155
169
  private accessor feed: 'comments' | 'history' = 'comments';
156
170
 
171
+ /**
172
+ * The pinned composer covers the foot of the main column: its height is the column's scroll
173
+ * padding, so what scrolls into view there, such as a question the hint shows, is not under it.
174
+ */
175
+ private composerObserver?: ResizeObserver;
176
+ private observedComposer: Element | null = null;
177
+
157
178
  public static styles = [
158
179
  ...kanbanStyles,
159
180
  insetInlineStyles('--detail-inset-inline'),
@@ -198,6 +219,11 @@ export class DeesKanbanTicketDetail extends DeesElement {
198
219
  scrollbar-width: thin;
199
220
  }
200
221
 
222
+ /* What scrolls into view, a revealed question or a focused control, stops short of the composer. */
223
+ .main {
224
+ scroll-padding-bottom: calc(var(--detail-composer-block-size, 0px) + var(--dees-spacing-md));
225
+ }
226
+
201
227
  /* Positioned content of the main column is placed in it, so it scrolls with it, not over the panes. */
202
228
  .main > :not(aside) {
203
229
  position: relative;
@@ -633,6 +659,27 @@ export class DeesKanbanTicketDetail extends DeesElement {
633
659
  gap: 14px;
634
660
  }
635
661
 
662
+ .open-questions {
663
+ margin-bottom: 16px;
664
+ }
665
+
666
+ .open-questions-row {
667
+ display: flex;
668
+ flex-wrap: wrap;
669
+ align-items: center;
670
+ justify-content: space-between;
671
+ gap: 8px 12px;
672
+ }
673
+
674
+ .open-questions-row p {
675
+ color: var(--dees-color-text-primary);
676
+ font-weight: 600;
677
+ }
678
+
679
+ .auto-row {
680
+ margin-top: 8px;
681
+ }
682
+
636
683
  .conflict p + p,
637
684
  .conflict p + dees-button {
638
685
  margin-top: 8px;
@@ -719,10 +766,15 @@ export class DeesKanbanTicketDetail extends DeesElement {
719
766
  overflow: visible;
720
767
  }
721
768
  .main > .error,
769
+ .main > .open-questions,
722
770
  .lead,
723
771
  .body {
724
772
  padding-inline: var(--detail-inset-inline, 16px);
725
773
  }
774
+ .main > .open-questions {
775
+ margin: 0;
776
+ padding-block: 12px 0;
777
+ }
726
778
  .main > .error {
727
779
  padding-block: 10px 0;
728
780
  }
@@ -793,6 +845,35 @@ export class DeesKanbanTicketDetail extends DeesElement {
793
845
  // A button this render added draws its face, which takes the focus, in its own first update.
794
846
  void target?.updateComplete.then(() => target.focus());
795
847
  }
848
+ this.observeComposer();
849
+ }
850
+
851
+ public async disconnectedCallback(): Promise<void> {
852
+ this.composerObserver?.disconnect();
853
+ this.observedComposer = null;
854
+ await super.disconnectedCallback();
855
+ }
856
+
857
+ public async connectedCallback(): Promise<void> {
858
+ const connection = super.connectedCallback();
859
+ // Back in the page after leaving it: its composer is watched again.
860
+ if (this.hasUpdated) this.observeComposer();
861
+ await connection;
862
+ }
863
+
864
+ private observeComposer(): void {
865
+ const composer = this.shadowRoot?.querySelector('.main > .composer') ?? null;
866
+ if (composer === this.observedComposer) return;
867
+ this.composerObserver ??= new ResizeObserver(([entry]) => this.padForComposer(entry?.borderBoxSize[0]?.blockSize ?? 0));
868
+ if (this.observedComposer) this.composerObserver.unobserve(this.observedComposer);
869
+ if (composer) this.composerObserver.observe(composer);
870
+ else this.padForComposer(0);
871
+ this.observedComposer = composer;
872
+ }
873
+
874
+ /** Makes the composer's height the main column's scroll padding. */
875
+ private padForComposer(blockSize: number): void {
876
+ this.shadowRoot?.querySelector<HTMLElement>('.main')?.style.setProperty('--detail-composer-block-size', `${blockSize}px`);
796
877
  }
797
878
 
798
879
  /**
@@ -914,6 +995,50 @@ export class DeesKanbanTicketDetail extends DeesElement {
914
995
  private addComment = (input: Parameters<NonNullable<IKanbanProvider['addComment']>>[0]) =>
915
996
  this.provider.addComment!(input);
916
997
 
998
+ private askQuestion = (input: Parameters<NonNullable<IKanbanProvider['askQuestion']>>[0]) =>
999
+ this.provider.askQuestion!(input);
1000
+
1001
+ private answerQuestion = (input: Parameters<NonNullable<IKanbanProvider['answerQuestion']>>[0]) =>
1002
+ this.provider.answerQuestion!(input);
1003
+
1004
+ /**
1005
+ * Shows the ticket's first unanswered question in the discussion, ready for an answer where the
1006
+ * reader may give one.
1007
+ */
1008
+ private async revealOpenQuestion(questionId: string): Promise<void> {
1009
+ this.feed = 'comments';
1010
+ await this.updateComplete;
1011
+ // The observer reports a composer's height a frame after it comes; the scroll needs it now.
1012
+ const composer = this.shadowRoot?.querySelector<HTMLElement>('.main > .composer');
1013
+ if (composer) this.padForComposer(composer.getBoundingClientRect().height);
1014
+ await this.shadowRoot?.querySelector<DeesKanbanDiscussion>('dees-kanban-discussion:not(.composer)')
1015
+ ?.revealQuestion(questionId);
1016
+ }
1017
+
1018
+ /** Says how many questions wait for an answer, with a button to the first. */
1019
+ private renderOpenQuestions(ticket: IKanbanTicket): TemplateResult | '' {
1020
+ const open = this.comments.filter(
1021
+ (item): item is IKanbanQuestion => isKanbanQuestion(item) && item.ticketId === ticket.id && !item.answer,
1022
+ );
1023
+ if (!open.length) return '';
1024
+ const first = open.reduce((oldest, item) =>
1025
+ Date.parse(item.createdAt) < Date.parse(oldest.createdAt) ? item : oldest);
1026
+ const canAnswer = Boolean(this.provider.answerQuestion) && ticket.permissions?.answer !== false;
1027
+ return html`<div class="open-questions">
1028
+ <dees-hint type="warning">
1029
+ <div class="open-questions-row">
1030
+ <p>${this.t('kanban.openQuestions', { count: open.length })}</p>
1031
+ <dees-button
1032
+ size="sm"
1033
+ type=${canAnswer ? 'accent' : 'secondary'}
1034
+ text=${this.t(canAnswer ? 'kanban.answerQuestion' : 'kanban.showQuestion')}
1035
+ @clicked=${() => this.revealOpenQuestion(first.id)}
1036
+ ></dees-button>
1037
+ </div>
1038
+ </dees-hint>
1039
+ </div>`;
1040
+ }
1041
+
917
1042
  /** Keeps the comment the reader is writing, so that the next render gives the composer it back, not an older one. */
918
1043
  private keepCommentDraft = (event: CustomEvent<{ ticketId: string; body: TReferenceContent }>) => {
919
1044
  if (event.detail.ticketId === this.ticket?.id) this.commentDraft = event.detail.body;
@@ -958,6 +1083,7 @@ export class DeesKanbanTicketDetail extends DeesElement {
958
1083
  <div class="panes">
959
1084
  <div class="main">
960
1085
  ${this.error ? html`<p class="error" role="alert">${this.error}</p>` : ''}
1086
+ ${this.renderOpenQuestions(ticket)}
961
1087
  <section class="lead">
962
1088
  ${this.editing && editable
963
1089
  ? html`<div class="edit">
@@ -1145,12 +1271,18 @@ export class DeesKanbanTicketDetail extends DeesElement {
1145
1271
  }}
1146
1272
  @input=${(event: Event) => event.stopPropagation()}
1147
1273
  ></dees-input-tags>
1274
+ ${ticket.autoLabels?.length
1275
+ ? html`<div class="row auto-row">
1276
+ ${renderKanbanAutoLabels(this.t, this.autoLabelDefinitions, ticket.autoLabels)}
1277
+ </div>`
1278
+ : ''}
1148
1279
  </div>`
1149
1280
  : html`<div class="labels">
1150
1281
  <label class="caption">${this.t('kanban.labels')}</label>
1151
- ${ticket.labels?.length
1282
+ ${ticket.labels?.length || ticket.autoLabels?.length
1152
1283
  ? html`<div class="row value">
1153
- ${ticket.labels.map(label => html`<span class="badge">${label}</span>`)}
1284
+ ${renderKanbanAutoLabels(this.t, this.autoLabelDefinitions, ticket.autoLabels)}
1285
+ ${ticket.labels?.map(label => html`<span class="badge">${label}</span>`)}
1154
1286
  </div>`
1155
1287
  : this.renderUnset(this.t('kanban.noLabels'))}
1156
1288
  </div>`}
@@ -1240,6 +1372,9 @@ export class DeesKanbanTicketDetail extends DeesElement {
1240
1372
  .view=${'entries'}
1241
1373
  .ticketId=${ticket.id}
1242
1374
  .comments=${this.comments}
1375
+ .answerQuestion=${this.provider.answerQuestion && ticket.permissions?.answer !== false
1376
+ ? this.answerQuestion
1377
+ : undefined}
1243
1378
  .loading=${this.loadingComments}
1244
1379
  .error=${this.commentsError}
1245
1380
  .showHeader=${!inFeed}
@@ -1258,6 +1393,9 @@ export class DeesKanbanTicketDetail extends DeesElement {
1258
1393
  .searchTickets=${this.searchTickets}
1259
1394
  .currentPerson=${this.currentPerson}
1260
1395
  .addComment=${this.provider.addComment ? this.addComment : undefined}
1396
+ .askQuestion=${this.provider.askQuestion && ticket.permissions?.ask !== false
1397
+ ? this.askQuestion
1398
+ : undefined}
1261
1399
  ?hidden=${!!this.provider.loadActivity && this.feed !== 'comments'}
1262
1400
  @kanban-comment-draft=${this.keepCommentDraft}
1263
1401
  ></dees-kanban-discussion>`;
@@ -1269,9 +1407,9 @@ export class DeesKanbanTicketDetail extends DeesElement {
1269
1407
  */
1270
1408
  private renderFeed(ticket: IKanbanTicket): TemplateResult {
1271
1409
  const comments = this.comments.filter(comment => comment.ticketId === ticket.id).length;
1272
- // The discussion shows the comments; the history shows the changes.
1410
+ // The discussion shows the comments and questions; the history shows the changes.
1273
1411
  const changes = this.activity.filter(
1274
- entry => entry.ticketId === ticket.id && entry.action !== 'commented',
1412
+ entry => entry.ticketId === ticket.id && !discussionActions.has(entry.action),
1275
1413
  );
1276
1414
  const history = this.feed === 'history';
1277
1415
  return html`<section class="feed">
@@ -1,4 +1,5 @@
1
1
  export * from './interfaces.js';
2
+ export { kanbanOpenQuestionLabel } from './kanban.helpers.js';
2
3
  export * from './dees-kanban/dees-kanban.js';
3
4
  export * from './dees-kanban-card/dees-kanban-card.js';
4
5
  export * from './dees-kanban-column/dees-kanban-column.js';