@datagrok/hit-triage 1.10.9 → 1.11.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/.grokignore +2 -0
- package/.turbo/turbo-build.log +25 -3
- package/CHANGELOG.md +78 -0
- package/CLAUDE.md +87 -10
- package/README_HD.md +14 -14
- package/README_HT.md +6 -6
- package/README_PH.md +110 -0
- package/bdd/bdd.config.json +3 -1
- package/bdd/bindings/campaign.ts +626 -0
- package/bdd/bindings/hit-design.ts +36 -42
- package/bdd/bindings/landing.ts +839 -0
- package/bdd/bindings/pepti-hit.ts +35 -0
- package/bdd/features/campaign/crumbs.feature +22 -0
- package/bdd/features/campaign/grid.feature +56 -0
- package/bdd/features/campaign/merge.feature +105 -0
- package/bdd/features/campaign/molecule-vid.feature +40 -0
- package/bdd/features/campaign/permissions.feature +46 -0
- package/bdd/features/campaign/progress-tracker.feature +89 -0
- package/bdd/features/campaign/refresh-hint.feature +33 -0
- package/bdd/features/campaign/ribbon.feature +49 -0
- package/bdd/features/campaign/stage-choices.feature +39 -0
- package/bdd/features/campaign/submit.feature +135 -0
- package/bdd/features/campaign/tracker-cards.feature +46 -0
- package/bdd/features/campaign/view-only.feature +37 -0
- package/bdd/features/landing/campaign-deep-links.feature +61 -0
- package/bdd/features/landing/hit-design-campaigns-fixes.feature +116 -0
- package/bdd/features/landing/hit-design-campaigns.feature +153 -0
- package/bdd/features/landing/hit-triage-campaigns.feature +99 -0
- package/bdd/features/landing/new-campaign.feature +69 -0
- package/bdd/features/landing/pep-triage-campaigns.feature +41 -0
- package/bdd/features/landing/pepti-hit-landing.feature +132 -0
- package/bdd/features/pepti-hit/helm-edit.feature +47 -0
- package/bdd/features/templates/template-editor.feature +130 -0
- package/bdd/features/templates/template-picker.feature +112 -0
- package/bdd/features/templates/triage-forms.feature +59 -0
- package/bdd/fixtures/bar-chart.layout +1 -0
- package/bdd/fixtures/merge-local.csv +2 -0
- package/bdd/generated/campaign/crumbs.test.ts +33 -0
- package/bdd/generated/campaign/grid.test.ts +79 -0
- package/bdd/generated/campaign/merge.test.ts +134 -0
- package/bdd/generated/campaign/molecule-vid.test.ts +52 -0
- package/bdd/generated/campaign/permissions.test.ts +58 -0
- package/bdd/generated/campaign/progress-tracker.test.ts +129 -0
- package/bdd/generated/campaign/refresh-hint.test.ts +44 -0
- package/bdd/generated/campaign/ribbon.test.ts +65 -0
- package/bdd/generated/campaign/stage-choices.test.ts +55 -0
- package/bdd/generated/campaign/submit.test.ts +167 -0
- package/bdd/generated/campaign/tracker-cards.test.ts +49 -0
- package/bdd/generated/campaign/view-only.test.ts +51 -0
- package/bdd/generated/hit-design/campaign-column-metadata.test.ts +1 -0
- package/bdd/generated/landing/campaign-deep-links.test.ts +68 -0
- package/bdd/generated/landing/hit-design-campaigns-fixes.test.ts +99 -0
- package/bdd/generated/landing/hit-design-campaigns.test.ts +160 -0
- package/bdd/generated/landing/hit-triage-campaigns.test.ts +107 -0
- package/bdd/generated/landing/new-campaign.test.ts +78 -0
- package/bdd/generated/landing/pep-triage-campaigns.test.ts +52 -0
- package/bdd/generated/landing/pepti-hit-landing.test.ts +130 -0
- package/bdd/generated/pepti-hit/helm-edit.test.ts +64 -0
- package/bdd/generated/templates/template-editor.test.ts +137 -0
- package/bdd/generated/templates/template-picker.test.ts +119 -0
- package/bdd/generated/templates/triage-forms.test.ts +68 -0
- package/css/hit-triage.css +27 -23
- package/dist/package-test.js +690 -4
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +318 -73
- package/dist/package.js.map +1 -1
- package/package.json +11 -7
- package/queries/locks.sql +37 -0
- package/src/app/accordeons/layout-input.ts +52 -44
- package/src/app/accordeons/new-campaign-accordeon.ts +91 -54
- package/src/app/accordeons/new-hit-design-campaign-accordeon.ts +3 -67
- package/src/app/accordeons/new-pep-triage-template-accordeon.ts +39 -41
- package/src/app/accordeons/new-template-accordeon.ts +41 -24
- package/src/app/ai/view-functions.ts +22 -19
- package/src/app/base-view.ts +99 -8
- package/src/app/consts.ts +8 -5
- package/src/app/dialogs/functions-dialog.ts +14 -9
- package/src/app/dialogs/merge-table-dialog.ts +181 -325
- package/src/app/hit-app-base.ts +61 -90
- package/src/app/hit-design-app.ts +481 -886
- package/src/app/hit-design-views/info-view.ts +57 -407
- package/src/app/hit-design-views/submit-view.ts +216 -111
- package/src/app/hit-design-views/tiles-view.ts +168 -123
- package/src/app/hit-design-views/utils.css +0 -8
- package/src/app/hit-triage-app.ts +69 -38
- package/src/app/hit-triage-views/info-view.ts +70 -371
- package/src/app/pep-triage-app.ts +2 -2
- package/src/app/pep-triage-views/info-view.ts +42 -83
- package/src/app/pepti-hit-app.ts +32 -183
- package/src/app/pepti-hits-views/info-view.ts +15 -37
- package/src/app/shared/campaign-catalog.ts +408 -0
- package/src/app/shared/campaign-session.ts +557 -0
- package/src/app/shared/compute-editor.ts +274 -0
- package/src/app/shared/hit-home.ts +45 -0
- package/src/app/shared/new-campaign-form.ts +90 -0
- package/src/app/shared/permissions-editor.ts +93 -0
- package/src/app/shared/template-editor.ts +331 -0
- package/src/app/shared/template-picker.ts +154 -0
- package/src/app/utils/merge-table.ts +183 -78
- package/src/app/utils.ts +34 -325
- package/src/package-api.ts +29 -8
- package/src/package-test.ts +17 -2
- package/src/package.g.ts +12 -8
- package/src/package.ts +19 -7
- package/src/tests/ai.ts +244 -0
- package/src/tests/campaign-layout.ts +82 -0
- package/src/tests/campaign-session.ts +168 -0
- package/src/tests/campaigns.ts +23 -0
- package/src/tests/catalog.ts +156 -0
- package/src/tests/compat.ts +482 -0
- package/src/tests/compute.ts +165 -0
- package/src/tests/fixtures.ts +359 -0
- package/src/tests/merge.ts +149 -0
- package/src/tests/owners.ts +11 -0
- package/src/tests/save-lock.ts +932 -0
- package/src/tests/storage.ts +106 -0
- package/src/tests/template-editor.ts +538 -0
- package/src/tests/templates.ts +143 -0
- package/src/tests/triage-start.ts +81 -0
- package/src/tests/u2-guards.ts +384 -0
- package/src/tests/vid.ts +77 -0
- package/src/app/accordeons/new-hit-design-template-accordeon.ts +0 -238
- package/src/app/dialogs/permissions-dialog.ts +0 -66
|
@@ -1,135 +1,240 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
1
|
+
/* The Submit dialog of a Hit Design / PeptiHit campaign: what the campaign is (read-only rows, its name and folder
|
|
2
|
+
editable in place), its status with the statuses other campaigns have, and the function it is submitted to. SAVE
|
|
3
|
+
stores the status; SUBMIT runs the function on the campaign's rows, then saves. A campaign the user may only view
|
|
4
|
+
offers neither, saying why. */
|
|
3
5
|
import * as grok from 'datagrok-api/grok';
|
|
4
6
|
import * as DG from 'datagrok-api/dg';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {HitTriageSubmitTag} from '../consts';
|
|
10
|
-
import {getFuncPackageNameSafe} from '../utils';
|
|
7
|
+
import {ChoiceInput, Dialog, DynamicInput, Form, Input, LabelColumn, SuggestInput, TextInput, computed, div,
|
|
8
|
+
iconButton, signal} from '@datagrok-libraries/u2';
|
|
9
|
+
import {ViewHost} from '@datagrok-libraries/u2/dg';
|
|
10
|
+
import type {HitDesignApp} from '../hit-design-app';
|
|
11
|
+
import {CampaignTableName, HitTriageSubmitTag, i18n} from '../consts';
|
|
12
|
+
import {checkFileExists, getFuncPackageNameSafe} from '../utils';
|
|
13
|
+
import {fieldText} from '../shared/campaign-catalog';
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
private statusSuggestionsMenu: DG.Menu;
|
|
15
|
-
content: HTMLDivElement;
|
|
16
|
-
constructor(app: HitDesignApp) {
|
|
17
|
-
super(app);
|
|
18
|
-
this.name = 'Submit';
|
|
19
|
-
this.statusInput = ui.input.string('Status', {value: this.app.campaign?.status, nullable: false});
|
|
20
|
-
this.statusSuggestionsMenu = DG.Menu.popup();
|
|
21
|
-
this.statusInput.root.style.marginLeft = '12px';
|
|
22
|
-
this.content = ui.div();
|
|
15
|
+
const VIEW_ONLY = 'You can view this campaign but not change it';
|
|
16
|
+
const NOT_SAVED = 'The campaign was not saved';
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const status = (this.statusInput.value ?? '').toLowerCase();
|
|
27
|
-
// eslint-disable-next-line max-len
|
|
28
|
-
const similarStatuses = this.app.existingStatuses.filter((s) => s?.toLowerCase()?.includes(status) && s?.toLowerCase() !== status).filter((_, i) => i < 5);
|
|
29
|
-
if (similarStatuses.length) {
|
|
30
|
-
similarStatuses.forEach((s) => {
|
|
31
|
-
this.statusSuggestionsMenu.item(s, () => {
|
|
32
|
-
this.statusInput.value = s;
|
|
33
|
-
this.statusSuggestionsMenu.root.remove();
|
|
34
|
-
this.statusInput.root.focus();
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
if (this.content.parentElement?.parentElement) {
|
|
38
|
-
const xOffset = this.statusInput.root.offsetLeft + (this.statusInput.input?.offsetLeft ?? 0);
|
|
39
|
-
const yOffset = this.statusInput.root.offsetTop + this.statusInput.root.offsetHeight + this.content.parentElement.offsetTop;
|
|
40
|
-
this.statusSuggestionsMenu.show({element: this.content.parentElement.parentElement!, x: xOffset, y: yOffset});
|
|
41
|
-
}
|
|
42
|
-
} else
|
|
43
|
-
this.statusSuggestionsMenu.root.remove();
|
|
44
|
-
});
|
|
45
|
-
}
|
|
18
|
+
export class HitDesignSubmitView {
|
|
19
|
+
constructor(private readonly app: HitDesignApp) {}
|
|
46
20
|
|
|
47
|
-
|
|
48
|
-
|
|
21
|
+
/** The functions a campaign can be submitted to, by friendly name. */
|
|
22
|
+
private static submitFunctions(): Map<string, DG.Func> {
|
|
23
|
+
const funcs = new Set([...DG.Func.find({meta: {role: HitTriageSubmitTag}}),
|
|
24
|
+
...DG.Func.find({tags: [HitTriageSubmitTag]})]);
|
|
25
|
+
return new Map([...funcs].map((f) => [f.friendlyName ?? f.name, f]));
|
|
49
26
|
}
|
|
50
27
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
28
|
+
render(): void {
|
|
29
|
+
const app = this.app;
|
|
30
|
+
const campaign = app.campaign;
|
|
31
|
+
const canEdit = app.canEdit;
|
|
32
|
+
const functions = HitDesignSubmitView.submitFunctions();
|
|
33
|
+
const preset = app.submitParams;
|
|
34
|
+
const presetName = [...functions].find(([, f]) => f.name === preset?.fName &&
|
|
35
|
+
getFuncPackageNameSafe(f) === preset?.package)?.[0] ?? null;
|
|
36
|
+
const dialog = new Dialog('Submit', {name: 'submit'});
|
|
37
|
+
dialog.build(() => {
|
|
38
|
+
const column = new LabelColumn();
|
|
39
|
+
const summary = new Form({quiet: true, labelColumn: column});
|
|
40
|
+
for (const input of this.summaryRows())
|
|
41
|
+
summary.add(input);
|
|
42
|
+
const inputs = new Form({labelColumn: column});
|
|
43
|
+
const status = new SuggestInput({label: 'Status', name: 'status', value: campaign?.status ?? '',
|
|
44
|
+
readOnly: !canEdit, minChars: 1, source: async (query) => {
|
|
45
|
+
const q = query.toLowerCase();
|
|
46
|
+
return app.existingStatuses.filter((s) => s?.toLowerCase().includes(q) && s.toLowerCase() !== q).slice(0, 5);
|
|
47
|
+
}});
|
|
48
|
+
const func = new ChoiceInput({label: 'Submit function', name: 'submit-function', items: [...functions.keys()],
|
|
49
|
+
value: presetName, nullable: true, readOnly: !canEdit});
|
|
50
|
+
inputs.add(status);
|
|
51
|
+
inputs.add(func);
|
|
52
|
+
dialog.add(div([summary.root, inputs.root]));
|
|
67
53
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
54
|
+
const statusToSave = () => status.peek()?.trim() || campaign?.status || 'No Status';
|
|
55
|
+
/** The chosen submit function into the campaign's template; answers the undo. */
|
|
56
|
+
const keepSubmitFunction = () => {
|
|
57
|
+
const template = app.campaign?.template;
|
|
58
|
+
const before = template?.submit;
|
|
59
|
+
const f = functions.get(func.peek() ?? '');
|
|
60
|
+
if (template)
|
|
61
|
+
template.submit = f ? {fName: f.name, package: getFuncPackageNameSafe(f)} : undefined;
|
|
62
|
+
return () => template && (template.submit = before);
|
|
63
|
+
};
|
|
64
|
+
const chosen = computed(() => functions.get(func.value ?? ''));
|
|
65
|
+
dialog.addButton('Save', async () => {
|
|
66
|
+
const saving = app.campaign;
|
|
67
|
+
if (!saving)
|
|
68
|
+
return;
|
|
69
|
+
const undo = keepSubmitFunction();
|
|
70
|
+
const before = saving.status;
|
|
71
|
+
saving.status = statusToSave();
|
|
72
|
+
if (await app.saveCampaign() !== undefined)
|
|
73
|
+
dialog.close();
|
|
74
|
+
else {
|
|
75
|
+
saving.status = before;
|
|
76
|
+
undo();
|
|
77
|
+
}
|
|
78
|
+
}, {disabled: canEdit ? null : VIEW_ONLY});
|
|
79
|
+
dialog.onOK(async () => {
|
|
80
|
+
const undo = keepSubmitFunction();
|
|
81
|
+
let submitted = false;
|
|
82
|
+
try {
|
|
83
|
+
submitted = await this.submit(statusToSave());
|
|
84
|
+
} finally {
|
|
85
|
+
// a submit function that threw leaves the template as it was; the dialog shows the error
|
|
86
|
+
if (!submitted)
|
|
87
|
+
undo();
|
|
88
|
+
}
|
|
89
|
+
return submitted;
|
|
90
|
+
}, {text: 'Submit', primary: true});
|
|
91
|
+
dialog.okDisabled(computed(() => !canEdit ? VIEW_ONLY :
|
|
92
|
+
chosen.value === undefined ? 'Choose a submit function' : null));
|
|
93
|
+
dialog.status(computed(() => chosen.value === undefined ? null :
|
|
94
|
+
`Submits ${app.dataFrame?.filter.trueCount ?? 0} molecules to ${chosen.value.friendlyName}`));
|
|
75
95
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const submitFunctions = Array.from(new Set(DG.Func.find({meta: {role: HitTriageSubmitTag}}).concat(DG.Func.find({tags: [HitTriageSubmitTag]}))));
|
|
80
|
-
const submitFunctionMap = submitFunctions.reduce((acc, fn) => {
|
|
81
|
-
acc[fn.friendlyName ?? fn.name] = fn;
|
|
82
|
-
return acc;
|
|
83
|
-
}, {} as Record<string, DG.Func>);
|
|
84
|
-
if (submitFunctions.length > 0) {
|
|
85
|
-
const chosenFunctionParams = this.app.submitParams;
|
|
86
|
-
const foundFunction = chosenFunctionParams ? submitFunctions.find((fn) => fn.name === chosenFunctionParams.fName && getFuncPackageNameSafe(fn) == chosenFunctionParams.package) : undefined;
|
|
87
|
-
const foundFunctionKey = foundFunction?.friendlyName ?? foundFunction?.name;
|
|
88
|
-
const submitFunctionInput = ui.input.choice('Submit function', {
|
|
89
|
-
value: foundFunctionKey,
|
|
90
|
-
items: [...Object.keys(submitFunctionMap)],
|
|
91
|
-
nullable: true,
|
|
92
|
-
});
|
|
96
|
+
ViewHost.of(app.designView!).show(dialog, {width: 640});
|
|
97
|
+
}
|
|
93
98
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
99
|
+
/** The summary rows: what the campaign is, its fields, its size and compute, its name and folder editable. */
|
|
100
|
+
private summaryRows(): Input<any>[] {
|
|
101
|
+
const app = this.app;
|
|
102
|
+
const campaign = app.campaign;
|
|
103
|
+
const template = app.template;
|
|
104
|
+
const code = app.campaignId ?? campaign?.name ?? '';
|
|
105
|
+
const text = (label: string, value: unknown) => new TextInput({label, value: String(value ?? ''), readOnly: true});
|
|
106
|
+
const name = this.editable(text('Name', campaign?.friendlyName ?? campaign?.name ?? code), 'Edit Campaign Name',
|
|
107
|
+
async (value) => {
|
|
108
|
+
if (!value.trim())
|
|
109
|
+
return 'Campaign name can not be empty';
|
|
110
|
+
const saving = app.campaign!;
|
|
111
|
+
const before = saving.friendlyName;
|
|
112
|
+
saving.friendlyName = value;
|
|
113
|
+
if (await app.saveCampaign(true) !== undefined)
|
|
114
|
+
return null;
|
|
115
|
+
saving.friendlyName = before;
|
|
116
|
+
return NOT_SAVED;
|
|
107
117
|
});
|
|
108
|
-
|
|
109
|
-
|
|
118
|
+
const path = this.editable(text('File Path', app.campaignFolder), 'Edit file path', async (value) => {
|
|
119
|
+
if (!await checkFileExists(value))
|
|
120
|
+
return 'Given folder does not exist';
|
|
121
|
+
const before = app.filePath;
|
|
122
|
+
app.filePath = `${value.replace(/\/$/, '')}/${code}/${CampaignTableName}`;
|
|
123
|
+
if (app.campaign)
|
|
124
|
+
app.campaign.savePath = app.filePath;
|
|
125
|
+
if (await app.saveCampaign(true) !== undefined)
|
|
126
|
+
return null;
|
|
127
|
+
app.filePath = before;
|
|
128
|
+
if (app.campaign)
|
|
129
|
+
app.campaign.savePath = before;
|
|
130
|
+
return NOT_SAVED;
|
|
131
|
+
});
|
|
132
|
+
path.addOptions(iconButton('arrow-to-bottom', () => app.download(app.dataFrame!, code || 'Molecules'),
|
|
133
|
+
{tooltip: i18n.download}));
|
|
134
|
+
const rows: Input<any>[] = [name, text('Code', code), text('Template', template?.name ?? 'Molecules'), path];
|
|
135
|
+
if (campaign?.authorUserFriendlyName)
|
|
136
|
+
rows.push(text('Author', campaign.authorUserFriendlyName));
|
|
137
|
+
if (campaign?.lastModifiedUserName)
|
|
138
|
+
rows.push(text('Last Modified By', campaign.lastModifiedUserName));
|
|
139
|
+
if (campaign?.createDate)
|
|
140
|
+
rows.push(text('Create Date', campaign.createDate));
|
|
141
|
+
for (const [key, value] of Object.entries(campaign?.campaignFields ?? app.campaignProps)) {
|
|
142
|
+
const field = template?.campaignFields?.find((f) => f.name === key);
|
|
143
|
+
if (field?.type === 'Molecule' && value) {
|
|
144
|
+
rows.push(new DynamicInput<string>({label: key, value,
|
|
145
|
+
render: (smiles) => smiles ? grok.chem.drawMolecule(smiles, 160, 100) : null}));
|
|
146
|
+
}
|
|
147
|
+
else
|
|
148
|
+
rows.push(text(key, field?.type === 'Date' ? fieldText(value) : value));
|
|
110
149
|
}
|
|
150
|
+
rows.push(text('Number of Molecules', app.dataFrame?.rowCount ?? 0));
|
|
151
|
+
const compute = template?.compute;
|
|
152
|
+
const friendly = (f: {package: string, name: string}) =>
|
|
153
|
+
DG.Func.find({package: f.package, name: f.name})[0]?.friendlyName ?? f.name;
|
|
154
|
+
const methods = [compute?.descriptors.enabled ? 'Descriptors' : '', ...(compute?.functions ?? []).map(friendly)];
|
|
155
|
+
rows.push(text('Enrichment Methods', methods.filter((m) => m.trim() !== '').join(', ')));
|
|
156
|
+
return rows;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** A read-only row with a pencil: it turns into an input with save and cancel (Enter and Escape alike); a save
|
|
160
|
+
* that answers a problem keeps the input open, the problem under it. */
|
|
161
|
+
private editable(input: TextInput, tooltip: string, save: (value: string) => Promise<string | null>): TextInput {
|
|
162
|
+
const saved = signal(input.peek());
|
|
163
|
+
const editing = signal(false);
|
|
164
|
+
const problem = signal<{value: string, message: string} | null>(null);
|
|
165
|
+
input.addValidator((value) => problem.value?.value === value ? problem.value.message : null);
|
|
166
|
+
const done = (value: string) => {
|
|
167
|
+
saved.value = value;
|
|
168
|
+
problem.value = null;
|
|
169
|
+
input.reset(value);
|
|
170
|
+
editing.value = false;
|
|
171
|
+
};
|
|
172
|
+
const accept = async () => {
|
|
173
|
+
const value = input.peek() ?? '';
|
|
174
|
+
const error = await save(value);
|
|
175
|
+
if (error === null)
|
|
176
|
+
done(value);
|
|
177
|
+
else {
|
|
178
|
+
problem.value = {value, message: error};
|
|
179
|
+
input.touch();
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
const cancel = () => done(saved.peek() ?? '');
|
|
183
|
+
const pencil = iconButton('pencil', () => {
|
|
184
|
+
editing.value = true;
|
|
185
|
+
input.focus();
|
|
186
|
+
}, {tooltip});
|
|
187
|
+
const acceptButton = iconButton('check', accept, {tooltip: 'Save'});
|
|
188
|
+
const cancelButton = iconButton('times', cancel, {tooltip: 'Cancel'});
|
|
189
|
+
for (const option of [pencil, acceptButton, cancelButton])
|
|
190
|
+
input.addOptions(option);
|
|
191
|
+
// while editing, Enter and Escape are the row's: the dialog would submit or close
|
|
192
|
+
input.scope.listen(input.root, 'keydown', (e) => {
|
|
193
|
+
const key = (e as KeyboardEvent).key;
|
|
194
|
+
if (!editing.peek() || key !== 'Enter' && key !== 'Escape')
|
|
195
|
+
return;
|
|
196
|
+
e.preventDefault();
|
|
197
|
+
e.stopPropagation();
|
|
198
|
+
void (key === 'Enter' ? accept() : cancel());
|
|
199
|
+
});
|
|
200
|
+
input.effect(() => {
|
|
201
|
+
const on = editing.value;
|
|
202
|
+
input.readOnly = !on;
|
|
203
|
+
pencil.hidden = on;
|
|
204
|
+
acceptButton.hidden = !on;
|
|
205
|
+
cancelButton.hidden = !on;
|
|
206
|
+
});
|
|
207
|
+
return input;
|
|
111
208
|
}
|
|
112
209
|
|
|
113
|
-
|
|
210
|
+
/** The AI's submit: the status given, else the campaign's, else "Submitted". */
|
|
211
|
+
async submitWithStatus(status?: string): Promise<boolean> {
|
|
212
|
+
return await this.submit(status?.trim() || this.app.campaign?.status || 'Submitted');
|
|
114
213
|
}
|
|
115
214
|
|
|
116
|
-
/**
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
215
|
+
/** Runs the campaign's submit function on its rows (the filtered ones), then saves the campaign with `status`.
|
|
216
|
+
* Answers whether both happened. */
|
|
217
|
+
async submit(status: string = this.app.campaign?.status ?? 'No Status'): Promise<boolean> {
|
|
218
|
+
const app = this.app;
|
|
219
|
+
const params = app.submitParams;
|
|
220
|
+
if (!params) {
|
|
120
221
|
grok.shell.error('No submit function selected. Please select a function to submit the campaign.');
|
|
121
222
|
return false;
|
|
122
223
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
224
|
+
const fn = DG.Func.find({name: params.fName, package: params.package})[0];
|
|
225
|
+
if (!fn) {
|
|
226
|
+
grok.shell.error(`Function ${params.fName} not found.`);
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
const filtered = DG.DataFrame.fromCsv(app.dataFrame!.toCsv({filteredRowsOnly: true}));
|
|
230
|
+
await fn.apply({df: filtered, molecules: app.molColName});
|
|
231
|
+
const campaign = app.campaign!;
|
|
232
|
+
const before = campaign.status;
|
|
233
|
+
campaign.status = status;
|
|
234
|
+
if (await app.saveCampaign() === undefined) {
|
|
235
|
+
campaign.status = before;
|
|
127
236
|
return false;
|
|
128
237
|
}
|
|
129
|
-
const filteredDf = DG.DataFrame.fromCsv(this.app.dataFrame!.toCsv({filteredRowsOnly: true}));
|
|
130
|
-
await submitFn.apply({df: filteredDf, molecules: this.app.molColName});
|
|
131
|
-
this.app.campaign!.status = this.getStatus();
|
|
132
|
-
await this.app.saveCampaign();
|
|
133
238
|
grok.shell.info('Submitted successfully.');
|
|
134
239
|
return true;
|
|
135
240
|
}
|