Skip to content

Commit

Permalink
corrected function checkFieldStates() considering empty fields #1650
Browse files Browse the repository at this point in the history
  • Loading branch information
user committed Jun 17, 2024
1 parent bcb1899 commit 980448b
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions dataedit/static/peer_review/opr_reviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,26 +758,29 @@ function checkReviewComplete() {


function checkFieldStates() {
var fieldList = makeFieldList();
for (var i = 0; i < fieldList.length; i++) {
var fieldName = fieldList[i].replace('field_', '');
var fieldState = state_dict[fieldName];
if (fieldState !== 'ok') {
return false; // Ein Feld hat nicht den Status "ok"
const fieldList = getAllFieldsAndValues();

for (const { fieldName, fieldValue } of fieldList) {
if (!isEmptyValue(fieldValue)) {
const fieldState = state_dict[fieldName];
if (fieldState !== 'ok') {
return false;
}
}
}
return true; // Alle Felder haben den Status "ok"
return true;
}



/**
* Checks if all fields are accepted and activates award badge div to finish the review.
* Also deactivates the submitbutton.
*/
function check_if_review_finished() {
if (checkFieldStates() && !clientSideReviewFinished) {
clientSideReviewFinished = true;
showToast("Review completed!", "You completed the review an can now award a suitable badge!", 'success');
showToast("Review completed!", "You completed the review and can now award a suitable badge!", 'success');
// Creating the div with radio buttons
var reviewerDiv = $('<div class="bg-warning" id="finish-review-div"></div>');
var bronzeRadio = $('<input type="radio" name="reviewer-option" value="bronze"> Bronze<br>');
Expand All @@ -787,6 +790,8 @@ function check_if_review_finished() {
var reviewText = $('<p>The review is complete. Please award a badge and finish the review.</p>');
var finishButton = $('<button type="button" id="review-finish-button">Finish</button>');



// Adding the radio buttons, text, and button to the div
reviewerDiv.append(reviewText);
reviewerDiv.append(bronzeRadio);
Expand All @@ -809,7 +814,6 @@ function check_if_review_finished() {
$('#review-window').css('visibility', 'hidden');
}


// Adding the div to the desired location in the document
$('.content-finish-review').append(reviewerDiv);
}
Expand Down

0 comments on commit 980448b

Please sign in to comment.