implementing ske stuff
This commit is contained in:
@@ -129,3 +129,38 @@ def do_chosen_examples(example_list, entry):
|
||||
options.append(h("br", {}, []))
|
||||
|
||||
return modal_template(options, "Examples picker", (message.DoChosenExamples, example_list))
|
||||
|
||||
|
||||
def ske_list(search_term, data, senses, ske_kinds):
|
||||
list_contents = []
|
||||
ske_list_hidden = False
|
||||
|
||||
if data is None:
|
||||
list_contents.append(h("div.loadingspinner", {}, ""))
|
||||
elif type(data) is list:
|
||||
for line in data:
|
||||
list_contents.append(h("label.ske-line", {}, [
|
||||
h("input.ske-line-check", {"props": { "type": "checkbox" }}, ""),
|
||||
h("span.checkable", {}, line.view())]))
|
||||
elif type(data) is str:
|
||||
ske_list_hidden = True
|
||||
else:
|
||||
list_contents.append(h("span.error", {}, "Something went wrong in SKE: {}".format(data)))
|
||||
|
||||
contents = [
|
||||
h("div.flex.three", {}, [
|
||||
h("select#ske-select.third", {}, [
|
||||
h("option", {}, "{}".format(x)) for x in ske_kinds]),
|
||||
h("label.third.ske-mid-input", {}, [
|
||||
h("input#ske-search", {"props": {"value": search_term, "type": "text"}}, "")]),
|
||||
h("span.third.button.ske-right-button",
|
||||
{"on": {"click": message.msg(message.SearchInSkeModal)}}, "Isci")]),
|
||||
h("div.ske-list",
|
||||
{"style": {"visibility": "hidden" if ske_list_hidden else "visible"}},
|
||||
list_contents),
|
||||
h("div.flex.three", {}, [
|
||||
h("span.third", {}, "Vstavi v:"),
|
||||
h("select#ske-sense-select.two-third", {}, [ h("option", {}, "{} {}".format(
|
||||
idx + 1, sense.definition["indicator"])) for idx, sense in enumerate(senses)])])]
|
||||
|
||||
return modal_template(contents, "SKE", (message.SkeInsert, data))
|
||||
|
||||
@@ -42,7 +42,8 @@ class View:
|
||||
txt_clusters = "Hide clusters" if model.clusters_shown else "Show clusters"
|
||||
|
||||
return [h("span.button.toggle", {"on": {"click": msg(ToggleExamples)}}, txt_examples),
|
||||
h("span.button.toggle", {"on": {"click": msg(ToggleClusters)}}, txt_clusters)]
|
||||
h("span.button.toggle", {"on": {"click": msg(ToggleClusters)}}, txt_clusters),
|
||||
View.view_ske_button(model)]
|
||||
|
||||
@staticmethod
|
||||
def view_translations(translations, parent, model):
|
||||
@@ -53,6 +54,20 @@ class View:
|
||||
result.append(h("button.add-button", {"on": {"click": msg(ShowAddTranslation, parent)}}, "+"))
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def view_ske_button(model):
|
||||
return h(
|
||||
"span#ske-button.button.toggle",
|
||||
{ "on": {"click": msg(ShowSkeModal, model.entry.headword, 0)} },
|
||||
h("svg#ske-img", {
|
||||
"attrs": {
|
||||
"xmlns": "http://www.w3.org/2000/svg",
|
||||
"height": "1.4em",
|
||||
"viewBox": "0 0 9.82 9.82" }},
|
||||
h("path", {"attrs": {
|
||||
"d": "M0 5C0 .1 0 .1 4.9.1s4.9 0 4.9 4.9 0 4.9-4.9 4.9S0 9.9 0 5zm6.05 4.36C9.28 8.518 10.46 4.68 8.3 2c-.432-.54-2.04.978-2.05 1.93-.001.227.01.233.486.233 1.58.001 1.8 2.17.26 2.42-2.44.396-2.43-3.48.018-5.05.52-.334.53-.296-.125-.602-4.62-2.16-8.77 3.6-5.2 7.24.624.638.99.562 1.6-.328.543-.798.56-1.23.047-1.23-1.12 0-1.77-.88-1.32-1.77.564-1.1 2.2-.863 2.64.4.385 1.12.006 2.36-1.03 3.36-.61.588-.594.62.38.838.398.09 1.57.048 2.03-.072z",
|
||||
"fill": "#fff"}})))
|
||||
|
||||
@staticmethod
|
||||
def view_menu(location, menu_target, entry):
|
||||
style = {
|
||||
|
||||
Reference in New Issue
Block a user