Skip to content

Commit

Permalink
fix for regressions of descriptions with tomato (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgershman committed Dec 6, 2020
1 parent f2186c5 commit 2ce4884
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion crouton.php
Expand Up @@ -5,7 +5,7 @@
Description: A tabbed based display for showing meeting information.
Author: bmlt-enabled
Author URI: https://bmlt.app
Version: 3.11.12
Version: 3.11.13
*/
/* Disallow direct access to the plugin file */
if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
Expand Down
26 changes: 13 additions & 13 deletions croutonjs/src/js/crouton-core.js
Expand Up @@ -1086,10 +1086,10 @@ function getFalseResult(options, ctx) {
return options.inverse !== undefined ? options.inverse(ctx) : false;
}

function getMasterFormatId(code) {
function getMasterFormatId(code, data) {
for (var f = 0; f < crouton.masterFormatCodes.length; f++) {
var format = crouton.masterFormatCodes[f];
if (format['key_string'] === code) {
if (format['key_string'] === code && format['root_server_uri'] === data['root_server_uri']) {
return format['id'];
}
}
Expand All @@ -1113,22 +1113,22 @@ crouton_Handlebars.registerHelper('formatDataPointer', function(str) {
});

crouton_Handlebars.registerHelper('isVirtual', function(data, options) {
return ((inArray(getMasterFormatId('HY'), getFormats(data)) && !inArray(getMasterFormatId('TC'), getFormats(data)))
|| inArray(getMasterFormatId('VM'), getFormats(data)))
return ((inArray(getMasterFormatId('HY', data), getFormats(data)) && !inArray(getMasterFormatId('TC', data), getFormats(data)))
|| inArray(getMasterFormatId('VM', data), getFormats(data)))
&& (data['virtual_meeting_link'] || data['phone_meeting_number']) ? getTrueResult(options, this) : getFalseResult(options, this);
});

crouton_Handlebars.registerHelper('isHybrid', function(data, options) {
return inArray(getMasterFormatId('HY'), getFormats(data))
return inArray(getMasterFormatId('HY', data), getFormats(data))
&& (data['virtual_meeting_link'] || data['phone_meeting_number']) ? getTrueResult(options, this) : getFalseResult(options, this);
});

crouton_Handlebars.registerHelper('isTemporarilyClosed', function(data, options) {
return inArray(getMasterFormatId('TC'), getFormats(data)) ? getTrueResult(options, this) : getFalseResult(options, this);
return inArray(getMasterFormatId('TC', data), getFormats(data)) ? getTrueResult(options, this) : getFalseResult(options, this);
});

crouton_Handlebars.registerHelper('isNotTemporarilyClosed', function(data, options) {
return !inArray(getMasterFormatId('TC'), getFormats(data)) ? getTrueResult(options, this) : getFalseResult(options, this);
return !inArray(getMasterFormatId('TC', data), getFormats(data)) ? getTrueResult(options, this) : getFalseResult(options, this);
});

crouton_Handlebars.registerHelper('hasFormats', function(formats, data, options) {
Expand All @@ -1143,24 +1143,24 @@ crouton_Handlebars.registerHelper('hasFormats', function(formats, data, options)
});

crouton_Handlebars.registerHelper('temporarilyClosed', function(data, options) {
if (data['formats_expanded'].getArrayItemByObjectKeyValue('id', getMasterFormatId('TC')) !== undefined) {
return data['formats_expanded'].getArrayItemByObjectKeyValue('id', getMasterFormatId('TC'))['description'];
if (data['formats_expanded'].getArrayItemByObjectKeyValue('id', getMasterFormatId('TC', data)) !== undefined) {
return data['formats_expanded'].getArrayItemByObjectKeyValue('id', getMasterFormatId('TC', data))['description'];
} else {
return "FACILITY IS TEMPORARILY CLOSED";
}
});

crouton_Handlebars.registerHelper('meetsVirtually', function(data, options) {
if (data['formats_expanded'].getArrayItemByObjectKeyValue('id', getMasterFormatId('VM')) !== undefined) {
return data['formats_expanded'].getArrayItemByObjectKeyValue('id', getMasterFormatId('VM'))['description'];
if (data['formats_expanded'].getArrayItemByObjectKeyValue('id', getMasterFormatId('VM', data)) !== undefined) {
return data['formats_expanded'].getArrayItemByObjectKeyValue('id', getMasterFormatId('VM', data))['description'];
} else {
return "MEETS VIRTUALLY";
}
});

crouton_Handlebars.registerHelper('meetsHybrid', function(data, options) {
if (data['formats_expanded'].getArrayItemByObjectKeyValue('id', getMasterFormatId('HY')) !== undefined) {
return data['formats_expanded'].getArrayItemByObjectKeyValue('id', getMasterFormatId('HY'))['description'];
if (data['formats_expanded'].getArrayItemByObjectKeyValue('id', getMasterFormatId('HY', data)) !== undefined) {
return data['formats_expanded'].getArrayItemByObjectKeyValue('id', getMasterFormatId('HY', data))['description'];
} else {
return "MEETS VIRTUALLY AND IN PERSON";
}
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Expand Up @@ -5,7 +5,7 @@ Tags: na, meeting list, meeting finder, maps, recovery, addiction, webservant, b
Requires at least: 4.0
Required PHP: 5.6
Tested up to: 5.4.1
Stable tag: 3.11.12
Stable tag: 3.11.13
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
crouton implements a Tabbed UI for BMLT.
Expand Down Expand Up @@ -36,6 +36,9 @@ https://demo.bmlt.app/crouton

== Changelog ==

= 3.11.13 =
* Fix for regressions of descriptions with tomato.

= 3.11.12 =
* Fix for descriptions for VM, TC, and HY in non-English languages.

Expand Down

0 comments on commit 2ce4884

Please sign in to comment.