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

126 edit validation fixes #1238

Merged
merged 4 commits into from
Mar 4, 2019
Merged
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
6 changes: 6 additions & 0 deletions client/custom_validations/validators.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*eslint-disable*/
export function isNotBlankSpace(value) {
if (value)
return value.replace(/\s/g,'')!='';
return false;
}
1 change: 0 additions & 1 deletion client/src/components/application/Examine/CompName.vue
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@
},
runManualRecipe(){
console.log("Running manual recipe on " + this.searchStr + '/' + this.exactPhrase);
console.log('HERE2: ', this.exactPhrase)
this.$store.dispatch('runManualRecipe', {searchStr:this.searchStr, exactPhrase:this.exactPhrase});
},
setIcon(name_state) {
Expand Down
32 changes: 26 additions & 6 deletions client/src/components/application/Examine/RequestInfoHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,21 @@
<td>1.</td>
<td>
<input v-model="compName1.name" class="form-control" :onchange="$v.compName1.name.$touch()" />
<div class="error" v-if="!$v.compName1.name.required">The first name choice is required.</div>
<div class="error" v-if="$v.compName1.name.$error">The first name choice is required.</div>
</td>
</tr>
<tr>
<tr :class="{'form-group-error': $v.compName2.name.$error}">
<td>2.</td>
<td><input v-model="compName2.name" class="form-control" /></td>
<td>
<input v-model="compName2.name" class="form-control" :onchange="$v.compName2.name.$touch()"/>
<div class="error" v-if="$v.compName2.name.$error">To include a 3rd name choice the 2nd name choice is required.</div>
</td>
</tr>
<tr>
<td>3.</td>
<td><input v-model="compName3.name" class="form-control" /></td>
<td>
<input v-model="compName3.name" class="form-control" :onchange="$v.compName2.name.$touch()"/>
</td>
</tr>
</table>
<table v-else style="width: 100%;">
Expand Down Expand Up @@ -238,6 +243,7 @@
import clientinfoview from '@/components/application/Examine/client/ClientInfoHeader.vue';
import nwpta from '@/components/application/Examine/nwpta/nwpta.vue';
import { required } from 'vuelidate/lib/validators'
import { isNotBlankSpace } from "../../../../custom_validations/validators";
import axios from '@/axios-auth';


Expand All @@ -256,17 +262,32 @@ export default {
}
},
validations: function () {

// set basic validations that aren't conditional on any other fields
var validations = {
// first name choice is always required
compName1: {
name: {
required,
isNotBlankSpace
}
},
}

// if compName3 exists then compName2 must exist
if (this.compName3.name && this.compName3.name.replace(/\s/g,'')) {
validations.compName2 = {
name: {
required,
isNotBlankSpace
}
}
} else {
validations.compName2 = {
name: {
}
}
}

// validate jurisdiction if required
if (this.jurisdiction_required && !this.is_closed) {
validations.jurisdiction = {
Expand Down Expand Up @@ -337,7 +358,6 @@ export default {
},
}
}

return validations;

},
Expand Down
33 changes: 31 additions & 2 deletions client/test/unit/specs/RequestInfoHeader.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ describe('RequestInfoHeader.vue', () => {
state: "NE"
}],
natureBusinessInfo: "Nature of business can be pretty long so this one is more realistic. It even contains " +
"spaces and punctuation.",
"spaces and punctuation.",
nrNum: "NR 2000948",
nwpta: [],
previousNr: null,
Expand Down Expand Up @@ -565,7 +565,7 @@ describe('RequestInfoHeader.vue', () => {
state: "NE"
}],
natureBusinessInfo: "Nature of business can be pretty long so this one is more realistic. It even contains " +
"spaces and punctuation.",
"spaces and punctuation.",
nrNum: "NR 2000948",
nwpta: [],
previousNr: null,
Expand Down Expand Up @@ -650,6 +650,35 @@ describe('RequestInfoHeader.vue', () => {
console.log('finished');
});
});

it('Validates the name choices properly', () => {
vm.compName1.name = '';
expect(vm.validate()).toBeFalsy();
vm.compName1.name = 'COLDSTREAM REFRIGERATION HVAC SERVICES LIMITED';
vm.compName2.name = '';
vm.compName3.name = '';
expect(vm.validate()).toBeTruthy();
vm.compName3.name = 'Test add name choice 3';
expect(vm.validate()).toBeFalsy();
vm.compName2.name = 'Test add name choice 2';
expect(vm.validate()).toBeTruthy();
vm.compName2.name = ' ';
expect(vm.validate()).toBeFalsy();
vm.compName2.name = '';
vm.compName3.name = ' ';
expect(vm.validate()).toBeTruthy();
vm.compName3.name = 'Test add name choice 3';
expect(vm.validate()).toBeFalsy();

// this should do nothing
click('#nr-details-save-button');

// reset names and cancel edit - if above 'saved' this will error
vm.compName2.name = '';
vm.compName3.name = '';
expect(vm.validate()).toBeTruthy();
click('#nr-details-cancel-button');
});
});

describe('Edit button hiding testing', () => {
Expand Down