Skip to content

Commit

Permalink
Merge branch 'release/2.3.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
pbchase committed Dec 11, 2023
2 parents 598a51e + 7a4d783 commit 897603d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 18 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
All notable changes to the REDCap Entity project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [2.3.8] - 2023-12-11
### Changed
- Add namespace to SchemaManagerPage Clears PSALM errors (@ChemiKyle, #36)
- Fix implementaiton of Select2 in project dropdowns (@ChemiKyle, #32)


## [2.3.7] - 2022-09-01
### Changed
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.7
2.3.8
11 changes: 9 additions & 2 deletions classes/EntityList.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,9 +733,13 @@ protected function loadPageScripts() {
// 9.3.? has begun migrating some files from ExternalModule/manager/ to Resources/
// The complicated nature of this ternary is essential due to backup pathing, realpath cannot simplify this
// APP_PATH_EXTMOD and APP_URL_EXTMOD are not interchangeable for their respective uses
// 10.? removed select2 from Resources, it appears available in core itself but just to be safe get 4.0.5 from CDN
$this->jsFiles[] = file_exists(APP_PATH_EXTMOD . 'manager/js/select2.js') ?
APP_URL_EXTMOD . 'manager/js/select2.js' :
APP_PATH_JS . 'select2.js';
(file_exists(APP_PATH_JS . 'select2.js') ?
APP_PATH_JS . 'select2.js' :
"https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js"
);
$this->jsFiles[] = ExternalModules::getUrl(REDCAP_ENTITY_PREFIX, 'manager/js/entity_list.js');
$this->jsFiles[] = ExternalModules::getUrl(REDCAP_ENTITY_PREFIX, 'manager/js/entity_fields.js');

Expand All @@ -750,7 +754,10 @@ protected function loadPageScripts() {
protected function loadPageStyles() {
$this->cssFiles[] = file_exists(APP_PATH_EXTMOD . 'manager/css/select2.css') ?
APP_URL_EXTMOD . 'manager/css/select2.css' :
APP_PATH_CSS . 'select2.css';
(file_exists(APP_PATH_CSS . 'select2.css') ?
APP_PATH_CSS . 'select2.css':
'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/css/select2.min.css'
);
$this->cssFiles[] = ExternalModules::getUrl(REDCAP_ENTITY_PREFIX, 'manager/css/entity_list.css');

parent::loadPageStyles();
Expand Down
1 change: 0 additions & 1 deletion classes/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ function render($context, $title, $icon) {
case 'global':
$objHtmlPage = new HtmlPage();
$objHtmlPage->addExternalJS(APP_PATH_JS . 'base.js');
$objHtmlPage->addStylesheet('jquery-ui.min.css', 'screen,print');
$objHtmlPage->addStylesheet('style.css', 'screen,print');
$objHtmlPage->addStylesheet('home.css', 'screen,print');
$objHtmlPage->PrintHeader();
Expand Down
2 changes: 2 additions & 0 deletions classes/SchemaManagerPage.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace REDCapEntity\ExternalModule;

require_once 'Page.php';

use REDCapEntity\Page;
Expand Down
29 changes: 15 additions & 14 deletions manager/js/entity_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@ $(function() {
$('select.redcap-entity-select-project').each(function() {
var label = $('label[for="' + $(this).prop('id') + '"]').text();

$(this).select2({
placeholder: '-- ' + label + '--',
allowClear: true,
ajax: {
url: redcapEntity.projectReferenceUrl,
dataType: 'json',
cache: true,
delay: 250,
data: function (params) {
return {
'parameters': params.term
};
}
}
let element = $(this);

// select2's built-in ajax functionality disables select2 filtering
// instead populate options with array from a completed ajax call
// See: https:select2.org/data-sources/ajax#transforming-response-data
$.ajax({
type: 'GET',
url: redcapEntity.projectReferenceUrl,
dataType: 'json'
}).then(function (data) {
element.select2({
placeholder: '-- ' + label + '--',
allowClear: true,
data: data.results
})
});
});

Expand Down

0 comments on commit 897603d

Please sign in to comment.