You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
868 B
JavaScript
29 lines
868 B
JavaScript
import { NamedPage } from 'vj/misc/Page';
|
|
import { ConfirmDialog } from 'vj/components/dialog';
|
|
import tpl from 'vj/utils/tpl';
|
|
import i18n from 'vj/utils/i18n';
|
|
import request from 'vj/utils/request';
|
|
|
|
export default new NamedPage('training_edit', () => {
|
|
let confirmed = false;
|
|
$(document).on('click', '[name="operation"]', (ev) => {
|
|
ev.preventDefault();
|
|
if (confirmed) {
|
|
return request.post('.', { operation: 'delete' }).then((res) => {
|
|
window.location.href = res.url;
|
|
});
|
|
}
|
|
const message = 'Confirm deleting this training? Its status will be deleted as well.';
|
|
return new ConfirmDialog({
|
|
$body: tpl`
|
|
<div class="typo">
|
|
<p>${i18n(message)}</p>
|
|
</div>`,
|
|
}).open().then((action) => {
|
|
if (action !== 'yes') return;
|
|
confirmed = true;
|
|
ev.target.click();
|
|
});
|
|
});
|
|
});
|