diff --git a/src/js/models/metadata/eml211/EMLAttribute.js b/src/js/models/metadata/eml211/EMLAttribute.js index 47e993b38..4e0b1381a 100644 --- a/src/js/models/metadata/eml211/EMLAttribute.js +++ b/src/js/models/metadata/eml211/EMLAttribute.js @@ -481,25 +481,27 @@ define(["jquery", "underscore", "backbone", "uuid", errors.measurementScale = "Choose a measurement scale category for this attribute."; } else{ - var measurementScaleIsValid = measurementScaleModel.isValid(); - - // If there is a measurement scale model and it is valid and there are no other - // errors, then trigger this model as valid and exit. - if( measurementScaleIsValid && !Object.keys(errors).length ){ - - this.trigger("valid", this); - return; - - } - else if( !measurementScaleIsValid ){ + if( !measurementScaleModel.isValid() ){ errors.measurementScale = "More information is needed."; } - } - - //If there is at least one error, then return the errors object - if(Object.keys(errors).length) - return errors; + } + + // Validate the missing value codes + var missingValueCodesErrors = this.get("missingValueCodes")?.validate(); + if (missingValueCodesErrors) { + // Just display the first error message + errors.missingValueCodes = Object.values(missingValueCodesErrors)[0] + } + // If there is a measurement scale model and it is valid and there are no other + // errors, then trigger this model as valid and exit. + if (!Object.keys(errors).length) { + this.trigger("valid", this); + return; + } else { + //If there is at least one error, then return the errors object + return errors; + } }, /* diff --git a/src/js/views/metadata/EML211MissingValueView.js b/src/js/views/metadata/EML211MissingValueView.js index f4a4461ed..bac4ac39d 100644 --- a/src/js/views/metadata/EML211MissingValueView.js +++ b/src/js/views/metadata/EML211MissingValueView.js @@ -12,7 +12,7 @@ define([ * collection, the view will also provide a button to remove the model from * the collection. * @classcategory Views/Metadata - * @screenshot views/metadata/EMLMissingValueView.png // <- TODO + * @screenshot views/metadata/EMLMissingValueView.png * @extends Backbone.View * @since x.x.x */ diff --git a/src/js/views/metadata/EML211MissingValuesView.js b/src/js/views/metadata/EML211MissingValuesView.js index 373d84a78..2563fcab8 100644 --- a/src/js/views/metadata/EML211MissingValuesView.js +++ b/src/js/views/metadata/EML211MissingValuesView.js @@ -19,7 +19,7 @@ define([ * "Remove" button next to the code. A new row of inputs will automatically be * added to the view when the user starts typing in the last row of inputs. * @classcategory Views/Metadata - * @screenshot views/metadata/EMLMissingValuesView.png // <- TODO + * @screenshot views/metadata/EMLMissingValuesView.png * @extends Backbone.View * @since x.x.x */ @@ -101,6 +101,7 @@ define([ } this.setListeners(); this.el.innerHTML = ""; + this.el.setAttribute("data-category", "missingValueCodes"); this.renderText(); this.renderRows(); @@ -125,7 +126,6 @@ define([ this.notification = document.createElement("p"); this.notification.classList.add(this.classes.notification); - this.notification.setAttribute("data-category", "missingValueCodes"); this.el.appendChild(this.notification); },