Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Historical numbers and Interactive Labels #2405

Merged
merged 89 commits into from
Jan 16, 2025
Merged
Changes from 1 commit
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
09a1c07
implementation for historical numbers
RK206 Jun 25, 2024
c591ee0
add banners text
amdomanska Jun 25, 2024
6fb37ae
add top banner
amdomanska Jun 25, 2024
f669080
tiny scss adjustment
amdomanska Jun 25, 2024
a7af522
generate banner text randomly
amdomanska Jun 25, 2024
95da7d0
read cms data from the template rather than directly
amdomanska Jun 25, 2024
88eb164
refactor the renderGroupInfo function in dashboard
amdomanska Jun 26, 2024
9912615
move activities to includes file
amdomanska Jun 28, 2024
ea73f56
add historical statistics
amdomanska Jun 28, 2024
8f02b97
remove js-yaml
amdomanska Jun 28, 2024
80d601c
remove commented out code
amdomanska Jun 28, 2024
7c36573
start testdrive implementation
amdomanska Jun 28, 2024
9dc508e
add helpers class
amdomanska Jul 1, 2024
79b2096
Add testdrive
amdomanska Jul 3, 2024
0a62647
add functional tests
amdomanska Jul 3, 2024
05aabde
small change to functional tests
amdomanska Jul 3, 2024
aadbed0
fixes to testdrive
amdomanska Jul 3, 2024
e5396d2
change name of variable
amdomanska Jul 3, 2024
594910b
Merge branch 'develop' into feature/3849_historical_numbers
amdomanska Jul 3, 2024
bcc2e95
fix tab behaviour
amdomanska Jul 9, 2024
1116bb1
remove accidental csv files
amdomanska Jul 9, 2024
1379328
remove accidental file
amdomanska Jul 9, 2024
b79d3e6
Merge branch 'develop' into feature/3849_historical_numbers
amdomanska Jul 29, 2024
fd29ab6
add unassigned fragment to 'by editor' list
amdomanska Jul 29, 2024
7536426
add interactive color legend
amdomanska Jul 29, 2024
06d70b0
simplify the progress-bar scss file and add title to the color legend…
amdomanska Jul 29, 2024
3ae0e37
add functional test
amdomanska Jul 29, 2024
e9a6135
Merge branch 'develop' into feature/3849_historical_numbers
richard-jones Sep 4, 2024
1b249f3
a bit of code tidy up
richard-jones Sep 5, 2024
6918646
minor wording change to motivational banner
richard-jones Sep 5, 2024
ec6536d
display 0 for groups with no apps
amdomanska Sep 12, 2024
5808c8e
remove package json files
amdomanska Sep 12, 2024
dfd8128
rm unnecessary file
amdomanska Sep 12, 2024
795d186
rm unnecessary file
amdomanska Sep 12, 2024
8bf5ee3
correct historical statistics functional test for admin
amdomanska Sep 12, 2024
0a0eea0
ensure index consistency in statistics testdrive
amdomanska Sep 12, 2024
bb47fb4
Refactor methods names
amdomanska Sep 12, 2024
7def99d
check for hs being none
amdomanska Sep 12, 2024
f0730ab
add mini tour to the colour legend links
amdomanska Sep 23, 2024
1b6ef34
Merge branch 'feature/3849_historical_numbers' into feature/3917_sear…
amdomanska Sep 23, 2024
6f4b5d0
add editor and remove assed from the new tour
amdomanska Oct 1, 2024
bcb1089
implementation for historical numbers
RK206 Jun 25, 2024
0e7b3c2
add banners text
amdomanska Jun 25, 2024
218884e
add top banner
amdomanska Jun 25, 2024
f73ff70
tiny scss adjustment
amdomanska Jun 25, 2024
3e2fbdf
generate banner text randomly
amdomanska Jun 25, 2024
c8517bd
read cms data from the template rather than directly
amdomanska Jun 25, 2024
a1703f8
refactor the renderGroupInfo function in dashboard
amdomanska Jun 26, 2024
ec85d0f
move activities to includes file
amdomanska Jun 28, 2024
44d84fb
add historical statistics
amdomanska Jun 28, 2024
5436de9
remove js-yaml
amdomanska Jun 28, 2024
ad23cfe
remove commented out code
amdomanska Jun 28, 2024
06fb3b3
start testdrive implementation
amdomanska Jun 28, 2024
c8d0ddb
add helpers class
amdomanska Jul 1, 2024
47dc49b
Add testdrive
amdomanska Jul 3, 2024
8910628
add functional tests
amdomanska Jul 3, 2024
0498269
small change to functional tests
amdomanska Jul 3, 2024
94134c1
fixes to testdrive
amdomanska Jul 3, 2024
0307794
change name of variable
amdomanska Jul 3, 2024
45a5953
fix tab behaviour
amdomanska Jul 9, 2024
898ac77
remove accidental csv files
amdomanska Jul 9, 2024
36d39cf
remove accidental file
amdomanska Jul 9, 2024
398524d
add unassigned fragment to 'by editor' list
amdomanska Jul 29, 2024
7adf2f2
a bit of code tidy up
richard-jones Sep 5, 2024
bdabd30
minor wording change to motivational banner
richard-jones Sep 5, 2024
1c66a71
display 0 for groups with no apps
amdomanska Sep 12, 2024
2ef0d53
remove package json files
amdomanska Sep 12, 2024
4fa5415
rm unnecessary file
amdomanska Sep 12, 2024
6543693
rm unnecessary file
amdomanska Sep 12, 2024
1a51957
correct historical statistics functional test for admin
amdomanska Sep 12, 2024
73b32a0
ensure index consistency in statistics testdrive
amdomanska Sep 12, 2024
9e051dc
Refactor methods names
amdomanska Sep 12, 2024
f8b920e
check for hs being none
amdomanska Sep 12, 2024
5c6a9a5
dont display the header of a by status graph if no applications and a…
amdomanska Oct 1, 2024
45ac7a2
fix the name vs id bug
amdomanska Oct 1, 2024
a8c00d0
move file
amdomanska Oct 1, 2024
6a616f0
merge
amdomanska Oct 1, 2024
e538f28
update
amdomanska Oct 1, 2024
4552530
move file back
amdomanska Oct 1, 2024
58becae
remove leftover colour legend
amdomanska Oct 16, 2024
f039774
fix editors names in historical statistics
amdomanska Oct 16, 2024
a319adb
display all open applications correctly
amdomanska Oct 16, 2024
c38fb8d
dont display the header of a by status graph if no applications and a…
amdomanska Oct 16, 2024
12ee4a1
fix assed name issue
amdomanska Oct 16, 2024
df58be3
remove unnecessary tour, update the text
amdomanska Oct 16, 2024
cf8d428
hide the historical stats header when not needed
amdomanska Oct 16, 2024
f867e2e
migrate template changes to new template structure
richard-jones Oct 23, 2024
efa0d96
Merge branch 'develop' into feature/3917_search_by_status
Steven-Eardley Nov 13, 2024
0f8565a
Merge branch 'develop' into feature/3917_search_by_status
Steven-Eardley Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
229 changes: 108 additions & 121 deletions portality/static/js/dashboard.js
Original file line number Diff line number Diff line change
@@ -72,153 +72,140 @@ doaj.dashboard.loadGroupTab = function (groupId) {
doaj.dashboard.groupLoaded = function (data) {
let container = $("#group-tab");
container.html(doaj.dashboard.renderGroupInfo(data));
console.log(data);
}

doaj.dashboard.groupLoadError = function (data) {
alert("Unable to determine group status at this time");
}

doaj.dashboard.renderGroupInfo = function (data) {
// ~~-> EditorGroup:Model~~

// first remove the editor from the associates list if they are there
if (data.editor_group.associates && data.editor_group.associates.length > 0) {
let edInAssEd = data.editor_group.associates.indexOf(data.editor_group.editor)
if (edInAssEd > -1) {
data.editor_group.associates.splice(edInAssEd, 1);
// Remove the editor from the associates list if they are there
_removeEditorFromAssociates = function (data) {
if (data.editor_group.associates && data.editor_group.associates.length > 0) {
let edInAssEd = data.editor_group.associates.indexOf(data.editor_group.editor);
if (edInAssEd > -1) {
data.editor_group.associates.splice(edInAssEd, 1);
}
} else {
data.editor_group.associates = []; // to avoid having to keep checking it below
}
} else {
data.editor_group.associates = []; // just to avoid having to keep checking it below
}

let allEditors = [data.editor_group.editor].concat(data.editor_group.associates);
// Generate the search query source
_generateSearchQuerySource = function (term, sort) {
return doaj.searchQuerySource({
"term": term,
"sort": sort
});
}

let editorListFrag = "";
for (let i = 0; i < allEditors.length; i++) {
let ed = allEditors[i];
// ~~-> ApplicationSearch:Page~~
let appQuerySource = doaj.searchQuerySource({
"term": [
// Generate the editor list fragment
_generateEditorListFragment = function (data, allEditors) {
let editorListFrag = "";
for (let i = 0; i < allEditors.length; i++) {
let ed = allEditors[i];
let appQuerySource = _generateSearchQuerySource([
{"admin.editor.exact": ed},
{"admin.editor_group.exact": data.editor_group.name},
{"index.application_type.exact": "new application"} // this is required so we only see open applications, not finished ones
],
"sort": [{"admin.date_applied": {"order": "asc"}}]
})
// // ~~-> UpdateRequestsSearch:Page ~~
// let urQuerySource = doaj.searchQuerySource({"term" : [
// {"admin.editor.exact" : ed},
// {"admin.editor_group.exact" : data.editor_group.name},
// {"index.application_type.exact" : "update request"} // this is required so we only see open update requests, not finished ones
// ]})
let appCount = 0;
let urCount = 0;
if (data.by_editor[ed]) {
appCount = data.by_editor[ed].applications || 0;
urCount = data.by_editor[ed].update_requests || 0;
}

if (data.editors[ed]) {
let isEd = "";
if (i === 0) { // first one in the list is always the editor
isEd = " (Editor)"
{"index.application_type.exact": "new application"} // only see open applications, not finished ones
], [{"admin.date_applied": {"order": "asc"}}]);

let appCount = data.by_editor[ed]?.applications || 0;
let urCount = data.by_editor[ed]?.update_requests || 0;

if (data.editors[ed]) {
let isEd = i === 0 ? " (Editor)" : "";
editorListFrag += `<li>`;
if (data.editors[ed].email) {
editorListFrag += `<a href="mailto:${data.editors[ed].email}" target="_blank" class="label tag" title="Send an email to ${ed}">${ed}${isEd}</a>`;
} else {
editorListFrag += `<span class="label tag">${ed}${isEd} (no email)</span>`;
}
editorListFrag += `<a href="${doaj.dashboard.context.applicationsSearchBase}?source=${appQuerySource}" class="tag tag--tertiary" title="See ${ed}’s applications" style="margin-right: 1.5rem;"><strong>${appCount}</strong> <span class="sr-only">applications</span></a></li>`;
}

editorListFrag += `<li>`
if (data.editors[ed].email) {
editorListFrag += `<a href="mailto:${data.editors[ed].email}" target="_blank" class="label tag" title="Send an email to ${ed}">${ed}${isEd}</a>`
} else {
editorListFrag += `<span class="label tag">${ed}${isEd} (no email)</span>`
}

editorListFrag += `<a href= "${doaj.dashboard.context.applicationsSearchBase}?source=${appQuerySource}" class="tag tag--tertiary" title="See ${ed}’s applications" style="margin-right: 1.5rem;"><strong>${appCount}</strong> <span class="sr-only">applications</span></a>
</li>`;
}
return editorListFrag;
}

// ~~-> ApplicationSearch:Page~~
let appUnassignedSource = doaj.searchQuerySource({
"term": [
// Generate the unassigned applications fragment
_generateUnassignedApplicationsFragment = function (data) {
let appUnassignedSource = _generateSearchQuerySource([
{"admin.editor_group.exact": data.editor_group.name},
{"index.has_editor.exact": "No"},
{"index.application_type.exact": "new application"} // this is required so we only see open applications, not finished ones
],
"sort": [{"admin.date_applied": {"order": "asc"}}]
});
// ~~-> UpdateRequestsSearch:Page ~~
// let urUnassignedSource = doaj.searchQuerySource({"term" : [
// {"admin.editor_group.exact" : data.editor_group.name},
// {"index.has_editor.exact": "No"},
// {"index.application_type.exact" : "update request"} // this is required so we only see open update requests, not finished ones
// ]})
editorListFrag += `<li>
<span class="label tag tag--featured">Unassigned</span>
<a href="${doaj.dashboard.context.applicationsSearchBase}?source=${appUnassignedSource}" class="tag tag--tertiary" title="See unassigned applications">${data.unassigned.applications} <span class="sr-only">applications</span></a>
</li>`;

let appStatusProgressBar = "";

for (let j = 0; j < doaj.dashboard.statusOrder.length; j++) {
let status = doaj.dashboard.statusOrder[j];
if (data.by_status.hasOwnProperty(status)) {
if (data.by_status[status].applications > 0) {
// ~~-> ApplicationSearch:Page~~
let appStatusSource = doaj.searchQuerySource({
"term": [
{"admin.editor_group.exact": data.editor_group.name},
{"admin.application_status.exact": status},
{"index.application_type.exact": "new application"} // this is required so we only see open applications, not finished ones
],
"sort": [{"admin.date_applied": {"order": "asc"}}]
})
{"index.application_type.exact": "new application"} // only see open applications, not finished ones
], [{"admin.date_applied": {"order": "asc"}}]);

return `<li>
<span class="label tag tag--featured">Unassigned</span>
<a href="${doaj.dashboard.context.applicationsSearchBase}?source=${appUnassignedSource}" class="tag tag--tertiary" title="See unassigned applications">${data.unassigned.applications} <span class="sr-only">applications</span></a>
</li>`;
}

// Generate the status progress bar
_generateStatusProgressBar = function (data) {
let appStatusProgressBar = "";
for (let status of doaj.dashboard.statusOrder) {
if (data.by_status[status]?.applications > 0) {
let appStatusSource = _generateSearchQuerySource([
{"admin.editor_group.exact": data.editor_group.name},
{"admin.application_status.exact": status},
{"index.application_type.exact": "new application"} // only see open applications, not finished ones
], [{"admin.date_applied": {"order": "asc"}}]);

appStatusProgressBar += `<li class="progress-bar__bar progress-bar__bar--${status.replace(' ', '-')}" style="width: ${(data.by_status[status].applications / data.total.applications) * 100}%;">
<a href="${doaj.dashboard.context.applicationsSearchBase}?source=${appStatusSource}" class="progress-bar__link" title="See ${data.by_status[status].applications} ${status} application(s)">
<strong>${data.by_status[status].applications}</strong>
</a></li>`;
}
}
return appStatusProgressBar;
}

// ~~-> ApplicationSearch:Page~~
let appGroupSource = doaj.searchQuerySource({
"term": [
// Generate the main fragment
_renderMainFragment = function (data) {
_removeEditorFromAssociates(data);

let allEditors = [data.editor_group.editor].concat(data.editor_group.associates);
let editorListFrag = _generateEditorListFragment(data, allEditors);
let unassignedFragment = _generateUnassignedApplicationsFragment(data);
let appStatusProgressBar = _generateStatusProgressBar(data);

let appGroupSource = _generateSearchQuerySource([
{"admin.editor_group.exact": data.editor_group.name},
{"index.application_type.exact": "new application"} // this is required so we only see open applications, not finished ones
],
"sort": [{"admin.date_applied": {"order": "asc"}}]
});
// ~~-> UpdateRequestsSearch:Page ~~
// let urGroupSource = doaj.searchQuerySource({ "term" : [
// {"admin.editor_group.exact" : data.editor_group.name},
// {"index.application_type.exact" : "update request"} // this is required so we only see open applications, not finished ones
// ]})
let frag = `<div class="tabs__content card">
<h3>
${data.editor_group.name}’s open applications
<a href="${doaj.dashboard.context.applicationsSearchBase}?source=${appGroupSource}" class="tag tag--secondary" title="See all ${data.editor_group.name}’s open applications ">${data.total.applications}<span class="sr-only"> applications</span></a>
</h3>

<section>
<h4 class="label label--secondary">By editor</h4>
<ul class="inlined-list">
${editorListFrag}
</ul>
</section>

<section>
<h4 class="label label--secondary">Applications by status</h4>
<h3 class="sr-only">Status progress bar colour legend</h3>
<ul class="inlined-list">
<li><span class="progress-bar__bar--pending label label--secondary" style="padding: .5em;">Pending</span></li>
<li><span class="progress-bar__bar--in-progress label label--secondary" style="padding: .5em;">In progress</span></li>
<li><span class="progress-bar__bar--completed label label--secondary" style="padding: .5em;">Completed</span></li>
<li><span class="progress-bar__bar--on-hold label label--secondary" style="padding: .5em;">On hold</span></li>
<li><span class="progress-bar__bar--ready label" style="padding: .5em; color: #FFF;">Ready</span></li>
</ul>
<ul class="inlined-list progress-bar">
${appStatusProgressBar}
</ul>
</section>
</div>`;
return frag;
{"index.application_type.exact": "new application"} // only see open applications, not finished ones
], [{"admin.date_applied": {"order": "asc"}}]);

return `<div class="tabs__content card">
<h3>
${data.editor_group.name}’s open applications
<a href="${doaj.dashboard.context.applicationsSearchBase}?source=${appGroupSource}" class="tag tag--secondary" title="See all ${data.editor_group.name}’s open applications">${data.total.applications}<span class="sr-only"> applications</span></a>
</h3>
<section>
<h4 class="label label--secondary">By editor</h4>
<ul class="inlined-list">
${editorListFrag}
${unassignedFragment}
</ul>
</section>
<section>
<h4 class="label label--secondary">Applications by status</h4>
<h3 class="sr-only">Status progress bar colour legend</h3>
<ul class="inlined-list">
<li><span class="progress-bar__bar--pending label label--secondary" style="padding: .5em;">Pending</span></li>
<li><span class="progress-bar__bar--in-progress label label--secondary" style="padding: .5em;">In progress</span></li>
<li><span class="progress-bar__bar--completed label label--secondary" style="padding: .5em;">Completed</span></li>
<li><span class="progress-bar__bar--on-hold label label--secondary" style="padding: .5em;">On hold</span></li>
<li><span class="progress-bar__bar--ready label" style="padding: .5em; color: #FFF;">Ready</span></li>
</ul>
<ul class="inlined-list progress-bar">
${appStatusProgressBar}
</ul>
</section>
</div>`;
}

return _renderMainFragment(data);
}