mirror of
https://github.com/garraflavatra/rolens.git
synced 2025-01-18 13:07:58 +00:00
Find view: paste ID and press Enter (fixes #55)
This commit is contained in:
parent
5476df5fe9
commit
6027ab155a
@ -22,3 +22,10 @@ export function looseJsonIsValid(json) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function stringCouldBeID(string) {
|
||||||
|
if (looseJsonIsValid(string)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return /^[a-zA-Z0-9_-]{1,}$/.test(string);
|
||||||
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
import { startProgress } from '$lib/progress';
|
import { startProgress } from '$lib/progress';
|
||||||
import applicationSettings from '$lib/stores/settings';
|
import applicationSettings from '$lib/stores/settings';
|
||||||
import views from '$lib/stores/views';
|
import views from '$lib/stores/views';
|
||||||
import { convertLooseJson } from '$lib/strings';
|
import { convertLooseJson, stringCouldBeID } from '$lib/strings';
|
||||||
import { FindItems, RemoveItemById, UpdateFoundDocument } from '$wails/go/app/App';
|
import { FindItems, RemoveItemById, UpdateFoundDocument } from '$wails/go/app/App';
|
||||||
import { EJSON } from 'bson';
|
import { EJSON } from 'bson';
|
||||||
|
|
||||||
@ -46,6 +46,10 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stringCouldBeID(form.query)) {
|
||||||
|
form.query = `{ "_id": "${form.query}" }`;
|
||||||
|
}
|
||||||
|
|
||||||
querying = `Querying ${collection.key}…`;
|
querying = `Querying ${collection.key}…`;
|
||||||
activePath = [];
|
activePath = [];
|
||||||
const newResult = await FindItems(collection.hostKey, collection.dbKey, collection.key, JSON.stringify({
|
const newResult = await FindItems(collection.hostKey, collection.dbKey, collection.key, JSON.stringify({
|
||||||
@ -172,7 +176,7 @@
|
|||||||
placeholder={defaults.query}
|
placeholder={defaults.query}
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
spellcheck="false"
|
spellcheck="false"
|
||||||
use:input={{ type: 'json', autofocus: true }}
|
use:input
|
||||||
bind:this={queryField}
|
bind:this={queryField}
|
||||||
bind:value={form.query}
|
bind:value={form.query}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user