Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
47 changes: 45 additions & 2 deletions dataedit/static/peer_review/opr_contributor.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ function peerReview(config) {
selectNextField();
renderSummaryPageFields();
updateTabProgressIndicatorClasses();
updatePercentageDisplay();
}

/**
Expand Down Expand Up @@ -260,7 +261,6 @@ function clearInputFields() {
function switchCategoryTab(category) {
const currentTab = document.querySelector('.tab-pane.active'); // Get the currently active tab
const tabIdForCategory = getCategoryToTabIdMapping()[category];
console.log("tabID", tabIdForCategory);
if (currentTab.getAttribute('id') !== tabIdForCategory) {
// The clicked field does not belong to the current tab, switch to the next tab
const targetTab = document.getElementById(tabIdForCategory);
Expand Down Expand Up @@ -337,8 +337,25 @@ function selectField(fieldList, field) {
*/
function selectState(state) { // eslint-disable-line no-unused-vars
selectedState = state;
updateClientStateDict(fieldKey = selectedField, state = state);
}

function updateClientStateDict(fieldKey, state) {
state_dict = state_dict ?? {};
if (fieldKey in state_dict) {
// console.log(`Der Schlüssel '${fieldKey}' ist vorhanden.`);
state_dict[fieldKey] = state;
} else {
// console.log(`Der Schlüssel '${fieldKey}' ist nicht vorhanden.`);
state_dict[fieldKey] = state;
}
}






/**
* Renders fields on the Summary page, sorted by review state
*/
Expand Down Expand Up @@ -621,6 +638,7 @@ function saveEntrances() {
selectNextField();
renderSummaryPageFields();
updateTabProgressIndicatorClasses();
updatePercentageDisplay() ;
}

/**
Expand Down Expand Up @@ -736,7 +754,32 @@ function updateTabClasses() {
}
}
}
window.addEventListener('DOMContentLoaded', updateTabClasses);
window.addEventListener('DOMContentLoaded', function() {
updateTabClasses();
updatePercentageDisplay() ;
});

function calculateOkPercentage(stateDict) {
let totalCount = 0;
let okCount = 0;

for (let key in stateDict) {
let fieldValue = $(document.getElementById(`field_${key}`)).find('.value').text().replace(/\s+/g, ' ').trim();
if (!isEmptyValue(fieldValue)) {
totalCount++;
if (stateDict[key] === "ok") {
okCount++;
}
}
}

return totalCount === 0 ? 0 : (okCount / totalCount) * 100;
}

function updatePercentageDisplay() {
const percentage = calculateOkPercentage(state_dict);
document.getElementById("percentageDisplay").textContent = percentage.toFixed(2);
}


/**
Expand Down
25 changes: 16 additions & 9 deletions dataedit/static/peer_review/opr_reviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function peerReview(config) {
selectNextField();
renderSummaryPageFields();
updateTabProgressIndicatorClasses();
// updatePercentageDisplay();
updatePercentageDisplay();
if (state_dict) {
check_if_review_finished();
}
Expand Down Expand Up @@ -555,6 +555,7 @@ function renderSummaryPageFields() {

updateSummaryTable();
updateTabProgressIndicatorClasses();
updatePercentageDisplay();
}

/**
Expand Down Expand Up @@ -722,8 +723,9 @@ function saveEntrances() {

renderSummaryPageFields();
updateTabProgressIndicatorClasses();
// updatePercentageDisplay();
updatePercentageDisplay();
}

function getFieldState(fieldKey) {
if (state_dict && state_dict[fieldKey] !== undefined) {
return state_dict[fieldKey];
Expand Down Expand Up @@ -918,29 +920,34 @@ function updateTabClasses() {


window.addEventListener('DOMContentLoaded', function() {
updateTabClasses();
// updatePercentageDisplay() ;
updateTabClasses();
updatePercentageDisplay() ;
updateTabClasses();
});




function getTotalFieldCount() {
var allFields = makeFieldList();
return allFields.length;
}


function calculateOkPercentage(stateDict) {
let totalCount = getTotalFieldCount();
let totalCount = 0;
let okCount = 0;

for (let key in stateDict) {
if (stateDict[key] === "ok") {
okCount++;
let fieldValue = $(document.getElementById(`field_${key}`)).find('.value').text().replace(/\s+/g, ' ').trim();
if (!isEmptyValue(fieldValue)) {
totalCount++;
if (stateDict[key] === "ok") {
okCount++;
}
}
}

let percentage = (okCount / totalCount) * 100;
let percentage = totalCount === 0 ? 0 : (okCount / totalCount) * 100;
return percentage.toFixed(2);
}

Expand Down
4 changes: 2 additions & 2 deletions dataedit/templates/dataedit/opr_contributor.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ <h1 class="main-header__title">
</div>
</div>


<div class="content content-finish-review">
<p> Fields with "OK" state: <span id="percentageDisplay"></span>% </p>
<!-- Modal -->
<div class="modal fade modal-xl" id="myModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
Expand Down Expand Up @@ -292,8 +294,6 @@ <h2 id="review-field-name" style="display:none"></h2>
</main>




{% endblock main %}


Expand Down
1 change: 1 addition & 0 deletions dataedit/templates/dataedit/opr_review.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ <h1 class="main-header__title">
</div>

<div class="content content-finish-review">
<p> Fields with "OK" state: <span id="percentageDisplay"></span>% </p>
<!-- Modal -->
<div class="modal fade modal-xl" id="myModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
Expand Down
8 changes: 8 additions & 0 deletions versions/changelogs/current.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Changes

- All visitors can use metadata builder in standalone version [(#1746)](https://github.com/OpenEnergyPlatform/oeplatform/pull/1746)

- Scenario Bundle Comparison: Harmonize usage of scenario types & study descriptors on bundle & comparison pages. Additionally make all Chips clickable and provide link to oeo class description pages. [#1751](https://github.com/OpenEnergyPlatform/oeplatform/pull/1751)

- The auto-select feature on the scenario bundle/scenario edit page now shows table resources from the scenario topic in the format of: "Metadata Table Title (table_name)" to harmonize the display of table resources also when displaying a bundle. Note: Existing resources must currently be updated manually. [(#1753)](https://github.com/OpenEnergyPlatform/oeplatform/pull/1753)

- Reviewer&Contributor page: calculation of percentage of progress of reviewed fields takes into account empty fields [(#1386)](https://github.com/OpenEnergyPlatform/oeplatform/pull/1386)

## Features

## Bugs
Expand Down