diff --git a/CodebookConcertina.php b/CodebookConcertina.php new file mode 100644 index 0000000..95c4ad2 --- /dev/null +++ b/CodebookConcertina.php @@ -0,0 +1,134 @@ +0 && PAGE==='Design/data_dictionary_codebook.php') { + $btnTextShow = $this->getShowButtonText(); + $btnTextShowAll = $this->getShowAllButtonText(); + $btnTextHide = $this->getHideButtonText(); + $btnTextHideAll = $this->getHideAllButtonText(); + $defaultVisibility = $this->getDefaultVisibility(); + // add js to page to add toggle buttons and hide/show + ?> + + getProjectSetting('default-visibility'); + if ($defaultVisibility!='0' && $defaultVisibility!='1') { + $defaultVisibility = self::DEFAULT_VISIBILITY; + $this->setProjectSetting('default-visibility', $defaultVisibility); + } + return $defaultVisibility; + } + + protected function getShowButtonText() { + return $this->getButtonText('button-text-show', self::DEFAULT_TEXT_SHOW); + } + + protected function getShowAllButtonText() { + return $this->getButtonText('button-text-show-all', self::DEFAULT_TEXT_SHOW_ALL); + } + + protected function getHideButtonText() { + return $this->getButtonText('button-text-hide', self::DEFAULT_TEXT_HIDE); + } + + protected function getHideAllButtonText() { + return $this->getButtonText('button-text-hide-all', self::DEFAULT_TEXT_HIDE_ALL); + } + + protected function getButtonText($setting, $default) { + $btnText = $this->getProjectSetting($setting); + + if ($btnText=='') { + $this->setProjectSetting($setting, $default); + $btnText = $default; + } + return REDCap::escapeHtml($btnText); + } +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..ae0a447 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +******************************************************************************** +# Codebook Concertina + +Luke Stevens, Murdoch Children's Research Institute https://www.mcri.edu.au + +******************************************************************************** +## Summary + +The Codebook page displays a table of all project variables in sections +corresponding to the instrument in which they appear. + +This module provides a button in each instrument header that the user may click +to collapse or expand the fields for that instrument. A "Collapse all"/"Expand +all" button is also added above the table. + +******************************************************************************** \ No newline at end of file diff --git a/config.json b/config.json new file mode 100644 index 0000000..4019223 --- /dev/null +++ b/config.json @@ -0,0 +1,72 @@ +{ + "name": "Codebook Concertina", + + "description": "On the Codebook page, expand and collapse the table rows for the fields of each instrument.", + + "namespace": "MCRI\\CodebookConcertina", + + "authors": [ + { + "name": "Luke Stevens", + "email": "luke.stevens@mcri.edu.au", + "institution": "Murdoch Children's Research Institute" + } + ], + + "permissions": [ + "redcap_every_page_top" + ], + + "enable-every-page-hooks-on-system-pages": false, + + "links": { + }, + + "no-auth-pages": [ + ], + + "system-settings": [ + ], + + "project-settings": [ + { + "key": "default-visibility", + "name": "Default visibility of codebook variable rows", + "required": true, + "type": "radio", + "choices": [ + { "value": "0", "name": "Collapsed" }, + { "value": "1", "name": "Expanded" } + ], + "default": "1" + }, + { + "key": "button-text-show", + "name": "Button text 'Expand instrument'", + "required": true, + "type": "text", + "default": "Expand" + }, + { + "key": "button-text-show-all", + "name": "Button text 'Expand all'", + "required": true, + "type": "text", + "default": "Expand all instruments" + }, + { + "key": "button-text-hide", + "name": "Button text 'Collapse instrument'", + "required": true, + "type": "text", + "default": "Collapse" + }, + { + "key": "button-text-hide-all", + "name": "Button text 'Collapse all'", + "required": true, + "type": "text", + "default": "Collapse all instruments" + } + ] +}