Skip to content

Commit

Permalink
correct sorting of empty fields on the summary page #1650
Browse files Browse the repository at this point in the history
  • Loading branch information
user committed Jul 10, 2024
1 parent 8d6cbf8 commit c5fc815
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions dataedit/static/peer_review/opr_reviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,22 +422,24 @@ function renderSummaryPageFields() {
const suggestingFields = [];
const rejectedFields = [];
const missingFields = [];
const emptyFields = [];

if (state_dict && Object.keys(state_dict).length > 0) {
const fields = document.querySelectorAll('.field');
for (let field of fields) {
let field_id = field.id.slice(6);
const fieldValue = $(field).find('.value').text().replace(/\s+/g, ' ').trim();
console.log("value " + fieldValue)
const fieldState = getFieldState(field_id);
const fieldCategory = field.getAttribute('data-category');
if (fieldState === 'ok') {
acceptedFields.push({field_id, fieldValue, fieldCategory});
if (isEmptyValue(fieldValue)) {
emptyFields.push({ field_id, fieldValue, fieldCategory: "emptyFields" });
} else if (fieldState === 'ok') {
acceptedFields.push({ field_id, fieldValue, fieldCategory });
} else if (fieldState === 'suggestion') {
suggestingFields.push({ field_id, fieldValue, fieldCategory });
} else if (fieldState === 'rejected') {
rejectedFields.push({ field_id, fieldValue, fieldCategory });
}
// TODO: The following line duplicates enties in the summary tab
// else if (fieldState === 'suggestion' || fieldState === 'rejected') {
// missingFields.push({ field_id, fieldValue, fieldCategory });
// }
}
}

Expand All @@ -447,12 +449,14 @@ function renderSummaryPageFields() {
const fieldState = review.fieldReview.state;
const fieldCategory = review.category;

if (fieldState === 'ok') {
acceptedFields.push({field_id, fieldValue, fieldCategory});
if (isEmptyValue(fieldValue)) {
emptyFields.push({ field_id, fieldValue, fieldCategory: "emptyFields" });
} else if (fieldState === 'ok') {
acceptedFields.push({ field_id, fieldValue, fieldCategory });
} else if (fieldState === 'suggestion') {
suggestingFields.push({field_id, fieldValue, fieldCategory});
suggestingFields.push({ field_id, fieldValue, fieldCategory });
} else if (fieldState === 'rejected') {
rejectedFields.push({field_id, fieldValue, fieldCategory});
rejectedFields.push({ field_id, fieldValue, fieldCategory });
}
}

Expand All @@ -471,8 +475,8 @@ function renderSummaryPageFields() {
const found = current_review.reviews.some((review) => review.key === field_id);
const fieldState = getFieldState(field_id);
const fieldCategory = field.getAttribute('data-category');
if (!found && fieldState !== 'ok') {
missingFields.push({field_id, fieldValue, fieldCategory});
if (!found && fieldState !== 'ok' && !isEmptyValue(fieldValue)) {
missingFields.push({ field_id, fieldValue, fieldCategory });
}
}
}
Expand Down Expand Up @@ -531,22 +535,21 @@ function renderSummaryPageFields() {
}


function updateSummaryTable() {
function updateSummaryTable() {
clearSummaryTable();

let allData = [];
allData.push(...missingFields.map((item) => ({...item, fieldStatus: 'Missing'})));
allData.push(...acceptedFields.map((item) => ({...item, fieldStatus: 'Accepted'})));
allData.push(...suggestingFields.map((item) => ({...item, fieldStatus: 'Suggested'})));
allData.push(...rejectedFields.map((item) => ({...item, fieldStatus: 'Rejected'})));
allData.push(...emptyFields.map((item) => ({...item, fieldStatus: 'Empty'})));

let table = generateTable(allData);
summaryContainer.appendChild(table);
}

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

/**
Expand Down

0 comments on commit c5fc815

Please sign in to comment.