edited/modified example atribute supported
This commit is contained in:
parent
42aef17473
commit
b24af95d5d
|
@ -49,6 +49,7 @@ class EditExampleText(Message):
|
||||||
def update_model(self, model):
|
def update_model(self, model):
|
||||||
example = self.get_arg(0, Example)
|
example = self.get_arg(0, Example)
|
||||||
example.overwrite_with_copy()
|
example.overwrite_with_copy()
|
||||||
|
example.edited = True
|
||||||
|
|
||||||
idx = 0
|
idx = 0
|
||||||
for txt in document.getElementsByClassName("example-component-text"):
|
for txt in document.getElementsByClassName("example-component-text"):
|
||||||
|
|
|
@ -15,17 +15,21 @@ class Example(Data):
|
||||||
self.translations = []
|
self.translations = []
|
||||||
self.inner = None
|
self.inner = None
|
||||||
self.components = []
|
self.components = []
|
||||||
|
self.edited = False
|
||||||
|
|
||||||
def import_xml(self, example_xml):
|
def import_xml(self, example_xml):
|
||||||
self.translations = from_container_list(example_xml.querySelectorAll("translationContainer"))
|
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")
|
inner_xml = example_xml.querySelector("corpusExample")
|
||||||
if inner_xml is not None:
|
if inner_xml is not None:
|
||||||
self.inner = CorpusExample()
|
self.inner = CorpusExample()
|
||||||
else:
|
else:
|
||||||
inner_xml = example_xml.querySelector("multiwordExample")
|
inner_xml = example_xml.querySelector("multiwordExample")
|
||||||
self.inner = MultiwordExample()
|
self.inner = MultiwordExample()
|
||||||
|
|
||||||
self.inner.import_xml(inner_xml)
|
self.inner.import_xml(inner_xml)
|
||||||
|
|
||||||
for comp_xml in inner_xml.childNodes:
|
for comp_xml in inner_xml.childNodes:
|
||||||
|
@ -37,6 +41,9 @@ class Example(Data):
|
||||||
def export(self, doc):
|
def export(self, doc):
|
||||||
result = doc.createElement("exampleContainer")
|
result = doc.createElement("exampleContainer")
|
||||||
|
|
||||||
|
if self.edited:
|
||||||
|
result.setAttribute("modified", "true")
|
||||||
|
|
||||||
inner = self.inner.export(doc)
|
inner = self.inner.export(doc)
|
||||||
# TODO: bad quick fix
|
# TODO: bad quick fix
|
||||||
for comp in self.components:
|
for comp in self.components:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user