forked from MapComplete/MapComplete
Improve wikidata search with filtering, add search box for species to trees
This commit is contained in:
parent
1271f24160
commit
389e3f18a0
7 changed files with 249 additions and 113 deletions
42
test.ts
42
test.ts
|
@ -1,31 +1,17 @@
|
|||
import Combine from "./UI/Base/Combine";
|
||||
import ValidatedTextField from "./UI/Input/ValidatedTextField";
|
||||
import Title from "./UI/Base/Title";
|
||||
import {FixedUiElement} from "./UI/Base/FixedUiElement";
|
||||
import {VariableUiElement} from "./UI/Base/VariableUIElement";
|
||||
import {UIEventSource} from "./Logic/UIEventSource";
|
||||
import {Translation} from "./UI/i18n/Translation";
|
||||
import Wikidata from "./Logic/Web/Wikidata";
|
||||
import Combine from "./UI/Base/Combine";
|
||||
import {FixedUiElement} from "./UI/Base/FixedUiElement";
|
||||
|
||||
new Combine(
|
||||
ValidatedTextField.AvailableTypes().map(key => {
|
||||
let inp;
|
||||
const feedback = new UIEventSource<Translation>(undefined)
|
||||
try {
|
||||
inp = ValidatedTextField.ForType(key).ConstructInputElement({
|
||||
feedback,
|
||||
country: () => "be"
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
inp = new FixedUiElement(e).SetClass("alert")
|
||||
}
|
||||
|
||||
return new Combine([
|
||||
new Title(key),
|
||||
inp,
|
||||
new VariableUiElement(inp.GetValue()),
|
||||
new VariableUiElement(feedback.map(v => v?.SetClass("alert")))
|
||||
]);
|
||||
}
|
||||
)
|
||||
).AttachTo("maindiv")
|
||||
const result = UIEventSource.FromPromise(
|
||||
Wikidata.searchAdvanced("WOlf", {
|
||||
lang: "nl",
|
||||
maxCount: 100,
|
||||
instanceOf: 5
|
||||
})
|
||||
)
|
||||
result.addCallbackAndRunD(r => console.log(r))
|
||||
new VariableUiElement(result.map(items =>new Combine( (items??[])?.map(i =>
|
||||
new FixedUiElement(JSON.stringify(i, null, " ")).SetClass("p-4 block")
|
||||
)) )).SetClass("flex flex-col").AttachTo("maindiv")
|
Loading…
Add table
Add a link
Reference in a new issue