From 607c8c04fce9595177fa734ddc21d301e1ddca6f Mon Sep 17 00:00:00 2001
From: user <martimanovadarina@gmail.com>
Date: Mon, 16 Oct 2023 18:42:06 +0200
Subject: [PATCH] dynamic percentage of fields that have state ok for reviewer
 page #1247

---
 dataedit/static/peer_review/opr_reviewer.js | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/dataedit/static/peer_review/opr_reviewer.js b/dataedit/static/peer_review/opr_reviewer.js
index 5789a58d5..46e5fa496 100644
--- a/dataedit/static/peer_review/opr_reviewer.js
+++ b/dataedit/static/peer_review/opr_reviewer.js
@@ -885,7 +885,7 @@ function getTotalFieldCount() {
 
 
 function calculateOkPercentage(stateDict) {
-  let totalCount = Object.keys(stateDict).length;
+  let totalCount = getTotalFieldCount();
   let okCount = 0;
 
   for (let key in stateDict) {
@@ -894,13 +894,15 @@ function calculateOkPercentage(stateDict) {
     }
   }
 
-  return (okCount / totalCount) * 100;
+  let percentage = (okCount / totalCount) * 100;
+  return percentage.toFixed(2);
 }
 
 function updatePercentageDisplay() {
-  document.getElementById("percentageDisplay").textContent = calculateOkPercentage(state_dict).toFixed(2);
+  document.getElementById("percentageDisplay").textContent = calculateOkPercentage(state_dict);
 }
 
+
 function updateTabProgressIndicatorClasses() {
   const tabNames = ['general', 'spatiotemporal', 'source', 'license', 'contributor', 'resource'];