UNCLASSIFIED

Commit 72508796 authored by Michael Winberry's avatar Michael Winberry
Browse files

Update missionappdns fields to only be required if one or more fields is filled out.

parent e624c051
...@@ -7,29 +7,26 @@ ...@@ -7,29 +7,26 @@
class="mb-8" class="mb-8"
label="Dns Credential Name" label="Dns Credential Name"
v-model="dns.credentialName" v-model="dns.credentialName"
hint="* Required" :hint="hint"
persistent-hint persistent-hint
required :required="isRequired"
:rules="[inputRules.required]"
/> />
<v-text-field <v-text-field
class="mb-8" class="mb-8"
label="App Host Name" label="App Host Name"
v-model="dns.appHostname" v-model="dns.appHostname"
hint="* Required" :hint="hint"
persistent-hint persistent-hint
required :required="isRequired"
:rules="[inputRules.required]"
/> />
<v-select <v-select
class="stagingSelect" class="stagingSelect"
v-model="dns.targetEnvironment" v-model="dns.targetEnvironment"
:items="environments" :items="environments"
label="Target Environment" label="Target Environment"
hint="* Required" :hint="hint"
persistent-hint persistent-hint
required :required="isRequired"
:rules="[inputRules.required]"
solo solo
/> />
</div> </div>
...@@ -48,6 +45,18 @@ export default { ...@@ -48,6 +45,18 @@ export default {
inputRules, inputRules,
environments: ["IL2", "IL4", "IL5"], environments: ["IL2", "IL4", "IL5"],
}), }),
computed: {
isRequired() {
return (
this.dns.credentialName ||
this.dns.appHostname ||
this.dns.targetEnvironment
);
},
hint() {
return this.isRequired ? "* Required" : "";
},
},
watch: { watch: {
dns() { dns() {
this.$emit("input", this.dns); this.$emit("input", this.dns);
......
...@@ -42,4 +42,20 @@ describe("Mission App Dns Form Section", () => { ...@@ -42,4 +42,20 @@ describe("Mission App Dns Form Section", () => {
wrapper.vm.environments[0] wrapper.vm.environments[0]
); );
}); });
describe("Required behavior | all or none", () => {
it("sets required to true if any of the fields are defined", () => {
inputs.at(0).setValue("dns-credentials");
expect(wrapper.vm.isRequired).toBeTruthy();
});
it("sets the hint to required if any of the fields are defined", () => {
inputs.at(0).setValue("dns-credentials");
expect(wrapper.vm.hint).toBe("* Required");
});
it("Does not return a hint if none of the fields are defined", () => {
expect(wrapper.vm.hint).toBe("");
});
});
}); });
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment