From c2f92fdc4bcc9c440a97503f94090a748ef6c30a Mon Sep 17 00:00:00 2001 From: guerler Date: Fri, 1 Dec 2017 17:29:58 -0500 Subject: [PATCH] Restore dict helper, some toolshed elements use the new client but the toolshed backend --- lib/tool_shed/util/form_util.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/tool_shed/util/form_util.py b/lib/tool_shed/util/form_util.py index 792ebdcba92..8bd4564a866 100644 --- a/lib/tool_shed/util/form_util.py +++ b/lib/tool_shed/util/form_util.py @@ -39,6 +39,15 @@ class BaseField(object): else: return '' + def to_dict(self): + return { + 'name' : self.name, + 'label' : self.label, + 'disabled' : self.disabled, + 'optional' : self.optional, + 'value' : self.value, + 'help' : self.help + } class CheckboxField(BaseField): """ @@ -84,6 +93,11 @@ class CheckboxField(BaseField): else: self.checked = value + def to_dict(self): + d = super(CheckboxField, self).to_dict() + d['type'] = 'boolean' + return d + class SelectField(BaseField): """ @@ -269,6 +283,16 @@ class SelectField(BaseField): return selected_options return None + def to_dict(self): + d = super(SelectField, self).to_dict() + d['type'] = 'select' + d['display'] = self.display + d['multiple'] = self.multiple + d['data'] = [] + for value in self.selectlist: + d['data'].append({'label': value, 'value': value}) + return d + def get_suite(): """Get unittest suite for this module"""