Skip to content

Commit

Permalink
add a function for getting all fields and their values #1650
Browse files Browse the repository at this point in the history
  • Loading branch information
user committed Jun 6, 2024
1 parent 43098ec commit 0bce2e1
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion dataedit/static/peer_review/opr_reviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ function switchCategoryTab(category) {
}
}


/**
* Function to provide the mapping of category to the correct tab ID
*/
Expand Down Expand Up @@ -715,8 +716,31 @@ function getFieldState(fieldKey) {
/**
* Checks if all fields are reviewed and activates submit button if ready
*/
function checkReviewComplete() {
/**
* Returns a list of all fields and their values.
* @returns {Array} List of objects with field names and values.
*/
function getAllFieldsAndValues() {
const fields = document.querySelectorAll('.field');
const fieldList = [];

fields.forEach(field => {
const fieldName = field.id.slice(6);
const fieldValue = $(field).find('.value').text().replace(/\s+/g, ' ').trim();
fieldList.push({ fieldName, fieldValue });
});

return fieldList;
}



/**
* Checks if all fields are reviewed and activates submit button if ready
*/
function checkReviewComplete() {
const fields = getAllFieldsAndValues();

for (let field of fields) {
let fieldName = field.id.slice(6);
const fieldState = getFieldState(fieldName);
Expand Down

0 comments on commit 0bce2e1

Please sign in to comment.