Should be finished v2

This commit is contained in:
matic_t
2020-10-05 06:54:01 -07:00
parent 5e741343c3
commit 5f26dd6034
6 changed files with 64 additions and 9 deletions

View File

@@ -2,6 +2,11 @@ from lib.snabbdom import h
import message
from view.modal_templates import *
from view.utils import show_toggle_cluster_buttons
from export import export_to_xml, export_example_to_entry_xml
from update import update
from model.entry import Entry
import lib.screenful as screenful
from model.model import Model
import model
@@ -127,7 +132,37 @@ def edit_comment(comment):
return modal_template(big_question("Edit comment", comment), "Comment", (message.EditComment,), (message.DeleteComment,))
def do_chosen_examples(example_list, entry):
def do_chosen_examples(example_list, model, multiword_example):
if multiword_example is False:
return move_examples_to_sense(example_list, model.entry)
else:
return modal_template([
h("button.shyButton", {"on": {"click": (lambda: move_to_view(example_list, model))}}, "Premakni v pomen"),
h("button.shyButton", {"on": {"click": (lambda: export_to_new_entry())}},
"Izvozi v novo geslo")], "Izberite željeno akcijo", None)
def move_to_view(example_list, model):
model.modal_reset()
model.modal_set(lambda: move_examples_to_sense(example_list, model.entry))
update.view.view(model, True)
def export_to_new_entry(multiword_example, example_list):
other_examples = []
for example in example_list:
if example.is_multiword() is False:
other_examples.append(example)
entry_xml = export_example_to_entry_xml(multiword_example, other_examples if len(example_list) > 0 else None)
new_entry = Entry()
new_entry.import_xml(entry_xml)
new_model = Model()
new_model.entry = new_entry
screenful.screenful().Editor['new'](None, export_to_xml(new_model))
def move_examples_to_sense(example_list, entry):
example_senses = []
for idx, sense in enumerate(entry.senses):
for ex in sense.examples:
@@ -150,7 +185,7 @@ def do_chosen_examples(example_list, entry):
options.append(h("label.checkable", {"attrs": {"for": id_}}, text))
options.append(h("br", {}, []))
return modal_template(options, "Examples picker", (message.DoChosenExamples, example_list))
return modal_template(options, "Examples picker", (message.MoveExamplesToSense, example_list))
def ske_list(search_term, data, page_num, senses, ske_kinds):