From d713993f35cf363a7676af12f9a7fd18e633992f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20R=C3=B8ed=20Hestvik?= Date: Sat, 8 Jun 2024 13:57:08 +0200 Subject: [PATCH 1/2] change to react parent class --- .../extensions/phone-number/PhoneNumber.ts | 25 +++++++++++++++++-- .../templates/navdesign/field/form.ejs | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/packages/shared-components/src/formio/components/extensions/phone-number/PhoneNumber.ts b/packages/shared-components/src/formio/components/extensions/phone-number/PhoneNumber.ts index 5ffdffed1..5e1bee95e 100644 --- a/packages/shared-components/src/formio/components/extensions/phone-number/PhoneNumber.ts +++ b/packages/shared-components/src/formio/components/extensions/phone-number/PhoneNumber.ts @@ -1,10 +1,31 @@ -import FormioPhoneNumber from 'formiojs/components/phonenumber/PhoneNumber'; +import { InputMode } from '@navikt/skjemadigitalisering-shared-domain'; +import BaseComponent from '../../base/BaseComponent'; +import TextField from '../../core/textfield/TextField'; +import phoneNumberBuilder from './PhoneNumber.builder'; import phoneNumberForm from './PhoneNumber.form'; -class PhoneNumber extends FormioPhoneNumber { +class PhoneNumber extends TextField { + static schema() { + return BaseComponent.schema({ + label: 'Telefonnummer', + type: 'phoneNumber', + key: 'telefonNummer', + inputMode: 'decimal', // FIXME: trenger vi denne? + inputType: 'tel', + }); + } + static editForm() { return phoneNumberForm(); } + + static get builderInfo() { + return phoneNumberBuilder(); + } + + getInputMode(): InputMode { + return this.component?.inputType || 'tel'; + } } export default PhoneNumber; diff --git a/packages/shared-components/src/formio/template/templates/navdesign/field/form.ejs b/packages/shared-components/src/formio/template/templates/navdesign/field/form.ejs index a2315f92a..927743515 100644 --- a/packages/shared-components/src/formio/template/templates/navdesign/field/form.ejs +++ b/packages/shared-components/src/formio/template/templates/navdesign/field/form.ejs @@ -1,4 +1,4 @@ -{% if (ctx.component.type === "textfield" || ctx.component.type === "textarea" || ctx.component.type === "orgNr" || ctx.component.type === "bankAccount" || ctx.component.type === "htmlelement" || ctx.component.type === "radiopanel" || ctx.component.type === "attachment" || ctx.component.type === "email" || ctx.component.type === "activities" || ctx.component.type === "accordion" || ctx.component.type === "navDatepicker" || ctx.component.type === "navCheckbox" || ctx.component.type === "number" || ctx.component.type === "currency") { %} +{% if (ctx.component.type === "textfield" || ctx.component.type === "textarea" || ctx.component.type === "orgNr" || ctx.component.type === "bankAccount" || ctx.component.type === "htmlelement" || ctx.component.type === "radiopanel" || ctx.component.type === "attachment" || ctx.component.type === "email" || ctx.component.type === "activities" || ctx.component.type === "accordion" || ctx.component.type === "navDatepicker" || ctx.component.type === "navCheckbox" || ctx.component.type === "number" || ctx.component.type === "currency" || ctx.component.type === "phoneNumber") { %} {{ctx.element}} {% } else { %} {% if (ctx.component.description && ctx.component.type !== "datagrid" && ctx.component.descriptionPosition === "above") { %} From da51318aa7835e4cc32071d888c4a434e45877c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20R=C3=B8ed=20Hestvik?= Date: Mon, 17 Jun 2024 12:59:29 +0200 Subject: [PATCH 2/2] Removed inputMode and inputType from schema since they are not used --- .../formio/components/extensions/phone-number/PhoneNumber.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/shared-components/src/formio/components/extensions/phone-number/PhoneNumber.ts b/packages/shared-components/src/formio/components/extensions/phone-number/PhoneNumber.ts index 5e1bee95e..568a37fd3 100644 --- a/packages/shared-components/src/formio/components/extensions/phone-number/PhoneNumber.ts +++ b/packages/shared-components/src/formio/components/extensions/phone-number/PhoneNumber.ts @@ -10,8 +10,6 @@ class PhoneNumber extends TextField { label: 'Telefonnummer', type: 'phoneNumber', key: 'telefonNummer', - inputMode: 'decimal', // FIXME: trenger vi denne? - inputType: 'tel', }); } @@ -24,7 +22,7 @@ class PhoneNumber extends TextField { } getInputMode(): InputMode { - return this.component?.inputType || 'tel'; + return 'tel'; } }