Skip to content

Commit

Permalink
Value relation order by value (#949)
Browse files Browse the repository at this point in the history
* Add 'orderbyvalue' to Edite Type Value Relation.

* Refactoring

* Typo

* Add 'allowmulti' options in valuerelation widget

---------

Co-authored-by: wlorenzetti <[email protected]>
  • Loading branch information
wlorenzetti and wlorenzetti authored Oct 9, 2024
1 parent 78847e7 commit 924a242
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion g3w-admin/qdjango/utils/edittype.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 924a242

Please sign in to comment.