Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
6064d9847c | |||
235a90b0a7 | |||
4abddac94f | |||
f12c353905 |
5
app.go
5
app.go
@@ -2,7 +2,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
|
||||||
|
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
// App struct
|
// App struct
|
||||||
@@ -139,5 +140,5 @@ func (a *App) SetSetting(key string, value int64) WailsGenericAck {
|
|||||||
|
|
||||||
//region other
|
//region other
|
||||||
func (a *App) Close() {
|
func (a *App) Close() {
|
||||||
os.Exit(0)
|
runtime.Quit(a.ctx)
|
||||||
}
|
}
|
@@ -30,9 +30,24 @@
|
|||||||
name = name.trim();
|
name = name.trim();
|
||||||
if (!name) {
|
if (!name) {
|
||||||
foodSearch = [];
|
foodSearch = [];
|
||||||
|
} else {
|
||||||
|
updateAutocomplete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateAutocomplete() {
|
||||||
|
if (!per100Edited)
|
||||||
|
GetLastPer100(name.trim()).then((res) => {
|
||||||
|
// Prevent search when there's nothing to search
|
||||||
|
// Sometimes we get search results after deleting name
|
||||||
|
if (res.success && res.data && name) {
|
||||||
|
foodSearch = res.data;
|
||||||
|
} else {
|
||||||
|
foodSearch = [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function update(event: KeyboardEvent & { currentTarget: EventTarget & HTMLTableCellElement }) {
|
async function update(event: KeyboardEvent & { currentTarget: EventTarget & HTMLTableCellElement }) {
|
||||||
name = name.trim();
|
name = name.trim();
|
||||||
amount = amount.trim();
|
amount = amount.trim();
|
||||||
@@ -69,17 +84,6 @@
|
|||||||
nameElement.focus();
|
nameElement.focus();
|
||||||
foodSearch = [];
|
foodSearch = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!per100Edited)
|
|
||||||
GetLastPer100(name.trim()).then((res) => {
|
|
||||||
// Prevent search when there's nothing to search
|
|
||||||
// Sometimes we get search results after deleting name
|
|
||||||
if (res.success && res.data && name) {
|
|
||||||
foodSearch = res.data;
|
|
||||||
} else {
|
|
||||||
foodSearch = [];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let hiLiteIndex: number | null = null;
|
let hiLiteIndex: number | null = null;
|
||||||
@@ -101,7 +105,7 @@
|
|||||||
// }
|
// }
|
||||||
function setInputVal(food: main.Food) {
|
function setInputVal(food: main.Food) {
|
||||||
name = food.food;
|
name = food.food;
|
||||||
per100 = String(food.per100)
|
per100 = String(food.per100);
|
||||||
hiLiteIndex = null;
|
hiLiteIndex = null;
|
||||||
foodSearch = [];
|
foodSearch = [];
|
||||||
}
|
}
|
||||||
@@ -132,6 +136,8 @@
|
|||||||
contenteditable="true"
|
contenteditable="true"
|
||||||
autofocus
|
autofocus
|
||||||
on:keydown={update}
|
on:keydown={update}
|
||||||
|
on:focusin={updateAutocomplete}
|
||||||
|
on:focusout={() => foodSearch = []}
|
||||||
bind:this={nameElement}
|
bind:this={nameElement}
|
||||||
/>
|
/>
|
||||||
<td
|
<td
|
||||||
@@ -161,11 +167,7 @@
|
|||||||
{#if foodSearch.length > 0}
|
{#if foodSearch.length > 0}
|
||||||
<ul bind:this={autocompleteList} class="z-50 fixed top-0 left-0 w-3/12 border border-x-gray-800">
|
<ul bind:this={autocompleteList} class="z-50 fixed top-0 left-0 w-3/12 border border-x-gray-800">
|
||||||
{#each foodSearch as f, i}
|
{#each foodSearch as f, i}
|
||||||
<FoodSearchEntry
|
<FoodSearchEntry itemLabel={f.food} highlighted={i == hiLiteIndex} on:click={() => setInputVal(f)} />
|
||||||
itemLabel={f.food}
|
|
||||||
highlighted={i == hiLiteIndex}
|
|
||||||
on:click={() => setInputVal(f)}
|
|
||||||
/>
|
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
{/if}
|
{/if}
|
||||||
|
BIN
spellfix.dll
Normal file
BIN
spellfix.dll
Normal file
Binary file not shown.
Reference in New Issue
Block a user