altered tag search in order to preserve case of input
re-set focus on inpt when selection option on autocomplete field Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
let selected = $state(null);
|
let selected = $state(null);
|
||||||
let candidates = $state([]);
|
let candidates = $state([]);
|
||||||
let timer = null;
|
let timer = null;
|
||||||
let list_elem;
|
let input, list_elem;
|
||||||
|
|
||||||
async function dummyGetCandidates(text){
|
async function dummyGetCandidates(text){
|
||||||
console.warn(`getCandidates(${text}) not overridden!`);
|
console.warn(`getCandidates(${text}) not overridden!`);
|
||||||
@@ -117,6 +117,7 @@
|
|||||||
function select(index){
|
function select(index){
|
||||||
candidate = candidates[index];
|
candidate = candidates[index];
|
||||||
disableDropdown();
|
disableDropdown();
|
||||||
|
input.focus();
|
||||||
onSelect(candidate);
|
onSelect(candidate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +150,7 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<span class="autocomplete">
|
<span class="autocomplete">
|
||||||
<input type="text" bind:value={candidate.display} {onkeyup} autofocus={autofocus} {id} {onblur} disabled={!enabled} />
|
<input bind:this={input} type="text" bind:value={candidate.display} {onkeyup} autofocus={autofocus} {id} {onblur} disabled={!enabled} />
|
||||||
{#if candidates && candidates.length > 0}
|
{#if candidates && candidates.length > 0}
|
||||||
<ul bind:this={list_elem} class="suggestions" tabindex="-1">
|
<ul bind:this={list_elem} class="suggestions" tabindex="-1">
|
||||||
{#each candidates as candidate,i}
|
{#each candidates as candidate,i}
|
||||||
|
|||||||
@@ -40,6 +40,11 @@ public class TagModule extends BaseHandler implements TagService {
|
|||||||
tagDb.deleteEntity(module,entityId);
|
tagDb.deleteEntity(module,entityId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteEntity(String module, long entityId, long userId) {
|
||||||
|
tagDb.deleteEntity(module,entityId,userId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doDelete(Path path, HttpExchange ex) throws IOException {
|
public boolean doDelete(Path path, HttpExchange ex) throws IOException {
|
||||||
addCors(ex);
|
addCors(ex);
|
||||||
@@ -137,9 +142,11 @@ public class TagModule extends BaseHandler implements TagService {
|
|||||||
return sendContent(ex,tuples.map(t -> Map.of(TAG,t.a,COUNT,t.b)));
|
return sendContent(ex,tuples.map(t -> Map.of(TAG,t.a,COUNT,t.b)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private String modifyCase(String entry, String key, String lKey) {
|
||||||
public void deleteEntity(String module, long entityId, long userId) {
|
if (entry.toLowerCase().startsWith(lKey)) return key + entry.substring(key.length());
|
||||||
tagDb.deleteEntity(module,entityId,userId);
|
var pos = entry.toLowerCase().indexOf(" "+lKey);
|
||||||
|
if (pos >= 0) entry = entry.substring(0,pos+1)+key+entry.substring(pos+key.length()+1);
|
||||||
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -158,8 +165,10 @@ public class TagModule extends BaseHandler implements TagService {
|
|||||||
return tagDb.search(key, user);
|
return tagDb.search(key, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean searchTags(HttpExchange ex, String head, UmbrellaUser user) throws IOException {
|
private boolean searchTags(HttpExchange ex, String key, UmbrellaUser user) throws IOException {
|
||||||
return sendContent(ex, search(head, user));
|
var tags = search(key, user);
|
||||||
|
var lKey = key.toLowerCase();
|
||||||
|
return sendContent(ex, tags.stream().map(entry -> modifyCase(entry, key, lKey)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user