Skip to content

Commit

Permalink
[Consent] Group consents + Improve UI (#6044)
Browse files Browse the repository at this point in the history
- Adds vertical tabs for each parent consent and renders within that tab all the children consents
- For each consent rendering: adds a HeaderElement for the consent label, changes label for Yes/No select Element to 'Response', changes label for Date element to 'Date of Response'
- Hides Consent history by default
- Add Show/Hide Consent history toggling
- Cleans up the rendering of the history string
  • Loading branch information
zaliqarosli authored Aug 19, 2020
1 parent f95525a commit d504f85
Show file tree
Hide file tree
Showing 4 changed files with 270 additions and 207 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ requesting a new account and will be displayed in the User Accounts module (PR #
### Modules
#### Issue Tracker
- Readability of comments and history was improved. (PR #6138)
#### Candidate Parameters
- Consents may now be grouped in UI of consent tab (PR #6042, PR #6044)
### Clean Up
- *Add item here*
### Notes For Existing Projects
Expand Down
35 changes: 18 additions & 17 deletions modules/candidate_parameters/ajax/getData.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ function getConsentStatusFields()
$date = [];
$withdrawalDate = [];

// Get consent groups
$consentGroups = \Utility::getConsentGroups();

// Get list of all consent types
$consentDetails = \Utility::getConsentList();
// Get list of consents for candidate
Expand All @@ -431,6 +434,10 @@ function getConsentStatusFields()
foreach ($consentDetails as $consentID=>$consent) {
$consentName = $consent['Name'];
$consentList[$consentName] = $consent['Label'];
$groupID = $consent['ConsentGroupID'];

// Append consent as a child to its group
$consentGroups[$groupID]['Children'][] = $consentName;

if (isset($candidateConsent[$consentID])) {
$candidateConsentID = $candidateConsent[$consentID];
Expand All @@ -453,6 +460,7 @@ function getConsentStatusFields()
'withdrawals' => $withdrawalDate,
'consents' => $consentList,
'history' => $history,
'consentGroups' => $consentGroups,
];

return $result;
Expand All @@ -469,7 +477,7 @@ function getConsentStatusFields()
*/
function getConsentStatusHistory($pscid)
{
$db = \Database::singleton();
$db = (\NDB_Factory::singleton())->database();

$historyData = $db->pselect(
"SELECT EntryDate, DateGiven, DateWithdrawn, PSCID,
Expand All @@ -481,23 +489,16 @@ function getConsentStatusHistory($pscid)
);

$formattedHistory = [];
foreach ($historyData as $key => $entry) {
$consentName = $entry['ConsentName'];
$consentLabel = $entry['ConsentLabel'];

$history = [
'data_entry_date' => $entry['EntryDate'],
'entry_staff' => $entry['EntryStaff'],
$consentName => $entry['Status'],
$consentName . '_date' => $entry['DateGiven'],
$consentName . '_withdrawal' => $entry['DateWithdrawn'],
];
$consentHistory = [
$key => $history,
'label' => $consentLabel,
'consentType' => $consentName,
foreach ($historyData as $entry) {
$formattedHistory[] = [
'data_entry_date' => $entry['EntryDate'],
'entry_staff' => $entry['EntryStaff'],
'consentStatus' => $entry['Status'],
'date' => $entry['DateGiven'],
'withdrawal' => $entry['DateWithdrawn'],
'label' => $entry['ConsentLabel'],
'consentType' => $entry['ConsentName'],
];
$formattedHistory[$key] = $consentHistory;
}
return $formattedHistory;
}
Expand Down
Loading

0 comments on commit d504f85

Please sign in to comment.