Add Buefy support for email preview buttons

This commit is contained in:
Lance Edgar 2019-04-15 19:54:17 -05:00
parent a0cd1f4cd0
commit 4a92b05b57
3 changed files with 79 additions and 14 deletions

View file

@ -1,8 +1,9 @@
## -*- coding: utf-8; -*- ## -*- coding: utf-8; -*-
<%inherit file="/master/view.mako" /> <%inherit file="/master/view.mako" />
<%def name="head_tags()"> <%def name="extra_javascript()">
${parent.head_tags()} ${parent.extra_javascript()}
% if not use_buefy:
<script type="text/javascript"> <script type="text/javascript">
% if not email.get_template('html'): % if not email.get_template('html'):
$(function() { $(function() {
@ -17,16 +18,80 @@
}); });
% endif % endif
</script> </script>
% endif
</%def> </%def>
${parent.body()} ${parent.body()}
${h.form(url('email.preview'), name='send-email-preview', class_='autodisable')} % if use_buefy:
${h.csrf_token(request)}
${h.hidden('email_key', value=instance['key'])} ${h.form(url('email.preview'))}
${h.link_to("Preview HTML", '{}?key={}&type=html'.format(url('email.preview'), instance['key']), id='preview-html', class_='button', target='_blank')} ${h.csrf_token(request)}
${h.link_to("Preview TXT", '{}?key={}&type=txt'.format(url('email.preview'), instance['key']), id='preview-txt', class_='button', target='_blank')} ${h.hidden('email_key', value=instance['key'])}
or
${h.text('recipient', value=request.user.email_address or '')} <div class="field is-grouped">
${h.submit('send_{}'.format(instance['key']), value="Send Preview Email")}
${h.end_form()} <div class="control">
% if email.get_template('html'):
<a class="button"
href="${url('email.preview')}?key=${instance['key']}&type=html"
target="_blank">
Preview HTML
</a>
% else:
<button class="button"
type="button"
title="There is no HTML template on file for this email."
disabled>
Preview HTML
</button>
% endif
</div>
<div class="control">
% if email.get_template('txt'):
<a class="button"
href="${url('email.preview')}?key=${instance['key']}&type=txt"
target="_blank">
Preview TXT
</a>
% else:
<button class="button"
type="button"
title="There is no TXT template on file for this email."
disabled>
Preview TXT
</button>
% endif
</div>
<div class="control">
or
</div>
<div class="control">
<input name="recipient" type="email" class="input" value="${request.user.email_address or ''}" />
</div>
<div class="control">
<input type="submit" class="button" name="send_${instance['key']}" value="Send Preview Email" />
</div>
</div><!-- field -->
${h.end_form()}
% else:
## not buefy; do traditional thing
${h.form(url('email.preview'), name='send-email-preview', class_='autodisable')}
${h.csrf_token(request)}
${h.hidden('email_key', value=instance['key'])}
${h.link_to("Preview HTML", '{}?key={}&type=html'.format(url('email.preview'), instance['key']), id='preview-html', class_='button', target='_blank')}
${h.link_to("Preview TXT", '{}?key={}&type=txt'.format(url('email.preview'), instance['key']), id='preview-txt', class_='button', target='_blank')}
or
${h.text('recipient', value=request.user.email_address or '')}
${h.submit('send_{}'.format(instance['key']), value="Send Preview Email")}
${h.end_form()}
% endif

View file

@ -318,8 +318,8 @@
## Bulma 0.7.4 ## Bulma 0.7.4
${h.stylesheet_link('https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.4/css/bulma.min.css')} ${h.stylesheet_link('https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.4/css/bulma.min.css')}
## Buefy 0.7.3 ## Buefy 0.7.4
${h.stylesheet_link('https://unpkg.com/buefy@0.7.3/dist/buefy.min.css')} ${h.stylesheet_link('https://unpkg.com/buefy@0.7.4/dist/buefy.min.css')}
## ${self.jquery_theme()} ## ${self.jquery_theme()}
## ${h.stylesheet_link(request.static_url('tailbone:static/css/jquery.loadmask.css'))} ## ${h.stylesheet_link(request.static_url('tailbone:static/css/jquery.loadmask.css'))}

View file

@ -294,7 +294,6 @@ class MasterView(View):
context = { context = {
'grid': grid, 'grid': grid,
'use_buefy': use_buefy,
} }
return self.render_to_response('index', context) return self.render_to_response('index', context)
@ -2088,6 +2087,7 @@ class MasterView(View):
""" """
context = { context = {
'master': self, 'master': self,
'use_buefy': self.get_use_buefy(),
'mobile': mobile, 'mobile': mobile,
'model_title': self.get_model_title(), 'model_title': self.get_model_title(),
'model_title_plural': self.get_model_title_plural(), 'model_title_plural': self.get_model_title_plural(),