diff --git a/src/assets/scss/components/appForm.scss b/src/assets/scss/components/appForm.scss index c114ba9..bb532bd 100644 --- a/src/assets/scss/components/appForm.scss +++ b/src/assets/scss/components/appForm.scss @@ -147,6 +147,7 @@ .appForm__fileUploadItemName { color: var(--global-textColor); font-style: italic; + text-align: left; } .appForm__row { diff --git a/src/assets/scss/components/appPage.scss b/src/assets/scss/components/appPage.scss index 54a8fba..4a1771b 100644 --- a/src/assets/scss/components/appPage.scss +++ b/src/assets/scss/components/appPage.scss @@ -372,9 +372,13 @@ .appPageSection__tableActions { display: flex; - gap: 24px; - padding: 0; + gap: 10px; + align-items: center; flex-wrap: wrap; + + &.lessGap { + gap: 12px; + } } .appPageSection__addToFavourites { @@ -385,12 +389,18 @@ justify-content: center; border-radius: 50%; border: none; - background-color: var(--message-info-color); - color: white; + background-color: transparent; + color: var(--global-textColor); padding: 0; &:hover { cursor: pointer; + color: var(--message-info-color); + } + + &[data-active="true"] { + background-color: var(--message-info-color); + color: white; } &[disabled] { diff --git a/src/assets/scss/components/misc.scss b/src/assets/scss/components/misc.scss index c276636..0b795e1 100644 --- a/src/assets/scss/components/misc.scss +++ b/src/assets/scss/components/misc.scss @@ -118,6 +118,10 @@ user-select: none; } +.p-dropdown-panel { + max-width: 100%; +} + .p-inputgroup.flex-1 { align-items: center; } diff --git a/src/components/FormField/components/Datepicker/index.js b/src/components/FormField/components/Datepicker/index.js index 6744491..b33c13c 100644 --- a/src/components/FormField/components/Datepicker/index.js +++ b/src/components/FormField/components/Datepicker/index.js @@ -28,18 +28,17 @@ const Datepicker = ({ control={control} defaultValue={defaultValue} rules={config} - render={({ field, fieldState }) => ( - field.onChange(e.value)} - dateFormat="dd/mm/yy" - hourFormat="24" - timeOnly={timeOnly} - showIcon - minDate={minDate} - maxDate={maxDate} - className={classNames({ 'p-invalid': fieldState.invalid })}/> + render={({ field, fieldState }) => ( field.onChange(e.value)} + dateFormat="dd/mm/yy" + hourFormat="24" + timeOnly={timeOnly} + showIcon + minDate={minDate} + maxDate={maxDate} + className={classNames({ 'p-invalid': fieldState.invalid })}/> )}/> {infoText ? {infoText} : null} ) diff --git a/src/components/FormField/components/NumberInput/index.js b/src/components/FormField/components/NumberInput/index.js index d5d4ee4..62a90e9 100644 --- a/src/components/FormField/components/NumberInput/index.js +++ b/src/components/FormField/components/NumberInput/index.js @@ -1,7 +1,7 @@ import React from 'react'; import { classNames } from 'primereact/utils'; import { Controller } from 'react-hook-form'; -import { is } from 'ramda'; +import { is, isEmpty } from 'ramda'; import { InputNumber } from 'primereact/inputnumber'; @@ -23,6 +23,8 @@ const NumberInput = ({ disabled = false, useGrouping = true }) => { + const minAttr = config.min ? config.min : min; + const maxAttr = config.max ? config.max : max; const input = field.onChange(e.value)} - min={min} - max={max} + min={minAttr} + max={maxAttr} locale={locale} useGrouping={useGrouping} maxFractionDigits={!isNaN(parseInt(maxFractionDigits)) ? parseInt(maxFractionDigits) : 0} @@ -45,6 +47,8 @@ const NumberInput = ({ <> {inputgroup ?
diff --git a/src/components/FormFieldRepeater/index.js b/src/components/FormFieldRepeater/index.js index 9d69312..fe00a72 100644 --- a/src/components/FormFieldRepeater/index.js +++ b/src/components/FormFieldRepeater/index.js @@ -73,6 +73,7 @@ const FormFieldRepeater = ({ const properField = (item, i) => { return !isNil(item.lookUpDataId) ? selectItem(e, i)} optionDisabled={(opt) => usedExistingValues().includes(opt.value)} diff --git a/src/components/FormFieldRepeaterCriteria/index.js b/src/components/FormFieldRepeaterCriteria/index.js index 7882cf8..9f96447 100644 --- a/src/components/FormFieldRepeaterCriteria/index.js +++ b/src/components/FormFieldRepeaterCriteria/index.js @@ -79,6 +79,7 @@ const FormFieldRepeaterCriteria = ({ const properField = (item, i) => { return !isNil(item.lookUpDataId) ? selectItem(e, i)} optionDisabled={(opt) => usedExistingValues().includes(opt.value)} diff --git a/src/components/FormFieldRepeaterFaq/index.js b/src/components/FormFieldRepeaterFaq/index.js index 2420943..5ba60a3 100644 --- a/src/components/FormFieldRepeaterFaq/index.js +++ b/src/components/FormFieldRepeaterFaq/index.js @@ -182,6 +182,7 @@ const FormFieldRepeaterFaq = ({ disabled={disabled} icon="pi pi-plus" onClick={addNewItem}/> selectItem(e)} + filter disabled={disabled} optionDisabled={(opt) => usedExistingValues().includes(opt.title)} options={stateOptionsData} diff --git a/src/components/TopBarProfileMenu/index.js b/src/components/TopBarProfileMenu/index.js index 4288572..2c3c729 100644 --- a/src/components/TopBarProfileMenu/index.js +++ b/src/components/TopBarProfileMenu/index.js @@ -78,6 +78,7 @@ const TopBarProfileMenu = ({ menuLeftRef }) => { icon: 'pi pi-sign-out', command: () => { storeSet.main.doLogout(); + window.location.reload(); }, enable: true } diff --git a/src/components/UnsavedChangesDetector/index.js b/src/components/UnsavedChangesDetector/index.js index 86c21fd..fefef9d 100644 --- a/src/components/UnsavedChangesDetector/index.js +++ b/src/components/UnsavedChangesDetector/index.js @@ -26,6 +26,7 @@ const UnsavedChangesDetector = ({ getValuesFn }) => { } formData = wrap(formData).insert(['dates'], starDate, 0).value(); + delete formData.startDate; } if (formData.endDate) { let endDate; @@ -38,6 +39,7 @@ const UnsavedChangesDetector = ({ getValuesFn }) => { } formData = wrap(formData).insert(['dates'], endDate, 1).value(); + delete formData.endDate; } if (!isNil(formData.startTime)) { if (!is(String, formData.startTime)) { @@ -54,7 +56,7 @@ const UnsavedChangesDetector = ({ getValuesFn }) => { const initial = storeGet.main.formInitialData(); const isEqual = equal(initial, formData); - // TODO + // debug /*console.log('isEqual', isEqual, initial, formData, diff(initial, formData))*/ diff --git a/src/configData.js b/src/configData.js index a7d3d1c..5de2560 100644 --- a/src/configData.js +++ b/src/configData.js @@ -13,4 +13,33 @@ export const mimeTypes = [ } ]; -export const defaultMaxFileSize = 314572800; // 314572800 = 300 Mb \ No newline at end of file +export const defaultMaxFileSize = 314572800; // 314572800 = 300 Mb + +const dynamicDataForTextinput = [ + { label: 'company name', value: 'company.companyName' }, + { label: 'company piva', value: 'company.vatNumber' }, + { label: 'company codiceFiscale', value: 'company.codiceFiscale' }, + { label: 'company address', value: 'company.address' }, + { label: 'company phoneNumber', value: 'company.phoneNumber' }, + { label: 'company city', value: 'company.city' }, + { label: 'company province', value: 'company.province' }, + { label: 'company cap', value: 'company.cap' }, + { label: 'company country', value: 'company.country' }, + { label: 'company pec', value: 'company.pec' }, + { label: 'company email', value: 'company.email' }, + { label: 'company contactName', value: 'company.contactName' }, + { label: 'company contactEmail', value: 'company.contactEmail' }, + { label: 'user email', value: 'user.email' }, + { label: 'user firstName', value: 'user.firstName' }, + { label: 'user lastName', value: 'user.lastName' }, + { label: 'user phoneNumber', value: 'user.phoneNumber' }, + { label: 'user codiceFiscale', value: 'user.codiceFiscale' } +] + +export const dynamicDataOptions = { + datepicker: [ + { label: 'user dateOfBirth', value: 'user.dateOfBirth' } + ], + textinput: dynamicDataForTextinput, + textarea: dynamicDataForTextinput +} \ No newline at end of file diff --git a/src/pages/BandiBeneficiario/components/AllBandiAccordion/index.js b/src/pages/BandiBeneficiario/components/AllBandiAccordion/index.js index a4cdef6..e6a155f 100644 --- a/src/pages/BandiBeneficiario/components/AllBandiAccordion/index.js +++ b/src/pages/BandiBeneficiario/components/AllBandiAccordion/index.js @@ -2,14 +2,18 @@ import React, { useState, useEffect} from 'react'; import { __ } from '@wordpress/i18n'; import { is, uniq, isNil, isEmpty } from 'ramda'; import { wrap } from 'object-path-immutable'; +import { useNavigate } from 'react-router-dom'; // store -import { storeSet, useStore } from '../../../../store'; +import { storeGet, storeSet, useStore } from '../../../../store'; // tools import getBandoSeverity from '../../../../helpers/getBandoSeverity'; import getBandoLabel from '../../../../helpers/getBandoLabel'; import getDateFromISOstring from '../../../../helpers/getDateFromISOstring'; +import set404FromErrorResponse from '../../../../helpers/set404FromErrorResponse'; +import getNumberWithCurrency from '../../../../helpers/getNumberWithCurrency'; +import renderHtmlContent from '../../../../helpers/renderHtmlContent'; // api import BandoService from '../../../../service/bando-service'; @@ -20,11 +24,8 @@ import { Column } from 'primereact/column'; import { Dropdown } from 'primereact/dropdown'; import { Tag } from 'primereact/tag'; import ProperBandoLabel from '../../../../components/ProperBandoLabel'; -import getNumberWithCurrency from '../../../../helpers/getNumberWithCurrency'; -import renderHtmlContent from '../../../../helpers/renderHtmlContent'; import { Button } from 'primereact/button'; -import { useNavigate } from 'react-router-dom'; -import set404FromErrorResponse from '../../../../helpers/set404FromErrorResponse'; +import PreferredBandoService from '../../../../service/preferred-bando-service'; const AllBandiAccordion = () => { @@ -38,8 +39,10 @@ const AllBandiAccordion = () => { useEffect(() => { storeSet.main.setAsyncRequest(); - BandoService.getBandi(getCallback, errGetCallbacks); - }, []); + BandoService.getBandi(getCallback, errGetCallbacks, [ + ['companyId', chosenCompanyId] + ]); + }, [chosenCompanyId]); const getCallback = (data) => { if (data.status === 'SUCCESS') { @@ -93,21 +96,68 @@ const AllBandiAccordion = () => { return ; }; - /*const addToFavourites = () => { - console.log('addToFavourites'); - }*/ + const addToFavourites = (id, preferredId) => { + const companyId = storeGet.main.chosenCompanyId() + const data = { + companyId, + callId: id + } + if (preferredId && preferredId !== 0) { + PreferredBandoService.deleteFromPreferred(preferredId, (data) => removeFavCallback(data, id), errToggleFavCallback); + } else { + PreferredBandoService.addToPreferred(data, addFavCallback, errToggleFavCallback); + } + } + + const removeFavCallback = (data, id) => { + if (data.status === 'SUCCESS') { + const newItems = items.map((o) => { + if (o.id === id) { + return { + ...o, + preferredCallId: null + } + } else { + return o; + } + }); + setItems(newItems) + } + } + const addFavCallback = (data) => { + if (data.status === 'SUCCESS') { + const newItems = items.map((o) => { + if (o.id === data.data.callId) { + return { + ...o, + preferredCallId: data.data.id + } + } else { + return o; + } + }); + setItems(newItems) + } + } + + const errToggleFavCallback = (data) => { + set404FromErrorResponse(data); + } const goToBandoPage = (id) => { navigate(`/bandi/${id}`) } - /*const actionsBodyTemplate = (rowData) => { + const actionsBodyTemplate = (rowData) => { return
-
- }*/ + } const rowExpansionTemplate = (data) => { return ( @@ -150,10 +200,12 @@ const AllBandiAccordion = () => { - {/**/} + {!isEmpty(chosenCompanyId) && chosenCompanyId !== 0 + ? : null}
) diff --git a/src/pages/BandiBeneficiario/index.js b/src/pages/BandiBeneficiario/index.js index ba0571d..be925d3 100644 --- a/src/pages/BandiBeneficiario/index.js +++ b/src/pages/BandiBeneficiario/index.js @@ -1,12 +1,13 @@ import React from 'react'; import { __ } from '@wordpress/i18n'; -import { Link, useNavigate } from 'react-router-dom'; +import { Link } from 'react-router-dom'; +import { isEmpty } from 'ramda'; + +// store +import { useStore } from '../../store'; // components import AllBandiAccordion from './components/AllBandiAccordion'; -import { Button } from 'primereact/button'; -import { isEmpty } from 'ramda'; -import { useStore } from '../../store'; const BandiBeneficiario = () => { const chosenCompanyId = useStore().main.chosenCompanyId(); diff --git a/src/pages/BandoEdit/components/BandoEditFormActions/index.js b/src/pages/BandoEdit/components/BandoEditFormActions/index.js index 3b65462..4658387 100644 --- a/src/pages/BandoEdit/components/BandoEditFormActions/index.js +++ b/src/pages/BandoEdit/components/BandoEditFormActions/index.js @@ -5,27 +5,29 @@ import { isNil } from 'ramda'; // components import { Button } from 'primereact/button'; -const BandoEditFormActions = ({ id, openPreview, openPreviewEvaluation, submitFn }) => { +const BandoEditFormActions = ({ id, openPreview, submitFn, status }) => { return (
) diff --git a/src/pages/BandoEdit/components/BandoEditFormStep1/index.js b/src/pages/BandoEdit/components/BandoEditFormStep1/index.js index 4117123..5d1d12b 100644 --- a/src/pages/BandoEdit/components/BandoEditFormStep1/index.js +++ b/src/pages/BandoEdit/components/BandoEditFormStep1/index.js @@ -27,7 +27,7 @@ import { storeSet } from '../../../../store'; import set404FromErrorResponse from '../../../../helpers/set404FromErrorResponse'; import getTimeParsedFromString from '../../../../helpers/getTimeParsedFromString'; -const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors, status }, ref) { +const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, getFormErrors, status }, ref) { const navigate = useNavigate(); const [aimedToOptions, setAimedToOptions] = useState([]); const [faqOptions, setFaqOptions] = useState([]); @@ -86,7 +86,6 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors, st formData.startTime = tzAwareDate.toISOString().substring(11, 16); } } - if (!isNil(formData.endTime)) { if (!is(String, formData.endTime)) { const tzAwareDate = new TZDate(formData.endTime, 'Europe/Berlin'); @@ -112,7 +111,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors, st toast.current.show({ severity: 'success', summary: '', - detail: __('Il bando è stato aggiornato corretamente!', 'gepafin') + detail: __('Il bando è stato aggiornato correttamente!', 'gepafin') }); } const values = getValues(); @@ -120,6 +119,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors, st navigate(`/bandi/${data.data.id}`); } else { setFormInitialData(data.data); + setInitialData(data.data); } } } @@ -176,8 +176,13 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors, st storeSet.main.unsetAsyncRequest(); } - const shouldDisableField = () => { - return values.status === 'PUBLISH' + const shouldDisableField = (fieldName) => { + return values.status === 'PUBLISH' && + ![ + 'descriptionShort', 'descriptionLong', 'documentationRequested', 'threshold', + 'aimedTo', 'criteria', 'docs', 'checklist', 'faq', 'amount', 'amountMin', 'amountMax', + 'email', 'phoneNumber', 'checkList', 'images' + ].includes(fieldName) } useImperativeHandle( @@ -239,7 +244,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors, st { - return values.status === 'PUBLISH' + const shouldDisableField = (fieldName) => { + return values.status === 'PUBLISH' && + ![ + 'descriptionShort', 'descriptionLong', 'documentationRequested', 'threshold', + 'aimedTo', 'criteria', 'docs', 'checklist', 'faq', 'amount', 'amountMin', 'amountMax', + 'email', 'phoneNumber', 'checkList', 'images' + ].includes(fieldName) } const acceptAllFormats = () => { @@ -219,7 +224,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors, st { {!isEmpty(data) ? <> {activeStep === 0 - ? : null} + ? + : null} {activeStep === 1 - ? : null} + ? + : null}

{__('Crea o modifica il Form compilabile dal Beneficiario', 'gepafin')}

diff --git a/src/pages/BandoFlowEdit/index.js b/src/pages/BandoFlowEdit/index.js index f10d9e0..e6b210d 100644 --- a/src/pages/BandoFlowEdit/index.js +++ b/src/pages/BandoFlowEdit/index.js @@ -112,7 +112,7 @@ const BandoFlowEdit = () => { toast.current.show({ severity: 'success', summary: '', - detail: __('Il flusso è stato aggiornato corretamente!', 'gepafin') + detail: __('Il flusso è stato aggiornato correttamente!', 'gepafin') }); } } diff --git a/src/pages/BandoForms/index.js b/src/pages/BandoForms/index.js index ea70e59..cee1051 100644 --- a/src/pages/BandoForms/index.js +++ b/src/pages/BandoForms/index.js @@ -91,7 +91,7 @@ const BandoForms = () => { toast.current.show({ severity: 'success', summary: '', - detail: __('Il form è stato aggiornato corretamente!', 'gepafin') + detail: __('Il form è stato aggiornato correttamente!', 'gepafin') }); } @@ -235,7 +235,7 @@ const BandoForms = () => { outlined disabled={!selectedForm} onClick={goToEditForm} - label={'PUBLISH' === bandoStatus ? __('Mostra', 'gepafin') : __('Modifica', 'gepafin')} + label={__('Modifica', 'gepafin')} icon="pi pi-cog" iconPos="right"/>
diff --git a/src/pages/BandoFormsEdit/components/BuilderElement/index.js b/src/pages/BandoFormsEdit/components/BuilderElement/index.js index ff1fbc0..56fde4a 100644 --- a/src/pages/BandoFormsEdit/components/BuilderElement/index.js +++ b/src/pages/BandoFormsEdit/components/BuilderElement/index.js @@ -11,7 +11,7 @@ import { Button } from 'primereact/button'; import { Tag } from 'primereact/tag'; import BuilderElementProperLabel from '../BuilderElementProperLabel'; -const BuilderElement = ({ id, name, label, index }) => { +const BuilderElement = ({ id, name, label, index, bandoStatus }) => { const draggingElementId = useStore().main.draggingElementId(); const ref = useRef(null); @@ -109,28 +109,10 @@ const BuilderElement = ({ id, name, label, index }) => {
) - - /*return ( -
- {draggingId === id - ?
- : <> -
- - -
-
-
- - } -
- )*/ } export default BuilderElement; \ No newline at end of file diff --git a/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSetting/index.js b/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSetting/index.js index 6264b89..6e2dcfc 100644 --- a/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSetting/index.js +++ b/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSetting/index.js @@ -11,7 +11,7 @@ import { Editor } from 'primereact/editor'; import { mimeTypes } from '../../../../../../configData'; import ElementSettingTableColumns from '../ElementSettingTableColumns'; -const ElementSetting = ({ setting, changeFn, updateDataFn }) => { +const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => { const settingLabels = { label: __('Label', 'gepafin'), @@ -48,6 +48,7 @@ const ElementSetting = ({ setting, changeFn, updateDataFn }) => { return } else if (setting.name === 'mime') { return { return } else { return { const [stateFieldData, setStateFieldData] = useState([]); @@ -53,10 +54,10 @@ const ElementSettingRepeater = ({ {stateFieldData.map((o, i) =>
{properField(o, i)} -
)} - + +