From f4f435c68276a3c344fe933492025fb69b5b62dc Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 21 May 2019 20:11:57 -0500 Subject: [PATCH] Add `` component for Buefy templates i.e. just a button, which allows only one click and then auto-disables --- .../static/js/tailbone.buefy.oncebutton.js | 45 ++++++++++ tailbone/templates/master/merge.mako | 87 +++++++++++++------ tailbone/templates/themes/falafel/base.mako | 1 + 3 files changed, 108 insertions(+), 25 deletions(-) create mode 100644 tailbone/static/js/tailbone.buefy.oncebutton.js diff --git a/tailbone/static/js/tailbone.buefy.oncebutton.js b/tailbone/static/js/tailbone.buefy.oncebutton.js new file mode 100644 index 00000000..aa1b5440 --- /dev/null +++ b/tailbone/static/js/tailbone.buefy.oncebutton.js @@ -0,0 +1,45 @@ + +const OnceButton = { + + template: [ + '', + '{{ text }}', + '' + ].join(' '), + + props: { + type: String, + nativeType: String, + text: String, + working: String, + workingText: String + }, + + data() { + return { + disabled: false + } + }, + + methods: { + + clicked(event) { + this.disabled = true + if (this.workingText) { + this.text = this.workingText + } else if (this.working) { + this.text = this.working + ", please wait..." + } else { + this.text = "Working, please wait..." + } + } + } + +} + +Vue.component('once-button', OnceButton) diff --git a/tailbone/templates/master/merge.mako b/tailbone/templates/master/merge.mako index a2ba8e4c..470e28e2 100644 --- a/tailbone/templates/master/merge.mako +++ b/tailbone/templates/master/merge.mako @@ -91,6 +91,59 @@
  • ${h.link_to("Back to {}".format(model_title_plural), url(route_prefix))}
  • + +% if use_buefy: + + + + + +## end of buefy +% endif + +
      ${self.context_menu_items()}
    @@ -141,34 +194,18 @@ % if use_buefy: -
    -
    - - - -
    - ${h.form(request.current_route_url())} - ${h.csrf_token(request)} - ${h.hidden('uuids', value='{},{}'.format(object_to_keep.uuid, object_to_remove.uuid))} - ${h.submit('submit', "Swap which {} is kept/removed".format(model_title), class_='button')} - ${h.end_form()} -
    - -
    - ${h.form(request.current_route_url())} - ${h.csrf_token(request)} - ${h.hidden('uuids', value='{},{}'.format(object_to_remove.uuid, object_to_keep.uuid))} - ${h.hidden('commit-merge', value='yes')} - ${h.submit('merge', "Yes, perform this merge", class_='button is-primary')} - ${h.end_form()} -
    - -
    +
    +
    + + % else: +## no buefy; do legacy stuff ${h.form(request.current_route_url(), class_='merge')} ${h.csrf_token(request)}
    diff --git a/tailbone/templates/themes/falafel/base.mako b/tailbone/templates/themes/falafel/base.mako index 46a0e501..0785cf90 100644 --- a/tailbone/templates/themes/falafel/base.mako +++ b/tailbone/templates/themes/falafel/base.mako @@ -289,6 +289,7 @@ ## Tailbone / Buefy stuff ${h.javascript_link(request.static_url('tailbone:static/js/tailbone.buefy.datepicker.js') + '?ver={}'.format(tailbone.__version__))} + ${h.javascript_link(request.static_url('tailbone:static/js/tailbone.buefy.oncebutton.js') + '?ver={}'.format(tailbone.__version__))}