Make some call fields editable after publishing the call

- call form fields are editable (according to the list of keys);
- some parts of the form are editable;
This commit is contained in:
Vitalii Kiiko
2024-11-14 14:27:19 +01:00
parent 74647cc2fd
commit b08e2d46c0
15 changed files with 55 additions and 48 deletions

View File

@@ -5,14 +5,16 @@ import { isNil } from 'ramda';
// components
import { Button } from 'primereact/button';
const BandoEditFormActions = ({ id, openPreview, openPreviewEvaluation, submitFn }) => {
const BandoEditFormActions = ({ id, openPreview, openPreviewEvaluation, submitFn, status }) => {
return (
<div className="appPageSection">
<div className="appPageSection__actions">
<Button
type="button"
onClick={submitFn}
label={__('Salva bozza', 'gepafin')} icon="pi pi-save" iconPos="right"/>
label={status === 'PUBLISH'
? __('Modifica', 'gepafin')
: __('Salva bozza', 'gepafin')} icon="pi pi-save" iconPos="right"/>
<Button
type="button"
disabled={isNil(id)}

View File

@@ -180,7 +180,8 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors, st
return values.status === 'PUBLISH' &&
![
'descriptionShort', 'descriptionLong', 'documentationRequested', 'threshold',
'aimedTo', 'criteria', 'docs', 'checklist', 'faq'
'aimedTo', 'criteria', 'docs', 'checklist', 'faq', 'amount', 'amountMin', 'amountMax',
'email', 'phoneNumber', 'checkList', 'images'
].includes(fieldName)
}

View File

@@ -206,8 +206,13 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors, st
}
}, []);
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)
}
const acceptAllFormats = () => {
@@ -219,7 +224,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors, st
<UnsavedChangesDetector getValuesFn={getValues}/>
<FormFieldRepeaterCriteria
data={values}
disabled={shouldDisableField()}
disabled={shouldDisableField('criteria')}
setDataFn={setValue}
fieldName="criteria"
options={criteriaOptions}
@@ -238,7 +243,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors, st
<FormField
type="fileuploadasync"
disabled={shouldDisableField()}
disabled={shouldDisableField('docs')}
setDataFn={setValue}
fieldName="docs"
label={__('Documentazione', 'gepafin')}
@@ -257,7 +262,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors, st
<FormField
type="fileuploadasync"
disabled={shouldDisableField()}
disabled={shouldDisableField('images')}
setDataFn={setValue}
fieldName="images"
label={__('Immagine del Bando', 'gepafin')}
@@ -273,7 +278,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors, st
<FormFieldRepeater
data={values['checkList']}
disabled={shouldDisableField()}
disabled={shouldDisableField('checkList')}
setDataFn={setValue}
fieldName="checkList"
options={checklistOptions}