2
0
mirror of https://github.com/frappe/books.git synced 2025-02-09 23:48:56 +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,15 +9,13 @@ 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(
remote.getCurrentWindow(),
{
title: _('Select folder'), title: _('Select folder'),
defaultPath: 'frappe-books.db' defaultPath: 'frappe-books.db'
}, };
filePath => {
let { filePath } = await remote.dialog.showSaveDialog(options);
if (filePath) { if (filePath) {
if (!filePath.endsWith('.db')) { if (!filePath.endsWith('.db')) {
filePath = filePath + '.db'; filePath = filePath + '.db';
@ -31,19 +29,16 @@ export function createNewDatabase() {
label: _('Overwrite'), label: _('Overwrite'),
action() { action() {
fs.unlinkSync(filePath); fs.unlinkSync(filePath);
resolve(filePath); return filePath;
} }
}, },
{ label: _('Cancel'), action() {} } { label: _('Cancel'), action() {} }
] ]
}); });
} else { } else {
resolve(filePath); return filePath;
} }
} }
}
);
});
} }
export function loadExistingDatabase() { export function loadExistingDatabase() {