Skip to content

Commit

Permalink
Updates describe-your-home step for Manufacturer MHR (#1389)
Browse files Browse the repository at this point in the history
* Sets up a new manufacturer registration

* Updates yourHome to handle manufacturer reg

* Only shows CSA option for manufacturer reg

* Disables manufacturer field and adds year select

* Adds tests for yourHome and modified subComponents

* Changes padding to previous values

* Utilize compute to improve readbility

* Minor styling updates

* Code clean up

* Version Bump

* small space fix
  • Loading branch information
orelbn authored Jun 19, 2023
1 parent 52e9203 commit fea51d8
Show file tree
Hide file tree
Showing 22 changed files with 638 additions and 141 deletions.
4 changes: 2 additions & 2 deletions ppr-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ppr-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ppr-ui",
"version": "2.0.10",
"version": "2.0.11",
"private": true,
"appName": "Assets UI",
"sbcName": "SBC Common Components",
Expand Down
11 changes: 8 additions & 3 deletions ppr-ui/src/components/common/RegistrationsWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,14 @@ export default defineComponent({
} = useStore()
const {
// Getters
getRegTableBaseRegs, getRegTableDraftsBaseReg, isMhrRegistration, getRegTableTotalRowCount, getStateModel,
getRegTableDraftsChildReg, hasMorePages, getRegTableNewItem, getRegTableSortOptions, getRegTableSortPage,
getUserSettings, getMhRegTableBaseRegs
getRegTableBaseRegs, getRegTableDraftsBaseReg, isMhrRegistration, isMhrManufacturerRegistration,
getRegTableTotalRowCount, getStateModel, getRegTableDraftsChildReg, hasMorePages, getRegTableNewItem,
getRegTableSortOptions, getRegTableSortPage, getUserSettings, getMhRegTableBaseRegs
} = storeToRefs(useStore())
const {
initNewMhr,
initNewManufacturerMhr,
fetchMhRegistrations
} = useNewMhrRegistration()
Expand Down Expand Up @@ -389,6 +390,10 @@ export default defineComponent({
setRegistrationType(selectedRegistration)
setRegTableCollapsed(null)
if (!isMhDraft && isMhrManufacturerRegistration.value) {
await initNewManufacturerMhr()
}
const route = isMhrRegistration.value ? RouteNames.YOUR_HOME : RouteNames.LENGTH_TRUST
await router.replace({ name: route })
}
Expand Down
12 changes: 8 additions & 4 deletions ppr-ui/src/components/common/SimpleHelpToggle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
class="help-btn px-0"
:ripple="false"
@click="isHelpContentOpen = !isHelpContentOpen"
data-test-id="help-toggle-btn"
>
<v-icon class="mr-1">
mdi-help-circle-outline
</v-icon>
{{ isHelpContentOpen ? 'Hide ' + title : title }}
{{ title }}
</v-btn>
<v-expand-transition>
<div v-show="isHelpContentOpen" class="help-content mb-10">
Expand All @@ -34,19 +35,22 @@
</template>

<script lang="ts">
import { computed } from 'vue'
import { defineComponent, reactive, toRefs } from 'vue-demi'
export default defineComponent({
name: 'SimleHelpToggle',
name: 'SimpleHelpToggle',
props: {
toggleButtonTitle: { default: '' },
/* show or hide secondary toggle within content */
hasBottomHideToggle: { default: true }
hasBottomHideToggle: { default: true },
defaultHideText: { default: true }
},
setup (props) {
const localState = reactive({
isHelpContentOpen: false,
title: props.toggleButtonTitle,
hideText: props.defaultHideText ? 'Hide Help' : 'Hide ' + props.toggleButtonTitle,
title: computed(() : string => localState.isHelpContentOpen ? localState.hideText : props.toggleButtonTitle),
showBottomToggle: props.hasBottomHideToggle
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@

<simple-help-toggle
toggleButtonTitle="Help with Business and Organization Owners"
:defaultHideText="false"
>
<h3 class="text-center mb-2">
Business and Organization Owners
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
<template>
<v-card flat rounded id="mhr-home-certification" class="mt-8 pa-8 pr-6">
<v-card flat rounded id="mhr-home-certification" class="mt-8 pa-8 pr-6" :class="{'py-10': !showRadio}">
<v-row no-gutters>
<v-col cols="12" sm="2">
<label class="generic-label" :class="{'error-text': validate}">Certification</label>
</v-col>
<v-col cols="12" sm="10" class="pl-1">
<v-radio-group
id="certification-option-btns"
v-model="certificationOption"
class="mt-0 pr-1" row
hide-details="true"
>
<v-radio
id="csa-option"
class="csa-radio"
label="CSA Number"
active-class="selected-radio"
:value="HomeCertificationOptions.CSA"
/>
<v-radio
id="engineer-option"
class="engineer-radio"
label="Engineer's Inspection"
active-class="selected-radio"
:value="HomeCertificationOptions.ENGINEER_INSPECTION"
/>
</v-radio-group>
<template v-if="showRadio">
<v-radio-group
id="certification-option-btns"
v-model="certificationOption"
class="mt-0 pr-1" row
hide-details="true"
>
<v-radio
id="csa-option"
class="csa-radio"
label="CSA Number"
active-class="selected-radio"
:value="HomeCertificationOptions.CSA"
/>
<v-radio
id="engineer-option"
class="engineer-radio"
label="Engineer's Inspection"
active-class="selected-radio"
:value="HomeCertificationOptions.ENGINEER_INSPECTION"
/>
</v-radio-group>
<v-divider class="my-9 ml-0 mr-2" v-if="!!certificationOption"/>
</template>

<!-- CSA Section -->
<div v-show="isCsaOption">
<v-divider class="my-9 ml-0 mr-2" />
<v-row no-gutters>
<v-col cols="12">
<v-form id="csa-form" ref="csaForm" v-model="isCsaValid">
Expand Down Expand Up @@ -59,8 +61,7 @@
</div>

<!-- Engineer Section -->
<div v-show="isEngineerOption">
<v-divider class="my-9 ml-0 mr-2" />
<div v-show="isEngineerOption" v-if="showEngineerOption">
<v-row no-gutters>
<v-col cols="12">
<v-form id="engineer-form" ref="engineerForm" v-model="isEngineerValid">
Expand Down Expand Up @@ -124,7 +125,8 @@ export default defineComponent({
},
setup (props) {
const { setMhrHomeDescription } = useStore()
const { getMhrRegistrationHomeDescription, getMhrRegistrationValidationModel } = storeToRefs(useStore())
const { getMhrRegistrationHomeDescription, getMhrRegistrationValidationModel,
isMhrManufacturerRegistration } = storeToRefs(useStore())
// Composable(s)
const {
customRules,
Expand Down Expand Up @@ -180,7 +182,9 @@ export default defineComponent({
// Determined by YEAR value in Manufacturers, Make, Model Section
const utcDate = createUtcDate(getMhrRegistrationHomeDescription.value?.baseInformation.year, 0, 1)
return localTodayDate(utcDate)
})
}),
showRadio: computed(() => !isMhrManufacturerRegistration.value),
showEngineerOption: computed(() => !isMhrManufacturerRegistration.value)
})
const validateForms = async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<template>
<v-row id="mhr-home-manufacturer-year">
<v-col cols="2">
<label
class="generic-label"
for="manufacturer-year"
:class="{ 'error-text': validate && hasError(yearRef) }"
>
Year of Manufacture
</label>
</v-col>
<v-col cols="4">
<v-text-field
id="manufacturer-year"
ref="yearRef"
v-model="yearOfManufacture"
filled
:rules="manufactureYearRules"
label="Year of Manufacture"
persistent-hint
hint="YYYY"
data-test-id="manufacture-year"
/>
</v-col>
<v-col cols="6">
<v-checkbox
id="circa-year"
label="This Year of Manufacture is approximate"
v-model="circa"
class="float-left"
data-test-id="circa-year-checkbox"
/>
<v-tooltip
top
content-class="top-tooltip pa-5"
transition="fade-transition"
data-test-id="circa-year-tooltip"
nudge-right="3"
nudge-bottom="22"
>
<template v-slot:activator="{ on }">
<v-icon
class="circa-tooltip-icon ml-2 mt-n1"
color="primary"
v-on="on"
>
mdi-information-outline
</v-icon>
</template>
When the exact year of manufacture is unknown, enter an estimated
year and indicate that the year is approximate.
</v-tooltip>
</v-col>
</v-row>
</template>

<script lang="ts">
import {
computed,
defineComponent,
reactive,
ref,
toRefs,
watch
} from 'vue-demi'
import { useStore } from '@/store/store'
import { useInputRules, useMhrValidations } from '@/composables/'
import { storeToRefs } from 'pinia'
export default defineComponent({
name: 'ManufacturedYearInput',
props: {
validate: {
type: Boolean,
default: false
}
},
setup () {
const yearRef = ref(null)
const { setMhrHomeBaseInformation } = useStore()
const {
// Getters
getMhrRegistrationValidationModel,
getMhrRegistrationYearOfManufacture,
getMhrRegistrationIsYearApproximate
} = storeToRefs(useStore())
const {
customRules,
required,
minLength,
maxLength,
startsWith,
greaterThan,
isNumber
} = useInputRules()
const {
hasError
} = useMhrValidations(toRefs(getMhrRegistrationValidationModel.value))
const manufactureYearRules = computed((): Array<Function> =>
customRules(
required('Enter a year of manufacture'),
isNumber(),
minLength(4, true),
maxLength(4, true),
startsWith(['19', '20'], 'Year must begin with 19 or 20'),
greaterThan(new Date().getFullYear() + 1, 'Year cannot be more than 1 year in the future')
)
)
const localState = reactive({
yearOfManufacture: getMhrRegistrationYearOfManufacture.value?.toString(),
circa: getMhrRegistrationIsYearApproximate.value
})
watch(() => localState.yearOfManufacture, (val: string) => {
if (parseInt(val)) {
setMhrHomeBaseInformation({ key: 'year', value: parseInt(val) })
}
})
watch(() => localState.circa, (val: boolean) => {
setMhrHomeBaseInformation({ key: 'circa', value: val })
})
return {
hasError,
yearRef,
manufactureYearRules,
...toRefs(localState)
}
}
})
</script>

<style lang="scss" scoped>
::v-deep .circa-tooltip-icon {
line-height: 3em;
}
</style>
Loading

0 comments on commit fea51d8

Please sign in to comment.