Skip to content

Commit

Permalink
Stabilisation12 (#738)
Browse files Browse the repository at this point in the history
* Removed next_date for deferred jurors + Change Service Start date to deferred to date for deferred jurors (#732)

* Third party details in the juror record does not save the details (#730)

* update known issues

* update yarn known issues

* Multiple tabs open are causing data issues (#707)

* add juror-number to session keys to keep multiple versions of data separated

* update cached data for etag on editing juror details

* update to prevent a crash if the user tries to edit a juror in two different tabs in the same browser / session context

* update error message and add a route to store if the user has multiple tabs or not in their session object

* update the multiple tab warning to show a red box on top of the page

* make multiple-tabs.js its own file

* push webpack config

* update edit-pool and first summon jurors into the pool ('requested -> created' process)

* update summons update to work with multiple tabs (#718)

* Update trial-management flows to restrict multi-tab data issues (#717)

* Update trial-management flows to restrict multi-tab data issues

* removed unnecessary logs

* update the error checks to allow nulls and undefineds to do the redirect

---------

Co-authored-by: Callum Young <[email protected]>

* update the multiple tabs script to only be served for signed in people (#729)

* Added support for third party details on edit juror

* fix styling

* add fallback '-' for empty fields on thirdparty

---------

Co-authored-by: Ricardo Rocha <[email protected]>
Co-authored-by: Ricardo <[email protected]>
Co-authored-by: Callum Young <[email protected]>

* add timezone formats for the report times (possible fix) (#723)

* Returning a jury without check out time can leave jurors in limbo (#733)

* Prevent a jury from bring returned to jurors in waiting if the day has been confirmed

* Added information banner for when previous day is not confirmed for jurors in waiting

* Updated logic to use previous working day instead of yesterday

* Rebase

* Added error handling

* Added error handling

* fix styling and update const to let for reassigning data

---------

Co-authored-by: Ricardo <[email protected]>

* Digital - Assign Replies - Total is at the bottom. This has not matched where it was located in heritage (Juror digital) (#736)

* update assign replies total to be on top of the table

* remove old bureau code

* remove more old bureau code

* Removed approval limit for anyone who is not a system admin (#741)

* update age disqualification function to add missing jurorNumber property (#740)

* Updated how additional summons previousJurorCount is derived (#742)

* Update edit user permissions (#739)

* Disqualifying juror by age on editing the juror details does not save the date-of-birth (#743)

* update update juror-record journey to save update details first and then disqualify by age

* update the disqualify flow

* hotfix/JM-8077: Deferral Maintenance Screen Not Sorting on Pagination (#737)

* Fixed sorting and checking on deferral maintenance

* Updated table template

* Moved selection caption

* updated links in deferrals table

* Update sorting logic

* add spacing for jury officer to sign letters (#744)

* Updated juror details save button text (#746)

* Fixed third party details (#745)

* add a way to sort printable reports (#731)

* update known issues

* update yarn known issues

* Multiple tabs open are causing data issues (#707)

* add juror-number to session keys to keep multiple versions of data separated

* update cached data for etag on editing juror details

* update to prevent a crash if the user tries to edit a juror in two different tabs in the same browser / session context

* update error message and add a route to store if the user has multiple tabs or not in their session object

* update the multiple tab warning to show a red box on top of the page

* make multiple-tabs.js its own file

* push webpack config

* update edit-pool and first summon jurors into the pool ('requested -> created' process)

* update summons update to work with multiple tabs (#718)

* Update trial-management flows to restrict multi-tab data issues (#717)

* Update trial-management flows to restrict multi-tab data issues

* removed unnecessary logs

* update the error checks to allow nulls and undefineds to do the redirect

---------

Co-authored-by: Callum Young <[email protected]>

* update the multiple tabs script to only be served for signed in people (#729)

* add a way to sort printable reports

* allow sorting by address

* add sorting to grouped reports with a new sorting class

* remove double script for multiple tabs

* update the report definitions to include a default sort column.. update the printer to default to ascending and allow multi table reports

* remove loggings.. add error handling for print sorting and handle more sorting values correctly

* update from review comments

* update to fix issues in bespoke reports and missing columns

* revert summon-citizens change

* update report sorting from review comments

* add optional chaining on the sort checker for printing

* add query params to print url on first load if any

---------

Co-authored-by: Callum Young <[email protected]>

* update pagination modules on pool-management (#748)

* Warning triangle shouldn't show up for 2nd deferral on summons reply (#747)

* update the digital response details object to include an excusal flag to show the warning icon correctly (#749)

* update button label on edit address when submitting paper-reply (#752)

---------

Co-authored-by: Ricardo Rocha <[email protected]>
Co-authored-by: Ricardo <[email protected]>
Co-authored-by: Callum Young <[email protected]>
  • Loading branch information
4 people authored Aug 22, 2024
1 parent b0118d8 commit f016ba3
Show file tree
Hide file tree
Showing 40 changed files with 1,081 additions and 400 deletions.
172 changes: 172 additions & 0 deletions client/js/print-sortable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
$('DOMContentLoaded', () => {
$('[data-is-print-sortable="true"]').each((_, element) => {
$(element).click((e) => {
e.preventDefault();
if (e.target.tagName.toLowerCase() !== 'button') return;

const sortBy = $(element).data('sort-key');
const sortDirection = $(element).attr('aria-sort') === 'ascending' ? 'descending' : 'ascending';
setUrlSortedBy(sortBy, sortDirection);
updatePrintUrl(sortBy, sortDirection);
});
});

$('[data-module="mod-sortable-table"]').each((_, element) => {
new GroupedSortableTable(element);
});
});

function setUrlSortedBy(sortBy, sortDirection) {
const url = new URL(window.location.href);
url.searchParams.set('sortBy', sortBy);
url.searchParams.set('sortDirection', sortDirection);
window.history.pushState(null, null, url);
}

function updatePrintUrl(sortBy, sortDirection) {
const printButton = $('#print-button')[0];

const printUrl = new URL(printButton.href);
printUrl.searchParams.set('sortBy', sortBy);
printUrl.searchParams.set('sortDirection', sortDirection);

printButton.href = printUrl;
}

// this class is an adaptation of the MOJFrontend.SortableTable prototype to work with grouped tables
class GroupedSortableTable {

constructor(element) {
this.table = $(element);
this.body = this.table.find('tbody'); // find all tbody in the table

this.createStatusBox();
this.createHeadingButtons();
this.initialiseSortedColumn();
this.table.on('click', 'th button', this.onSortButtonClick.bind(this));

this.statusMessage = 'Sort by %heading% (%direction%)';
}

createStatusBox() {
this.status = $('<div aria-live="polite" role="status" aria-atomic="true" class="govuk-visually-hidden" />');
this.table.parent().append(this.status);
};

createHeadingButtons() {
const headings = this.table.find('thead th');
let heading;
for(let i = 0; i < headings.length; i++) {
heading = $(headings[i]);
if(heading.attr('aria-sort')) {
this.createHeadingButton(heading, i);
}
}
}

createHeadingButton(heading, i) {
const text = heading.text();
const button = $(`<button type="button" data-index="${i}">${text}</button>`);
heading.text('');
heading.append(button);
}

onSortButtonClick(e) {
e.preventDefault();
if (e.target.tagName.toLowerCase() !== 'button') return;

const button = $(e.target);
const columnNumber = button.data('index');
const sortBy = button.parent().data('sort-key');
const sortDirection = button.parent().attr('aria-sort') === 'ascending' ? 'descending' : 'ascending';

for (const body of this.body) {
const rows = $(body).find('tr').filter(':not([data-fixed-index])');
const sortedRows = this.sort(rows, columnNumber, sortDirection);
this.addRows(body, sortedRows);
}

this.table.find('thead th').attr('aria-sort', 'none');
button.parent().attr('aria-sort', sortDirection);

let message = this.statusMessage
.replace('%heading%', button.text())
.replace('%direction%', sortDirection);
this.status.text(message);

setUrlSortedBy(sortBy, sortDirection);
updatePrintUrl(sortBy, sortDirection);
}

initialiseSortedColumn() {
for (const body of this.body) {
const rows = $(body).find('tr').filter(':not([data-fixed-index])');

this.table.find('th')
.filter('[aria-sort="ascending"], [aria-sort="descending"]')
.first()
.each((_, el) => {
const sortDirection = $(el).attr('aria-sort');
const columnNumber = $(el).find('button').attr('data-index');
const sortedRows = this.sort(rows, columnNumber, sortDirection);
this.addRows(body, sortedRows);
});
}
}

addRows(body, rows) {
$(body).append(rows);
$(body).find('[data-fixed-index]').each((_, element) => {
const fixedIndex = $(element).attr('data-fixed-index');
if (fixedIndex === '0') {
$(body).prepend(element);
} else {
$(body).append(element);
}
});
}

sort(rows, columnNumber, sortDirection) {
return rows.sort((a, b) => {
let aValue = $(a).find('td').eq(columnNumber).attr('data-sort-value') || $(a).find('td').eq(columnNumber).text();
let bValue = $(b).find('td').eq(columnNumber).attr('data-sort-value') || $(b).find('td').eq(columnNumber).text();

if (typeof this.cellValue(aValue) === 'number' && typeof this.cellValue(bValue) === 'number') {
aValue = this.cellValue(aValue);
bValue = this.cellValue(bValue);

return this.numericSort(sortDirection, aValue, bValue);
}

return this.comparableSort(sortDirection, aValue, bValue);
});
}

numericSort(sortDirection, aValue, bValue) {
if (sortDirection === 'ascending') {
if (aValue > bValue) return 1;
if (aValue < bValue) return -1;
return 0;
} else {
if (aValue < bValue) return 1;
if (aValue > bValue) return -1;
return 0;
}
}

comparableSort(sortDirection, aValue, bValue) {
if (sortDirection === 'ascending') {
return aValue.localeCompare(bValue);
} else {
return bValue.localeCompare(aValue);
}
}

cellValue(value) {
if ($.isNumeric(value)) {
return parseFloat(value, 10);
}

return value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
}
]
}
} if user.userType === "court"
} if user.userType === "court" and isSystemAdministrator
]
}) }}
{{ csrfProtection(csrftoken) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
}) }}
{% endif %}

{% if userType === "court" %}
{% if userType === "court" and isSystemAdministrator %}
{{ govukInput({
id: "approvalLimit",
name: "approvalLimit",
Expand Down
2 changes: 1 addition & 1 deletion client/templates/administration/users/edit-user.njk
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
}) }}
{% endif %}

{% if user.userType === "COURT" and isManager %}
{% if user.userType === "COURT" and isSystemAdministrator %}
{{ govukInput({
id: "approvalLimit",
name: "approvalLimit",
Expand Down
2 changes: 1 addition & 1 deletion client/templates/administration/users/user-record.njk
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<h1 class="govuk-heading-xl govuk-!-margin-top-3 govuk-!-margin-bottom-3">{{ user.name }}</h1>
</div>

{% if not isSJO and user.email !== authentication.email %}
{% if (isManager or isSystemAdministrator) and user.email !== authentication.email %}
<div class="govuk-grid-column-one-half mod-flex mod-justify-end">
{{ govukButton({
text: "Edit user",
Expand Down
Loading

0 comments on commit f016ba3

Please sign in to comment.