Skip to content

Commit

Permalink
UI Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
otrok7 committed Dec 1, 2024
1 parent 8fa1988 commit d4885ad
Show file tree
Hide file tree
Showing 11 changed files with 174 additions and 66 deletions.
24 changes: 17 additions & 7 deletions admin/class-bread-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,7 @@ function get($url, $cookies = array())
'timeout' => '120',
'cookies' => $cookies,
);
if (
isset($this->options['user_agent'])
if (isset($this->options['user_agent'])
&& $this->bread->getOption('user_agent') != 'None'
) {
$args['headers'] = array(
Expand Down Expand Up @@ -451,7 +450,7 @@ function pwsix_process_wizard()
if (!$this->current_user_can_create()) {
return;
}
$layout = sanitize_url($_POST['wizard_layout']);
$layout = sanitize_text_field($_POST['wizard_layout']);
$encode_options = file_get_contents(plugin_dir_path(__FILE__) . 'templates/' . $layout);
while (0 === strpos(bin2hex($encode_options), 'efbbbf')) {
$encode_options = substr($encode_options, 3);
Expand All @@ -473,7 +472,7 @@ function pwsix_process_wizard()
$settings['additional_list_format_key'] = '@Virtual@';
}
$str = file_get_contents(plugin_dir_path(__FILE__) . 'templates/meeting_data_templates.json');
$meeting_templates = json_decode($str);
$meeting_templates = json_decode($str, true);
if ($vm_flag == '1') {
$settings['custom_section_content'] =
'<table style="width: 100%;">
Expand All @@ -484,7 +483,7 @@ function pwsix_process_wizard()
</tbody>
</table>
<p>[additional_meetinglist]</p>' . $settings['custom_section_content'];
$settings['additional_list_template_content'] = $meeting_templates['Online Meeting Two Column'];
$settings['additional_list_template_content'] = join('', $meeting_templates['Online Meeting Two Column - Link in QR-Code']);
}
$settings['meeting_sort'] = sanitize_text_field($_POST['wizard_meeting_sort']);
if ($settings['meeting_sort'] != 'day') {
Expand All @@ -496,16 +495,27 @@ function pwsix_process_wizard()
}
}
update_option($optionsName, $settings);
$this->bread->setAndSaveSetting($id, 'Setting ' . $id);
$setting_name = sanitize_title($_POST['wizard-setting-name']);
$setting_name = $setting_name == '' ? $setting_name : 'Setting ' . $id;
$this->bread->setAndSaveSetting($id, $setting_name);
$this->bread->getMLOptions($id);
$this->bread->setRequestedSetting($id);
ignore_user_abort(true);
ob_clean();
header('Content-Type: application/json; charset=utf-8');
header("Expires: 0");
$message = ['result' => ['setting' => $id]];
$data = json_encode($message);
header('Content-Length: ' . strlen($data));
file_put_contents('php://output', $data);
}
function pwsix_process_settings_admin()
{
if (! wp_verify_nonce($_POST['pwsix_settings_admin_nonce'], 'pwsix_settings_admin_nonce')) {
return;
}
$this->bread->getMLOptions($this->bread->getRequestedSetting());
if (isset($_POST['delete'])) {
if (isset($_POST['delete_settings'])) {
if (!$this->current_user_can_modify()) {
return;
}
Expand Down
14 changes: 14 additions & 0 deletions admin/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -509,3 +509,17 @@ select.service_body_select {
.chosen-container-multi .chosen-choices li.search-field input[type=text] {
font-family: "Open Sans",sans-serif !important;
}
.step-description {
margin: 10px;
border: solid;
padding: 10px;
background-color: cornsilk;
}
.invalid-feedback {
color: red;
font-weight: bold;
}
.valid-feedback {
color: green;
font-weight: bold;
}
47 changes: 42 additions & 5 deletions admin/js/bread-wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,50 @@ jQuery(document).ready(function($){
return false;
})
}
BreadWizard.prototype.ajax_submit = function() {
var myform = document.getElementById("wizard_form");

var formData = new FormData(myform);

fetch(window.location.href, {
method: "POST",
body: formData,
})
.then((response) => {
if (!response.ok) {
throw new Error("network returns error");
}
return response.json();
})
.then((resp) => {
finalInstructions(resp);
})
.catch((error) => {
// Handle error
console.log("error ", error);
});
}
var href;
finalInstructions = function(response) {
$('#wizard-before-create').hide();
$('#wizard-after-create').show();
href = window.location.href.substring(0, window.location.href.indexOf('/wp-admin'));
href = href+"?current-meeting-list="+response.result.setting;
const tag = '<pre>&lt;a href="'+href+'"&gt;'+href+'</pre>';
$('#wizard-show-link').html(tag);
}
BreadWizard.prototype.generate_meeting_list = function() {
window.open(href, '_blank').focus();
}
BreadWizard.prototype.test_root_server = function() {
ask_bmlt("switcher=GetServerInfo",
(info) => {
$('#wizard_root_server_result').removeClass('invalid-feedback')
.addClass('valid-feedback').html('BMLT Server version '+info[0]['version']);
$('#wizard_root_server_result').removeClass('invalid-feedback dashicons-dismiss')
.addClass('valid-feedback dashicons-before dashicons-yes-alt').html('Connected! - BMLT Server version '+info[0]['version']);
},
(error) => {
$('#wizard_root_server_result').removeClass('valid-feedback')
.addClass('invalid-feedback').html('Could not connect: Check spelling and internet connection.');
$('#wizard_root_server_result').removeClass('valid-feedback dashicons-yes-alt')
.addClass('invalid-feedback dashicons-before dashicons-dismiss').html('Could not connect: Check spelling and internet connection.');
});
}
BreadWizard.prototype.root_server_keypress = function(event) {
Expand Down Expand Up @@ -113,8 +148,10 @@ jQuery(document).ready(function($){
break;
case 3:
lang_options();
case 3:
case 4:
if ($("wizard_layout").val()=='') handle_error('Layout not defined');
$('#wizard-before-create').show();
$('#wizard-after-create').hide();
default:
break;
}
Expand Down
21 changes: 11 additions & 10 deletions admin/partials/_bmlt_server_setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<p>
<input type="checkbox" id="sslverify" name="sslverify" value="1" checked />
<label for="sslverify">Disable SSL verification of server</label>
<?php }
<?php }
} elseif ($this->bread->emptyOption('root_server')) {
echo "<span style='color: #f00;'><div style='font-size: 16px;vertical-align: middle;' class='dashicons dashicons-dismiss'></div>ERROR: Please enter a BMLT Server</span>";
echo '<input type="hidden" id="user_agent" value="' . $this->bread->getOption('user_agent') . '" />';
Expand All @@ -51,7 +51,7 @@
<input type="checkbox" id="sslverify" name="sslverify" value="1" <?php echo $this->bread->getOption('sslverify') ? 'checked' : ''; ?> />
<label for="sslverify">Disable SSL verification of server</label>
</p>
<?php
<?php
}
?>
<p>
Expand Down Expand Up @@ -92,14 +92,15 @@
<h3 class="hndle">Include Extra Meetings<span class="my-tooltip" data-tooltip-content="#extrameetings-tooltip-content"><span class="tooltipster-icon">(?)</span></span></h3>
<div class="inside">
<p class="ctrl_key" style="display:none; color: #00AD00;">Hold CTRL Key down to select multiple meetings.</p>
<select class="chosen-select" style="width: 100%;" data-placeholder="<?php
if ($this->bread->getOption('extra_meetings_enabled') == 0) {
echo 'Not Enabled';
} elseif (!$this->connected) {
echo 'Not Connected';
} else {
echo 'Select Extra Meetings';
} ?>" id="extra_meetings" name="extra_meetings[]" multiple="multiple">
<select class="chosen-select" style="width: 100%;" data-placeholder="
<?php
if ($this->bread->getOption('extra_meetings_enabled') == 0) {
echo 'Not Enabled';
} elseif (!$this->connected) {
echo 'Not Connected';
} else {
echo 'Select Extra Meetings';
} ?>" id="extra_meetings" name="extra_meetings[]" multiple="multiple">
<?php
if ($this->connected && $this->bread->getOption('extra_meetings_enabled') == 1) {
$extra_meetings_array = $this->bread->bmlt()->get_all_meetings();
Expand Down
49 changes: 46 additions & 3 deletions admin/partials/_bread_wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,20 @@
</a>
</li>
</ul>
<form method="post">
<form method="post" id="wizard_form">
<?php wp_nonce_field('pwsix_wizard_nonce', 'pwsix_wizard_nonce'); ?>
<input type="hidden" name="pwsix_action" value="wizard" />
<div class="tab-content">
<div id="step-1" class="tab-pane" role="tabpanel" aria-labelledby="step-1">
<h3>Step 1: Enter your BMLT root server</h3>
<div class="step-description">
<p>This wizard guides you through the initial configuation of a meeting list. If you have already created one or more meeting lists,
don't worry, this process alway creates a new configuration, and never overwrites old ones.</p>
<p>Bread is highly customizable, as areas often try to maintain the appearance of their old meeting lists. This wizard only attempts to give you a reasonable
starting point, not an end product. At the end of the wizard we make a few suggestions for possible next steps.</p>
<p>The first thing we need is the location of your BMLT root server. Once you have entered it, you need check that the URL is correct
by clicking the "Test Connection" button.</p>
</div>
<p>Visit <a target="_blank" href="https://doihavethebmlt.org/">Do I have the BMLT?</a> to find your BMLT server<br/>
<label for="wizard_root_server">BMLT Server URL: </label>
<input class="bmlt-input" id="wizard_root_server" type="text" name="wizard_root_server"
Expand All @@ -49,6 +57,10 @@
<div id="step-2" class="tab-pane" role="tabpanel" aria-labelledby="step-2">
<div style="min-height: 300px;">
<h3>Step 2: Select a service body</h3>
<div class="step-description">
<p>Next, we need to know which meetings are going to be on the meeting list. This will help the wizard when it
tries to choose an a appropriate layout for you.</p>
</div>
<select class="chosen-select" style="width: 400px;" data-placeholder="Choose up to 5 service bodies" id="wizard_service_bodies" name="wizard_service_bodies[]" multiple="multiple">
<option value=1>The is placeholder 1 Hello</option>
<option value=2>The is placeholder 1 Hello</option>
Expand All @@ -63,12 +75,19 @@
<div id="wizard_service_body_result">
</div>
<p>If you want to limit the meeting list to a particular format, for instance, to create a language-specific meeting list, you can enter it here.
<br/><select style="width: 400px;" id="wizard_format_filter" name="wizard_format_filte">
<br/><select style="width: 400px;" id="wizard_format_filter" name="wizard_format_filter">
</select></p>
</div>
</div>
<div id="step-3" class="tab-pane" role="tabpanel" aria-labelledby="step-3">
<h3>Step 3: Page Layout</h3>
<div class="step-description">
<p>Most areas try to fit their meetings onto a single sheet of paper. And it is particularly adventageous to
use a tri-fold format, so that the list can be printed at home and placed along side the pamphlets. Remember though, that when fonts become
too small, the meeting list becomes unreadable. For many areas, a booklet format is better, even
if the reqire more effort or expense to print.</p>
<p>In this step we suggest suitible formats based on your meeting count.</p>
</div>
<p>Number of meetings on list: <span id="wizard_meeting_count"></span></p>
<p>Select one of the layouts appropriate to the number of meetings</p>
<select id="wizard_layout" name="wizard_layout">
Expand Down Expand Up @@ -96,7 +115,31 @@
</select>
</div>
<div id="step-5" class="tab-pane" role="tabpanel" aria-labelledby="step-5">
<?php submit_button(__('Create Meeting List'), 'button-primary', 'create_meeting_list', false); ?>
<div class="step-description">
<p>In this step, we create the meeting list settings. If you already have a meeting list defined
on this site, the old settings will not be overwriten, rather, a new setting will be created.</p>
<p>Before creating the meeting list configuration, you are given the opportunity to give the configuration
a mnemonic name. If you are managing multiple meeting lists on this same, this name can help you keep track of which
configuration is which.</p>
<p>After creating the configuration, you will be able to view the resulting meeting list. Note that this is not usually
ready to be printed. Users almost always want to add content, such as service meetings, help lines, place for people to
collect phone numbers etc. To do this, click on the "Customize" tab to the left, and then go to either the "Front Page" or
"Custom Section" tabs. The editors there contain a "Meeting List Shortcodes" dropdown menu. Using these, new structures can
be added with only a few mouse clicks.</p>
<p>You may also want to adjust the font sizes on your meeting list so that it fits on a single sheet or is more readable. This is only
of the many options available in the "Customizer".</p>
</div>
<div id="wizard-before-create">
<p><label for="wizard-setting-name">Enter a custom name for this configuration: </label>
<input type="text" placeholder="Use default value" id="wizard-setting-name" name="wizard-setting-name"/></p>
<button type="button" class="btn btn-primary" onClick="breadWizard.ajax_submit()">Create Meeting List</button>
</div>
<div id="wizard-after-create">
<button type="button" class="btn btn-primary" onClick="breadWizard.generate_meeting_list()">Generate Meeting List</button>
<p>
To add a link to the meeting list on your website, use the following link.
</p><div id="wizard-show-link"></div>
</div>
</div>
</div>
<!-- Include optional progressbar HTML -->
Expand Down
Loading

0 comments on commit d4885ad

Please sign in to comment.