sense -> relatedEntryList read/edit/view/write
This commit is contained in:
parent
8eada0d246
commit
28dc5472c6
|
@ -64,6 +64,14 @@ def export_entry(entry):
|
||||||
variant.textContent = v
|
variant.textContent = v
|
||||||
variants.appendChild(variant)
|
variants.appendChild(variant)
|
||||||
|
|
||||||
|
relist = doc.createElement("relatedEntryList")
|
||||||
|
head.appendChild(relist)
|
||||||
|
|
||||||
|
for re in entry.related_entries:
|
||||||
|
relateEntry = doc.createElement("relatedEntry")
|
||||||
|
relateEntry.textContent = re
|
||||||
|
relist.appendChild(relateEntry)
|
||||||
|
|
||||||
head.appendChild(_export_label_list(doc, entry.labels))
|
head.appendChild(_export_label_list(doc, entry.labels))
|
||||||
|
|
||||||
comment = doc.createElement("comment")
|
comment = doc.createElement("comment")
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from message.simple_messages import NoReset, Reset, ModalNotOkClose, ClickMessage, DataChgClickMessage, KeyboardPress
|
from message.simple_messages import NoReset, Reset, ModalNotOkClose, ClickMessage, DataChgClickMessage, KeyboardPress
|
||||||
from message.translation_edit import EditTranslation, MoveRight, MoveLeft, BinTranslation
|
from message.translation_edit import EditTranslation, MoveRight, MoveLeft, BinTranslation
|
||||||
from message.show_messages import ShowEntryLabelsEdit, ShowEditTranslation, ShowSenseLabelEdit, ShowSenseDefinitionEdit, ShowCommentEdit, ShowAddTranslation, ShowExampleEdit, ShowExampleTranslationEdit, ShowVariantsEdit
|
from message.show_messages import ShowEntryLabelsEdit, ShowEditTranslation, ShowSenseLabelEdit, ShowSenseDefinitionEdit, ShowCommentEdit, ShowAddTranslation, ShowExampleEdit, ShowExampleTranslationEdit, ShowVariantsEdit, ShowRelatedEntriesEdit
|
||||||
from message.simple_edits import EditSenseLabel, EditSenseDefinition, EditComment, AddSenseLabel, AddSense, EditExample, AddExampleTranslation, EditExampleTranslation, DoChosenExamples, AddToLabelList, AddToGenericList, EditVariants, EditEntryLabels
|
from message.simple_edits import EditSenseLabel, EditSenseDefinition, EditComment, AddSenseLabel, AddSense, EditExample, AddExampleTranslation, EditExampleTranslation, DoChosenExamples, AddToLabelList, AddToGenericList, EditVariants, EditRelatedEntries, EditEntryLabel
|
||||||
from message.show_menu import ShowTranslationMenu, ShowSenseMenu, ShowExampleMenu
|
from message.show_menu import ShowTranslationMenu, ShowSenseMenu, ShowExampleMenu
|
||||||
from message.sense_edit import SenseMoveUp, SenseMoveDown, SenseBin
|
from message.sense_edit import SenseMoveUp, SenseMoveDown, SenseBin
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,12 @@ class ShowVariantsEdit(ClickMessage):
|
||||||
model.modal_set(lambda: modals.edit_variants(model.entry))
|
model.modal_set(lambda: modals.edit_variants(model.entry))
|
||||||
|
|
||||||
|
|
||||||
|
class ShowRelatedEntriesEdit(ClickMessage):
|
||||||
|
def update_model(self, model):
|
||||||
|
model.entry.make_copy()
|
||||||
|
model.modal_set(lambda: modals.edit_related_entries(model.entry))
|
||||||
|
|
||||||
|
|
||||||
class ShowExampleEdit(KeyPlusClickMessage):
|
class ShowExampleEdit(KeyPlusClickMessage):
|
||||||
def update_model_default(self, model):
|
def update_model_default(self, model):
|
||||||
example = self.get_arg(0, Example)
|
example = self.get_arg(0, Example)
|
||||||
|
|
|
@ -95,6 +95,12 @@ class EditVariants(Message):
|
||||||
model.entry.variants = variants
|
model.entry.variants = variants
|
||||||
|
|
||||||
|
|
||||||
|
class EditRelatedEntries(Message):
|
||||||
|
def update_model(self, model):
|
||||||
|
related_entries = common_accessors.generic_list_getter()
|
||||||
|
model.entry.related_entries = related_entries
|
||||||
|
|
||||||
|
|
||||||
class EditEntryLabels(Message):
|
class EditEntryLabels(Message):
|
||||||
def update_model(self, model):
|
def update_model(self, model):
|
||||||
labels = common_accessors.label_list_getter()
|
labels = common_accessors.label_list_getter()
|
||||||
|
|
|
@ -14,6 +14,7 @@ class Entry(Editable):
|
||||||
self.grammar = grammar.textContent if grammar else ""
|
self.grammar = grammar.textContent if grammar else ""
|
||||||
self.comment = comment.textContent if comment else ""
|
self.comment = comment.textContent if comment else ""
|
||||||
self.variants = [v.textContent for v in entry_xml.querySelectorAll("head variantList variant")]
|
self.variants = [v.textContent for v in entry_xml.querySelectorAll("head variantList variant")]
|
||||||
|
self.related_entries = [re.textContent for re in entry_xml.querySelectorAll("head relatedEntryList relatedEntry")]
|
||||||
|
|
||||||
self.lexical_unit = {}
|
self.lexical_unit = {}
|
||||||
lex_unit = entry_xml.querySelector("lexical_unit lexeme,lexicalUnit lexeme")
|
lex_unit = entry_xml.querySelector("lexical_unit lexeme,lexicalUnit lexeme")
|
||||||
|
|
|
@ -43,6 +43,12 @@ def edit_variants(entry):
|
||||||
return modal_template(content, "Add or remove variants", message.EditVariants())
|
return modal_template(content, "Add or remove variants", message.EditVariants())
|
||||||
|
|
||||||
|
|
||||||
|
def edit_related_entries(entry):
|
||||||
|
reget = lambda: entry.copy().related_entries
|
||||||
|
content = generic_list_editor("Related entries", reget)
|
||||||
|
return modal_template(content, "Add or remove related entries", message.EditRelatedEntries())
|
||||||
|
|
||||||
|
|
||||||
def edit_entry_labels(entry):
|
def edit_entry_labels(entry):
|
||||||
content = label_list_editor(entry.copy().labels, message.AddToLabelList(entry.copy().labels))
|
content = label_list_editor(entry.copy().labels, message.AddToLabelList(entry.copy().labels))
|
||||||
return modal_template(content, "Translation", message.EditEntryLabels())
|
return modal_template(content, "Translation", message.EditEntryLabels())
|
||||||
|
|
|
@ -49,8 +49,9 @@ class View:
|
||||||
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"),
|
||||||
|
h("button.success", clk(ShowRelatedEntriesEdit()), "Povezano"),
|
||||||
h("button.success", clk(ShowEntryLabelsEdit()), "Labels"),
|
h("button.success", clk(ShowEntryLabelsEdit()), "Labels"),
|
||||||
h("button.warning", clk(ShowCommentEdit()), "Comment")]
|
h("button.normal", clk(ShowCommentEdit()), "Comment")]
|
||||||
|
|
||||||
view_buttons = []
|
view_buttons = []
|
||||||
view_table = []
|
view_table = []
|
||||||
|
@ -60,16 +61,21 @@ class View:
|
||||||
else:
|
else:
|
||||||
view_table.append((buttons[0], ", ".join(entry.variants)))
|
view_table.append((buttons[0], ", ".join(entry.variants)))
|
||||||
|
|
||||||
if len(entry.labels) == 0:
|
if len(entry.related_entries) == 0:
|
||||||
view_buttons.append(buttons[1])
|
view_buttons.append(buttons[1])
|
||||||
else:
|
else:
|
||||||
labels = ", ".join([clean_label(val) for _, val in entry.labels])
|
view_table.append((buttons[1], ", ".join(entry.related_entries)))
|
||||||
view_table.append((buttons[1], labels))
|
|
||||||
|
|
||||||
if entry.comment == "":
|
if len(entry.labels) == 0:
|
||||||
view_buttons.append(buttons[2])
|
view_buttons.append(buttons[2])
|
||||||
else:
|
else:
|
||||||
view_table.append((buttons[2], entry.comment))
|
labels = ", ".join([clean_label(val) for _, val in entry.labels])
|
||||||
|
view_table.append((buttons[2], labels))
|
||||||
|
|
||||||
|
if entry.comment == "":
|
||||||
|
view_buttons.append(buttons[3])
|
||||||
|
else:
|
||||||
|
view_table.append((buttons[3], entry.comment))
|
||||||
|
|
||||||
table_rows = [
|
table_rows = [
|
||||||
h("tr", {}, [ h("td", {}, btn), h("td", {}, content)])
|
h("tr", {}, [ h("td", {}, btn), h("td", {}, content)])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user