mt-additional-xml-shema-support #6

Merged
lkavcic merged 10 commits from mt-additional-xml-shema-support into master 2020-08-14 09:32:35 +00:00
2 changed files with 7 additions and 4 deletions
Showing only changes of commit 752ec44d43 - Show all commits

View File

@ -10,13 +10,16 @@ def generic_list_getter():
return result
# Formats data from inputs to name-value objects
def double_list_getter(firstParameter, secondParameter):
def double_list_getter(firstParameter, secondParameter, allowEmptyField = False):
result = []
for row in document.getElementsByClassName("double-list-row"):
firstValue = row.querySelector("." + firstParameter + "-input").value
secondValue = row.querySelector("." + secondParameter + "-input").value
if ("" in [firstValue, secondValue]):
if (allowEmptyField is False and '' in [firstValue, secondValue]):
continue
if (allowEmptyField is True and all('' == value or value.isspace() for value in [firstValue, secondValue])):
continue
result.append({firstParameter: firstValue, secondParameter: secondValue})

View File

@ -13,8 +13,8 @@ class EditTranslation(DataChgClickMessage):
self.old_cluster_idx = self.get_arg(1, int)
self.translation.translation = document.getElementById("etv").value
# This could be dangerous if generic_list_getter is getting data from any other list as well.
self.translation.explanationList = common_accessors.generic_list_getter()
# This could be dangerous if double_list_getter is getting data from any other list as well.
self.translation.explanationList = common_accessors.double_list_getter('value', 'language', True)
# common_accessors.label_list_getter()
self.translation.tags = common_accessors.label_list_getter()