mirror of
https://github.com/frappe/books.git
synced 2024-11-14 01:14:03 +00:00
incr: button for db delete
This commit is contained in:
parent
fa063b719a
commit
64d1f13e42
@ -116,6 +116,10 @@ export default function registerIpcMainActionListeners(main: Main) {
|
||||
return app.getVersion();
|
||||
});
|
||||
|
||||
ipcMain.handle(IPC_ACTIONS.DELETE_FILE, async (_, filePath) => {
|
||||
await fs.unlink(filePath);
|
||||
});
|
||||
|
||||
/**
|
||||
* Database Related Actions
|
||||
*/
|
||||
|
@ -98,6 +98,21 @@
|
||||
{{ file.modified }}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
class="
|
||||
ml-auto
|
||||
p-2
|
||||
hover:bg-red-200
|
||||
rounded-full
|
||||
w-8
|
||||
h-8
|
||||
text-gray-600
|
||||
hover:text-red-400
|
||||
"
|
||||
@click.stop="() => deleteDb(i)"
|
||||
>
|
||||
<feather-icon name="x" class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<hr v-if="files?.length" />
|
||||
@ -134,16 +149,19 @@
|
||||
import { setupDummyInstance } from 'dummy';
|
||||
import { ipcRenderer } from 'electron';
|
||||
import fs from 'fs';
|
||||
import { t } from 'fyo';
|
||||
import { ConfigKeys } from 'fyo/core/types';
|
||||
import { addNewFile } from 'fyo/telemetry/helpers';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { DateTime } from 'luxon';
|
||||
import Button from 'src/components/Button.vue';
|
||||
import LanguageSelector from 'src/components/Controls/LanguageSelector.vue';
|
||||
import FeatherIcon from 'src/components/FeatherIcon.vue';
|
||||
import Loading from 'src/components/Loading.vue';
|
||||
import WindowControls from 'src/components/WindowControls.vue';
|
||||
import { fyo } from 'src/initFyo';
|
||||
import { getSavePath } from 'src/utils/ipcCalls';
|
||||
import { deleteDb, getSavePath } from 'src/utils/ipcCalls';
|
||||
import { showMessageDialog } from 'src/utils/ui';
|
||||
import { IPC_ACTIONS } from 'utils/messages';
|
||||
|
||||
export default {
|
||||
@ -166,6 +184,28 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async deleteDb(i) {
|
||||
const file = this.files[i];
|
||||
const vm = this;
|
||||
|
||||
await showMessageDialog({
|
||||
message: t`Delete ${file.companyName}?`,
|
||||
detail: t`Database file: ${file.dbPath}`,
|
||||
buttons: [
|
||||
{
|
||||
label: this.t`Yes`,
|
||||
async action() {
|
||||
await deleteDb(file.dbPath);
|
||||
vm.setFiles();
|
||||
},
|
||||
},
|
||||
{
|
||||
label: this.t`No`,
|
||||
action() {},
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
async createDemo() {
|
||||
const { filePath, canceled } = await getSavePath('demo', 'db');
|
||||
if (canceled || !filePath) {
|
||||
@ -251,6 +291,12 @@ export default {
|
||||
this.$emit('file-selected', filePath, !!isNew);
|
||||
},
|
||||
},
|
||||
components: { LanguageSelector, WindowControls, Button, Loading },
|
||||
components: {
|
||||
LanguageSelector,
|
||||
WindowControls,
|
||||
Button,
|
||||
Loading,
|
||||
FeatherIcon,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -9,10 +9,14 @@ import { WindowAction } from './types';
|
||||
import { showToast } from './ui';
|
||||
|
||||
export async function checkForUpdates(force = false) {
|
||||
ipcRenderer.invoke(IPC_ACTIONS.CHECK_FOR_UPDATES, force);
|
||||
await ipcRenderer.invoke(IPC_ACTIONS.CHECK_FOR_UPDATES, force);
|
||||
await setLanguageMap();
|
||||
}
|
||||
|
||||
export async function deleteDb(filePath: string) {
|
||||
await ipcRenderer.invoke(IPC_ACTIONS.DELETE_FILE, filePath);
|
||||
}
|
||||
|
||||
export async function saveData(data: string, savePath: string) {
|
||||
await ipcRenderer.invoke(IPC_ACTIONS.SAVE_DATA, data, savePath);
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ export enum IPC_ACTIONS {
|
||||
GET_FILE = 'get-file',
|
||||
GET_CREDS = 'get-creds',
|
||||
GET_VERSION = 'get-version',
|
||||
DELETE_FILE = 'delete-file',
|
||||
// Database messages
|
||||
DB_CREATE = 'db-create',
|
||||
DB_CONNECT = 'db-connect',
|
||||
|
Loading…
Reference in New Issue
Block a user