forest-cli 5.24.3 → 5.25.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.
- package/dist/services/dumpers/agent-nodejs.d.ts.map +1 -1
- package/dist/services/dumpers/agent-nodejs.js +11 -4
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/back.hbs +1 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/back.js +154 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/component.js +154 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/data-map.css +416 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/data-map.hbs +99 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/data-map.js +243 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/demo-guide.css +278 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/demo-guide.hbs +38 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/demo-guide.js +353 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-activity.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-agent.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-ai.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-charts.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-collections.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-custom-components.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-inboxes.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-roles.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-segments.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-smart-actions.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-workflows.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-workspaces.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature.css +1109 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature.hbs +286 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/go-to.hbs +4 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/go-to.js +217 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/kyc-flow.css +580 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/kyc-flow.hbs +80 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/kyc-flow.js +49 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/run-action.hbs +3 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/run-action.js +96 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/select-first.css +131 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/select-first.hbs +4 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/select-first.js +205 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/senior-guide.hbs +39 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/senior-guide.js +189 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/style.css +372 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/template.hbs +83 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/forest-layout.json +52897 -8498
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/203696b1-e9ca-45f3-9bd3-5bc6fb4fd8c3.bpmn +161 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/2bc0c0ff-486c-44b1-ae31-3de204f7b14f.bpmn +107 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/4b37a274-117f-4c2d-96ad-21d1be4d0bc7.bpmn +159 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/56ff9484-8308-4971-9e02-3de5eea2e240.bpmn +67 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/619e3e88-4a9c-4f02-84fb-732c16f9b5bf.bpmn +43 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/76516b9e-aac0-4f7b-9794-8f86c529531b.bpmn +75 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/86b4fc1e-b10a-4906-9fd1-e601eaad83c0.bpmn +81 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/92b119e5-c908-48d1-9a0d-23173c57bd5b.bpmn +47 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/92c02240-9c8a-49e7-9993-077af3e1ddcc.bpmn +77 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/aac25aee-f626-40a8-9459-d2a933fb8446.bpmn +105 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/b269dbff-5fde-401f-a05b-76a7dac79387.bpmn +75 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/d8b208a9-fc71-4005-acb9-ba5fedd2499f.bpmn +73 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/e3abab67-7bc6-4a44-9848-c7f83a55a56d.bpmn +71 -0
- package/dist/services/dumpers/templates/agent-nodejs/javascript/index.hbs +45 -4
- package/dist/services/dumpers/templates/agent-nodejs/typescript/index.hbs +45 -4
- package/dist/utils/messages.js +2 -2
- package/oclif.manifest.json +376 -376
- package/package.json +6 -2
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/30d581e3-294e-4790-b723-0f16509ecae0.bpmn +0 -2
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/52e0acb4-6064-472a-9823-cdfd7fa7a3ab.bpmn +0 -2
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/71f692b4-fe4f-476d-8251-fdc5af1ec51e.bpmn +0 -2
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/9d564d80-19d1-4ce4-bb4b-aaf41e7ef5b6.bpmn +0 -2
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/c8ab4b5d-20df-4d28-9160-0d4376282c90.bpmn +0 -2
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/d0289f67-2c9e-4c69-b1ee-ecbbace841b3.bpmn +0 -2
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/d07aa5ee-9a49-4916-a1b5-1f953bfe9a8e.bpmn +0 -2
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/e25c6237-b882-498b-9655-b16b30131b10.bpmn +0 -2
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/f01b9e61-4156-47b8-b6a1-5c90adbcd2ba.bpmn +0 -2
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* eslint-disable import/no-unresolved -- runs inside the Forest app, which provides these */
|
|
2
|
+
/* eslint-env browser */
|
|
3
|
+
/**
|
|
4
|
+
* "Retail onboarding, step by step": the picture is built by the agent (kyc-flow.js) as a
|
|
5
|
+
* fixed-size stage; this component scales it to fill its cell, keeping its proportions, and plays
|
|
6
|
+
* or pauses it on a click. The cell's size comes from the component's own grid size (Forest
|
|
7
|
+
* updates it while the box is resized), not from the page: the cell's elements wrap their content.
|
|
8
|
+
* Generated as hub/kyc-flow.{hbs,js,css}.
|
|
9
|
+
*/
|
|
10
|
+
import { action } from '@ember/object';
|
|
11
|
+
import { htmlSafe } from '@ember/template';
|
|
12
|
+
import Component from '@glimmer/component';
|
|
13
|
+
import { tracked } from '@glimmer/tracking';
|
|
14
|
+
|
|
15
|
+
// Forest's grid cell, in px (WORKSPACE_GRID_CELL_WIDTH and _HEIGHT).
|
|
16
|
+
const CELL = 20;
|
|
17
|
+
// The stage's size: kyc-flow.js writes it here at build time.
|
|
18
|
+
const STAGE = {"width":944,"height":424}
|
|
19
|
+
const reducedMotion = () => window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
|
|
20
|
+
|
|
21
|
+
export default class KycFlow extends Component {
|
|
22
|
+
@tracked paused = reducedMotion() || false;
|
|
23
|
+
|
|
24
|
+
get stageClass() {
|
|
25
|
+
return this.paused ? 'kf-stage kf-paused' : 'kf-stage';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
get scale() {
|
|
29
|
+
const box = this.args.component?.displaySettings;
|
|
30
|
+
if (!box?.width || !box?.height) return 1;
|
|
31
|
+
|
|
32
|
+
return Math.min((box.width * CELL) / STAGE.width, (box.height * CELL) / STAGE.height);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
get wrapStyle() {
|
|
36
|
+
const { scale } = this;
|
|
37
|
+
|
|
38
|
+
return htmlSafe(`width:${STAGE.width * scale}px;height:${STAGE.height * scale}px`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get stageStyle() {
|
|
42
|
+
return htmlSafe(`transform:scale(${this.scale})`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@action
|
|
46
|
+
toggle() {
|
|
47
|
+
this.paused = !this.paused;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/* eslint-disable import/no-unresolved -- runs inside the Forest app, which provides these */
|
|
2
|
+
/* eslint-env browser */
|
|
3
|
+
/**
|
|
4
|
+
* Run action: a workspace Custom component, one button that runs a Global Smart Action through
|
|
5
|
+
* Forest's own flow (its form or confirmation, the result card, the lists refreshed, the activity
|
|
6
|
+
* log), in the look of the other desk buttons (select-first.css, dark). Set in its own url:
|
|
7
|
+
* `run-action.js?collection=kyc_cases&action=Reset the demo cases&label=…`. Served by the agent as
|
|
8
|
+
* hub/run-action.{hbs,js} (select-first-files.js).
|
|
9
|
+
*/
|
|
10
|
+
import { action } from '@ember/object';
|
|
11
|
+
import { inject as service } from '@ember/service';
|
|
12
|
+
import { htmlSafe } from '@ember/template';
|
|
13
|
+
import Component from '@glimmer/component';
|
|
14
|
+
import { tracked } from '@glimmer/tracking';
|
|
15
|
+
|
|
16
|
+
// Forest's grid cell, in px (WORKSPACE_GRID_CELL_WIDTH and _HEIGHT).
|
|
17
|
+
const CELL = 20;
|
|
18
|
+
|
|
19
|
+
/** As select-first's: one line, at most 40% of the box's height, the whole text in its width. */
|
|
20
|
+
function fittedFont(component, text, { min = 11, max = 36 } = {}) {
|
|
21
|
+
const box = component?.displaySettings;
|
|
22
|
+
if (!box?.width || !box?.height) return null;
|
|
23
|
+
const byHeight = box.height * CELL * 0.4;
|
|
24
|
+
const byWidth = (box.width * CELL - 44) / (0.6 * Math.max(String(text).length, 1));
|
|
25
|
+
|
|
26
|
+
return Math.round(Math.max(min, Math.min(max, byHeight, byWidth)));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const listOf = rows => (rows && rows.toArray ? rows.toArray() : Array.from(rows || []));
|
|
30
|
+
|
|
31
|
+
export default class RunAction extends Component {
|
|
32
|
+
@service store;
|
|
33
|
+
|
|
34
|
+
@tracked busy = false;
|
|
35
|
+
|
|
36
|
+
@tracked note = null;
|
|
37
|
+
|
|
38
|
+
get params() {
|
|
39
|
+
const url = this.args.component?.options?.componentUrl || '';
|
|
40
|
+
|
|
41
|
+
return new URLSearchParams(url.split('?')[1] || '');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
get actionName() {
|
|
45
|
+
return this.params.get('action') || '';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
get text() {
|
|
49
|
+
if (this.busy) return 'Running…';
|
|
50
|
+
|
|
51
|
+
return this.note || this.params.get('label') || this.actionName || 'Run';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get buttonClass() {
|
|
55
|
+
if (this.busy) return 'sf-button sf-button--dark sf-button--busy';
|
|
56
|
+
|
|
57
|
+
return this.note ? 'sf-button sf-button--note' : 'sf-button sf-button--dark';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get buttonStyle() {
|
|
61
|
+
const size = fittedFont(this.args.component, this.params.get('label') || this.actionName);
|
|
62
|
+
|
|
63
|
+
return size ? htmlSafe(`font-size:${size}px`) : null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The action's model, as Forest's own buttons hold it. */
|
|
67
|
+
get smartAction() {
|
|
68
|
+
const name = this.params.get('collection');
|
|
69
|
+
const collection = listOf(this.store.peekAll('collection')).find(c => c.name === name);
|
|
70
|
+
|
|
71
|
+
return listOf(collection?.customActions).find(a => a.name === this.actionName) || null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@action
|
|
75
|
+
async run() {
|
|
76
|
+
if (this.busy) return;
|
|
77
|
+
const { smartAction } = this;
|
|
78
|
+
|
|
79
|
+
if (!smartAction) {
|
|
80
|
+
this.note = `No action "${this.actionName}" here`;
|
|
81
|
+
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
this.note = null;
|
|
86
|
+
this.busy = true;
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
await this.args.triggerCustomAction(smartAction, []);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.warn(`run-action: ${this.actionName} failed`, error);
|
|
92
|
+
} finally {
|
|
93
|
+
this.busy = false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/* Select first and Go to: a primary button in Forest's brand (chartreuse fill, dark text), as wide
|
|
2
|
+
and tall as its cell. Forest adds this file to the page as a global style element: every class
|
|
3
|
+
starts with sf. The components set the font size from the box (fittedFont); 18 px otherwise. */
|
|
4
|
+
.sf {
|
|
5
|
+
position: relative;
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
height: 100%;
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.sf .sf-button {
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 100%;
|
|
18
|
+
margin: 0;
|
|
19
|
+
padding: 0 20px;
|
|
20
|
+
overflow: hidden;
|
|
21
|
+
border: 1px solid #c8dc1f;
|
|
22
|
+
border-radius: 8px;
|
|
23
|
+
background: #ddf327;
|
|
24
|
+
color: #1a2208;
|
|
25
|
+
font: 600 18px/1.15 Matter, Inter, system-ui, sans-serif;
|
|
26
|
+
white-space: nowrap;
|
|
27
|
+
text-overflow: ellipsis;
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
transition: background 0.15s, color 0.15s;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.sf .sf-button:hover {
|
|
33
|
+
border-color: #262d1e;
|
|
34
|
+
background: #262d1e;
|
|
35
|
+
color: #ddf327;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.sf .sf-button:focus-visible {
|
|
39
|
+
outline: 2px solid #3f5b1e;
|
|
40
|
+
outline-offset: 2px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.sf .sf-button--dark {
|
|
44
|
+
border-color: #262d1e;
|
|
45
|
+
background: #262d1e;
|
|
46
|
+
color: #ddf327;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.sf .sf-button--dark:hover {
|
|
50
|
+
border-color: #3f5b1e;
|
|
51
|
+
background: #3f5b1e;
|
|
52
|
+
color: #ffffff;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* A link to a workspace (Go to's look=link): text only, as Forest's link component. */
|
|
56
|
+
.sf .sf-button--link,
|
|
57
|
+
.sf .sf-button--link:hover {
|
|
58
|
+
padding: 0;
|
|
59
|
+
border: none;
|
|
60
|
+
background: none;
|
|
61
|
+
color: #2f6fed;
|
|
62
|
+
text-align: left;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.sf .sf-button--link:hover {
|
|
66
|
+
text-decoration: underline;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* A way back (Go to's look=back): the desks' "← Hub" pill. */
|
|
70
|
+
.sf .sf-button--back {
|
|
71
|
+
border-color: #e9e6df;
|
|
72
|
+
border-radius: 999px;
|
|
73
|
+
background: #e3f68b;
|
|
74
|
+
color: #1a2208;
|
|
75
|
+
font-weight: 700;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.sf .sf-button--back:hover {
|
|
79
|
+
border-color: #ddf327;
|
|
80
|
+
background: #ddf327;
|
|
81
|
+
text-decoration: none;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.sf .sf-button--busy {
|
|
85
|
+
cursor: progress;
|
|
86
|
+
opacity: 0.6;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.sf .sf-button--note {
|
|
90
|
+
border-color: #e9e6df;
|
|
91
|
+
background: #ece9e0;
|
|
92
|
+
color: #686c62;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* Locked (Select first's `after`, Go to's `after` or `unlock`): grey, and on hover a dark bubble
|
|
96
|
+
with the reason, drawn inside the box (Forest's cell cuts anything that overflows it). The
|
|
97
|
+
components size its text to the box (tipFont); 13 px otherwise. */
|
|
98
|
+
.sf .sf-button[disabled] {
|
|
99
|
+
border-color: #e9e6df;
|
|
100
|
+
background: #ece9e0;
|
|
101
|
+
color: #9a9d94;
|
|
102
|
+
text-decoration: none;
|
|
103
|
+
cursor: not-allowed;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.sf .sf-tip {
|
|
107
|
+
position: absolute;
|
|
108
|
+
top: 50%;
|
|
109
|
+
/* Left and right, not left 50% and a shift: that would cap the bubble at half the box. */
|
|
110
|
+
right: 3%;
|
|
111
|
+
left: 3%;
|
|
112
|
+
box-sizing: border-box;
|
|
113
|
+
width: fit-content;
|
|
114
|
+
max-width: 94%;
|
|
115
|
+
margin: 0 auto;
|
|
116
|
+
padding: 0.3em 0.7em;
|
|
117
|
+
border-radius: 0.5em;
|
|
118
|
+
background: #262d1e;
|
|
119
|
+
color: #ddf327;
|
|
120
|
+
font: 600 13px/1.3 Matter, Inter, system-ui, sans-serif;
|
|
121
|
+
text-align: center;
|
|
122
|
+
white-space: normal;
|
|
123
|
+
opacity: 0;
|
|
124
|
+
pointer-events: none;
|
|
125
|
+
transform: translateY(-50%);
|
|
126
|
+
transition: opacity 0.15s;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.sf.sf--locked:hover .sf-tip {
|
|
130
|
+
opacity: 1;
|
|
131
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<div class={{this.rootClass}}>
|
|
2
|
+
<button type="button" class={{this.buttonClass}} style={{this.buttonStyle}} disabled={{this.locked}} title={{this.tip}} {{on "click" this.selectFirst}}>{{this.text}}</button>
|
|
3
|
+
{{#if this.locked}}<span class="sf-tip" role="tooltip" style={{this.tipStyle}}>{{this.tip}}</span>{{/if}}
|
|
4
|
+
</div>
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/* eslint-disable import/no-unresolved -- runs inside the Forest app, which provides these */
|
|
2
|
+
/* eslint-env browser */
|
|
3
|
+
/**
|
|
4
|
+
* Select first: a workspace Custom component, one button that picks a row of a native collection
|
|
5
|
+
* component, as a click on that row would: the first one, or the one with a given reference. Served
|
|
6
|
+
* as hub/select-first.{hbs,js,css} (select-first-files.js).
|
|
7
|
+
*
|
|
8
|
+
* Set in the component's own url: `select-first.js?list=List_Untreated&ref=KYC-DEMO-0001&label=…`
|
|
9
|
+
* (list: default List_Untreated; ref: the row's reference, default the first row; label: the
|
|
10
|
+
* button's text). The text's size follows the button's box (fittedFont).
|
|
11
|
+
*
|
|
12
|
+
* `after=KYC-DEMO-0001` locks the button (grey, a hint on hover) until that row of the list shows
|
|
13
|
+
* one of `afterStatus` (comma-separated, default APPROVED): the demo's second case waits for the
|
|
14
|
+
* first. The list is read
|
|
15
|
+
* again every LOCK_POLL_MS, so the button opens as soon as the list refreshes after the action.
|
|
16
|
+
*
|
|
17
|
+
* What a row click does in Forest's collection component, done here the same way: select the row
|
|
18
|
+
* in the list's records context (the highlight), publish it as the component's selectedRecord
|
|
19
|
+
* (fields, buttons and workflows that follow the list), then the full record, fetched as the list
|
|
20
|
+
* fetches it.
|
|
21
|
+
*/
|
|
22
|
+
import { action } from '@ember/object';
|
|
23
|
+
import { inject as service } from '@ember/service';
|
|
24
|
+
import { htmlSafe } from '@ember/template';
|
|
25
|
+
import Component from '@glimmer/component';
|
|
26
|
+
import { tracked } from '@glimmer/tracking';
|
|
27
|
+
|
|
28
|
+
const DEFAULT_LIST = 'List_Untreated';
|
|
29
|
+
const DEFAULT_LABEL = 'Select a KYC Case';
|
|
30
|
+
const DEFAULT_TIP = 'Complete the first case before moving on to the second one!';
|
|
31
|
+
const LOCK_POLL_MS = 1500;
|
|
32
|
+
// Forest's grid cell, in px (WORKSPACE_GRID_CELL_WIDTH and _HEIGHT).
|
|
33
|
+
const CELL = 20;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A font size that fits `text` on one line in the component's box: at most 40% of its height,
|
|
37
|
+
* and narrow enough for the whole text (600 weight: about 0.6 em a character, 44 px of padding).
|
|
38
|
+
*/
|
|
39
|
+
function fittedFont(component, text, { min = 11, max = 36 } = {}) {
|
|
40
|
+
const box = component?.displaySettings;
|
|
41
|
+
if (!box?.width || !box?.height) return null;
|
|
42
|
+
const byHeight = box.height * CELL * 0.4;
|
|
43
|
+
const byWidth = (box.width * CELL - 44) / (0.6 * Math.max(String(text).length, 1));
|
|
44
|
+
|
|
45
|
+
return Math.round(Math.max(min, Math.min(max, byHeight, byWidth)));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The hint bubble's text size: the largest that fits the whole hint inside the box, on one, two
|
|
50
|
+
* or three lines (the bubble covers the button; Forest's cell cuts anything outside it).
|
|
51
|
+
*/
|
|
52
|
+
function tipFont(component, text) {
|
|
53
|
+
const box = component?.displaySettings;
|
|
54
|
+
if (!box?.width || !box?.height) return null;
|
|
55
|
+
const length = Math.max(String(text || '').length, 1);
|
|
56
|
+
const best = Math.max(
|
|
57
|
+
...[1, 2, 3].map(lines =>
|
|
58
|
+
// Lines of 1.3 em plus 0.6 em of padding; 0.62 em a character (bold) plus 1.4 em of padding.
|
|
59
|
+
Math.min(
|
|
60
|
+
(box.height * CELL * 0.92) / (lines * 1.3 + 0.6),
|
|
61
|
+
(box.width * CELL * 0.94) / (0.62 * Math.ceil(length / lines) + 1.4),
|
|
62
|
+
),
|
|
63
|
+
),
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
return Math.round(Math.max(12, Math.min(30, best)));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const listOf = rows => (rows && rows.toArray ? rows.toArray() : Array.from(rows || []));
|
|
70
|
+
// A row's fields are its "forest-<field>" attributes (Forest's model namespace).
|
|
71
|
+
const fieldOf = (row, name) =>
|
|
72
|
+
row?.[`forest-${name}`] ?? row?.getAttributesSerialized?.()[name] ?? row?.[name];
|
|
73
|
+
const referenceOf = row => fieldOf(row, 'reference');
|
|
74
|
+
|
|
75
|
+
export default class SelectFirst extends Component {
|
|
76
|
+
@service('feature/client-record') clientRecordFeature;
|
|
77
|
+
|
|
78
|
+
@tracked busy = false;
|
|
79
|
+
|
|
80
|
+
@tracked note = null;
|
|
81
|
+
|
|
82
|
+
// Bumped every LOCK_POLL_MS while the button waits on another row, so `locked` reads again.
|
|
83
|
+
@tracked tick = 0;
|
|
84
|
+
|
|
85
|
+
constructor(owner, args) {
|
|
86
|
+
super(owner, args);
|
|
87
|
+
|
|
88
|
+
if (this.params.get('after')) {
|
|
89
|
+
this.timer = window.setInterval(() => {
|
|
90
|
+
this.tick += 1;
|
|
91
|
+
}, LOCK_POLL_MS);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
willDestroy(...args) {
|
|
96
|
+
super.willDestroy?.(...args);
|
|
97
|
+
window.clearInterval(this.timer);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
get params() {
|
|
101
|
+
const url = this.args.component?.options?.componentUrl || '';
|
|
102
|
+
|
|
103
|
+
return new URLSearchParams(url.split('?')[1] || '');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
get listName() {
|
|
107
|
+
return this.params.get('list') || DEFAULT_LIST;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
get reference() {
|
|
111
|
+
return this.params.get('ref');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
get text() {
|
|
115
|
+
return this.note || this.params.get('label') || DEFAULT_LABEL;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
get buttonStyle() {
|
|
119
|
+
const size = fittedFont(this.args.component, this.text);
|
|
120
|
+
|
|
121
|
+
return size ? htmlSafe(`font-size:${size}px`) : null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
get list() {
|
|
125
|
+
return this.args.component?.getWorkspaceComponentFromName?.(this.listName) || null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Waiting on another row: the one named by `after` has not reached `afterStatus` yet. */
|
|
129
|
+
get locked() {
|
|
130
|
+
const after = this.params.get('after');
|
|
131
|
+
if (!after) return false;
|
|
132
|
+
// eslint-disable-next-line no-unused-expressions, @typescript-eslint/no-unused-expressions -- read to recompute on each poll
|
|
133
|
+
this.tick;
|
|
134
|
+
const rows = listOf(this.list?.options?.recordsContext?.records);
|
|
135
|
+
const row = rows.find(r => referenceOf(r) === after);
|
|
136
|
+
|
|
137
|
+
const wanted = (this.params.get('afterStatus') || 'APPROVED').split(',');
|
|
138
|
+
|
|
139
|
+
return !wanted.includes(fieldOf(row, 'status'));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
get tip() {
|
|
143
|
+
return this.locked ? this.params.get('tip') || DEFAULT_TIP : null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
get tipStyle() {
|
|
147
|
+
const size = this.tip ? tipFont(this.args.component, this.tip) : null;
|
|
148
|
+
|
|
149
|
+
return size ? htmlSafe(`font-size:${size}px`) : null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
get rootClass() {
|
|
153
|
+
return this.locked ? 'sf sf--locked' : 'sf';
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
get buttonClass() {
|
|
157
|
+
if (this.busy) return 'sf-button sf-button--busy';
|
|
158
|
+
|
|
159
|
+
return this.note ? 'sf-button sf-button--note' : 'sf-button';
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@action
|
|
163
|
+
async selectFirst() {
|
|
164
|
+
const { list } = this;
|
|
165
|
+
if (this.locked) return;
|
|
166
|
+
const context = list?.options?.recordsContext;
|
|
167
|
+
const rows = listOf(context?.records);
|
|
168
|
+
const { reference } = this;
|
|
169
|
+
const first = reference ? rows.find(row => referenceOf(row) === reference) : rows[0];
|
|
170
|
+
|
|
171
|
+
if (!first) {
|
|
172
|
+
let why = 'No case in the list right now';
|
|
173
|
+
if (!list) why = `No component named ${this.listName}`;
|
|
174
|
+
else if (reference && rows.length) why = `${reference} is not in the list`;
|
|
175
|
+
this.note = why;
|
|
176
|
+
if (!context) console.warn(`select-first: ${this.listName} has no records loaded`);
|
|
177
|
+
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
this.note = null;
|
|
182
|
+
this.busy = true;
|
|
183
|
+
|
|
184
|
+
try {
|
|
185
|
+
listOf(list.appliedOn).forEach(c => {
|
|
186
|
+
if (c?.options && 'resetReadMode' in c.options) c.options.resetReadMode();
|
|
187
|
+
});
|
|
188
|
+
context.resetSelectedRecords();
|
|
189
|
+
context.areAllRecordsSelected = false;
|
|
190
|
+
context.selectRecord(first);
|
|
191
|
+
list.selectedRecords = [first];
|
|
192
|
+
list.selectedRecords = [
|
|
193
|
+
await this.clientRecordFeature.fetchRecordAndRequiredBelongsTo(
|
|
194
|
+
list.templatingRecordFetch,
|
|
195
|
+
list.options.filteredCollection,
|
|
196
|
+
first,
|
|
197
|
+
),
|
|
198
|
+
];
|
|
199
|
+
} catch (error) {
|
|
200
|
+
console.warn('select-first: the full record could not be fetched', error);
|
|
201
|
+
} finally {
|
|
202
|
+
this.busy = false;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<div class="dg" style={{this.rootStyle}}>
|
|
2
|
+
<div class="dg-head">
|
|
3
|
+
<span class="dg-badge">Senior officer</span>
|
|
4
|
+
{{#if this.progress}}<span class="dg-ref">{{this.progress}}</span>{{/if}}
|
|
5
|
+
</div>
|
|
6
|
+
<div class="dg-title">Four eyes on a medium risk</div>
|
|
7
|
+
<p class="dg-intro">An operator cannot approve a medium or high risk alone: they rate it and send it to the Senior sign-off queue. You are the second pair of eyes.</p>
|
|
8
|
+
<ol class="dg-steps">
|
|
9
|
+
{{#each this.how as |step|}}
|
|
10
|
+
<li class={{step.className}}>
|
|
11
|
+
<span class="dg-mark">{{step.mark}}</span>
|
|
12
|
+
<span class="dg-body">
|
|
13
|
+
<span class="dg-step-title">{{step.title}}</span>
|
|
14
|
+
<span class="dg-detail">{{step.detail}}</span>
|
|
15
|
+
</span>
|
|
16
|
+
</li>
|
|
17
|
+
{{/each}}
|
|
18
|
+
</ol>
|
|
19
|
+
<div class="dg-queue-title">The queue</div>
|
|
20
|
+
<ul class="dg-queue">
|
|
21
|
+
{{#each this.cases as |c|}}
|
|
22
|
+
<li class={{c.rowClass}}>
|
|
23
|
+
<span class="dg-case-head">
|
|
24
|
+
<span class="dg-case-ref">{{c.reference}}</span>
|
|
25
|
+
<span class={{c.chipClass}}>{{c.chip}}</span>
|
|
26
|
+
</span>
|
|
27
|
+
<span class="dg-detail">{{c.name}} · {{c.story}}</span>
|
|
28
|
+
{{#if c.later}}<span class="dg-detail">{{c.later}}</span>{{/if}}
|
|
29
|
+
</li>
|
|
30
|
+
{{/each}}
|
|
31
|
+
</ul>
|
|
32
|
+
{{#if this.end}}
|
|
33
|
+
<div class="dg-end">
|
|
34
|
+
<span class="dg-end-title">{{this.end.title}}</span>
|
|
35
|
+
<span class="dg-end-text">{{this.end.text}}</span>
|
|
36
|
+
</div>
|
|
37
|
+
{{/if}}
|
|
38
|
+
{{#if this.failed}}<p class="dg-failed">The agent does not answer: is it running?</p>{{/if}}
|
|
39
|
+
</div>
|