Add basic/generic Buefy support to the Form class
mostly just affects rendering, apparently backend logic needn't really change?
This commit is contained in:
parent
a125e381a9
commit
dfe0f49655
|
@ -340,7 +340,7 @@ class Form(object):
|
||||||
def __init__(self, fields=None, schema=None, request=None, mobile=False, readonly=False, readonly_fields=[],
|
def __init__(self, fields=None, schema=None, request=None, mobile=False, readonly=False, readonly_fields=[],
|
||||||
model_instance=None, model_class=None, nodes={}, enums={}, labels={}, renderers=None,
|
model_instance=None, model_class=None, nodes={}, enums={}, labels={}, renderers=None,
|
||||||
hidden={}, widgets={}, defaults={}, validators={}, required={}, helptext={}, focus_spec=None,
|
hidden={}, widgets={}, defaults={}, validators={}, required={}, helptext={}, focus_spec=None,
|
||||||
action_url=None, cancel_url=None):
|
action_url=None, cancel_url=None, use_buefy=None):
|
||||||
|
|
||||||
self.fields = None
|
self.fields = None
|
||||||
if fields is not None:
|
if fields is not None:
|
||||||
|
@ -374,6 +374,7 @@ class Form(object):
|
||||||
self.focus_spec = focus_spec
|
self.focus_spec = focus_spec
|
||||||
self.action_url = action_url
|
self.action_url = action_url
|
||||||
self.cancel_url = cancel_url
|
self.cancel_url = cancel_url
|
||||||
|
self.use_buefy = use_buefy
|
||||||
|
|
||||||
def __contains__(self, item):
|
def __contains__(self, item):
|
||||||
return item in self.fields
|
return item in self.fields
|
||||||
|
@ -685,6 +686,8 @@ class Form(object):
|
||||||
if not template:
|
if not template:
|
||||||
if self.readonly:
|
if self.readonly:
|
||||||
template = '/forms/form_readonly.mako'
|
template = '/forms/form_readonly.mako'
|
||||||
|
elif self.use_buefy:
|
||||||
|
template = '/forms/form_buefy.mako'
|
||||||
else:
|
else:
|
||||||
template = '/forms/form.mako'
|
template = '/forms/form.mako'
|
||||||
context = kwargs
|
context = kwargs
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
<div class="form-wrapper">
|
<div class="form-wrapper">
|
||||||
<p style="padding: 1em;">${report.__doc__}</p>
|
<p style="padding: 1em;">${report.__doc__}</p>
|
||||||
${form.render(template='/forms/form{}.mako'.format('_buefy' if use_buefy else ''))|n}
|
${form.render()|n}
|
||||||
</div><!-- form-wrapper -->
|
</div><!-- form-wrapper -->
|
||||||
|
|
||||||
<ul id="context-menu">
|
<ul id="context-menu">
|
||||||
|
|
|
@ -97,6 +97,10 @@ class MasterView(View):
|
||||||
supports_prev_next = False
|
supports_prev_next = False
|
||||||
supports_import_batch_from_file = False
|
supports_import_batch_from_file = False
|
||||||
|
|
||||||
|
# whether or not Buefy is supported for CRUD forms. we're turning this on,
|
||||||
|
# "one view at a time" until it makes sense for that to be global default.
|
||||||
|
supports_buefy_forms = False
|
||||||
|
|
||||||
# quickie (search)
|
# quickie (search)
|
||||||
supports_quickie_search = False
|
supports_quickie_search = False
|
||||||
expose_quickie_search = False
|
expose_quickie_search = False
|
||||||
|
@ -2823,6 +2827,7 @@ class MasterView(View):
|
||||||
'readonly': self.viewing,
|
'readonly': self.viewing,
|
||||||
'model_class': getattr(self, 'model_class', None),
|
'model_class': getattr(self, 'model_class', None),
|
||||||
'action_url': self.request.current_route_url(_query=None),
|
'action_url': self.request.current_route_url(_query=None),
|
||||||
|
'use_buefy': self.supports_buefy_forms and self.get_use_buefy(),
|
||||||
}
|
}
|
||||||
if self.creating:
|
if self.creating:
|
||||||
kwargs.setdefault('cancel_url', self.get_index_url())
|
kwargs.setdefault('cancel_url', self.get_index_url())
|
||||||
|
|
|
@ -350,7 +350,8 @@ class GenerateReport(View):
|
||||||
|
|
||||||
schema.add(node)
|
schema.add(node)
|
||||||
|
|
||||||
form = forms.Form(schema=schema, request=self.request)
|
form = forms.Form(schema=schema, request=self.request,
|
||||||
|
use_buefy=self.get_use_buefy())
|
||||||
form.submit_label = "Generate this Report"
|
form.submit_label = "Generate this Report"
|
||||||
form.cancel_url = self.request.route_url('generate_report')
|
form.cancel_url = self.request.route_url('generate_report')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue