Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHANGE][GWELLS-2089] Add validation for newly constructed wells #2136

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/frontend/src/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ export const TOOLTIP_TEXT = {
analysis_method: 'Mathematical solutions (Theis, Cooper-Jacob, Neuman, etc.) where response data (discharge, drawdown/time) from pumping tests are used to estimate the hydraulic properties of aquifers.',
},
}

export const DEWATERING_DRAINAGE_WELL_CLASS = "DEW_DRA";
export const WATER_SUPPLY_WELL_CLASS = "WATR_SPPLY";
export const PERMANENT_SUBCLASS = "46300f40-fc6b-4c77-a58e-74472cd69f5d";
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
</b-col>
</b-row>
<p v-if="!isStaffEdit">Submit activity on a well. <a href="/gwells/" target="_blank">Try a search</a> to see if the well exists in the system before submitting a report.</p>
<p>All form fields marked with a trailing asterisk are mandatory fields.</p>

<!-- Form load/save -->
<b-row v-if="!isStaffEdit">
Expand Down
80 changes: 76 additions & 4 deletions app/frontend/src/submissions/views/SubmissionsHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ import ActivitySubmissionForm from '@/submissions/components/SubmissionForm/Acti
import parseErrors from '@/common/helpers/parseErrors.js'
import { RESET_WELL_DATA } from '@/wells/store/actions.types.js'

import { DEWATERING_DRAINAGE_WELL_CLASS, WATER_SUPPLY_WELL_CLASS, PERMANENT_SUBCLASS } from '@/common/constants.js'

export default {
name: 'SubmissionsHome',
mixins: [inputFormatMixin, filterBlankRows],
Expand Down Expand Up @@ -579,9 +581,79 @@ export default {
}
this.componentUpdateTrigger = Date.now()
},
newlyConstructedWellValidation(errors) {

const {
owner_full_name,
owner_mailing_address,
drilling_methods,
total_depth_drilled,
finished_well_depth,
final_casing_stick_up,
work_start_date,
work_end_date,
well_class,
well_subclass,
identification_plate_number,
well_identification_plate_attached,
} = this.form

const mandatoryLicensingDate = new Date('2016-03-01');
mandatoryLicensingDate.setHours(0, 0 , 0 , 0);
const workStartDate = new Date(`${work_start_date}`);

if (this.activityType !== 'CON') return;

if (isNaN(workStartDate)) return errors.work_start_date = ['Invalid work start date.'];

if (workStartDate < mandatoryLicensingDate) return;

// If Class of Wells is Dewatering/Drainage (and well subclass is permanent) or Water supply: Well Identification Plate Number, Where Identification Plate Attached

if ((well_class === DEWATERING_DRAINAGE_WELL_CLASS && well_subclass === PERMANENT_SUBCLASS) || well_class === WATER_SUPPLY_WELL_CLASS) {
if (!identification_plate_number) {
errors.identification_plate_number = ['Identification Plate Number Required.'];
}
if (!well_identification_plate_attached) {
errors.well_identification_plate_attached = ['Well Identification Plate Attached Required.'];
}
}

// Start Date of Work, End Date of Work
if (!work_start_date) {
errors.work_start_date = ['Start Date of Work Required.'];
}
if (!work_end_date) {
errors.work_end_date = ['End Date of Work Required.'];
}

// Well Owner Name, Owner Mailing Address
if (!owner_full_name) {
errors.owner_full_name = ['Owners Full Name Required.'];
}
if (!owner_mailing_address) {
errors.owner_mailing_address = ['Owners Mailing Address Required.'];
}

// Geographic Coordinates (if possible/optional: error message for coordinates out of the province boundary)
// TODO: verify that this is already being done and doesn't need to be done within the scope of this ticket?

// Drilling Method(s)
if (!drilling_methods) {
errors.drilling_methods = ['Drilling Methods Required.'];
}

// Total Depth Drilled(?), Finished Well Depth, Final Casing Stick Up
if (!total_depth_drilled) { errors.total_depth_drilled = ['Total Depth Drilled Required.'] }
if (!finished_well_depth) { errors.finished_well_depth = ['Finished Well Depth Required.'] }
if (!final_casing_stick_up) { errors.final_casing_stick_up = ['Final Casing Stick Up'] }

},
isFormValid () {
const errors = {}

this.newlyConstructedWellValidation(errors)

let validateWellClassAndIntendedWaterUse = true
if ((this.activityType === 'ALT' || this.activityType === 'DEC') && this.form.well) {
validateWellClassAndIntendedWaterUse = false
Expand Down Expand Up @@ -653,10 +725,10 @@ export default {
})
},
handlePreviewButton () {
if (!this.formChanges()) {
this.$noty.info('<div class="errorTitle">Please add some data to your submission.</div>', { killer: true })
return
}
// if (!this.formChanges()) {
// this.$noty.info('<div class="errorTitle">Please add some data to your submission.</div>', { killer: true })
// return
// }

if (!this.isFormValid()) {
this.showErrorMessages()
Expand Down
Loading