2
0
mirror of https://github.com/frappe/books.git synced 2025-02-08 23:18:31 +00:00

fix create new database method

This commit is contained in:
Ankit Singhaniya 2021-08-25 01:40:16 +05:30 committed by 18alantom
parent 6343f11328
commit 649691939c

View File

@ -9,41 +9,36 @@ import router from '@/router';
import Avatar from '@/components/Avatar'; import Avatar from '@/components/Avatar';
import config from '@/config'; import config from '@/config';
export function createNewDatabase() { export async function createNewDatabase() {
return new Promise(resolve => { const options = {
remote.dialog.showSaveDialog( title: _('Select folder'),
remote.getCurrentWindow(), defaultPath: 'frappe-books.db'
{ };
title: _('Select folder'),
defaultPath: 'frappe-books.db' let { filePath } = await remote.dialog.showSaveDialog(options);
}, if (filePath) {
filePath => { if (!filePath.endsWith('.db')) {
if (filePath) { filePath = filePath + '.db';
if (!filePath.endsWith('.db')) { }
filePath = filePath + '.db'; if (fs.existsSync(filePath)) {
} showMessageDialog({
if (fs.existsSync(filePath)) { // prettier-ignore
showMessageDialog({ message: _('A file exists with the same name and it will be overwritten. Are you sure you want to continue?'),
// prettier-ignore buttons: [
message: _('A file exists with the same name and it will be overwritten. Are you sure you want to continue?'), {
buttons: [ label: _('Overwrite'),
{ action() {
label: _('Overwrite'), fs.unlinkSync(filePath);
action() { return filePath;
fs.unlinkSync(filePath); }
resolve(filePath); },
} { label: _('Cancel'), action() {} }
}, ]
{ label: _('Cancel'), action() {} } });
] } else {
}); return filePath;
} else { }
resolve(filePath); }
}
}
}
);
});
} }
export function loadExistingDatabase() { export function loadExistingDatabase() {