From 6be4964221c87cf4b9461d44461b58b915fb76b5 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 23 May 2019 18:13:19 -0500 Subject: [PATCH] Use `` where applicable for CRUD forms --- tailbone/templates/forms/deform_buefy.mako | 23 ++++++++++++++++++++-- tailbone/views/labels/profiles.py | 3 +++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/tailbone/templates/forms/deform_buefy.mako b/tailbone/templates/forms/deform_buefy.mako index f97f6a85..a10a9345 100644 --- a/tailbone/templates/forms/deform_buefy.mako +++ b/tailbone/templates/forms/deform_buefy.mako @@ -42,7 +42,18 @@ % elif not form.readonly and (buttons is Undefined or (buttons is not None and buttons is not False)):
- ${h.submit('save', getattr(form, 'submit_label', getattr(form, 'save_label', "Submit")), class_='button is-primary')} + ## TODO: deprecate / remove the latter option here + % if form.auto_disable_save or form.auto_disable: + + + % else: + + ${getattr(form, 'submit_label', getattr(form, 'save_label', "Submit"))} + + % endif % if getattr(form, 'show_reset', False): % endif @@ -50,7 +61,15 @@ % if form.mobile: ${h.link_to("Cancel", form.cancel_url, class_='ui-btn ui-corner-all')} % else: - ${h.link_to("Cancel", form.cancel_url, class_='cancel button{}'.format(' autodisable' if form.auto_disable_cancel else ''))} + % if form.auto_disable_cancel: + + + % else: + + Cancel + + % endif % endif % endif
diff --git a/tailbone/views/labels/profiles.py b/tailbone/views/labels/profiles.py index d1b3fea4..3fb5dd34 100644 --- a/tailbone/views/labels/profiles.py +++ b/tailbone/views/labels/profiles.py @@ -88,6 +88,7 @@ class ProfilesView(MasterView): pass def make_printer_settings_form(self, profile, printer): + use_buefy = self.get_use_buefy() schema = colander.Schema() for name, label in printer.required_settings.items(): @@ -98,11 +99,13 @@ class ProfilesView(MasterView): schema.add(node) form = forms.Form(schema=schema, request=self.request, + use_buefy=use_buefy, model_instance=profile, # TODO: ugh, this is necessary to avoid some logic # which assumes a ColanderAlchemy schema i think? appstruct=None) form.cancel_url = self.get_action_url('view', profile) + form.auto_disable_cancel = True form.insert_before(schema.children[0].name, 'label_profile') form.set_readonly('label_profile')