1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-01-18 13:07:58 +00:00

Find view: confirm deletion (fixes #58)

This commit is contained in:
Romein van Buren 2023-07-19 21:07:50 +02:00
parent 3d13dd974e
commit 5deab93162
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49
5 changed files with 42 additions and 1 deletions

View File

@ -1,3 +1,4 @@
import { AskConfirmation } from '$wails/go/app/App';
import InputDialog from '../dialogs/input.svelte'; import InputDialog from '../dialogs/input.svelte';
function newDialog(dialogComponent, data = {}) { function newDialog(dialogComponent, data = {}) {
@ -29,6 +30,10 @@ function enterText(title = '', description = '', value = '') {
}); });
} }
const dialogs = { new: newDialog, enterText }; function confirm(message = '') {
return AskConfirmation(message);
}
const dialogs = { new: newDialog, enterText, confirm };
export default dialogs; export default dialogs;

View File

@ -4,6 +4,7 @@
import ObjectGrid from '$components/objectgrid.svelte'; import ObjectGrid from '$components/objectgrid.svelte';
import ObjectViewer from '$components/objectviewer.svelte'; import ObjectViewer from '$components/objectviewer.svelte';
import input from '$lib/actions/input'; import input from '$lib/actions/input';
import dialogs from '$lib/dialogs';
import { deepClone } from '$lib/objects'; import { deepClone } from '$lib/objects';
import { startProgress } from '$lib/progress'; import { startProgress } from '$lib/progress';
import applicationSettings from '$lib/stores/settings'; import applicationSettings from '$lib/stores/settings';
@ -119,6 +120,10 @@
if (!activePath[0]) { if (!activePath[0]) {
return; return;
} }
const sure = await dialogs.confirm('Are you sure you wish to delete this item?');
if (!sure) {
return;
}
const ok = await RemoveItemById(collection.hostKey, collection.dbKey, collection.key, activePath[0]); const ok = await RemoveItemById(collection.hostKey, collection.dbKey, collection.key, activePath[0]);
if (ok) { if (ok) {
await submitQuery(); await submitQuery();

2
frontend/wailsjs/go/app/App.d.ts generated vendored
View File

@ -10,6 +10,8 @@ export function AddHost(arg1:string):Promise<string>;
export function Aggregate(arg1:string,arg2:string,arg3:string,arg4:string,arg5:string):Promise<void>; export function Aggregate(arg1:string,arg2:string,arg3:string,arg4:string,arg5:string):Promise<void>;
export function AskConfirmation(arg1:string):Promise<boolean>;
export function CreateIndex(arg1:string,arg2:string,arg3:string,arg4:string):Promise<string>; export function CreateIndex(arg1:string,arg2:string,arg3:string,arg4:string):Promise<string>;
export function DropCollection(arg1:string,arg2:string,arg3:string):Promise<boolean>; export function DropCollection(arg1:string,arg2:string,arg3:string):Promise<boolean>;

View File

@ -10,6 +10,10 @@ export function Aggregate(arg1, arg2, arg3, arg4, arg5) {
return window['go']['app']['App']['Aggregate'](arg1, arg2, arg3, arg4, arg5); return window['go']['app']['App']['Aggregate'](arg1, arg2, arg3, arg4, arg5);
} }
export function AskConfirmation(arg1) {
return window['go']['app']['App']['AskConfirmation'](arg1);
}
export function CreateIndex(arg1, arg2, arg3, arg4) { export function CreateIndex(arg1, arg2, arg3, arg4) {
return window['go']['app']['App']['CreateIndex'](arg1, arg2, arg3, arg4); return window['go']['app']['App']['CreateIndex'](arg1, arg2, arg3, arg4);
} }

View File

@ -141,3 +141,28 @@ func (a *App) ReportSharedStateVariable(key, value string) {
a.State.Store(key, value) a.State.Store(key, value)
wailsRuntime.LogDebug(a.ctx, fmt.Sprintf("State: %s=\"%s\"", key, value)) wailsRuntime.LogDebug(a.ctx, fmt.Sprintf("State: %s=\"%s\"", key, value))
} }
func (a *App) AskConfirmation(message string) bool {
var title string = ""
if runtime.GOOS == "darwin" {
title = message
message = ""
} else {
title = "Confirm"
}
button, err := wailsRuntime.MessageDialog(a.ctx, wailsRuntime.MessageDialogOptions{
Type: wailsRuntime.QuestionDialog,
Title: title,
Message: message,
Buttons: []string{"Yes", "No"},
DefaultButton: "Yes",
CancelButton: "No",
})
if err == nil {
return button == "Yes"
} else {
return false
}
}