Skip to content

Commit 65054d7

Browse files
committed
combine with commonOnClick
1 parent 0722d95 commit 65054d7

File tree

5 files changed

+38
-62
lines changed

5 files changed

+38
-62
lines changed

Signum.React.Extensions/Alerts/AlertsClient.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@ export function start(options: { routes: JSX.Element[], showAlerts?: (typeName:
5252
}));
5353

5454
Operations.addSettings(new EntityOperationSettings(AlertOperation.Delay, {
55-
onClick: (eoc) => chooseDate().then(d => d && eoc.defaultClick(d.toISO())),
55+
commonOnClick: (eoc) => chooseDate().then(d => d && eoc.defaultClick(d.toISO())),
5656
hideOnCanExecute: true,
57-
contextual: { onClick: (coc) => chooseDate().then(d => d && coc.defaultContextualClick(d.toISO())) },
58-
contextualFromMany: { onClick: (coc) => chooseDate().then(d => d && coc.defaultContextualClick(d.toISO())) },
57+
contextualFromMany: { onClick: (coc) => chooseDate().then(d => d && coc.defaultClick(d.toISO())) },
5958
}));
6059

6160
var cellFormatter = new Finder.CellFormatter((cell, ctx) => {

Signum.React.Extensions/Dynamic/DynamicViewClient.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,8 @@ export function start(options: { routes: JSX.Element[] }) {
6969
}));
7070

7171
Operations.addSettings(new EntityOperationSettings(DynamicViewOperation.Delete, {
72-
onClick: ctx => {
73-
cleanCaches();
74-
return ctx.defaultClick();
75-
},
76-
contextual: { onClick: ctx => { cleanCaches(); return ctx.defaultContextualClick(); } },
77-
contextualFromMany: { onClick: ctx => { cleanCaches(); return ctx.defaultContextualClick(); } },
72+
commonOnClick: oc => { cleanCaches(); return oc.defaultClick(); },
73+
contextualFromMany: { onClick: ctx => { cleanCaches(); return ctx.defaultClick(); } },
7874
}));
7975

8076
Operations.addSettings(new EntityOperationSettings(DynamicViewSelectorOperation.Save, {
@@ -85,12 +81,8 @@ export function start(options: { routes: JSX.Element[] }) {
8581
}));
8682

8783
Operations.addSettings(new EntityOperationSettings(DynamicViewSelectorOperation.Delete, {
88-
onClick: ctx => {
89-
cleanCaches();
90-
return ctx.defaultClick();
91-
},
92-
contextual: { onClick: ctx => { cleanCaches(); return ctx.defaultContextualClick(); } },
93-
contextualFromMany: { onClick: ctx => { cleanCaches(); return ctx.defaultContextualClick(); } },
84+
commonOnClick: ctx => { cleanCaches(); return ctx.defaultClick(); },
85+
contextualFromMany: { onClick: ctx => { cleanCaches(); return ctx.defaultClick(); } },
9486
}));
9587

9688
Navigator.setViewDispatcher(new DynamicViewViewDispatcher());

Signum.React.Extensions/MachineLearning/PredictorClient.tsx

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,10 @@ export function start(options: { routes: JSX.Element[] }) {
6868

6969
Operations.addSettings(new EntityOperationSettings(PredictorOperation.Publish, {
7070
hideOnCanExecute: true,
71-
onClick: eoc =>
72-
API.publications(eoc.entity.mainQuery.query!.key)
73-
.then(pubs => SelectorModal.chooseElement(pubs, { buttonDisplay: a => symbolNiceName(a), buttonName: a => a.key }))
74-
.then(pps => pps && eoc.defaultClick(pps))
75-
,
76-
contextual: {
77-
onClick: coc =>
78-
Navigator.API.fetch(coc.context.lites[0])
79-
.then(p => API.publications(p.mainQuery.query!.key))
80-
.then(pubs => SelectorModal.chooseElement(pubs, { buttonDisplay: a => symbolNiceName(a), buttonName: a => a.key }))
81-
.then(pps => pps && coc.defaultContextualClick(pps))
82-
83-
}
71+
commonOnClick: oc => oc.getEntity()
72+
.then(p => API.publications(p.mainQuery.query!.key))
73+
.then(pubs => SelectorModal.chooseElement(pubs, { buttonDisplay: a => symbolNiceName(a), buttonName: a => a.key }))
74+
.then(pps => pps && oc.defaultClick(pps)),
8475
}));
8576

8677
Operations.addSettings(new EntityOperationSettings(PredictorOperation.AfterPublishProcess, {

Signum.React.Extensions/Tree/TreeClient.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function start(options: { routes: JSX.Element[] }) {
3131
new EntityOperationSettings(TreeOperation.CreateNextSibling, { contextual: { isVisible: ctx => ctx.context.container instanceof SearchControlLoaded } }),
3232
new EntityOperationSettings(TreeOperation.Move, {
3333
onClick: ctx => moveModal(toLite(ctx.entity)).then(m => m && ctx.defaultClick(m)),
34-
contextual: { onClick: ctx => moveModal(ctx.context.lites[0]).then(m => m && ctx.defaultContextualClick(m)) }
34+
contextual: { onClick: ctx => moveModal(ctx.context.lites[0]).then(m => m && ctx.defaultClick(m)) }
3535
}),
3636
new EntityOperationSettings(TreeOperation.Copy, {
3737
onClick: ctx => copyModal(toLite(ctx.entity)).then(m => {
@@ -44,7 +44,7 @@ export function start(options: { routes: JSX.Element[] }) {
4444
onClick: ctx => copyModal(ctx.context.lites[0]).then(m => {
4545
if (m) {
4646
ctx.onConstructFromSuccess = pack => Operations.notifySuccess();
47-
ctx.defaultContextualClick(m);
47+
ctx.defaultClick(m);
4848
}
4949
})
5050
}

Signum.React.Extensions/Workflow/WorkflowClient.tsx

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,11 @@ export function start(options: { routes: JSX.Element[], overrideCaseActivityMixi
208208
}));
209209

210210
Operations.addSettings(new EntityOperationSettings(CaseOperation.Delete, {
211-
onClick: eoc => askDeleteMainEntity(eoc.entity.mainEntity)
212-
.then(u => u == undefined ? undefined : eoc.defaultClick(u)),
213-
contextual: {
214-
onClick: coc => askDeleteMainEntity(coc.pack!.entity.mainEntity)
215-
.then(u => u == undefined ? undefined : coc.defaultContextualClick(u))
216-
},
211+
commonOnClick: oc => oc.getEntity().then(e=> askDeleteMainEntity(e.mainEntity))
212+
.then(u => u == undefined ? undefined : oc.defaultClick(u)),
217213
contextualFromMany: {
218214
onClick: coc => askDeleteMainEntity()
219-
.then(u => u == undefined ? undefined : coc.defaultContextualClick(u))
215+
.then(u => u == undefined ? undefined : coc.defaultClick(u))
220216
},
221217
}));
222218

@@ -233,15 +229,11 @@ export function start(options: { routes: JSX.Element[], overrideCaseActivityMixi
233229
Operations.addSettings(new EntityOperationSettings(CaseActivityOperation.Delete, {
234230
hideOnCanExecute: true,
235231
isVisible: ctx => false,
236-
onClick: eoc => askDeleteMainEntity(eoc.entity.case.mainEntity)
237-
.then(u => u == undefined ? undefined : eoc.defaultClick(u)),
238-
contextual: {
239-
onClick: coc => askDeleteMainEntity(coc.pack!.entity.case.mainEntity)
240-
.then(u => u == undefined ? undefined : coc.defaultContextualClick(u))
241-
},
232+
commonOnClick: oc => oc.getEntity().then(e => askDeleteMainEntity(e.case.mainEntity))
233+
.then(u => u == undefined ? undefined : oc.defaultClick(u)),
242234
contextualFromMany: {
243235
onClick: coc => askDeleteMainEntity()
244-
.then(u => u == undefined ? undefined : coc.defaultContextualClick(u))
236+
.then(u => u == undefined ? undefined : coc.defaultClick(u))
245237
},
246238
}));
247239

@@ -267,7 +259,7 @@ export function start(options: { routes: JSX.Element[], overrideCaseActivityMixi
267259
onClick: coc =>
268260
Navigator.API.fetch(coc.context.lites[0])
269261
.then(ca => getWorkflowJumpSelector(toLite(ca.workflowActivity as WorkflowActivityEntity)))
270-
.then(dest => dest && coc.defaultContextualClick(dest))
262+
.then(dest => dest && coc.defaultClick(dest))
271263

272264
}
273265
}));
@@ -289,7 +281,7 @@ export function start(options: { routes: JSX.Element[], overrideCaseActivityMixi
289281
onClick: coc =>
290282
Navigator.API.fetch(coc.context.lites[0])
291283
.then(ca => getWorkflowFreeJump(ca.case.workflow))
292-
.then(dest => dest && coc.defaultContextualClick(dest))
284+
.then(dest => dest && coc.defaultClick(dest))
293285
}
294286
}));
295287
Operations.addSettings(new EntityOperationSettings(CaseActivityOperation.Timer, { isVisible: ctx => false }));
@@ -341,7 +333,7 @@ export function start(options: { routes: JSX.Element[], overrideCaseActivityMixi
341333
: <OperationMenuItem coc={coc} color={wa.customNextButton.style.toLowerCase() as BsColor}>{wa.customNextButton.name}</OperationMenuItem>];
342334

343335
} else if (wa.type == "Decision") {
344-
return wa.decisionOptions.map(mle => <OperationMenuItem coc={coc} onOperationClick={() => coc.defaultContextualClick(mle.element.name)} color={mle.element.style.toLowerCase() as BsColor}>{mle.element.name}</OperationMenuItem>);
336+
return wa.decisionOptions.map(mle => <OperationMenuItem coc={coc} onOperationClick={() => coc.defaultClick(mle.element.name)} color={mle.element.style.toLowerCase() as BsColor}>{mle.element.name}</OperationMenuItem>);
345337
}
346338
else
347339
return [];
@@ -379,16 +371,31 @@ export function start(options: { routes: JSX.Element[], overrideCaseActivityMixi
379371
Operations.addSettings(new EntityOperationSettings(WorkflowOperation.Deactivate, {
380372
onClick: eoc => chooseWorkflowExpirationDate([toLite(eoc.entity)]).then(val => !val ? undefined : eoc.defaultClick(val)),
381373
contextual: {
382-
onClick: coc => chooseWorkflowExpirationDate(coc.context.lites).then(val => !val ? undefined : coc.defaultContextualClick(val)),
374+
onClick: coc => chooseWorkflowExpirationDate(coc.context.lites).then(val => !val ? undefined : coc.defaultClick(val)),
383375
icon: ["far", "heart"],
384376
iconColor: "gray"
385377
},
386378
contextualFromMany: {
387-
onClick: coc => chooseWorkflowExpirationDate(coc.context.lites).then(val => !val ? undefined : coc.defaultContextualClick(val)),
379+
onClick: coc => chooseWorkflowExpirationDate(coc.context.lites).then(val => !val ? undefined : coc.defaultClick(val)),
388380
icon: ["far", "heart"],
389381
iconColor: "gray"
390382
},
391383
}));
384+
385+
function chooseWorkflowExpirationDate(workflows: Lite<WorkflowEntity>[]): Promise<string | undefined> {
386+
return ValueLineModal.show({
387+
type: { name: "string" },
388+
valueLineType: "DateTime",
389+
modalSize: "md",
390+
title: WorkflowMessage.DeactivateWorkflow.niceToString(),
391+
message:
392+
<div>
393+
<strong>{WorkflowMessage.PleaseChooseExpirationDate.niceToString()}</strong>
394+
<ul>{workflows.map((w, i) => <li key={i}>{getToString(w)}</li>)}</ul>
395+
</div>
396+
});
397+
}
398+
392399
Navigator.addSettings(new EntitySettings(WorkflowEntity, w => import('./Workflow/Workflow'), { avoidPopup: true }));
393400

394401
hide(WorkflowPoolEntity);
@@ -443,19 +450,6 @@ export function start(options: { routes: JSX.Element[], overrideCaseActivityMixi
443450
}
444451
}
445452

446-
function chooseWorkflowExpirationDate(workflows: Lite<WorkflowEntity>[]): Promise<string | undefined> {
447-
return ValueLineModal.show({
448-
type: { name: "string" },
449-
valueLineType: "DateTime",
450-
modalSize: "md",
451-
title: WorkflowMessage.DeactivateWorkflow.niceToString(),
452-
message:
453-
<div>
454-
<strong>{WorkflowMessage.PleaseChooseExpirationDate.niceToString()}</strong>
455-
<ul>{workflows.map((w, i) => <li key={i}>{getToString(w)}</li>)}</ul>
456-
</div>
457-
});
458-
}
459453

460454
export function workflowActivityMonitorUrl
461455
(workflow: Lite<WorkflowEntity>) {

0 commit comments

Comments
 (0)