mirror of
https://github.com/danbulant/Portfolio
synced 2026-07-04 18:40:47 +00:00
Merge pull request #208 from EETagent/form_fixes
Register form minor fixes
This commit is contained in:
commit
75ebef476d
4 changed files with 97 additions and 36 deletions
46
frontend/src/lib/components/textfield/AddressField.svelte
Normal file
46
frontend/src/lib/components/textfield/AddressField.svelte
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import TextField from './TextField.svelte';
|
||||||
|
|
||||||
|
export let helperText: string = 'Uveďte ulici a číslo popisné (např. Preslova 72/25).';
|
||||||
|
export let placeholder: string = '';
|
||||||
|
|
||||||
|
export let valueLeft: string = '';
|
||||||
|
export let valueRight: string = '';
|
||||||
|
|
||||||
|
let value: string = '';
|
||||||
|
|
||||||
|
if (valueLeft && valueRight) {
|
||||||
|
value = `${valueLeft} ${valueRight}`;
|
||||||
|
} else if (valueLeft) {
|
||||||
|
value = valueLeft;
|
||||||
|
}
|
||||||
|
|
||||||
|
$: {
|
||||||
|
const parsed = value.trim().split(' ');
|
||||||
|
console.log(parsed);
|
||||||
|
if (parsed.length >= 2) {
|
||||||
|
valueLeft = parsed.slice(0, parsed.length - 1).join(' ');
|
||||||
|
valueRight = parsed[parsed.length - 1];
|
||||||
|
} else {
|
||||||
|
valueLeft = parsed[0];
|
||||||
|
valueRight = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export let error: string = '';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<TextField
|
||||||
|
bind:error
|
||||||
|
bind:value
|
||||||
|
on:click
|
||||||
|
on:keydown
|
||||||
|
on:keyup
|
||||||
|
on:change
|
||||||
|
type="text"
|
||||||
|
{placeholder}
|
||||||
|
{helperText}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<style lang="postcss">
|
||||||
|
</style>
|
||||||
|
|
@ -24,7 +24,8 @@
|
||||||
content: helperText,
|
content: helperText,
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
showOnCreate: false,
|
showOnCreate: false,
|
||||||
delay: tooltipDelay
|
delay: tooltipDelay,
|
||||||
|
allowHTML: true,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
import SplitLayout from '$lib/components/layout/SplitLayout.svelte';
|
import SplitLayout from '$lib/components/layout/SplitLayout.svelte';
|
||||||
import SelectField from '$lib/components/select/SelectField.svelte';
|
import SelectField from '$lib/components/select/SelectField.svelte';
|
||||||
import EmailField from '$lib/components/textfield/EmailField.svelte';
|
import EmailField from '$lib/components/textfield/EmailField.svelte';
|
||||||
import IdField from '$lib/components/textfield/IdField.svelte';
|
import AddressField from '$lib/components/textfield/AddressField.svelte';
|
||||||
import NameField from '$lib/components/textfield/NameField.svelte';
|
import NameField from '$lib/components/textfield/NameField.svelte';
|
||||||
import TelephoneField from '$lib/components/textfield/TelephoneField.svelte';
|
import TelephoneField from '$lib/components/textfield/TelephoneField.svelte';
|
||||||
import TextField from '$lib/components/textfield/TextField.svelte';
|
import TextField from '$lib/components/textfield/TextField.svelte';
|
||||||
|
|
@ -131,13 +131,10 @@
|
||||||
.test((_val) => {
|
.test((_val) => {
|
||||||
if ($form.candidate.citizenship !== 'Česká republika') return true;
|
if ($form.candidate.citizenship !== 'Česká republika') return true;
|
||||||
if (!_val) return false;
|
if (!_val) return false;
|
||||||
if (isPersonalIdMatchingBirthdate(
|
if (isPersonalIdMatchingBirthdate(data.whoami.personalIdNumber, _val)) {
|
||||||
data.whoami.personalIdNumber,
|
|
||||||
_val
|
|
||||||
)) {
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
pushErrorText("Datum narození a rodné číslo se neshodují.")
|
pushErrorText('Datum narození a rodné číslo se neshodují.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
@ -151,6 +148,7 @@
|
||||||
.matches(/^[0-9]+(\/[0-9]+)?$/),
|
.matches(/^[0-9]+(\/[0-9]+)?$/),
|
||||||
city: yup.string().required(),
|
city: yup.string().required(),
|
||||||
zip: yup.string().required(),
|
zip: yup.string().required(),
|
||||||
|
letterAddress: yup.string(),
|
||||||
citizenship: yup.string().required(),
|
citizenship: yup.string().required(),
|
||||||
personalIdNumber: yup.string(),
|
personalIdNumber: yup.string(),
|
||||||
schoolName: yup.string().required(),
|
schoolName: yup.string().required(),
|
||||||
|
|
@ -307,7 +305,7 @@
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
values = oldValues;
|
values = oldValues;
|
||||||
$form = oldValues;
|
$form = oldValues;
|
||||||
console.error('error while submitting data: ' + e);
|
pushErrorText('Neznámá chyba při odesílání dat.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -346,7 +344,8 @@
|
||||||
$typedErrors['candidate']['city'] ||
|
$typedErrors['candidate']['city'] ||
|
||||||
$typedErrors['candidate']['street'] ||
|
$typedErrors['candidate']['street'] ||
|
||||||
$typedErrors['candidate']['houseNumber'] ||
|
$typedErrors['candidate']['houseNumber'] ||
|
||||||
$typedErrors['candidate']['zip']
|
$typedErrors['candidate']['zip'] ||
|
||||||
|
$typedErrors['candidate']['letterAddress']
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -410,24 +409,6 @@
|
||||||
return '+' + telephone.match(/[0-9]{1,3}/g)!.join(' ');
|
return '+' + telephone.match(/[0-9]{1,3}/g)!.join(' ');
|
||||||
};
|
};
|
||||||
|
|
||||||
let lastCitizenshipSelected = $form.candidate.citizenship;
|
|
||||||
$: if ($form.candidate.citizenship !== lastCitizenshipSelected) {
|
|
||||||
lastCitizenshipSelected = $form.candidate.citizenship;
|
|
||||||
$form.candidate.birthdate = '';
|
|
||||||
$form.candidate.sex = '';
|
|
||||||
|
|
||||||
if ($form.candidate.citizenship === 'Česká republika') {
|
|
||||||
let [birthdate, sex] = parseBirthdateSexFromPersonalId(data.whoami.personalIdNumber);
|
|
||||||
$form.candidate.birthdate = birthdate;
|
|
||||||
$form.candidate.sex = sex;
|
|
||||||
if (pageIndex === 4) {
|
|
||||||
pushSuccessText(
|
|
||||||
`Datum narození a pohlaví bylo vyplněno automaticky podle Vašeho rodného čísla (${data.whoami.personalIdNumber}).`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (details !== undefined) {
|
if (details !== undefined) {
|
||||||
details.candidate.birthdate = details.candidate.birthdate.split('-').reverse().join('.');
|
details.candidate.birthdate = details.candidate.birthdate.split('-').reverse().join('.');
|
||||||
|
|
||||||
|
|
@ -436,6 +417,8 @@
|
||||||
(x) => (x.telephone = x.telephone != '' ? formatTelephone(x.telephone) : '')
|
(x) => (x.telephone = x.telephone != '' ? formatTelephone(x.telephone) : '')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const addressArray = details.candidate.address.split(',');
|
||||||
|
const streetHouseNumber = addressArray[0].split(' ');
|
||||||
form.set({
|
form.set({
|
||||||
gdpr: true,
|
gdpr: true,
|
||||||
linkOk: true,
|
linkOk: true,
|
||||||
|
|
@ -444,8 +427,8 @@
|
||||||
personalIdErr: false,
|
personalIdErr: false,
|
||||||
candidate: {
|
candidate: {
|
||||||
...details.candidate,
|
...details.candidate,
|
||||||
street: details.candidate.address.split(',')[0].split(' ')[0],
|
street: streetHouseNumber.slice(0, streetHouseNumber.length - 1).join(' ').trim(),
|
||||||
houseNumber: details.candidate.address.split(',')[0].split(' ')[1],
|
houseNumber: streetHouseNumber[streetHouseNumber.length - 1],
|
||||||
city: details.candidate.address.split(',')[1],
|
city: details.candidate.address.split(',')[1],
|
||||||
zip: details.candidate.address.split(',')[2],
|
zip: details.candidate.address.split(',')[2],
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|
@ -468,6 +451,24 @@
|
||||||
pageIndex = editModePageIndex; // skip gdpr page
|
pageIndex = editModePageIndex; // skip gdpr page
|
||||||
pageTexts[2] = $LL.candidate.register.fourth.titleEdit();
|
pageTexts[2] = $LL.candidate.register.fourth.titleEdit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let lastCitizenshipSelected = $form.candidate.citizenship;
|
||||||
|
$: if ($form.candidate.citizenship !== lastCitizenshipSelected) {
|
||||||
|
lastCitizenshipSelected = $form.candidate.citizenship;
|
||||||
|
$form.candidate.birthdate = '';
|
||||||
|
$form.candidate.sex = '';
|
||||||
|
|
||||||
|
if ($form.candidate.citizenship === 'Česká republika') {
|
||||||
|
let [birthdate, sex] = parseBirthdateSexFromPersonalId(data.whoami.personalIdNumber);
|
||||||
|
$form.candidate.birthdate = birthdate;
|
||||||
|
$form.candidate.sex = sex;
|
||||||
|
if (pageIndex === 4) {
|
||||||
|
pushSuccessText(
|
||||||
|
`Datum narození a pohlaví bylo vyplněno automaticky podle Vašeho rodného čísla (${data.whoami.personalIdNumber}).`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<SplitLayout>
|
<SplitLayout>
|
||||||
|
|
@ -485,9 +486,11 @@
|
||||||
{/if}
|
{/if}
|
||||||
<div class="form relative bg-center">
|
<div class="form relative bg-center">
|
||||||
<div class="bottom-5/24 absolute flex w-full flex-col md:h-auto">
|
<div class="bottom-5/24 absolute flex w-full flex-col md:h-auto">
|
||||||
<div class="<md:hidden self-center">
|
{#if pageIndex !== 3}
|
||||||
<SchoolBadge />
|
<div class="<md:hidden self-center">
|
||||||
</div>
|
<SchoolBadge />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
<form on:submit={handleSubmit} id="triggerForm" class="invisible hidden" />
|
<form on:submit={handleSubmit} id="triggerForm" class="invisible hidden" />
|
||||||
{#if pageIndex === 0}
|
{#if pageIndex === 0}
|
||||||
<form on:submit={handleSubmit}>
|
<form on:submit={handleSubmit}>
|
||||||
|
|
@ -576,11 +579,11 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="field flex">
|
<div class="field flex">
|
||||||
<span class="w-[66%]">
|
<span class="w-[66%]">
|
||||||
<NameField
|
<AddressField
|
||||||
error={$typedErrors['candidate']['street'] ||
|
error={$typedErrors['candidate']['street'] ||
|
||||||
$typedErrors['candidate']['houseNumber']}
|
$typedErrors['candidate']['houseNumber']}
|
||||||
bind:valueName={$form.candidate.street}
|
bind:valueLeft={$form.candidate.street}
|
||||||
bind:valueSurname={$form.candidate.houseNumber}
|
bind:valueRight={$form.candidate.houseNumber}
|
||||||
placeholder={$LL.input.address()}
|
placeholder={$LL.input.address()}
|
||||||
helperText="Uveďte ulici a číslo popisné (např. Preslova 72/25)."
|
helperText="Uveďte ulici a číslo popisné (např. Preslova 72/25)."
|
||||||
/>
|
/>
|
||||||
|
|
@ -595,6 +598,17 @@
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex w-full flex-col">
|
||||||
|
<span class="field">
|
||||||
|
<TextField
|
||||||
|
error={$typedErrors['candidate']['letterAddress']}
|
||||||
|
bind:value={$form.candidate.letterAddress}
|
||||||
|
type="text"
|
||||||
|
placeholder={'Adresa pro doručování písemností (pokud odlišná)'}
|
||||||
|
helperText="Uveďte adresu pro doručování písemností. Musí obsahovat <strong>ulici a č.p., PSČ, Okres</strong> <br />(např. Preslova 72/25, 150 21, Praha 5)"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
{:else if pageIndex === 4}
|
{:else if pageIndex === 4}
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ const cs: BaseTranslation = {
|
||||||
},
|
},
|
||||||
single: {
|
single: {
|
||||||
title: 'Ano, přihlášku na SSPŠaG jsem podával/a jen jednu ({first:number})',
|
title: 'Ano, přihlášku na SSPŠaG jsem podával/a jen jednu ({first:number})',
|
||||||
title2: 'Ne, přihlášku na SSPŠaG jsem podával více přihlášek'
|
title2: 'Ne, na SSPŠaG jsem podával více přihlášek'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
personalIdConfirmCheckBox: {
|
personalIdConfirmCheckBox: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue