Skip to content

Commit

Permalink
1.1.14
Browse files Browse the repository at this point in the history
  • Loading branch information
nigel-bmlt committed Aug 17, 2024
1 parent d23ba3d commit 16e8300
Show file tree
Hide file tree
Showing 20 changed files with 1,846 additions and 484 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ hello.php
/docker/bmlt.env
/docker/bmlt3x.env
/docker/bmlt2x.env
/tests/testcafe/**
/docker/logs/**
/tests/testcafe/uploads/**
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.1.13 (Aug 13,2024)
- Feature: Map marker in quickedit is now movable, mimicking the behaviour of BMLT UI
- Support for the BMLT zip and county auto geocoding setting, which requires BMLT 3.1.1 or above (thanks @AdamH !)
- #184 - Feature: Support for publish/unpublish meetings on the virtual.na.org site, by adjusting the worldid from U to G (thanks @brustar64 !)
- Added deprecation of BMLT 2.x note to submissions page

## 1.1.12 (Jul 28, 2024)
- Haven't done this release thing in a while...

Expand Down
14 changes: 10 additions & 4 deletions admin/admin_submissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@
<option value="1"><?php echo __( 'Yes', 'bmlt-workflow' ); ?></option>
<option value="0"><?php echo __( 'No', 'bmlt-workflow' ); ?></option>
</select>
<label for="quickedit_virtualna_published"><?php echo __( 'Publish on virtual.na.org?', 'bmlt-workflow' ); ?></label>
<select class="quickedit-input" name="quickedit_virtualna_published" id="quickedit_virtualna_published">
<option value="1"><?php echo __( 'Yes', 'bmlt-workflow' ); ?></option>
<option value="0"><?php echo __( 'No', 'bmlt-workflow' ); ?></option>
</select>

<label for="quickedit_location_text"><?php echo __( "Location", 'bmlt-workflow' ); ?></label>
<input type="text" name="quickedit_location_text" id="quickedit_location_text" class="quickedit-input">
Expand All @@ -189,9 +194,10 @@
<div id="optional_location_province">
<label id="quickedit_location_province_label" for="quickedit_location_province"><?php echo sanitize_text_field(get_option('bmltwf_optional_location_province_displayname')) ?></label>
</div>
<label for="quickedit_location_postal_code_1"><?php echo sanitize_text_field(get_option('bmltwf_optional_postcode_displayname')) ?></label>
<input class="quickedit-input" type="text" name="quickedit_location_postal_code_1" id="quickedit_location_postal_code_1" required>

<div id="optional_postcode">
<label id="quickedit_location_postal_code_1_label" for="quickedit_location_postal_code_1"><?php echo sanitize_text_field(get_option('bmltwf_optional_postcode_displayname')) ?></label>
<input class="quickedit-input" type="text" name="quickedit_location_postal_code_1" id="quickedit_location_postal_code_1" required>
</div>
<div id="optional_location_nation">
<label id="location_nation_label" for="quickedit_location_nation"><?php echo sanitize_text_field(get_option('bmltwf_optional_location_nation_displayname')) ?></label>
<input class="quickedit-input" type="text" name="quickedit_location_nation" size="50" id="quickedit_location_nation">
Expand All @@ -217,7 +223,7 @@
<h2><?php echo __( "Meeting Submissions", 'bmlt-workflow' ); ?></h2>
<hr class="bmltwf-error-message">

<div class="dt-container">
<div class="dt-container" style="display: none;">
<table id="dt-submission" class="display" style="width:90%">
<thead>
<tr>
Expand Down
499 changes: 242 additions & 257 deletions bmlt-workflow.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docker/Dockerfile-wp-php8.3
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN apt-get update && \

ENV PHP_INI_PATH "/usr/local/etc/php/php.ini"

RUN pecl install xdebug-3.1.2 && docker-php-ext-enable xdebug \
RUN pecl install xdebug && docker-php-ext-enable xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" >> ${PHP_INI_PATH} \
&& echo "xdebug.remote_port=9000" >> ${PHP_INI_PATH} \
&& echo "xdebug.remote_enable=1" >> ${PHP_INI_PATH} \
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile-wpmultisite-php8.3
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN apt-get update && \

ENV PHP_INI_PATH "/usr/local/etc/php/php.ini"

RUN pecl install xdebug-3.1.2 && docker-php-ext-enable xdebug \
RUN pecl install xdebug && docker-php-ext-enable xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" >> ${PHP_INI_PATH} \
&& echo "xdebug.remote_port=9000" >> ${PHP_INI_PATH} \
&& echo "xdebug.remote_enable=1" >> ${PHP_INI_PATH} \
Expand Down
2 changes: 1 addition & 1 deletion docker/wp-multisite-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ EOF

sed -i -e "s/RewriteBase \/placeholder\//RewriteBase \/$WORDPRESS_HOST\//" $sitelocalpath/.htaccess

wp core multisite-install --path=$sitelocalpath --base=/$WORDPRESS_HOST/ --url=$siteurl --title="hi" --admin_user=admin --admin_password=admin [email protected]
wp db create
wp core multisite-install --path=$sitelocalpath --base=/$WORDPRESS_HOST/ --url=$siteurl --title="hi" --admin_user=admin --admin_password=admin [email protected]

mkdir $sitelocalpath/wp-content/plugins/bmlt-workflow
sync-plugin.sh $sitelocalpath
Expand Down
159 changes: 131 additions & 28 deletions js/admin_submissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@
// along with bmlt-workflow. If not, see <http://www.gnu.org/licenses/>.

/* global wp, jQuery, google */
/* global bmltwf_clear_notices, bmltwf_notice_success, bmltwf_notice_error, bmltwf_fetchJsonp */
/* global bmltwf_clear_notices, bmltwf_notice_success, bmltwf_notice_error, bmltwf_fetchJsonp, bmltwf_is_v3_server */
/* global bmltwf_gmaps_key, bmltwf_auto_geocoding_enabled, bmltwf_optional_location_nation, bmltwf_optional_location_sub_province, bmltwf_optional_location_province */
/* global bmltwf_do_states_and_provinces, bmltwf_counties_and_sub_provinces, bmltwf_remove_virtual_meeting_details_on_venue_change, bmltwf_bmlt_server_address */
/* global bmltwf_default_closed_meetings, bmltwf_bmlt_formats, bmltwf_datatables_delete_enabled, bmltwf_admin_submissions_rest_url, bmltwf_admin_bmltwf_service_bodies */
/* global bmltwf_optional_location_province_displayname, bmltwf_optional_location_sub_province_displayname, bmltwf_optional_location_nation_displayname */
/* global bmltwf_bmltserver_geolocate_rest_url, bmltwf_optional_postcode_displayname */
/* global bmltwf_bmltserver_geolocate_rest_url, bmltwf_optional_postcode, bmltwf_zip_auto_geocoding, bmltwf_county_auto_geocoding */

const { __ } = wp.i18n;

function initMap(origlat = null, origlng = null) {
let lat;
let lng;

// Show datatable once maps is loaded
jQuery('.dt-container').show();

if (origlat && origlng) {
if (typeof origlat === 'string') {
lat = parseFloat(origlat);
Expand All @@ -54,22 +57,32 @@ function initMap(origlat = null, origlng = null) {
const marker = new google.maps.marker.AdvancedMarkerElement({
position: { lat, lng },
map,
gmpDraggable: true,
title: 'Meeting Location',
});

const infowindow = new google.maps.InfoWindow({
content: `<p>Marker Location: ${marker.position.lat}, ${marker.position.lng}</p>`,
content: `Marker Location: ${marker.position.lat}, ${marker.position.lng}`,
});

google.maps.event.addListener(marker, 'click', () => {
infowindow.open(map, marker);
});

marker.addListener('dragend', () => {
jQuery('#quickedit_latitude').val(marker.position.lat);
jQuery('#quickedit_longitude').val(marker.position.lng);
infowindow.close();
infowindow.setContent(`Marker Location: ${marker.position.lat}, ${marker.position.lng}`);
infowindow.open(marker.map, marker);
});
}
}

function mysql2localdate(data) {
const t = data.split(/[- :]/);
const d = new Date(Date.UTC(t[0], t[1] - 1, t[2], t[3], t[4], t[5]));
const ds = `${d.getFullYear()}-${(`0${d.getMonth() + 1}`).slice(-2)}-${(`0${d.getDate()}`).slice(-2)} ${(`0${d.getHours()}`).slice(-2)}:${(`0${d.getMinutes()}`).slice(-2)}`;
const ds = `${d.getFullYear()}-${`0${d.getMonth() + 1}`.slice(-2)}-${`0${d.getDate()}`.slice(-2)} ${`0${d.getHours()}`.slice(-2)}:${`0${d.getMinutes()}`.slice(-2)}`;
return ds;
}

Expand All @@ -83,11 +96,23 @@ const venue_types = {
jQuery(document).ready(function ($) {
let bmltwf_changedata = {};

const weekdays = [__('Error', 'bmlt-workflow'), __('Sunday', 'bmlt-workflow'), __('Monday', 'bmlt-workflow'), __('Tuesday', 'bmlt-workflow'),
__('Wednesday', 'bmlt-workflow'), __('Thursday', 'bmlt-workflow'), __('Friday', 'bmlt-workflow'), __('Saturday', 'bmlt-workflow')];
const weekdays = [
__('Error', 'bmlt-workflow'),
__('Sunday', 'bmlt-workflow'),
__('Monday', 'bmlt-workflow'),
__('Tuesday', 'bmlt-workflow'),
__('Wednesday', 'bmlt-workflow'),
__('Thursday', 'bmlt-workflow'),
__('Friday', 'bmlt-workflow'),
__('Saturday', 'bmlt-workflow'),
];

$.getScript(`https://maps.googleapis.com/maps/api/js?key=${bmltwf_gmaps_key}&loading=async&libraries=marker&callback=initMap&v=weekly&async=2`);

if (!bmltwf_is_v3_server) {
bmltwf_notice_error(__('Support for BMLT Server version 2.x will end soon. Please upgrade your BMLT Server version to 3.x or above.'), 'bmltwf-error-message');
}

if (!bmltwf_auto_geocoding_enabled) {
$('#optional_auto_geocode_enabled').hide();
} else {
Expand Down Expand Up @@ -143,6 +168,22 @@ jQuery(document).ready(function ($) {
break;
}

switch (bmltwf_optional_postcode) {
case 'hidden':
case '':
$('#optional_postcode').hide();
break;
case 'display':
$('#optional_postcode').show();
break;
case 'displayrequired':
$('#optional_postcode').show();
$('#location_province_label').append('<span class="bmltwf-required-field"> *</span>');
break;
default:
break;
}

// fill in counties and sub provinces
if (bmltwf_counties_and_sub_provinces === false) {
$('#optional_location_sub_province').append('<input class="quickedit-input" type="text" name="quickedit_location_sub_province" size="50" id="quickedit_location_sub_province">');
Expand Down Expand Up @@ -253,6 +294,20 @@ jQuery(document).ready(function ($) {
// remove any content from the input fields
$('.quickedit-input').val('');

// zip and county are disabled if the option is set

const autocompleted = ` (${__('autocompleted')})`;
if (bmltwf_zip_auto_geocoding) {
$('#quickedit_location_postal_code_1').prop('disabled', true);
$('#quickedit_location_postal_code_1_label').append(autocompleted);
}

if (bmltwf_county_auto_geocoding) {
$('#optional_location_sub_province').show();
$('#quickedit_location_sub_province').prop('disabled', true);
$('#quickedit_location_sub_province_label').append(autocompleted);
}

// hide map and let it be shown later if required
$('#bmltwf_quickedit_map').hide();

Expand Down Expand Up @@ -532,7 +587,10 @@ jQuery(document).ready(function ($) {
});

$('#dt-submission_wrapper .dt-buttons').append(
`${__('Filter', 'bmlt-workflow')}: <select id='dt-submission-filters'><option value='all'>${__('All', 'bmlt-workflow')}</option><option value='pending'>${__('Pending', 'bmlt-workflow')}</option><option value='approved'>${__('Approved', 'bmlt-workflow')}</option><option value='rejected'>${__('Rejected', 'bmlt-workflow')}</option></select>`,
`${__('Filter', 'bmlt-workflow')}: <select id='dt-submission-filters'><option value='all'>${__('All', 'bmlt-workflow')}</option><option value='pending'>${__(
'Pending',
'bmlt-workflow',
)}</option><option value='approved'>${__('Approved', 'bmlt-workflow')}</option><option value='rejected'>${__('Rejected', 'bmlt-workflow')}</option></select>`,
);
$('#dt-submission-filters').change(function () {
$('#dt-submission').DataTable().draw();
Expand Down Expand Up @@ -653,17 +711,15 @@ jQuery(document).ready(function ($) {

Object.keys(c).forEach((key) => {
switch (key) {
case 'meeting_name':
{
case 'meeting_name': {
let mname = __('Meeting Name (new)', 'bmlt-workflow');
if (d.submission_type === 'reason_close') {
mname = __('Meeting Name', 'bmlt-workflow');
}
table += column(col_meeting_details, mname, c[key]);
break;
}
case 'venue_type':
{
case 'venue_type': {
const vtype = venue_types[c[key]];
if ('original_venue_type' in c) {
const ovtype = venue_types[c.original_venue_type];
Expand All @@ -673,22 +729,30 @@ jQuery(document).ready(function ($) {
}
break;
}
case 'published':
{
const published = ((c[key] === 1) ? 'Yes' : 'No');
case 'published': {
const published = c[key] === 1 ? 'Yes' : 'No';
if ('original_published' in c) {
const opublished = ((c.original_published === 1 || c.original_published === true) ? 'Yes' : 'No');
const opublished = c.original_published === 1 || c.original_published === true ? 'Yes' : 'No';
table += column(col_meeting_details, __('Published', 'bmlt-workflow'), `${opublished}${published}`);
} else {
table += column(col_meeting_details, __('Published', 'bmlt-workflow'), `${published}`);
}
break;
}
case 'virtualna_published': {
const published = c[key] === '1' ? 'Yes' : 'No';
if ('original_virtualna_published' in c) {
const opublished = c.original_published === 1 || c.original_published === true ? 'Yes' : 'No';
table += column(col_meeting_details, __('Virtual.na.org Published', 'bmlt-workflow'), `${opublished}${published}`);
} else {
table += column(col_meeting_details, __('Virtual.na.org Published', 'bmlt-workflow'), `${published}`);
}
break;
}
case 'start_time':
table += column(col_meeting_details, __('Start Time', 'bmlt-workflow'), c[key]);
break;
case 'duration_time':
{
case 'duration_time': {
const durationarr = d.changes_requested.duration_time.split(':');
table += column(col_meeting_details, __('Duration', 'bmlt-workflow'), `${durationarr[0]}h${durationarr[1]}m`);
break;
Expand All @@ -715,7 +779,7 @@ jQuery(document).ready(function ($) {
table += column(col_meeting_details, bmltwf_optional_location_nation_displayname, c[key]);
break;
case 'location_postal_code_1':
table += column(col_meeting_details, bmltwf_optional_postcode_displayname, c[key]);
table += column(col_meeting_details, bmltwf_optional_postcode, c[key]);
break;
case 'group_relationship':
table += column(col_personal_details, __('Relationship to Group', 'bmlt-workflow'), c[key]);
Expand All @@ -734,6 +798,12 @@ jQuery(document).ready(function ($) {
case 'other_reason':
table += column(col_fso_other, __('Other Reason', 'bmlt-workflow'), c[key]);
break;
case 'latitude':
table += column(col_fso_other, __('Latitude (calculated)', 'bmlt-workflow'), c[key]);
break;
case 'longitude':
table += column(col_fso_other, __('Longitude (calculated)', 'bmlt-workflow'), c[key]);
break;
case 'contact_number':
table += column(col_personal_details, __('Contact number (confidential)', 'bmlt-workflow'), c[key]);
break;
Expand All @@ -750,8 +820,7 @@ jQuery(document).ready(function ($) {
table += column(col_virtual_meeting_details, __('Virtual Meeting Link', 'bmlt-workflow'), c[key]);
break;

case 'format_shared_id_list':
{
case 'format_shared_id_list': {
const friendlyname = __('Meeting Formats', 'bmlt-workflow');
// convert the meeting formats to human readable
let friendlydata = '';
Expand Down Expand Up @@ -827,7 +896,16 @@ jQuery(document).ready(function ($) {
}

function geolocate_handler() {
const locfields = ['location_street', 'location_municipality', 'location_province', 'location_postal_code_1', 'location_sub_province', 'location_nation'];
const locfields = ['location_street', 'location_municipality', 'location_province', 'location_nation'];

if (!bmltwf_zip_auto_geocoding) {
locfields.push('location_postal_code_1');
}

if (!bmltwf_county_auto_geocoding) {
locfields.push('location_sub_province');
}

const locdata = [];

locfields.forEach((item) => {
Expand All @@ -852,8 +930,30 @@ jQuery(document).ready(function ($) {
},
})
.done(function (response) {
const lat = response.latitude;
const long = response.longitude;
// const lat = response.latitude;
// const long = response.longitude;
const lat = response.results[0].geometry.location.lat;
const long = response.results[0].geometry.location.lng;

if (bmltwf_zip_auto_geocoding) {
// eslint-disable-next-line consistent-return
$.each(response.results[0].address_components, function (i, v) {
if (v.types.includes('postal_code')) {
$('#quickedit_location_postal_code_1').val(v.short_name);
return false;
}
});
}
if (bmltwf_county_auto_geocoding) {
// eslint-disable-next-line consistent-return
$.each(response.results[0].address_components, function (i, v) {
if (v.types.includes('administrative_area_level_2')) {
$('#quickedit_location_sub_province').val(v.short_name);
return false;
}
});
}

$('#quickedit_latitude').val(lat);
$('#quickedit_longitude').val(long);
update_gmaps(lat, long);
Expand All @@ -878,17 +978,22 @@ jQuery(document).ready(function ($) {
if (short_id === 'format_shared_id_list') {
quickedit_changes_requested[short_id] = $(this).val().join(',');
} else if (short_id === 'duration_hours' || short_id === 'duration_minutes') {
// reconstruct our duration from the select list
// reconstruct our duration from the select list
// add duration entirely if either minutes or hours have changed
quickedit_changes_requested.duration_time = `${$('#quickedit_duration_hours').val()}:${$('#quickedit_duration_minutes').val()}:00`;
} else if ((short_id === 'virtual_meeting_additional_info' || short_id === 'phone_meeting_number' || short_id === 'virtual_meeting_link') && ($(this).val() === '(deleted)')) {
} else if ((short_id === 'virtual_meeting_additional_info' || short_id === 'phone_meeting_number' || short_id === 'virtual_meeting_link') && $(this).val() === '(deleted)') {
delete quickedit_changes_requested[short_id];
} else {
quickedit_changes_requested[short_id] = $(this).val();
}
}
});

if ($('#quickedit_latitude').val()) {
quickedit_changes_requested.latitude = $('#quickedit_latitude').val();
quickedit_changes_requested.longitude = $('#quickedit_longitude').val();
}

parameters.changes_requested = quickedit_changes_requested;

$.ajax({
Expand Down Expand Up @@ -969,9 +1074,7 @@ jQuery(document).ready(function ($) {
function generic_approve_handler(id, action, url, slug) {
const parameters = {};
if ($(`#${slug}_dialog_textarea`).length) {
const action_message = $(`#${slug}_dialog_textarea`)
.val()
.trim();
const action_message = $(`#${slug}_dialog_textarea`).val().trim();
if (action_message !== '') {
parameters.action_message = action_message;
}
Expand Down
Loading

0 comments on commit 16e8300

Please sign in to comment.