fixing double_list_getter

This commit is contained in:
matic_t 2020-08-07 01:34:47 -07:00
parent 83396ef8a0
commit 752ec44d43
2 changed files with 7 additions and 4 deletions

View File

@ -10,13 +10,16 @@ def generic_list_getter():
return result return result
# Formats data from inputs to name-value objects # Formats data from inputs to name-value objects
def double_list_getter(firstParameter, secondParameter): def double_list_getter(firstParameter, secondParameter, allowEmptyField = False):
result = [] result = []
for row in document.getElementsByClassName("double-list-row"): for row in document.getElementsByClassName("double-list-row"):
firstValue = row.querySelector("." + firstParameter + "-input").value firstValue = row.querySelector("." + firstParameter + "-input").value
secondValue = row.querySelector("." + secondParameter + "-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 continue
result.append({firstParameter: firstValue, secondParameter: secondValue}) 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.old_cluster_idx = self.get_arg(1, int)
self.translation.translation = document.getElementById("etv").value self.translation.translation = document.getElementById("etv").value
# This could be dangerous if generic_list_getter is getting data from any other list as well. # This could be dangerous if double_list_getter is getting data from any other list as well.
self.translation.explanationList = common_accessors.generic_list_getter() self.translation.explanationList = common_accessors.double_list_getter('value', 'language', True)
# common_accessors.label_list_getter() # common_accessors.label_list_getter()
self.translation.tags = common_accessors.label_list_getter() self.translation.tags = common_accessors.label_list_getter()