gristlabs_grist-core/app/client/components/Confirm.ts
Paul Fitzpatrick 1654a2681f (core) move client code to core
Summary:
This moves all client code to core, and makes minimal fix-ups to
get grist and grist-core to compile correctly.  The client works
in core, but I'm leaving clean-up around the build and bundles to
follow-up.

Test Plan: existing tests pass; server-dev bundle looks sane

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D2627
2020-10-02 13:24:21 -04:00

31 lines
906 B
TypeScript

// Grist client libs
import * as ModalDialog from 'app/client/components/ModalDialog';
import * as dom from 'app/client/lib/dom';
import * as kd from 'app/client/lib/koDom';
import * as kf from 'app/client/lib/koForm';
export function showConfirmDialog(title: string, btnText: string, onConfirm: () => Promise<void>,
explanation?: Element|string): void {
const body = dom('div.confirm',
explanation ? kf.row(explanation, kd.style('margin-bottom', '2rem')) : null,
kf.row(
1, kf.buttonGroup(
kf.button(() => dialog.hide(), 'Cancel')
),
1, kf.buttonGroup(
kf.accentButton(async () => {
await onConfirm();
dialog.hide();
}, btnText)
)
)
);
const dialog = ModalDialog.create({
title,
body,
width: '300px',
show: true
});
dialog.once('close', () => dialog.dispose());
}