edited/modified example atribute supported

This commit is contained in:
Ozbolt Menegatti 2020-05-19 22:10:36 +02:00
parent 42aef17473
commit b24af95d5d
2 changed files with 9 additions and 1 deletions

View File

@ -49,6 +49,7 @@ class EditExampleText(Message):
def update_model(self, model):
example = self.get_arg(0, Example)
example.overwrite_with_copy()
example.edited = True
idx = 0
for txt in document.getElementsByClassName("example-component-text"):

View File

@ -15,17 +15,21 @@ class Example(Data):
self.translations = []
self.inner = None
self.components = []
self.edited = False
def import_xml(self, example_xml):
self.translations = from_container_list(example_xml.querySelectorAll("translationContainer"))
if example_xml.hasAttribute("modified"):
self.edited = example_xml.getAttribute("modified") == "true"
inner_xml = example_xml.querySelector("corpusExample")
if inner_xml is not None:
self.inner = CorpusExample()
else:
inner_xml = example_xml.querySelector("multiwordExample")
self.inner = MultiwordExample()
self.inner.import_xml(inner_xml)
for comp_xml in inner_xml.childNodes:
@ -37,6 +41,9 @@ class Example(Data):
def export(self, doc):
result = doc.createElement("exampleContainer")
if self.edited:
result.setAttribute("modified", "true")
inner = self.inner.export(doc)
# TODO: bad quick fix
for comp in self.components: