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 candidates = $state([]);
|
||||
let timer = null;
|
||||
let list_elem;
|
||||
let input, list_elem;
|
||||
|
||||
async function dummyGetCandidates(text){
|
||||
console.warn(`getCandidates(${text}) not overridden!`);
|
||||
@@ -117,6 +117,7 @@
|
||||
function select(index){
|
||||
candidate = candidates[index];
|
||||
disableDropdown();
|
||||
input.focus();
|
||||
onSelect(candidate);
|
||||
}
|
||||
|
||||
@@ -149,7 +150,7 @@
|
||||
</style>
|
||||
|
||||
<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}
|
||||
<ul bind:this={list_elem} class="suggestions" tabindex="-1">
|
||||
{#each candidates as candidate,i}
|
||||
|
||||
@@ -40,6 +40,11 @@ public class TagModule extends BaseHandler implements TagService {
|
||||
tagDb.deleteEntity(module,entityId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteEntity(String module, long entityId, long userId) {
|
||||
tagDb.deleteEntity(module,entityId,userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doDelete(Path path, HttpExchange ex) throws IOException {
|
||||
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)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteEntity(String module, long entityId, long userId) {
|
||||
tagDb.deleteEntity(module,entityId,userId);
|
||||
private String modifyCase(String entry, String key, String lKey) {
|
||||
if (entry.toLowerCase().startsWith(lKey)) return key + entry.substring(key.length());
|
||||
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
|
||||
@@ -158,8 +165,10 @@ public class TagModule extends BaseHandler implements TagService {
|
||||
return tagDb.search(key, user);
|
||||
}
|
||||
|
||||
private boolean searchTags(HttpExchange ex, String head, UmbrellaUser user) throws IOException {
|
||||
return sendContent(ex, search(head, user));
|
||||
private boolean searchTags(HttpExchange ex, String key, UmbrellaUser user) throws IOException {
|
||||
var tags = search(key, user);
|
||||
var lKey = key.toLowerCase();
|
||||
return sendContent(ex, tags.stream().map(entry -> modifyCase(entry, key, lKey)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user