From e538f2811e27210100b6633fdb1d7500a93c0e5f Mon Sep 17 00:00:00 2001 From: Aga Date: Tue, 1 Oct 2024 18:04:36 +0100 Subject: [PATCH] update --- portality/static/js/dashboard.js | 111 ++++--------------------------- 1 file changed, 13 insertions(+), 98 deletions(-) diff --git a/portality/static/js/dashboard.js b/portality/static/js/dashboard.js index ef0e49560..bf55699ad 100644 --- a/portality/static/js/dashboard.js +++ b/portality/static/js/dashboard.js @@ -138,26 +138,8 @@ ${status}`; }).join('')} `; -doaj.dashboard.renderGroupInfo = function (data) { - // 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 - } } - // Generate the search query source - _generateSearchQuerySource = function (term, sort) { - return doaj.searchQuerySource({ - "term": term, - "sort": sort - }); - } // Generate the editor list fragment _generateEditorListFragment = function (data, allEditors) { @@ -205,19 +187,18 @@ doaj.dashboard.renderGroupInfo = function (data) { // 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 += `
  • - - ${data.by_status[status].applications} -
  • `; + let url = statusLinks[status]; // Get the URL from the precomputed status links + + appStatusProgressBar += ``; } } @@ -250,56 +231,6 @@ doaj.dashboard.renderGroupInfo = function (data) { `; } - _generateStatisticsFragment = function (data) { - let statisticsFrag = ""; - let historicalNumbers = data.historical_numbers; - - if (historicalNumbers) { - statisticsFrag += `
    -

    Statistics for the current year (${historicalNumbers.year})

    `; - - if (current_user.role.includes("admin")) { - // Ready applications by editor - statisticsFrag += `

    Editor's Ready Applications: `; - statisticsFrag += `${historicalNumbers.editor.id} ${historicalNumbers.editor.count}

    `; - } - - // Completed applications by associated editor - if (historicalNumbers.associate_editors.length) { - statisticsFrag += `

    Applications Completed by associated editors

    `; - statisticsFrag += `` - } - statisticsFrag += `
    `; - } - - return statisticsFrag; - }; - - - // 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 appStatusProgressBar = _generateStatusProgressBar(data); - let statisticsFragment = _generateStatisticsFragment(data); - - let appGroupSource = _generateSearchQuerySource([ - {"admin.editor_group.exact": data.editor_group.name}, - {"index.application_type.exact": "new application"} // only see open applications, not finished ones - ], [{"admin.date_applied": {"order": "asc"}}]); - - - // Combine all fragments - let frag = `
    -

    ${data.editor_group.name}’s open applications

    - return statisticsFrag; }; @@ -323,41 +254,26 @@ doaj.dashboard.renderGroupInfo = function (data) { // Combine all fragments let frag = `

    ${data.editor_group.name}’s open applications

    - +

    Status progress bar colour legend

    ${colorLegend}
    - +

    By editor

      ${editorListFrag}
    - if (data["total"]["applications"]) { - frag += `
    -

    Applications by status

    -
      - ${appStatusProgressBar} -
    -
    ` - } - frag += ` - ${statisticsFragment} -
    `; - - return frag; - } - - +

    Applications by status

      ${appStatusProgressBar}
    - + ${statisticsFragment}
    `; @@ -367,4 +283,3 @@ doaj.dashboard.renderGroupInfo = function (data) { return _renderMainFragment(data); } -