@things-factory/ai-dashboard 10.1.277 → 10.1.279

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 (60) hide show
  1. package/package.json +22 -8
  2. package/client/bootstrap.ts +0 -25
  3. package/client/components/card-dialogs.ts +0 -445
  4. package/client/components/card-library.ts +0 -285
  5. package/client/components/dashboard-card.ts +0 -411
  6. package/client/components/proposal-preview.ts +0 -95
  7. package/client/index.ts +0 -5
  8. package/client/pages/my-dashboard-page.ts +0 -373
  9. package/client/route.ts +0 -8
  10. package/client/tsconfig.json +0 -13
  11. package/client/utils/card-api.ts +0 -99
  12. package/client/utils/card-words.ts +0 -91
  13. package/client/utils/examples.ts +0 -15
  14. package/dist-client/bootstrap.js.map +0 -1
  15. package/dist-client/components/card-dialogs.js.map +0 -1
  16. package/dist-client/components/card-library.js.map +0 -1
  17. package/dist-client/components/dashboard-card.js.map +0 -1
  18. package/dist-client/components/proposal-preview.js.map +0 -1
  19. package/dist-client/index.js.map +0 -1
  20. package/dist-client/pages/my-dashboard-page.js.map +0 -1
  21. package/dist-client/route.js.map +0 -1
  22. package/dist-client/tsconfig.tsbuildinfo +0 -1
  23. package/dist-client/utils/card-api.js.map +0 -1
  24. package/dist-client/utils/card-words.js.map +0 -1
  25. package/dist-client/utils/examples.js.map +0 -1
  26. package/dist-server/index.js.map +0 -1
  27. package/dist-server/role-tasks.js.map +0 -1
  28. package/dist-server/service/card/card-access.js.map +0 -1
  29. package/dist-server/service/card/card-definition.js.map +0 -1
  30. package/dist-server/service/card/card-names.js.map +0 -1
  31. package/dist-server/service/card/card-proposal.js.map +0 -1
  32. package/dist-server/service/card/card-resolver.js.map +0 -1
  33. package/dist-server/service/card/card-run.js.map +0 -1
  34. package/dist-server/service/card/card-tool.js.map +0 -1
  35. package/dist-server/service/card/card-types.js.map +0 -1
  36. package/dist-server/service/card/dashboard-card.js.map +0 -1
  37. package/dist-server/service/card/long-text.js.map +0 -1
  38. package/dist-server/service/index.js.map +0 -1
  39. package/dist-server/tsconfig.tsbuildinfo +0 -1
  40. package/server/index.ts +0 -16
  41. package/server/role-tasks.ts +0 -12
  42. package/server/service/card/card-access.test.ts +0 -173
  43. package/server/service/card/card-access.ts +0 -24
  44. package/server/service/card/card-definition.ts +0 -468
  45. package/server/service/card/card-intent.test.ts +0 -285
  46. package/server/service/card/card-names.ts +0 -12
  47. package/server/service/card/card-proposal.ts +0 -46
  48. package/server/service/card/card-resolver.ts +0 -440
  49. package/server/service/card/card-run.test.ts +0 -237
  50. package/server/service/card/card-run.ts +0 -302
  51. package/server/service/card/card-tool.ts +0 -368
  52. package/server/service/card/card-types.ts +0 -145
  53. package/server/service/card/card-words.test.ts +0 -72
  54. package/server/service/card/dashboard-card.ts +0 -303
  55. package/server/service/card/long-text.ts +0 -25
  56. package/server/service/index.ts +0 -16
  57. package/test/card-menu.test.ts +0 -50
  58. package/test/translations.test.ts +0 -42
  59. package/test/words-not-codes.test.ts +0 -24
  60. package/tsconfig.json +0 -9
package/package.json CHANGED
@@ -1,8 +1,22 @@
1
1
  {
2
2
  "name": "@things-factory/ai-dashboard",
3
- "version": "10.1.277",
3
+ "version": "10.1.279",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
+ "files": [
7
+ "dist-client",
8
+ "dist-server",
9
+ "things-factory.config.js",
10
+ "translations",
11
+ "!**/*.map",
12
+ "!**/*.test.*",
13
+ "!**/*.spec.*",
14
+ "!**/test/**",
15
+ "!**/tests/**",
16
+ "!**/__tests__/**",
17
+ "!**/*.tsbuildinfo",
18
+ "!**/.DS_Store"
19
+ ],
6
20
  "things-factory": true,
7
21
  "license": "MIT",
8
22
  "author": "heartyoh <heartyoh@hatiolab.com>",
@@ -33,12 +47,12 @@
33
47
  "@operato/popup": "^10.29.39",
34
48
  "@operato/shell": "^10.29.69",
35
49
  "@operato/styles": "^10.0.0",
36
- "@things-factory/ai-assistant": "^10.1.277",
37
- "@things-factory/ai-client-base": "^10.1.277",
38
- "@things-factory/auth-base": "^10.1.277",
39
- "@things-factory/env": "^10.1.149",
40
- "@things-factory/organization": "^10.1.277",
41
- "@things-factory/shell": "^10.1.277",
50
+ "@things-factory/ai-assistant": "^10.1.279",
51
+ "@things-factory/ai-client-base": "^10.1.279",
52
+ "@things-factory/auth-base": "^10.1.279",
53
+ "@things-factory/env": "^10.1.279",
54
+ "@things-factory/organization": "^10.1.279",
55
+ "@things-factory/shell": "^10.1.279",
42
56
  "graphql-scalars": "^1.22.0",
43
57
  "graphql-tag": "^2.12.6",
44
58
  "lit": "^3.1.2"
@@ -46,5 +60,5 @@
46
60
  "devDependencies": {
47
61
  "copyfiles": "^2.4.1"
48
62
  },
49
- "gitHead": "85f409e7ea43686a4cda52924247d9e7a6b0bfa7"
63
+ "gitHead": "666c08055c408b408fde961ad10da080941b147c"
50
64
  }
@@ -1,25 +0,0 @@
1
- /*
2
- * The conversation's dashboard card (ADR-0160 decision 9): its preview under the card, and pressing it saves the stored
3
- * proposal to the person's dashboard. Registered here, by the package that declares the tool - the dock knows no kind.
4
- */
5
- import { i18next } from '@operato/i18n'
6
- import { registerProposalHandler, registerProposalView } from '@things-factory/ai-assistant/dist-client/index.js'
7
-
8
- import './components/proposal-preview.js'
9
- import { cardApi, dashboardChanged } from './utils/card-api.js'
10
-
11
- const TOOL = 'proposeDashboardCard'
12
-
13
- export default function bootstrap() {
14
- registerProposalView(TOOL, { previewTag: 'ai-dashboard-proposal-preview', runLabelKey: 'ai-dashboard.preview.save', runLabel: 'Save to my dashboard' })
15
- registerProposalHandler(TOOL, async (proposal, context) => {
16
- if (!context.sessionId || !proposal?.key) return { verdict: 'unavailable', errorCode: 'no-conversation' }
17
- const saved = await cardApi.saveProposal(context.sessionId, proposal.key)
18
- dashboardChanged()
19
- return {
20
- verdict: 'accepted',
21
- applied: 1,
22
- note: String(i18next.t(saved.version > 1 ? 'ai-dashboard.preview.saved-version' : 'ai-dashboard.preview.saved', { name: proposal.card?.name ?? '', version: saved.version }))
23
- }
24
- })
25
- }
@@ -1,445 +0,0 @@
1
- /*
2
- * The small forms a card opens - what to change with the assistant, a new name, whom to share it with, and its
3
- * versions (ADR-0160 decisions 7, 9). Each changes one card through its own door and tells an open dashboard.
4
- */
5
- import '@material/web/icon/icon.js'
6
- import '@material/web/button/filled-button.js'
7
- import '@material/web/button/text-button.js'
8
- import '@operato/popup/ox-popup-actions.js'
9
-
10
- import gql from 'graphql-tag'
11
- import { LitElement, css, html, nothing } from 'lit'
12
- import { customElement, property, state } from 'lit/decorators.js'
13
-
14
- import { QueryController } from '@operato/graphql'
15
- import { i18next, localize } from '@operato/i18n'
16
- import { notify, openPopup } from '@operato/layout'
17
- import { CommonPopupStyles, PopupBodyStyles } from '@operato/styles'
18
- import { askAssistant } from '@things-factory/ai-assistant/dist-client/index.js'
19
-
20
- import { cardApi, dashboardChanged, type CardItem, type CardShare, type CardVersion, type ShareOptions } from '../utils/card-api.js'
21
- import { cardSelection } from '../utils/card-words.js'
22
-
23
- const t = (key: string, options: Record<string, unknown> = {}) => String(i18next.t(key, options))
24
-
25
- /*
26
- * The house popup (CommonPopupStyles, PopupBodyStyles): only .body scrolls and ox-popup-actions stays put - a share
27
- * list of three people pushed 저장 out of sight (2026-10-25). The form fills the popup it is opened in.
28
- */
29
- const FormStyles = css`
30
- :host {
31
- height: 100%;
32
- line-height: 1.5;
33
- }
34
-
35
- p.lead,
36
- p.note {
37
- margin: 0;
38
- }
39
-
40
- p.lead {
41
- color: var(--ui-muted, var(--md-sys-color-on-surface-variant));
42
- }
43
-
44
- textarea,
45
- input[type='text'],
46
- input[type='search'] {
47
- box-sizing: border-box;
48
- width: 100%;
49
- padding: 9px 12px;
50
- border: 1px solid var(--ui-line, var(--md-sys-color-outline-variant));
51
- border-radius: 8px;
52
- background: var(--ui-panel, var(--md-sys-color-surface-container-lowest));
53
- color: inherit;
54
- font: inherit;
55
- }
56
-
57
- textarea {
58
- min-height: 88px;
59
- resize: vertical;
60
- }
61
-
62
- textarea:focus,
63
- input:focus {
64
- outline: 2px solid color-mix(in srgb, var(--ui-accent, var(--md-sys-color-primary)) 40%, transparent);
65
- border-color: var(--ui-accent, var(--md-sys-color-primary));
66
- }
67
-
68
- .hints {
69
- display: flex;
70
- flex-wrap: wrap;
71
- gap: 6px;
72
- }
73
-
74
- .hints button {
75
- padding: 4px 10px;
76
- border: 1px solid var(--ui-line, var(--md-sys-color-outline-variant));
77
- border-radius: 999px;
78
- background: transparent;
79
- color: var(--ui-muted, var(--md-sys-color-on-surface-variant));
80
- font: inherit;
81
- font-size: var(--ui-t-small, 12px);
82
- cursor: pointer;
83
- }
84
-
85
- .hints button:hover {
86
- border-color: var(--ui-accent, var(--md-sys-color-primary));
87
- color: var(--ui-accent, var(--md-sys-color-primary));
88
- }
89
-
90
- h5 {
91
- margin: 6px 0 0;
92
- font-size: var(--ui-t-small, 12px);
93
- font-weight: 600;
94
- color: var(--ui-muted, var(--md-sys-color-on-surface-variant));
95
- text-transform: none;
96
- }
97
-
98
- label.option {
99
- display: flex;
100
- align-items: center;
101
- gap: 10px;
102
- padding: 8px 10px;
103
- border: 1px solid var(--ui-line-soft, var(--md-sys-color-outline-variant));
104
- border-radius: 8px;
105
- cursor: pointer;
106
- }
107
-
108
- label.option small {
109
- margin-left: auto;
110
- color: var(--ui-faint, var(--md-sys-color-on-surface-variant));
111
- }
112
-
113
- .people {
114
- display: flex;
115
- flex-direction: column;
116
- gap: 6px;
117
- }
118
-
119
- .person {
120
- display: flex;
121
- align-items: center;
122
- gap: 8px;
123
- padding: 6px 10px;
124
- border-radius: 8px;
125
- background: var(--ui-panel-2, var(--md-sys-color-surface-container-low));
126
- --md-icon-size: 16px;
127
- }
128
-
129
- .person small {
130
- color: var(--ui-faint, var(--md-sys-color-on-surface-variant));
131
- }
132
-
133
- .person button,
134
- .found button {
135
- margin-left: auto;
136
- border: 0;
137
- background: transparent;
138
- color: var(--ui-accent, var(--md-sys-color-primary));
139
- font: inherit;
140
- cursor: pointer;
141
- }
142
-
143
- .found {
144
- display: flex;
145
- flex-direction: column;
146
- border: 1px solid var(--ui-line-soft, var(--md-sys-color-outline-variant));
147
- border-radius: 8px;
148
- }
149
-
150
- .found div {
151
- display: flex;
152
- align-items: center;
153
- gap: 8px;
154
- padding: 6px 10px;
155
- }
156
-
157
- .found div + div {
158
- border-top: 1px solid var(--ui-line-soft, var(--md-sys-color-outline-variant));
159
- }
160
-
161
- ol.versions {
162
- list-style: none;
163
- margin: 0;
164
- padding: 0;
165
- display: flex;
166
- flex-direction: column;
167
- gap: 6px;
168
- }
169
-
170
- ol.versions li {
171
- display: flex;
172
- align-items: center;
173
- gap: 12px;
174
- padding: 10px 12px;
175
- border: 1px solid var(--ui-line-soft, var(--md-sys-color-outline-variant));
176
- border-radius: 8px;
177
- }
178
-
179
- ol.versions .v {
180
- flex: none;
181
- min-width: 36px;
182
- font-weight: 650;
183
- font-variant-numeric: tabular-nums;
184
- color: var(--ui-accent, var(--md-sys-color-primary));
185
- }
186
-
187
- ol.versions .label {
188
- flex: 1;
189
- min-width: 0;
190
- }
191
-
192
- ol.versions small {
193
- display: block;
194
- color: var(--ui-faint, var(--md-sys-color-on-surface-variant));
195
- }
196
- `
197
-
198
- /** What to change in a card - sent to the conversation beside the page with the card picked, as a screen request. */
199
- @customElement('ai-dashboard-card-ai-form')
200
- export class CardAiForm extends localize(i18next)(LitElement) {
201
- static styles = [CommonPopupStyles, PopupBodyStyles, FormStyles]
202
- @property({ attribute: false }) card!: CardItem
203
- @state() private text = ''
204
-
205
- render() {
206
- const hints = ['ai-dashboard.ai.hint-period', 'ai-dashboard.ai.hint-top', 'ai-dashboard.ai.hint-line', 'ai-dashboard.ai.hint-table']
207
- return html`<div class="body">
208
- <p class="lead">${t('ai-dashboard.ai.lead', { name: this.card.name })}</p>
209
- <textarea .value=${this.text} placeholder=${t('ai-dashboard.ai.placeholder')} @input=${(e: any) => (this.text = e.target.value)} @keydown=${(e: KeyboardEvent) => e.key === 'Enter' && (e.metaKey || e.ctrlKey) && this.send()}></textarea>
210
- <div class="hints">${hints.map(key => html`<button @click=${() => (this.text = t(key))}>${t(key)}</button>`)}</div>
211
- </div>
212
- <ox-popup-actions>
213
- <md-text-button slot="cancel" @click=${() => this.close()}>${t('ai-dashboard.button.cancel')}</md-text-button>
214
- <md-filled-button slot="confirm" ?disabled=${!this.text.trim()} @click=${() => this.send()}>${t('ai-dashboard.ai.send')}</md-filled-button>
215
- </ox-popup-actions>`
216
- }
217
-
218
- private close() {
219
- this.dispatchEvent(new CustomEvent('done', { bubbles: true, composed: true }))
220
- }
221
-
222
- private send() {
223
- if (!this.text.trim()) return
224
- /* Closed first: the dock opens over the page, and a popup that is no longer the top one refuses to close. */
225
- this.close()
226
- askAssistant({
227
- ask: t('ai-dashboard.ai.ask', { name: this.card.name, version: this.card.version, change: this.text.trim() }),
228
- selection: cardSelection(this.card, t('ai-dashboard.title'))
229
- })
230
- }
231
- }
232
-
233
- /** A card's new name - a new version. */
234
- @customElement('ai-dashboard-card-rename-form')
235
- export class CardRenameForm extends localize(i18next)(LitElement) {
236
- static styles = [CommonPopupStyles, PopupBodyStyles, FormStyles]
237
- @property({ attribute: false }) card!: CardItem
238
- @state() private name = ''
239
-
240
- connectedCallback() {
241
- super.connectedCallback()
242
- this.name = this.card?.name ?? ''
243
- }
244
-
245
- render() {
246
- return html`<div class="body">
247
- <input type="text" .value=${this.name} maxlength="100" @input=${(e: any) => (this.name = e.target.value)} @keydown=${(e: KeyboardEvent) => e.key === 'Enter' && this.save()} />
248
- </div>
249
- <ox-popup-actions>
250
- <md-text-button slot="cancel" @click=${() => this.close()}>${t('ai-dashboard.button.cancel')}</md-text-button>
251
- <md-filled-button slot="confirm" ?disabled=${!this.name.trim() || this.name.trim() === this.card.name} @click=${() => this.save()}>${t('ai-dashboard.button.save')}</md-filled-button>
252
- </ox-popup-actions>`
253
- }
254
-
255
- private close() {
256
- this.dispatchEvent(new CustomEvent('done', { bubbles: true, composed: true }))
257
- }
258
-
259
- private async save() {
260
- try {
261
- await cardApi.rename(this.card.id, this.name.trim())
262
- dashboardChanged()
263
- this.close()
264
- } catch (error: any) {
265
- notify({ level: 'error', message: error?.message ?? String(error) })
266
- }
267
- }
268
- }
269
-
270
- /** Whom one's own card is shared with - the whole domain, one's own departments, people found by name. */
271
- @customElement('ai-dashboard-card-share-form')
272
- export class CardShareForm extends localize(i18next)(LitElement) {
273
- static styles = [CommonPopupStyles, PopupBodyStyles, FormStyles]
274
- @property({ attribute: false }) card!: CardItem
275
- @state() private shares: CardShare[] = []
276
- @state() private search = ''
277
- /** The name the people are found by - the typed text once typing pauses. */
278
- @state() private findBy = ''
279
- private searching?: ReturnType<typeof setTimeout>
280
-
281
- private optionsRead = new QueryController(
282
- this,
283
- gql`query { dashboardShareOptions { domainId domainName departments { id name } peopleAvailable roles { id name note } } }`
284
- )
285
- private peopleRead = new QueryController(this, gql`query ($text: String!) { dashboardSharePeople(text: $text) { id name note } }`, {
286
- variables: () => (this.findBy ? { text: this.findBy } : undefined)
287
- })
288
-
289
- private get options(): ShareOptions | undefined {
290
- return this.optionsRead.data?.dashboardShareOptions
291
- }
292
-
293
- private get found(): { id: string; name: string; note?: string }[] {
294
- return this.peopleRead.data?.dashboardSharePeople ?? []
295
- }
296
-
297
- connectedCallback() {
298
- super.connectedCallback()
299
- this.shares = [...(this.card?.shares ?? [])].map(({ scope, targetId, targetName }) => ({ scope, targetId, targetName }))
300
- }
301
-
302
- private has(scope: string, id: string) {
303
- return this.shares.some(one => one.scope === scope && one.targetId === id)
304
- }
305
-
306
- private toggle(share: CardShare, on: boolean) {
307
- this.shares = on ? [...this.shares.filter(one => !(one.scope === share.scope && one.targetId === share.targetId)), share] : this.shares.filter(one => !(one.scope === share.scope && one.targetId === share.targetId))
308
- }
309
-
310
- private find(text: string) {
311
- this.search = text
312
- clearTimeout(this.searching)
313
- this.searching = setTimeout(() => (this.findBy = text.trim()), 250)
314
- }
315
-
316
- render() {
317
- const options = this.options
318
- const people = this.shares.filter(one => one.scope === 'USER')
319
- return html`<div class="body">
320
- <p class="lead">${t('ai-dashboard.share.lead')}</p>
321
- ${options
322
- ? html`<h5>${t('ai-dashboard.share.everyone-title')}</h5>
323
- <label class="option">
324
- <input type="checkbox" .checked=${this.has('DOMAIN', options.domainId)} @change=${(e: any) => this.toggle({ scope: 'DOMAIN', targetId: options.domainId, targetName: options.domainName }, e.target.checked)} />
325
- <md-icon>domain</md-icon>${t('ai-dashboard.share.everyone-in', { name: options.domainName })}
326
- </label>
327
- ${options.departments.length
328
- ? html`<h5>${t('ai-dashboard.share.departments')}</h5>
329
- ${options.departments.map(
330
- one => html`<label class="option">
331
- <input type="checkbox" .checked=${this.has('DEPARTMENT', one.id)} @change=${(e: any) => this.toggle({ scope: 'DEPARTMENT', targetId: one.id, targetName: one.name }, e.target.checked)} />
332
- <md-icon>groups</md-icon>${one.name}<small>${t('ai-dashboard.share.department-members')}</small>
333
- </label>`
334
- )}`
335
- : nothing}
336
- ${options.roles.length
337
- ? html`<h5>${t('ai-dashboard.share.roles')}</h5>
338
- ${options.roles.map(
339
- one => html`<label class="option">
340
- <input type="checkbox" .checked=${this.has('ROLE', one.id)} @change=${(e: any) => this.toggle({ scope: 'ROLE', targetId: one.id, targetName: one.name }, e.target.checked)} />
341
- <md-icon>badge</md-icon>${one.name}<small>${t('ai-dashboard.share.role-holders')}</small>
342
- </label>`
343
- )}`
344
- : nothing}
345
- <h5>${t('ai-dashboard.share.people')}</h5>
346
- ${people.length
347
- ? html`<div class="people">
348
- ${people.map(one => html`<div class="person"><md-icon>person</md-icon>${one.targetName ?? one.targetId}<button @click=${() => this.toggle(one, false)}>${t('ai-dashboard.share.remove')}</button></div>`)}
349
- </div>`
350
- : nothing}
351
- ${options.peopleAvailable
352
- ? html`<input type="search" .value=${this.search} placeholder=${t('ai-dashboard.share.find-person')} @input=${(e: any) => this.find(e.target.value)} />
353
- ${this.found.length
354
- ? html`<div class="found">
355
- ${this.found
356
- .filter(one => !this.has('USER', one.id))
357
- .map(one => html`<div><md-icon>person_add</md-icon>${one.name} ${one.note ? html`<small>${one.note}</small>` : nothing}<button @click=${() => this.toggle({ scope: 'USER', targetId: one.id, targetName: one.name }, true)}>${t('ai-dashboard.share.add')}</button></div>`)}
358
- </div>`
359
- : nothing}`
360
- : html`<p class="note">${t('ai-dashboard.share.people-unavailable')}</p>`}
361
- <p class="note">${t('ai-dashboard.share.rule')}</p>`
362
- : nothing}
363
- </div>
364
- <ox-popup-actions>
365
- <md-text-button slot="cancel" @click=${() => this.close()}>${t('ai-dashboard.button.cancel')}</md-text-button>
366
- <md-filled-button slot="confirm" ?disabled=${!options} @click=${() => this.save()}>${t('ai-dashboard.button.save')}</md-filled-button>
367
- </ox-popup-actions>`
368
- }
369
-
370
- private close() {
371
- this.dispatchEvent(new CustomEvent('done', { bubbles: true, composed: true }))
372
- }
373
-
374
- private async save() {
375
- try {
376
- await cardApi.share(this.card.id, this.shares)
377
- notify({ level: 'info', message: t(this.shares.length ? 'ai-dashboard.text.shared' : 'ai-dashboard.text.private', { name: this.card.name }) })
378
- dashboardChanged()
379
- this.close()
380
- } catch (error: any) {
381
- notify({ level: 'error', message: error?.message ?? String(error) })
382
- }
383
- }
384
- }
385
-
386
- /** One's own card's versions, newest first - an earlier one comes back as a new version. */
387
- @customElement('ai-dashboard-card-versions')
388
- export class CardVersions extends localize(i18next)(LitElement) {
389
- static styles = [CommonPopupStyles, PopupBodyStyles, FormStyles]
390
- @property({ attribute: false }) card!: CardItem
391
-
392
- private versionsRead = new QueryController(
393
- this,
394
- gql`query ($id: String!) { dashboardCardVersions(id: $id) { version name definition creatorName createdAt } }`,
395
- { variables: () => (this.card ? { id: this.card.id } : undefined) }
396
- )
397
-
398
- private get versions(): CardVersion[] | undefined {
399
- return this.versionsRead.data?.dashboardCardVersions
400
- }
401
-
402
- render() {
403
- const view = (definition: any) => t(`ai-dashboard.view.${definition?.view?.kind ?? 'table'}`)
404
- return html`<div class="body">
405
- <p class="lead">${t('ai-dashboard.versions.lead')}</p>
406
- <ol class="versions">
407
- ${(this.versions ?? []).map(
408
- one => html`<li>
409
- <span class="v">v${one.version}</span>
410
- <span class="label">${one.name}<small>${view(one.definition)} · ${one.creatorName ?? ''} · ${one.createdAt ? new Date(one.createdAt).toLocaleString(i18next.language) : ''}</small></span>
411
- ${one.version === this.card.version
412
- ? html`<small>${t('ai-dashboard.versions.current')}</small>`
413
- : html`<md-text-button @click=${() => this.restore(one.version)}>${t('ai-dashboard.versions.restore')}</md-text-button>`}
414
- </li>`
415
- )}
416
- </ol>
417
- </div>`
418
- }
419
-
420
- private async restore(version: number) {
421
- try {
422
- await cardApi.restore(this.card.id, version)
423
- notify({ level: 'info', message: t('ai-dashboard.text.restored', { version }) })
424
- dashboardChanged()
425
- this.dispatchEvent(new CustomEvent('done', { bubbles: true, composed: true }))
426
- } catch (error: any) {
427
- notify({ level: 'error', message: error?.message ?? String(error) })
428
- }
429
- }
430
- }
431
-
432
- /*
433
- * 'fit' is the house size of a form of a few fields - it stands at its own height; a small popup was narrower than the form.
434
- * The wrapper only listens for `done`; it takes no box (display: contents), so the card sizes the form itself - a 'fit' card
435
- * shrinks the form in it to the screen, and a box between them would stop that (ox-floating-overlay).
436
- */
437
- function open(template: unknown, title: string, size: 'fit' | 'medium' = 'fit') {
438
- const popup: any = openPopup(html`<div style="display: contents" @done=${() => popup?.close?.()}>${template}</div>`, { backdrop: true, size, title })
439
- return popup
440
- }
441
-
442
- export const openCardAiPrompt = (card: CardItem) => open(html`<ai-dashboard-card-ai-form .card=${card}></ai-dashboard-card-ai-form>`, t('ai-dashboard.card.ai'), 'medium')
443
- export const openCardRename = (card: CardItem) => open(html`<ai-dashboard-card-rename-form .card=${card}></ai-dashboard-card-rename-form>`, t('ai-dashboard.card.rename'))
444
- export const openCardShare = (card: CardItem) => open(html`<ai-dashboard-card-share-form .card=${card}></ai-dashboard-card-share-form>`, t('ai-dashboard.share.title', { name: card.name }), 'medium')
445
- export const openCardVersions = (card: CardItem) => open(html`<ai-dashboard-card-versions .card=${card}></ai-dashboard-card-versions>`, t('ai-dashboard.card.versions'), 'medium')