- fixed login with spid fe issue;

- improved 'add user' form;
- added new field 'paragraph';
This commit is contained in:
Vitalii Kiiko
2024-10-01 09:37:11 +02:00
parent 128be9e245
commit 4ba883c073
7 changed files with 81 additions and 114 deletions

View File

@@ -11,6 +11,7 @@ import BandoService from '../../service/bando-service';
// tools // tools
import getBandoLabel from '../../helpers/getBandoLabel'; import getBandoLabel from '../../helpers/getBandoLabel';
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
// components // components
import { Button } from 'primereact/button'; import { Button } from 'primereact/button';
@@ -20,7 +21,6 @@ import BandoEditFormStep1 from './components/BandoEditFormStep1';
import BandoEditFormStep2 from './components/BandoEditFormStep2'; import BandoEditFormStep2 from './components/BandoEditFormStep2';
import { Messages } from 'primereact/messages'; import { Messages } from 'primereact/messages';
import FormsService from '../../service/forms-service'; import FormsService from '../../service/forms-service';
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
import BlockingOverlay from '../../components/BlockingOverlay'; import BlockingOverlay from '../../components/BlockingOverlay';
const BandoEdit = () => { const BandoEdit = () => {
@@ -30,8 +30,6 @@ const BandoEdit = () => {
const [activeStep, setActiveStep] = useState(null) const [activeStep, setActiveStep] = useState(null)
const [data, setData] = useState({}); const [data, setData] = useState({});
const [forms, setForms] = useState([]); const [forms, setForms] = useState([]);
//const [selectedTemplate, setSelectedTemplate] = useState(null);
//const [templates, setTemplate] = useState(null);
const formRef = useRef(null); const formRef = useRef(null);
const bandoMsgs = useRef(null); const bandoMsgs = useRef(null);
@@ -43,23 +41,7 @@ const BandoEdit = () => {
return false return false
} }
bandoMsgs.current.clear(); bandoMsgs.current.clear();
const isFormValid = formRef.current.isFormValid();
//const values = formRef.current.getValues();
//const diffData = equal(values, data);
// TODO warn about unsaved data
goToStep(0); goToStep(0);
/*if (isFormValid) {
goToStep(0)
} else {
bandoMsgs.current.show([
{
id: '98',
sticky: true, severity: 'error', summary: '',
detail: __('Potrai andare su altro step dopo risolvere errori della forma', 'gepafin'),
closable: true
}
]);
}*/
} }
}, },
{ {
@@ -68,25 +50,8 @@ const BandoEdit = () => {
if (activeStep === 1) { if (activeStep === 1) {
return false return false
} }
console.log('11');
bandoMsgs.current.clear(); bandoMsgs.current.clear();
const isFormValid = formRef.current.isFormValid();
//const values = formRef.current.getValues();
//const diffData = equal(values, data);
// TODO warn about unsaved data
goToStep(1); goToStep(1);
/*if (isFormValid) {
goToStep(1);
} else {
bandoMsgs.current.show([
{
id: '98',
sticky: true, severity: 'error', summary: '',
detail: __('Potrai andare su altro step dopo risolvere errori della forma', 'gepafin'),
closable: true
}
]);
}*/
} }
} }
]; ];
@@ -271,26 +236,6 @@ const BandoEdit = () => {
<div className="appPage__spacer"></div> <div className="appPage__spacer"></div>
{/*!isLoading
? <div className="pageBando__templateSelection">
<div className="appForm__field">
<label htmlFor="template">
{__('Usa Template Salvato', 'gepafin')}
</label>
<Dropdown
id="template"
value={selectedTemplate}
onChange={(e) => setSelectedTemplate(e.value)}
options={templates}
optionLabel="name"
placeholder={__('Seleziona template', 'gepafin')}/>
</div>
<Button
onClick={() => console.log('use template')}
label={__('Applica', 'gepafin')}
icon="pi pi-check"
iconPos="right"/>
</div> : null*/}
{!isEmpty(data) {!isEmpty(data)
? <Steps ? <Steps
model={stepItems} model={stepItems}

View File

@@ -11,7 +11,7 @@ const BuilderElementProperLabel = ({ id, defaultLabel }) => {
useEffect(() => { useEffect(() => {
const element = head(elements.filter(o => o.id === id)); const element = head(elements.filter(o => o.id === id));
const setting = head(element.settings.filter(o => o.name === 'label')); const setting = head(element.settings.filter(o => o.name === 'label'));
if (setting.value) { if (setting) {
setLabel(setting.value); setLabel(setting.value);
} else { } else {
setLabel(defaultLabel); setLabel(defaultLabel);

View File

@@ -16,6 +16,7 @@ const ElementSetting = ({ setting, changeFn, updateDataFn }) => {
step: __('Precisione decimale', 'gepafin'), step: __('Precisione decimale', 'gepafin'),
options: __('Opzioni', 'gepafin'), options: __('Opzioni', 'gepafin'),
mime: __('Tipo di file', 'gepafin'), mime: __('Tipo di file', 'gepafin'),
text: __('Testo formattato', 'gepafin')
} }
return <div className="formElementSettings__field" key={setting.name}> return <div className="formElementSettings__field" key={setting.name}>

View File

@@ -23,14 +23,14 @@ const BuilderElementSettings = ({ closeSettings }) => {
const [validators, setValidators] = useState({}); const [validators, setValidators] = useState({});
const textBasedValidatorFields = ['min', 'max', 'minLength', 'maxLength', 'pattern']; const textBasedValidatorFields = ['min', 'max', 'minLength', 'maxLength', 'pattern'];
const customValidationOptions = [ const customValidationOptions = [
{value: 'isPIVA', label: 'isPIVA'}, { value: 'isPIVA', label: 'isPIVA' },
{value: 'isCodiceFiscale', label: 'isCodiceFiscale'}, { value: 'isCodiceFiscale', label: 'isCodiceFiscale' },
{value: 'isCAP', label: 'isCAP'}, { value: 'isCAP', label: 'isCAP' },
{value: 'isIBAN', label: 'isIBAN'}, { value: 'isIBAN', label: 'isIBAN' },
{value: 'isEmail', label: 'isEmail'}, { value: 'isEmail', label: 'isEmail' },
{value: 'isEmailPEC', label: 'isEmailPEC'}, { value: 'isEmailPEC', label: 'isEmailPEC' },
{value: 'isUrl', label: 'isUrl'}, { value: 'isUrl', label: 'isUrl' },
{value: 'isMarcaDaBollo', label: 'isMarcaDaBollo'} { value: 'isMarcaDaBollo', label: 'isMarcaDaBollo' }
] ]
const onChange = (value, name) => { const onChange = (value, name) => {
@@ -116,7 +116,8 @@ const BuilderElementSettings = ({ closeSettings }) => {
updateDataFn={onUpdateOptions}/>) updateDataFn={onUpdateOptions}/>)
: null} : null}
</TabPanel> </TabPanel>
<TabPanel header={__('Validation', 'gepafin')}> {!isEmpty(validators)
? <TabPanel header={__('Validation', 'gepafin')}>
{validators {validators
? Object.keys(validators).map((k) => <div ? Object.keys(validators).map((k) => <div
className="formElementSettings__field" key={k}> className="formElementSettings__field" key={k}>
@@ -157,7 +158,7 @@ const BuilderElementSettings = ({ closeSettings }) => {
onChange={(e) => onChangeValidator(e.target.value, k)}/> onChange={(e) => onChangeValidator(e.target.value, k)}/>
</div> : null} </div> : null}
</div>) : null} </div>) : null}
</TabPanel> </TabPanel> : null}
</TabView> </TabView>
<Button label={__('Salva', 'gepafin')} onClick={saveSettings}/> <Button label={__('Salva', 'gepafin')} onClick={saveSettings}/>

View File

@@ -22,7 +22,7 @@ const Login = () => {
const loginWithSpid = () => { const loginWithSpid = () => {
if (!loading) { if (!loading) {
//window.location.replace(`${API_BASE_URL}/saml2/authenticate/loginumbria`); window.location.replace(`${API_BASE_URL}/saml2/authenticate/loginumbria`);
} }
} }

View File

@@ -1,6 +1,6 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { __ } from '@wordpress/i18n'; import { __ } from '@wordpress/i18n';
import { isEmpty } from 'ramda'; import { isEmpty, isNil } from 'ramda';
// components // components
import AllUsersTable from './components/AllUsersTable'; import AllUsersTable from './components/AllUsersTable';
@@ -12,6 +12,7 @@ import UserService from '../../service/user-service';
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse'; import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
import { storeSet } from '../../store'; import { storeSet } from '../../store';
import { klona } from 'klona'; import { klona } from 'klona';
import { classNames } from 'primereact/utils';
const Users = () => { const Users = () => {
const [isVisibleEditDialog, setIsVisibleEditDialog] = useState(false); const [isVisibleEditDialog, setIsVisibleEditDialog] = useState(false);
@@ -112,32 +113,37 @@ const Users = () => {
<div className="appPage__spacer"></div> <div className="appPage__spacer"></div>
<div className="appForm__cols"> <div className="appForm__cols">
<div className="appForm__field"> <div className="appForm__field">
<label>{__('Nome', 'gepafin')}*</label> <label className={classNames({ 'p-error': isEmpty(newUserData.firstName) || isNil(newUserData.firstName) })}>{__('Nome', 'gepafin')}*</label>
<InputText value={newUserData.firstName} <InputText value={newUserData.firstName}
invalid={isEmpty(newUserData.firstName) || isNil(newUserData.firstName)}
onChange={(e) => onChangeEditItem(e.target.value, 'firstName')}/> onChange={(e) => onChangeEditItem(e.target.value, 'firstName')}/>
</div> </div>
<div className="appForm__field"> <div className="appForm__field">
<label>{__('Cognome', 'gepafin')}*</label> <label className={classNames({ 'p-error': isEmpty(newUserData.lastName) || isNil(newUserData.lastName) })}>{__('Cognome', 'gepafin')}*</label>
<InputText value={newUserData.lastName} <InputText value={newUserData.lastName}
invalid={isEmpty(newUserData.lastName) || isNil(newUserData.lastName)}
onChange={(e) => onChangeEditItem(e.target.value, 'lastName')}/> onChange={(e) => onChangeEditItem(e.target.value, 'lastName')}/>
</div> </div>
</div> </div>
<div className="appForm__cols"> <div className="appForm__cols">
<div className="appForm__field"> <div className="appForm__field">
<label>{__('Email', 'gepafin')}*</label> <label className={classNames({ 'p-error': isEmpty(newUserData.email) || isNil(newUserData.email) })}>{__('Email', 'gepafin')}*</label>
<InputText value={newUserData.email} <InputText value={newUserData.email}
invalid={isEmpty(newUserData.email) || isNil(newUserData.email)}
onChange={(e) => onChangeEditItem(e.target.value, 'email')}/> onChange={(e) => onChangeEditItem(e.target.value, 'email')}/>
</div> </div>
<div className="appForm__field"> <div className="appForm__field">
<label>{__('Telefono', 'gepafin')}</label> <label className={classNames({ 'p-error': isEmpty(newUserData.phoneNumber) || isNil(newUserData.phoneNumber) })}>{__('Telefono', 'gepafin')}</label>
<InputText value={newUserData.phoneNumber} <InputText value={newUserData.phoneNumber}
invalid={isEmpty(newUserData.phoneNumber) || isNil(newUserData.phoneNumber)}
onChange={(e) => onChangeEditItem(e.target.value, 'phoneNumber')}/> onChange={(e) => onChangeEditItem(e.target.value, 'phoneNumber')}/>
</div> </div>
</div> </div>
<div className="appForm__field"> <div className="appForm__field">
<label>{__('Ruolo', 'gepafin')}</label> <label className={classNames({ 'p-error': isEmpty(newUserData.role) || isNil(newUserData.role) })}>{__('Ruolo', 'gepafin')}</label>
<Dropdown <Dropdown
value={newUserData.role} value={newUserData.role}
invalid={isEmpty(newUserData.role) || isNil(newUserData.role)}
onChange={(e) => onChangeEditItem(e.value, 'role')} onChange={(e) => onChangeEditItem(e.value, 'role')}
options={roles} options={roles}
optionLabel="name" optionLabel="name"

View File

@@ -719,5 +719,19 @@ export const elementItems = [
isRequired: false, isRequired: false,
custom: 'isMarcaDaBollo' custom: 'isMarcaDaBollo'
} }
},
{
id: 19,
sortOrder: 19,
name: 'paragraph',
label: 'Paragrafo',
description: 'Semplice testo formattato',
settings: [
{
name: "text",
value: "Testo formattato"
}
],
validators: {}
} }
] ]