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

[FSADT1-999] Add birth date to frontend #643

Merged
merged 24 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ab5eed9
feat: add a date input component
fterra-encora Nov 27, 2023
5da037b
refactor: extract date part component
fterra-encora Nov 27, 2023
173f3e2
fix: always revalidate day
fterra-encora Nov 27, 2023
a87655a
feat: add the date of birth to the form
fterra-encora Nov 27, 2023
c645a9b
refactor: reuse enum DatePart
fterra-encora Nov 27, 2023
062f910
feat: add condition for displaying the birthdate
fterra-encora Nov 27, 2023
6404304
feat: add birthdate label
fterra-encora Nov 27, 2023
a109cf9
style: replace single-quote with double-quote
fterra-encora Nov 27, 2023
f4c2e94
fix: disable the next button properly
fterra-encora Nov 27, 2023
fdf581a
fix: adjust validations and events
fterra-encora Nov 28, 2023
8b74cba
fix: issue after returning to the step containing the date
fterra-encora Nov 28, 2023
2b67458
feat: add business validations
fterra-encora Nov 29, 2023
c084b59
feat: apply text mask
fterra-encora Nov 29, 2023
35cdcd6
feat: auto-move to next date part
fterra-encora Nov 29, 2023
ccbf063
feat: perform conditional validation
fterra-encora Nov 29, 2023
0879deb
fix: revalidate everything on revalidate-bus
fterra-encora Nov 29, 2023
b95d132
Merge branch 'main' into feat/fe/FSADT1-999
fterra-encora Nov 29, 2023
24bbb5f
test: fill the birthdate field
fterra-encora Nov 29, 2023
3300c25
feat: replace some messages
fterra-encora Nov 30, 2023
039d6fb
fix: prevent highlighting all parts on error
fterra-encora Nov 30, 2023
cd07766
docs: improve code comment
fterra-encora Nov 30, 2023
2822592
fix: make complexity of regex linear
fterra-encora Nov 30, 2023
65b482b
refactor: move date part validations to props
fterra-encora Nov 30, 2023
357c6d0
Merge branch 'main' into feat/fe/FSADT1-999
fterra-encora Nov 30, 2023
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: 3 additions & 3 deletions frontend/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
import '@vue/runtime-core'

export {}

declare module '@vue/runtime-core' {
declare module 'vue' {
export interface GlobalComponents {
AddressGroupComponent: typeof import('./src/components/grouping/AddressGroupComponent.vue')['default']
AutoCompleteInputComponent: typeof import('./src/components/forms/AutoCompleteInputComponent.vue')['default']
ContactGroupComponent: typeof import('./src/components/grouping/ContactGroupComponent.vue')['default']
DataFetcher: typeof import('./src/components/DataFetcher.vue')['default']
DateInputComponent: typeof import('./src/components/forms/DateInputComponent/index.vue')['default']
DateInputPart: typeof import('./src/components/forms/DateInputComponent/DateInputPart.vue')['default']
DropdownInputComponent: typeof import('./src/components/forms/DropdownInputComponent.vue')['default']
ErrorNotificationGroupingComponent: typeof import('./src/components/grouping/ErrorNotificationGroupingComponent.vue')['default']
MainHeaderComponent: typeof import('./src/components/MainHeaderComponent.vue')['default']
Expand Down
6 changes: 6 additions & 0 deletions frontend/cypress/e2e/FormGeneral.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ describe("General Form", () => {

cy.wait("@selectCompany");

cy.get("#birthdate").should("be.visible");

cy.get("#birthdateYear").shadow().find("input").should("have.value", "").type("2001");
cy.get("#birthdateMonth").shadow().find("input").should("have.value", "").type("05");
cy.get("#birthdateDay").shadow().find("input").should("have.value", "").type("30");

cy.get('[data-test="wizard-next-button"]').should("be.visible").click();

cy.logout();
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/assets/styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,10 @@ cds-header-panel[expanded] {
transition: opacity 300ms cubic-bezier(0.5, 0, 0.1, 1), background-color 300ms cubic-bezier(0.5, 0, 0.1, 1);
}

.date-label {
margin-bottom: 1rem;
}



/* Small (up to 671px) */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<script setup lang="ts">
// Carbon
import '@carbon/web-components/es/components/text-input/index';
// Types
import { DatePart } from "./common";

// Define the input properties for this component
const props = defineProps<{
parentId: string;
datePart: DatePart;
selectedValue: string;
enabled?: boolean;
invalid: boolean;
}>();

const emit = defineEmits<{
blur: [event: FocusEvent]
input: [event: Event]
}>();

const datePartName = DatePart[props.datePart];

const capitalizedDatePart = datePartName[0].toUpperCase() + datePartName.substring(1);

const id = props.parentId + capitalizedDatePart;

defineExpose({
id,
});

const placeholders = {
[DatePart.year]: "YYYY",
[DatePart.month]: "MM",
[DatePart.day]: "DD"
};

const placeholder = placeholders[props.datePart];

const mask = "#".repeat(placeholder.length);
</script>

<template>
<div class="input-group">
<div class="cds--text-input__label-wrapper">
<label :id="parentId + capitalizedDatePart + 'Label'" :for="id" class="cds-text-input-label">
{{ enabled ? capitalizedDatePart : null }}
</label>
</div>
<cds-text-input
v-if="enabled"
:id="id"
type="tel"
:placeholder="placeholders[datePart]"
:value="selectedValue"
:disabled="!enabled"
:invalid="invalid"
@blur="(e) => emit('blur', e)"
@input="(e) => emit('input', e)"
:data-focus="id"
:data-scroll="id"
:data-id="'input-' + parentId + '-' + datePartName"
v-shadow="4"
v-masked="mask"
/>
</div>
</template>
10 changes: 10 additions & 0 deletions frontend/src/components/forms/DateInputComponent/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export enum DatePart {
year,
month,
day,
};

export interface DateValidator {
(value: string): string;
datePart?: DatePart
};
Loading
Loading