diff --git a/src/public/components/EditReserveCategoryModal.vue b/src/public/components/EditReserveCategoryModal.vue index e0a550dd..962ba02e 100644 --- a/src/public/components/EditReserveCategoryModal.vue +++ b/src/public/components/EditReserveCategoryModal.vue @@ -91,7 +91,6 @@
{ - this.currentCriteria = this.currentCriteria - 1 - }) + // clear form if this is the only criteria + if (this.reserveCategory.priority.length === 1) { + this.reserveCategory.priority = [ + { + ...deepClone(defaultCriteria), + }, + ] + } else { + const deletedLastCriteria = + this.currentCriteria === this.reserveCategory.priority.length - 1 + this.reserveCategory.priority.splice(this.currentCriteria, 1) + if (deletedLastCriteria) { + this.$nextTick(() => { + this.currentCriteria = this.currentCriteria - 1 + }) + } } this.$nextTick(() => { this.validatePriorities() diff --git a/src/public/pages/load-data.vue b/src/public/pages/load-data.vue index f345baa6..a47f6b26 100644 --- a/src/public/pages/load-data.vue +++ b/src/public/pages/load-data.vue @@ -205,7 +205,7 @@ export default { ? { min: 0, max: 100000 } : null, } - const errorMessage = `Patient ${ + const errorMessage = `Patient in row ${ patientIndex + 1 } has an invalid value for ${name}: ${field}.` let realFieldValue = field @@ -223,54 +223,57 @@ export default { recipientIds.push(realFieldValue) } } - let typeCheck = dataType - if (hasCustomRandomNumber) { - typeCheck = 'NUMBER' - } - switch (typeCheck) { - case 'BOOLEAN': { - const fieldUC = field.toUpperCase() - if (!['TRUE', 'FALSE'].includes(fieldUC)) { - throw new Error( - `${errorMessage} Please ensure this is a true/false value.` - ) - } - realFieldValue = fieldUC === 'TRUE' - break + if (required) { + let typeCheck = dataType + if (hasCustomRandomNumber) { + typeCheck = 'NUMBER' } - case 'NUMBER': { - if (field && !isFloat(field)) { - throw new Error( - `${errorMessage} Please ensure this is a real number.` - ) + + switch (typeCheck) { + case 'BOOLEAN': { + const fieldUC = field.toUpperCase() + if (!['TRUE', 'FALSE'].includes(fieldUC)) { + throw new Error( + `${errorMessage} Please ensure this is a true/false value.` + ) + } + realFieldValue = fieldUC === 'TRUE' + break } - const numberVal = parseFloat(field) - if (possibleValues && !isNaN(numberVal)) { - const { min, max } = possibleValues - if (numberVal < min || numberVal > max) { + case 'NUMBER': { + if (field && !isFloat(field)) { throw new Error( - `${errorMessage} Out of range. Please ensure number is between ${min} and ${max} (inclusive).` + `${errorMessage} Please ensure this is a real number.` ) } + const numberVal = parseFloat(field) + if (possibleValues && !isNaN(numberVal)) { + const { min, max } = possibleValues + if (numberVal < min || numberVal > max) { + throw new Error( + `${errorMessage} Out of range. Please ensure number is between ${min} and ${max} (inclusive).` + ) + } + } + realFieldValue = !isNaN(numberVal) ? numberVal : null + break } - realFieldValue = !isNaN(numberVal) ? numberVal : null - break + default: + case 'STRING': + if ( + possibleValues && + Array.isArray(possibleValues) && + !possibleValues.includes(field) + ) { + throw new Error( + `${errorMessage} Please ensure value is one of ${possibleValues.join( + ', ' + )}.` + ) + } + break } - default: - case 'STRING': - if ( - possibleValues && - Array.isArray(possibleValues) && - !possibleValues.includes(field) - ) { - throw new Error( - `${errorMessage} Please ensure value is one of ${possibleValues.join( - ', ' - )}.` - ) - } - break } acc[name] = realFieldValue === '' ? null : realFieldValue acc.usedGeneratedRandomNumber = !hasCustomRandomNumber diff --git a/src/public/pages/reserve-instances.vue b/src/public/pages/reserve-instances.vue index 2122513e..531e8bc0 100644 --- a/src/public/pages/reserve-instances.vue +++ b/src/public/pages/reserve-instances.vue @@ -272,7 +272,9 @@ export default { break case 'bins': priorityStringElements.push( - `number_of_bins = ${filteredPriority.bins.length}` + `number_of_bins = ${ + filteredPriority.coarsened ? filteredPriority.bins.length : 1 + }` ) break case 'numBins': @@ -308,7 +310,7 @@ export default { ]) outputArray.push([]) outputArray.push([`Unit Allocated: ${displayConfig.unitType}`]) - outputArray.push([`Number Allocated: ${displayConfig.supply}`]) + outputArray.push([`Total Supply Rationed: ${displayConfig.supply}`]) outputArray.push([`Units Left Over: ${leftOver}`]) outputArray.push([ [