- fixed typo;
- added tag 'csv' for enabled fields;
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import React from 'react';
|
||||
import { head, isEmpty, pathOr } from 'ramda';
|
||||
|
||||
// store
|
||||
import { useStoreValue } from '../../../../../store';
|
||||
|
||||
// components
|
||||
import { Tag } from 'primereact/tag';
|
||||
import BuilderElementProperLabel from '../../BuilderElementProperLabel';
|
||||
|
||||
const BuilderElementMeta = ({ id, name, label }) => {
|
||||
const elements = useStoreValue('formElements');
|
||||
const element = head(elements.filter(o => o.id === id));
|
||||
const elementSettings = pathOr([], ['settings'], element);
|
||||
const variable = head(elementSettings.filter(o => o.name === 'variable'));
|
||||
const formula = head(elementSettings.filter(o => o.name === 'formula'));
|
||||
const requestedAmount = head(elementSettings.filter(o => o.name === 'isRequestedAmount'));
|
||||
const delegation = head(elementSettings.filter(o => o.name === 'isDelegation'));
|
||||
const csvReportEnabled = head(elementSettings.filter(o => o.name === 'reportEnable'));
|
||||
const isVariable = variable && !isEmpty(variable.value) ? 'warning' : 'secondary';
|
||||
const isFormula = formula && !isEmpty(formula.value) ? 'warning' : 'secondary';
|
||||
const isRequestedAmount = requestedAmount && requestedAmount.value ? 'tertiary' : 'secondary';
|
||||
const isDelegation = delegation && delegation.value ? 'tertiary' : 'secondary';
|
||||
const isCsvReportEnabled = csvReportEnabled && csvReportEnabled.value ? 'tertiary' : 'secondary';
|
||||
|
||||
return (
|
||||
<div className="meta">
|
||||
<div className="tagHeader">
|
||||
<Tag value={label} severity="info"/>
|
||||
{['numberinput', 'criteria_table'].includes(name)
|
||||
? <Tag value="var" severity={isVariable} title={variable && variable.value ? variable.value : ''}/> : null}
|
||||
{name === 'numberinput'
|
||||
? <Tag value="f(x)" severity={isFormula} title={formula && formula.value ? formula.value : ''}/> : null}
|
||||
{requestedAmount && requestedAmount.value
|
||||
? <Tag value="importo" severity={isRequestedAmount}/> : null}
|
||||
{delegation && delegation.value
|
||||
? <Tag value="delega" severity={isDelegation}/> : null}
|
||||
{csvReportEnabled && csvReportEnabled.value
|
||||
? <Tag value="csv" severity={isCsvReportEnabled}/> : null}
|
||||
</div>
|
||||
<BuilderElementProperLabel id={id} defaultLabel={label}/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default BuilderElementMeta;
|
||||
@@ -1,8 +1,8 @@
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import React, { useCallback, useRef } from 'react'
|
||||
import { useDrag, useDrop } from 'react-dnd'
|
||||
import { ItemTypes } from '../ItemTypes';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { head, isEmpty, pathOr } from 'ramda';
|
||||
import { head } from 'ramda';
|
||||
import { klona } from 'klona';
|
||||
|
||||
// store
|
||||
@@ -13,22 +13,13 @@ import uniqid from '../../../../helpers/uniqid';
|
||||
|
||||
// components
|
||||
import { Button } from 'primereact/button';
|
||||
import { Tag } from 'primereact/tag';
|
||||
import BuilderElementProperLabel from '../BuilderElementProperLabel';
|
||||
import BuilderElementMeta from './components/BuilderElementMeta';
|
||||
|
||||
const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
const draggingElementId = useStoreValue('draggingElementId');
|
||||
const selectedElement = useStoreValue('selectedElement');
|
||||
const ref = useRef(null);
|
||||
const elements = useStoreValue('formElements');
|
||||
const element = head(elements.filter(o => o.id === id));
|
||||
const elementSettings = pathOr([], ['settings'], element);
|
||||
const [isVariable, setIsVariable] = useState('secondary');
|
||||
const [isFormula, setIsFormula] = useState('secondary');
|
||||
const [variableName, setVariableName] = useState('secondary');
|
||||
const [formulaName, setFormulaName] = useState('secondary');
|
||||
const [isRequestedAmount, setIsRequestedAmount] = useState(false);
|
||||
const [isDelegation, setIsDelegation] = useState(false);
|
||||
|
||||
const [{ handlerId }, drop] = useDrop({
|
||||
accept: ItemTypes.FIELD,
|
||||
@@ -134,35 +125,6 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
const opacity = isDragging ? 0 : 1;
|
||||
drag(drop(ref));
|
||||
|
||||
useEffect(() => {
|
||||
const variable = head(elementSettings.filter(o => o.name === 'variable'));
|
||||
const formula = head(elementSettings.filter(o => o.name === 'formula'));
|
||||
const isRequestedAmount = head(elementSettings.filter(o => o.name === 'isRequestedAmount'));
|
||||
const isDelegation = head(elementSettings.filter(o => o.name === 'isDelegation'));
|
||||
|
||||
if (variable && !isEmpty(variable.value)) {
|
||||
setIsVariable('warning');
|
||||
setVariableName(variable.value)
|
||||
}
|
||||
|
||||
if (formula && !isEmpty(formula.value)) {
|
||||
setIsFormula('warning');
|
||||
setFormulaName(formula.value)
|
||||
}
|
||||
|
||||
if (isRequestedAmount && !isEmpty(isRequestedAmount.value) && isRequestedAmount.value) {
|
||||
setIsRequestedAmount('tertiary');
|
||||
} else {
|
||||
setIsRequestedAmount(false);
|
||||
}
|
||||
|
||||
if (isDelegation && !isEmpty(isDelegation.value) && isDelegation.value) {
|
||||
setIsDelegation('tertiary');
|
||||
} else {
|
||||
setIsDelegation(false);
|
||||
}
|
||||
}, [elementSettings]);
|
||||
|
||||
return (
|
||||
draggingElementId === id
|
||||
? <div ref={ref} className="formBuilder__elementNew">
|
||||
@@ -173,20 +135,7 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
style={{ opacity }}
|
||||
onClick={selectElement}
|
||||
data-handler-id={handlerId}>
|
||||
<div className="meta">
|
||||
<div className="tagHeader">
|
||||
<Tag value={label} severity="info"/>
|
||||
{['numberinput', 'criteria_table'].includes(name)
|
||||
? <Tag value="var" severity={isVariable} title={variableName}/> : null}
|
||||
{name === 'numberinput'
|
||||
? <Tag value="f(x)" severity={isFormula} title={formulaName}/> : null}
|
||||
{isRequestedAmount
|
||||
? <Tag value="importo" severity={isRequestedAmount}/> : null}
|
||||
{isDelegation
|
||||
? <Tag value="delega" severity={isDelegation}/> : null}
|
||||
</div>
|
||||
<BuilderElementProperLabel id={id} defaultLabel={label}/>
|
||||
</div>
|
||||
<BuilderElementMeta id={id} name={name} label={label}/>
|
||||
<div className="actions">
|
||||
<Button icon="pi pi-clone" onClick={duplicateElement} outlined severity="success"/>
|
||||
<Button icon="pi pi-cog" onClick={openSettings} outlined severity="info"/>
|
||||
|
||||
@@ -17,9 +17,10 @@ import ElementSettingTableColumns from '../ElementSettingTableColumns';
|
||||
import { InputSwitch } from 'primereact/inputswitch';
|
||||
import ElementSettingChips from '../ElementSettingChips';
|
||||
import ElementSettingCriteriaTableColumns from '../ElementSettingCriteriaTableColumns';
|
||||
import ElementSettingTableColumnsForCsv from '../ElementSettingTableColumnsForCsv';
|
||||
|
||||
import { mimeTypes } from '../../../../../../configData';
|
||||
import ElementSettingTableColumnsForCsv from '../ElementSettingTableColumnsForCsv';
|
||||
import ElementSettingReportHeader from '../ElementSettingReportHeader';
|
||||
|
||||
|
||||
const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
||||
@@ -128,6 +129,8 @@ const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
||||
name={setting.name}
|
||||
bandoStatus={bandoStatus}
|
||||
setDataFn={updateDataFn}/>
|
||||
} else if (setting.name === 'reportHeader') {
|
||||
return <ElementSettingReportHeader setting={setting} changeFn={changeFn}/>
|
||||
} else if (['variable'].includes(setting.name)) {
|
||||
return <ElementSettingChips
|
||||
restrictedValues={[]}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import React from 'react';
|
||||
import { head } from 'ramda';
|
||||
|
||||
// components
|
||||
import { InputText } from 'primereact/inputtext';
|
||||
import { useStoreValue } from '../../../../../../store';
|
||||
|
||||
const ElementSettingReportHeader = ({ setting = {}, changeFn }) => {
|
||||
const chosenFieldSettings = useStoreValue('chosenFieldSettings');
|
||||
const label = head(chosenFieldSettings.filter(o => o.name === 'label'));
|
||||
|
||||
return (
|
||||
<InputText id={setting.name} aria-describedby={`${setting.name}-help`}
|
||||
value={setting.value}
|
||||
placeholder={label.value}
|
||||
onChange={(e) => changeFn(e.target.value, setting.name)}/>
|
||||
);
|
||||
}
|
||||
|
||||
export default ElementSettingReportHeader;
|
||||
@@ -68,7 +68,7 @@ const DocumentsBeneficiary = () => {
|
||||
|
||||
const footerAddNewDialog = () => {
|
||||
return <div>
|
||||
<Button type="button" label={__('Anulla', 'gepafin')} onClick={hideAddNewDialog} outlined/>
|
||||
<Button type="button" label={__('Annulla', 'gepafin')} onClick={hideAddNewDialog} outlined/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={loading || !isValidForm()}
|
||||
|
||||
@@ -611,7 +611,7 @@ const DomandaEditInstructorManager = () => {
|
||||
|
||||
const footerCompleteDialog = useCallback(() => {
|
||||
return <div>
|
||||
<Button type="button" label={__('Anulla', 'gepafin')} onClick={hideCompleteDialog} outlined/>
|
||||
<Button type="button" label={__('Annulla', 'gepafin')} onClick={hideCompleteDialog} outlined/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={loading || ('approve' === operationType && (!amountAccepted || isEmpty(amountAccepted) || amountAccepted === 0))}
|
||||
@@ -696,7 +696,7 @@ const DomandaEditInstructorManager = () => {
|
||||
|
||||
const footerAppointmentDialog = () => {
|
||||
return <div>
|
||||
<Button type="button" label={__('Anulla', 'gepafin')} onClick={hideAppointmentDialog} outlined/>
|
||||
<Button type="button" label={__('Annulla', 'gepafin')} onClick={hideAppointmentDialog} outlined/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={loading}
|
||||
|
||||
@@ -66,7 +66,7 @@ const ArchiveDocument = ({
|
||||
|
||||
const footerDialog = () => {
|
||||
return <div>
|
||||
<Button type="button" label={__('Anulla', 'gepafin')} onClick={hideDialog} outlined/>
|
||||
<Button type="button" label={__('Annulla', 'gepafin')} onClick={hideDialog} outlined/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={loading}
|
||||
|
||||
@@ -610,7 +610,7 @@ const DomandaEditPreInstructor = () => {
|
||||
|
||||
const footerCompleteDialog = useCallback(() => {
|
||||
return <div>
|
||||
<Button type="button" label={__('Anulla', 'gepafin')} onClick={hideCompleteDialog} outlined/>
|
||||
<Button type="button" label={__('Annulla', 'gepafin')} onClick={hideCompleteDialog} outlined/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={loading || ('approve' === operationType && (!amountAccepted || isEmpty(amountAccepted) || amountAccepted === 0))}
|
||||
@@ -695,7 +695,7 @@ const DomandaEditPreInstructor = () => {
|
||||
|
||||
const footerAppointmentDialog = () => {
|
||||
return <div>
|
||||
<Button type="button" label={__('Anulla', 'gepafin')} onClick={hideAppointmentDialog} outlined/>
|
||||
<Button type="button" label={__('Annulla', 'gepafin')} onClick={hideAppointmentDialog} outlined/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={loading}
|
||||
|
||||
@@ -77,7 +77,7 @@ const Domande = () => {
|
||||
|
||||
const footerEditDialog = () => {
|
||||
return <div>
|
||||
<Button type="button" label={__('Anulla', 'gepafin')} onClick={hideEditDialog} outlined/>
|
||||
<Button type="button" label={__('Annulla', 'gepafin')} onClick={hideEditDialog} outlined/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={loading}
|
||||
|
||||
@@ -77,7 +77,7 @@ const DomandeInstructorManager = () => {
|
||||
|
||||
const footerEditDialog = () => {
|
||||
return <div>
|
||||
<Button type="button" label={__('Anulla', 'gepafin')} onClick={hideEditDialog} outlined/>
|
||||
<Button type="button" label={__('Annulla', 'gepafin')} onClick={hideEditDialog} outlined/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={loading}
|
||||
|
||||
@@ -310,7 +310,7 @@ const SoccorsoAddInstructorManager = () => {
|
||||
type="button"
|
||||
outlined
|
||||
onClick={goToEvaluationPage}
|
||||
label={__('Anulla', 'gepafin')}
|
||||
label={__('Annulla', 'gepafin')}
|
||||
icon="pi pi-times" iconPos="right"/>
|
||||
<Button
|
||||
type="button"
|
||||
|
||||
@@ -310,7 +310,7 @@ const SoccorsoAddPreInstructor = () => {
|
||||
type="button"
|
||||
outlined
|
||||
onClick={goToEvaluationPage}
|
||||
label={__('Anulla', 'gepafin')}
|
||||
label={__('Annulla', 'gepafin')}
|
||||
icon="pi pi-times" iconPos="right"/>
|
||||
<Button
|
||||
type="button"
|
||||
|
||||
@@ -221,7 +221,7 @@ const SoccorsoEditInstructorManager = () => {
|
||||
|
||||
const footerCloseAmendDialog = () => {
|
||||
return <div>
|
||||
<Button type="button" label={__('Anulla', 'gepafin')} onClick={hideCloseAmendDialog} outlined/>
|
||||
<Button type="button" label={__('Annulla', 'gepafin')} onClick={hideCloseAmendDialog} outlined/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={isAsyncRequest || isEmpty(data.internalNotes)}
|
||||
@@ -272,7 +272,7 @@ const SoccorsoEditInstructorManager = () => {
|
||||
|
||||
const footerExtendRespDialog = () => {
|
||||
return <div>
|
||||
<Button type="button" label={__('Anulla', 'gepafin')} onClick={hideExtendRespDialog} outlined/>
|
||||
<Button type="button" label={__('Annulla', 'gepafin')} onClick={hideExtendRespDialog} outlined/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={isLoadingExtendingTime || isEmpty(extendedTime)}
|
||||
|
||||
@@ -76,7 +76,7 @@ const SoccorsoComunications = ({ amendmentId, soccorsoStatus }) => {
|
||||
|
||||
const footerNewComDialog = () => {
|
||||
return <div>
|
||||
<Button type="button" label={__('Anulla', 'gepafin')} onClick={hideNewComDialog} outlined/>
|
||||
<Button type="button" label={__('Annulla', 'gepafin')} onClick={hideNewComDialog} outlined/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={isLoadingCommunication || isEmpty(newCommData.title) || isEmpty(newCommData.comment)}
|
||||
|
||||
@@ -221,7 +221,7 @@ const SoccorsoEditPreInstructor = () => {
|
||||
|
||||
const footerCloseAmendDialog = () => {
|
||||
return <div>
|
||||
<Button type="button" label={__('Anulla', 'gepafin')} onClick={hideCloseAmendDialog} outlined/>
|
||||
<Button type="button" label={__('Annulla', 'gepafin')} onClick={hideCloseAmendDialog} outlined/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={isAsyncRequest || isEmpty(data.internalNotes)}
|
||||
@@ -272,7 +272,7 @@ const SoccorsoEditPreInstructor = () => {
|
||||
|
||||
const footerExtendRespDialog = () => {
|
||||
return <div>
|
||||
<Button type="button" label={__('Anulla', 'gepafin')} onClick={hideExtendRespDialog} outlined/>
|
||||
<Button type="button" label={__('Annulla', 'gepafin')} onClick={hideExtendRespDialog} outlined/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={isLoadingExtendingTime || isEmpty(extendedTime)}
|
||||
|
||||
@@ -133,7 +133,7 @@ const Users = () => {
|
||||
.filter(v => isInvalidField(newUserData, v));
|
||||
|
||||
return <div>
|
||||
<Button type="button" label={__('Anulla', 'gepafin')} onClick={hideEditDialog} outlined/>
|
||||
<Button type="button" label={__('Annulla', 'gepafin')} onClick={hideEditDialog} outlined/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={!isEmpty(errorValues) || loading}
|
||||
|
||||
Reference in New Issue
Block a user