From 924a242060d846d6cd7af794f4283def1052defb Mon Sep 17 00:00:00 2001 From: Walter Lorenzetti Date: Wed, 9 Oct 2024 12:14:39 +0200 Subject: [PATCH] Value relation order by value (#949) * Add 'orderbyvalue' to Edite Type Value Relation. * Refactoring * Typo * Add 'allowmulti' options in valuerelation widget --------- Co-authored-by: wlorenzetti --- g3w-admin/qdjango/utils/edittype.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/g3w-admin/qdjango/utils/edittype.py b/g3w-admin/qdjango/utils/edittype.py index faecec377..fc9041541 100644 --- a/g3w-admin/qdjango/utils/edittype.py +++ b/g3w-admin/qdjango/utils/edittype.py @@ -26,6 +26,17 @@ def __init__(self, **kwargs): def input_form(self): return dict() + def make_bool_from_value(self, value)->bool: + """ + From QGIS for widget parameters must be boolean for G3W-CLIENT. + Some time the values of widget parameter may be a boolean or a string/numeric + :param value: the value of a widget parameter + :return: bool + :rtype: bool + """ + + return True if value == '1' or value == 'true' or value is True else False + class QgisEditTypeCheckBox(QgisEditType): """ @@ -150,7 +161,9 @@ def input_form(self): input_form['input']['options'].update({ 'key': self.Value, 'value': self.Key, - 'usecompleter': True if self.UseCompleter == '1' or self.UseCompleter == 'true' or self.UseCompleter is True else False, + 'usecompleter': self.make_bool_from_value(self.UseCompleter), + 'orderbyvalue': self.make_bool_from_value(self.OrderByValue), + 'allowmulti': self.make_bool_from_value(self.AllowMulti), 'layer_id': self.Layer, 'loading': { 'state': None