changed view/css to actually show selected examples

pull/1/head
Ozbolt Menegatti 4 years ago
parent e7283c3ba1
commit 4c7ade67fc

@ -154,6 +154,8 @@
} }
.example { .example {
clear: left;
.example-dot, .example-rest { .example-dot, .example-rest {
float: left; float: left;
} }
@ -162,6 +164,14 @@
margin-right: 1em; margin-right: 1em;
} }
.example-rest {
border: 1px transparent solid;
}
.example-chosen {
border: 1px @gray solid;
}
.example-text { .example-text {
._hoverable(); ._hoverable();
} }

@ -21,14 +21,14 @@ class View:
def _view(self): def _view(self):
return h("div", {"on": { "click": msg(Reset()) }}, [ return h("div", {"on": { "click": msg(Reset()) }}, [
View.view_entry(self.model.entry), View.view_entry(self.model.entry, self.model),
h("button.blk", {"on": { "click": lambda _: console.log(export_to_xml(self.model)) } }, "XML2Console"), # h("button.blk", {"on": { "click": lambda _: console.log(export_to_xml(self.model)) } }, "XML2Console"),
View.view_menu(self.model.menu_location, self.model.menu_target), View.view_menu(self.model.menu_location, self.model.menu_target),
View.view_modal(self.model.modal_shown, self.model.modal)]) View.view_modal(self.model.modal_shown, self.model.modal)])
@staticmethod @staticmethod
def view_entry(entry): def view_entry(entry, model):
view_sense_list = [View.view_sense(sense, idx) for idx, sense in enumerate(entry.senses)] view_sense_list = [View.view_sense(sense, idx, model) for idx, sense in enumerate(entry.senses)]
return h("div#entry", {}, [ return h("div#entry", {}, [
h("div#entry-status", {}, entry.status), h("div#entry-status", {}, entry.status),
@ -36,13 +36,13 @@ class View:
h("span#headword", {}, entry.headword), h("span#headword", {}, entry.headword),
h("span#grammar", {}, entry.grammar), h("span#grammar", {}, entry.grammar),
h("span#measure", {}, entry.get_measure_text())]), h("span#measure", {}, entry.get_measure_text())]),
View.view_entry_button_section(entry), View.view_entry_button_section(entry, model),
h("div#sense-container", {}, view_sense_list), h("div#sense-container", {}, view_sense_list),
h("button.add-button", {"on": {"click": msg(AddSense())}}, "+")]) h("button.add-button", {"on": {"click": msg(AddSense())}}, "+")])
@staticmethod @staticmethod
def view_entry_button_section(entry): def view_entry_button_section(entry, model):
clk = lambda cls: {"on": {"click": msg(cls)}} clk = lambda cls: {"on": {"click": msg(cls)}}
buttons = [ buttons = [
h("button.normal", clk(ShowVariantsEdit()), "Variants"), h("button.normal", clk(ShowVariantsEdit()), "Variants"),
@ -76,8 +76,8 @@ class View:
return h("div", {}, view_buttons) return h("div", {}, view_buttons)
@staticmethod @staticmethod
def view_sense(sense, senseNum): def view_sense(sense, senseNum, model):
examples = [View.view_example(example) for example in sense.examples] examples = [View.view_example(example, model) for example in sense.examples]
return h("div.elm-div", {}, [ return h("div.elm-div", {}, [
h("div.sense-num", {"on": {"click": msg(ShowSenseMenu(sense))}}, str(senseNum + 1)), h("div.sense-num", {"on": {"click": msg(ShowSenseMenu(sense))}}, str(senseNum + 1)),
@ -85,14 +85,18 @@ class View:
h("span.sense-label-list", { "on": { "click": msg(ShowSenseLabelEdit(sense)) }}, [ h("span.sense-label-list", { "on": { "click": msg(ShowSenseLabelEdit(sense)) }}, [
h("span.sense-label", {}, clean_label(slabel)) for _, slabel in sense.labels ]), h("span.sense-label", {}, clean_label(slabel)) for _, slabel in sense.labels ]),
h("span.sense-definition", { "on": { "click": msg(ShowSenseDefinitionEdit(sense)) }}, sense.definition), h("span.sense-definition", { "on": { "click": msg(ShowSenseDefinitionEdit(sense)) }}, sense.definition),
h("div", {}, View.view_translations(sense.translations, sense)), h("div", {}, View.view_translations(sense.translations, sense, model)),
h("div", {}, examples)])]) h("div", {}, examples)])])
@staticmethod @staticmethod
def view_example(example): def view_example(example, model):
example_tag = "div.example-rest"
if example in model.chosen_examples:
example_tag += ".example-chosen"
return h("div.example", {}, [ return h("div.example", {}, [
h("div.example-dot", {}, ""), h("div.example-dot", {}, ""),
h("div.example-rest", {}, [ h(example_tag, {}, [
h("span.example-text", {"on": {"click": msg(ShowExampleEdit(example))} }, example.example), h("span.example-text", {"on": {"click": msg(ShowExampleEdit(example))} }, example.example),
h("div.example-translation-list", { "on": {"click": msg(ShowExampleTranslationEdit(example))} }, [ h("div.example-translation-list", { "on": {"click": msg(ShowExampleTranslationEdit(example))} }, [
h("div.example-translation", {}, [ h("div.example-translation", {}, [
@ -101,16 +105,16 @@ class View:
for t in example.translations])])]) for t in example.translations])])])
@staticmethod @staticmethod
def view_translations(translations, sense): def view_translations(translations, sense, model):
result = [] result = []
for cluster in translations: for cluster in translations:
result.append(h("div.translation-div-cluster", {}, [View.view_one_translation(t) for t in cluster])) result.append(h("div.translation-div-cluster", {}, [View.view_one_translation(t, model) for t in cluster]))
result.append(h("button.add-button", {"on": {"click": msg(ShowAddTranslation(sense))}}, "+")) result.append(h("button.add-button", {"on": {"click": msg(ShowAddTranslation(sense))}}, "+"))
return result return result
@staticmethod @staticmethod
def view_one_translation(translation): def view_one_translation(translation, model):
elements = [] elements = []
if translation.tags: if translation.tags:

Loading…
Cancel
Save