mirror of
https://github.com/garraflavatra/rolens.git
synced 2025-01-18 13:07:58 +00:00
Rename collection through zenity dialog
This commit is contained in:
parent
5968357abc
commit
1f76b16e75
@ -1,7 +1,4 @@
|
|||||||
<script>
|
<script>
|
||||||
import Icon from '$components/icon.svelte';
|
|
||||||
import Modal from '$components/modal.svelte';
|
|
||||||
import input from '$lib/actions/input';
|
|
||||||
import busy from '$lib/stores/busy';
|
import busy from '$lib/stores/busy';
|
||||||
import { connections } from '$lib/stores/connections';
|
import { connections } from '$lib/stores/connections';
|
||||||
import { EnterText, Hosts, RenameCollection } from '$wails/go/app/App';
|
import { EnterText, Hosts, RenameCollection } from '$wails/go/app/App';
|
||||||
@ -18,13 +15,8 @@
|
|||||||
export let activeCollKey = '';
|
export let activeCollKey = '';
|
||||||
|
|
||||||
let hostTree;
|
let hostTree;
|
||||||
|
|
||||||
let showHostDetail = false;
|
let showHostDetail = false;
|
||||||
let hostDetailKey = '';
|
let hostDetailKey = '';
|
||||||
|
|
||||||
let collToRename = '';
|
|
||||||
let newCollKey = '';
|
|
||||||
|
|
||||||
let exportInfo;
|
let exportInfo;
|
||||||
|
|
||||||
async function getHosts() {
|
async function getHosts() {
|
||||||
@ -48,21 +40,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function openEditCollModal(collKey) {
|
async function renameCollection(oldCollKey) {
|
||||||
newCollKey = collKey;
|
const newCollKey = await EnterText('Rename collection', `Enter a new name for collection ${oldCollKey}.`, oldCollKey);
|
||||||
collToRename = collKey;
|
if (newCollKey && (newCollKey !== oldCollKey)) {
|
||||||
}
|
busy.start();
|
||||||
|
const ok = await RenameCollection(activeHostKey, activeDbKey, oldCollKey, newCollKey);
|
||||||
async function renameCollection() {
|
if (ok) {
|
||||||
busy.start();
|
activeCollKey = newCollKey;
|
||||||
const ok = await RenameCollection(activeHostKey, activeDbKey, collToRename, newCollKey);
|
await hostTree.reload();
|
||||||
if (ok) {
|
}
|
||||||
activeCollKey = newCollKey;
|
busy.end();
|
||||||
collToRename = '';
|
|
||||||
newCollKey = '';
|
|
||||||
await hostTree.reload();
|
|
||||||
}
|
}
|
||||||
busy.end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createCollection() {
|
async function createCollection() {
|
||||||
@ -109,7 +97,7 @@
|
|||||||
on:newDatabase={createDatabase}
|
on:newDatabase={createDatabase}
|
||||||
on:newCollection={createCollection}
|
on:newCollection={createCollection}
|
||||||
on:editHost={e => editHost(e.detail)}
|
on:editHost={e => editHost(e.detail)}
|
||||||
on:renameCollection={e => openEditCollModal(e.detail)}
|
on:renameCollection={e => renameCollection(e.detail)}
|
||||||
on:exportCollection={e => exportCollection(e.detail)}
|
on:exportCollection={e => exportCollection(e.detail)}
|
||||||
on:dumpCollection={e => dumpCollection(e.detail)}
|
on:dumpCollection={e => dumpCollection(e.detail)}
|
||||||
/>
|
/>
|
||||||
@ -132,49 +120,9 @@
|
|||||||
|
|
||||||
<Export bind:info={exportInfo} {hosts} />
|
<Export bind:info={exportInfo} {hosts} />
|
||||||
|
|
||||||
{#if collToRename}
|
|
||||||
<Modal bind:show={collToRename} width="400px">
|
|
||||||
<form class="rename" on:submit|preventDefault={renameCollection}>
|
|
||||||
<div>Renaming collection <strong>{collToRename}</strong></div>
|
|
||||||
<Icon name="arr-d" />
|
|
||||||
<label class="field">
|
|
||||||
<input type="text" bind:value={newCollKey} use:input={{ autofocus: true }} spellcheck="false" />
|
|
||||||
</label>
|
|
||||||
<div class="cancelorsave">
|
|
||||||
<button class="btn secondary" type="button" on:click={() => collToRename = ''}>Cancel</button>
|
|
||||||
<button class="btn" type="submit">Save</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</Modal>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.tree {
|
.tree {
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rename {
|
|
||||||
text-align: center;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.5rem;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
.rename .field {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.rename input {
|
|
||||||
text-align: center;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.rename strong {
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
.rename .cancelorsave {
|
|
||||||
display: flex;
|
|
||||||
gap: 0.5rem;
|
|
||||||
justify-content: space-between;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
2
frontend/wailsjs/go/app/App.d.ts
vendored
2
frontend/wailsjs/go/app/App.d.ts
vendored
@ -19,7 +19,7 @@ export function DropDatabase(arg1:string,arg2:string):Promise<boolean>;
|
|||||||
|
|
||||||
export function DropIndex(arg1:string,arg2:string,arg3:string,arg4:string):Promise<boolean>;
|
export function DropIndex(arg1:string,arg2:string,arg3:string,arg4:string):Promise<boolean>;
|
||||||
|
|
||||||
export function EnterText(arg1:string,arg2:string):Promise<string>;
|
export function EnterText(arg1:string,arg2:string,arg3:string):Promise<string>;
|
||||||
|
|
||||||
export function Environment():Promise<app.EnvironmentInfo>;
|
export function Environment():Promise<app.EnvironmentInfo>;
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ export function DropIndex(arg1, arg2, arg3, arg4) {
|
|||||||
return window['go']['app']['App']['DropIndex'](arg1, arg2, arg3, arg4);
|
return window['go']['app']['App']['DropIndex'](arg1, arg2, arg3, arg4);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function EnterText(arg1, arg2) {
|
export function EnterText(arg1, arg2, arg3) {
|
||||||
return window['go']['app']['App']['EnterText'](arg1, arg2);
|
return window['go']['app']['App']['EnterText'](arg1, arg2, arg3);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Environment() {
|
export function Environment() {
|
||||||
|
@ -167,9 +167,8 @@ func (a *App) OpenDirectory(id, title string) string {
|
|||||||
return dir
|
return dir
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) EnterText(title, info string) string {
|
func (a *App) EnterText(title, info, defaultEntry string) string {
|
||||||
println("wertyuijhgfd")
|
input, err := zenity.Entry(info, zenity.Title(title), zenity.EntryText(defaultEntry))
|
||||||
input, err := zenity.Entry(info, zenity.Title(title))
|
|
||||||
|
|
||||||
if err == zenity.ErrCanceled {
|
if err == zenity.ErrCanceled {
|
||||||
return ""
|
return ""
|
||||||
|
Loading…
Reference in New Issue
Block a user