Hide newsletter agent options when save only checked

This commit is contained in:
JonnyWong16 2018-05-08 17:25:25 -07:00
parent 04029bd4d3
commit 365260401c
2 changed files with 77 additions and 56 deletions

View file

@ -1,17 +1,34 @@
function initConfigCheckbox(elem) { function initConfigCheckbox(elem, reverse) {
var config = $(elem).closest('div').next(); var config = $(elem).closest('div').next();
config.css('overflow', 'hidden'); config.css('overflow', 'hidden');
if ($(elem).is(":checked")) { if (reverse) {
config.show(); if ($(elem).is(":checked")) {
config.hide();
} else {
config.show();
}
} else { } else {
config.hide(); if ($(elem).is(":checked")) {
config.show();
} else {
config.hide();
}
} }
$(elem).click(function () { $(elem).click(function () {
var config = $(this).closest('div').next(); var config = $(this).closest('div').next();
if ($(this).is(":checked")) { if (reverse) {
config.slideDown(); if ($(this).is(":checked")) {
config.slideUp();
} else {
config.slideDown();
}
} else { } else {
config.slideUp(); if ($(this).is(":checked")) {
config.slideDown();
} else {
config.slideUp();
}
} }
}); });
} }

View file

@ -206,58 +206,60 @@
<p class="help-block">Enable to save the newsletter file without sending it to any notification agent.</p> <p class="help-block">Enable to save the newsletter file without sending it to any notification agent.</p>
<input type="hidden" id="newsletter_config_save_only" name="newsletter_config_save_only" value="${newsletter['config']['save_only']}"> <input type="hidden" id="newsletter_config_save_only" name="newsletter_config_save_only" value="${newsletter['config']['save_only']}">
</div> </div>
<div class="checkbox"> <div id="newsletter_agent_options">
<label> <div class="checkbox">
<input type="checkbox" id="newsletter_config_formatted_checkbox" data-id="newsletter_config_formatted" class="checkboxes" value="1" ${checked(newsletter['config']['formatted'])}> Send Newsletter as an HTML Formatted Email <label>
</label> <input type="checkbox" id="newsletter_config_formatted_checkbox" data-id="newsletter_config_formatted" class="checkboxes" value="1" ${checked(newsletter['config']['formatted'])}> Send Newsletter as an HTML Formatted Email
<p class="help-block">Enable to send the newsletter as an HTML formatted Email. Disable to only send a subject and body message to a different notification agent.</p> </label>
<input type="hidden" id="newsletter_config_formatted" name="newsletter_config_formatted" value="${newsletter['config']['formatted']}"> <p class="help-block">Enable to send the newsletter as an HTML formatted Email. Disable to only send a subject and body message to a different notification agent.</p>
</div> <input type="hidden" id="newsletter_config_formatted" name="newsletter_config_formatted" value="${newsletter['config']['formatted']}">
<div class="form-group" id="email_notifier_select">
<label for="newsletter_email_notifier_id">Email Notification Agent</label>
<div class="row">
<div class="col-md-12">
<select class="form-control" id="newsletter_email_notifier_id" name="newsletter_email_notifier_id">
% for notifier in email_notifiers:
<% selected = 'selected' if notifier['id'] == newsletter['email_config']['notifier_id'] else '' %>
% if notifier['friendly_name']:
<option value="${notifier['id']}" ${selected}>${notifier['agent_label']} (${notifier['id']} - ${notifier['friendly_name']})</option>
% elif notifier['id']:
<option value="${notifier['id']}" ${selected}>${notifier['agent_label']} (${notifier['id']})</option>
% else:
<option value="${notifier['id']}" ${selected}>${notifier['agent_label']}</option>
% endif
% endfor
</select>
</div>
</div> </div>
<p class="help-block"> <div class="form-group" id="email_notifier_select">
Select an existing Email notification agent or enter a new configuration below.<br> <label for="newsletter_email_notifier_id">Email Notification Agent</label>
Note: Make sure HTML support is enabled for the Email notification agent. <div class="row">
</p> <div class="col-md-12">
</div> <select class="form-control" id="newsletter_email_notifier_id" name="newsletter_email_notifier_id">
<div class="form-group" id="other_notifier_select"> % for notifier in email_notifiers:
<label for="newsletter_config_notifier_id">Notification Agent</label> <% selected = 'selected' if notifier['id'] == newsletter['email_config']['notifier_id'] else '' %>
<div class="row"> % if notifier['friendly_name']:
<div class="col-md-12"> <option value="${notifier['id']}" ${selected}>${notifier['agent_label']} (${notifier['id']} - ${notifier['friendly_name']})</option>
<select class="form-control" id="newsletter_config_notifier_id" name="newsletter_config_notifier_id"> % elif notifier['id']:
% for notifier in other_notifiers: <option value="${notifier['id']}" ${selected}>${notifier['agent_label']} (${notifier['id']})</option>
<% selected = 'selected' if notifier['id'] == newsletter['config']['notifier_id'] else '' %> % else:
% if notifier['friendly_name']: <option value="${notifier['id']}" ${selected}>${notifier['agent_label']}</option>
<option value="${notifier['id']}" ${selected}>${notifier['agent_label']} (${notifier['id']} - ${notifier['friendly_name']})</option> % endif
% elif notifier['id']: % endfor
<option value="${notifier['id']}" ${selected}>${notifier['agent_label']} (${notifier['id']})</option> </select>
% else: </div>
<option value="${notifier['id']}" ${selected}>${notifier['agent_label']}</option>
% endif
% endfor
</select>
</div> </div>
<p class="help-block">
Select an existing Email notification agent or enter a new configuration below.<br>
Note: Make sure HTML support is enabled for the Email notification agent.
</p>
</div>
<div class="form-group" id="other_notifier_select">
<label for="newsletter_config_notifier_id">Notification Agent</label>
<div class="row">
<div class="col-md-12">
<select class="form-control" id="newsletter_config_notifier_id" name="newsletter_config_notifier_id">
% for notifier in other_notifiers:
<% selected = 'selected' if notifier['id'] == newsletter['config']['notifier_id'] else '' %>
% if notifier['friendly_name']:
<option value="${notifier['id']}" ${selected}>${notifier['agent_label']} (${notifier['id']} - ${notifier['friendly_name']})</option>
% elif notifier['id']:
<option value="${notifier['id']}" ${selected}>${notifier['agent_label']} (${notifier['id']})</option>
% else:
<option value="${notifier['id']}" ${selected}>${notifier['agent_label']}</option>
% endif
% endfor
</select>
</div>
</div>
<p class="help-block">
Select an existing notification agent where the subject and body text will be sent.<br>
Note: Self-hosted newsletters must be enabled under <a data-tab-destination="tabs-notifications" data-dismiss="modal" data-target="#newsletter_self_hosted">Newsletters</a> to include a link to the newsletter.
</p>
</div> </div>
<p class="help-block">
Select an existing notification agent where the subject and body text will be sent.<br>
Note: Self-hosted newsletters must be enabled under <a data-tab-destination="tabs-notifications" data-dismiss="modal" data-target="#newsletter_self_hosted">Newsletters</a> to include a link to the newsletter.
</p>
</div> </div>
</div> </div>
<div id="newsletter-email-config" class="col-md-12" style="padding-top: 10px; border-top: 1px solid #444;"> <div id="newsletter-email-config" class="col-md-12" style="padding-top: 10px; border-top: 1px solid #444;">
@ -530,6 +532,8 @@
var incl_libraries = $incl_libraries[0].selectize; var incl_libraries = $incl_libraries[0].selectize;
incl_libraries.setValue(${json.dumps(next((c['value'] for c in newsletter['config_options'] if c['name'] == 'newsletter_config_incl_libraries'), [])) | n}); incl_libraries.setValue(${json.dumps(next((c['value'] for c in newsletter['config_options'] if c['name'] == 'newsletter_config_incl_libraries'), [])) | n});
initConfigCheckbox('#newsletter_config_save_only_checkbox', true);
function toggleEmailSelect () { function toggleEmailSelect () {
if ($('#newsletter_config_formatted_checkbox').is(':checked')) { if ($('#newsletter_config_formatted_checkbox').is(':checked')) {
$('#newsletter_body').hide(); $('#newsletter_body').hide();