Skip to content

Commit

Permalink
Fix thamara#240: waiver using electron dialog instead of js confirm
Browse files Browse the repository at this point in the history
  • Loading branch information
araujoarthur0 committed May 27, 2020
1 parent 0a96048 commit b287384
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/workday-waiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { validateTime, diffDays } = require('../js/time-math.js');
const { applyTheme } = require('../js/themes.js');
const { getDateStr } = require('../js/date-aux.js');
const { remote } = require('electron');
const { BrowserWindow, dialog } = remote;
const Store = require('electron-store');

const store = new Store({name: 'waived-workdays'});
Expand Down Expand Up @@ -111,13 +112,23 @@ function addWaiver() {
function deleteEntryOnClick(event) {
let deleteButton = $(event.target);
let day = deleteButton.data('day');
if (!confirm('Are you sure you want to delete waiver on day ' + day + '?')) {
return;
}
store.delete(day);

let row = deleteButton.closest('tr');
row.remove();
dialog.showMessageBox(BrowserWindow.getFocusedWindow(),
{
title: 'Time to Leave',
message: 'Are you sure you want to delete waiver on day ' + day + '?',
type: 'info',
buttons: ['Yes', 'No']
}).then((result) => {
const buttonId = result.response;
if (buttonId === 1) {
return;
}
store.delete(day);

let row = deleteButton.closest('tr');
row.remove();
});
}

$(() => {
Expand Down

0 comments on commit b287384

Please sign in to comment.