diff --git a/src/components/PaymentPlanHeadPanel.js b/src/components/PaymentPlanHeadPanel.js index d282846..f60e207 100644 --- a/src/components/PaymentPlanHeadPanel.js +++ b/src/components/PaymentPlanHeadPanel.js @@ -165,20 +165,6 @@ class PaymentPlanHeadPanel extends FormPanel { id="paymentPlan.headPanel.title" /> - {paymentPlanType.replace(/\s+/g, '') === PAYMENT_PLAN_TYPE.BENEFIT_PLAN && ( - - )} @@ -292,6 +278,30 @@ class PaymentPlanHeadPanel extends FormPanel { /> + + +
+ +
+ + + {paymentPlanType.replace(/\s+/g, '') === PAYMENT_PLAN_TYPE.BENEFIT_PLAN && ( + + )} + +
diff --git a/src/dialogs/AdvancedCriteriaDialog.js b/src/dialogs/AdvancedCriteriaDialog.js index 4cae67d..3350f08 100644 --- a/src/dialogs/AdvancedCriteriaDialog.js +++ b/src/dialogs/AdvancedCriteriaDialog.js @@ -37,18 +37,43 @@ const AdvancedCriteriaDialog = ({ setAppliedFiltersRowStructure, updateAttributes, getDefaultAppliedCustomFilters, + additionalParams, + confirmed, + edited, }) => { const [isOpen, setIsOpen] = useState(false); const [currentFilter, setCurrentFilter] = useState({ field: "", filter: "", type: "", value: "", amount: "" }) const [filters, setFilters] = useState(getDefaultAppliedCustomFilters()); - const createParams = (moduleName, objectTypeName, uuidOfObject=null) => { - return [ + const getBenefitPlanDefaultCriteria = () => { + const { jsonExt } = edited?.benefitPlan ?? {}; + try { + const jsonData = JSON.parse(jsonExt); + return jsonData.advanced_criteria || []; + } catch (error) { + return []; + } + }; + + useEffect(() => { + if (!getDefaultAppliedCustomFilters().length) { + setFilters(getBenefitPlanDefaultCriteria()); + } + }, [edited]); + + const createParams = (moduleName, objectTypeName, uuidOfObject = null, additionalParams = null) => { + const params = [ `moduleName: "${moduleName}"`, `objectTypeName: "${objectTypeName}"`, - uuidOfObject !== null ? `uuidOfObject: "${uuidOfObject}"`: ``, ]; + if (uuidOfObject) { + params.push(`uuidOfObject: "${uuidOfObject}"`); + } + if (additionalParams) { + params.push(`additionalParams: ${JSON.stringify(JSON.stringify(additionalParams))}`); + } + return params; }; const fetchFilters = (params) => fetchCustomFilter(params); @@ -60,13 +85,6 @@ const AdvancedCriteriaDialog = ({ const handleClose = () => { setCurrentFilter(CLEARED_STATE_FILTER); - setIsOpen(false); - }; - - const handleRemoveFilter = () => { - setCurrentFilter(CLEARED_STATE_FILTER); - setAppliedFiltersRowStructure([CLEARED_STATE_FILTER]); - setFilters([CLEARED_STATE_FILTER]); }; const handleAddFilter = () => { @@ -85,6 +103,12 @@ const AdvancedCriteriaDialog = ({ return updatedJsonExt; } + const handleRemoveFilter = () => { + setCurrentFilter(CLEARED_STATE_FILTER); + setAppliedFiltersRowStructure([CLEARED_STATE_FILTER]); + setFilters([]); + }; + const saveCriteria = () => { setAppliedFiltersRowStructure(filters); const outputFilters = JSON.stringify( @@ -101,6 +125,7 @@ const AdvancedCriteriaDialog = ({ handleClose(); }; + useEffect(() => { if (object && isEmptyObject(object) === false) { let paramsToFetchFilters = []; @@ -108,55 +133,22 @@ const AdvancedCriteriaDialog = ({ paramsToFetchFilters = createParams( moduleName, objectType, - isBase64Encoded(object.id) ? decodeId(object.id) : object.id + isBase64Encoded(object.id) ? decodeId(object.id) : object.id, + additionalParams, ); } else { paramsToFetchFilters = createParams( moduleName, objectType, + additionalParams, ); } fetchFilters(paramsToFetchFilters); } }, [object]); - - useEffect(() => {}, [filters]); return ( <> - - - - {formatMessage(intl, "paymentPlan", "paymentPlan.advancedCriteria.button.AdvancedCriteria")} - - {filters.map((filter, index) => { return () })} + { !confirmed ? (
@@ -178,6 +172,7 @@ const AdvancedCriteriaDialog = ({ height: "16px" }} onClick={handleAddFilter} + disabled={confirmed} />
-
- + ) : (<>) }
-
- -
-
+ - -
+ {formatMessage(intl, 'individual', 'paymentPlan.advancedCriteria.button.clearAllFilters')} + +
+
+
-
-
- +
+ ); -}; +} const mapStateToProps = (state, props) => ({ rights: !!state.core && !!state.core.user && !!state.core.user.i_user ? state.core.user.i_user.rights : [], diff --git a/src/dialogs/AdvancedCriteriaRowValue.js b/src/dialogs/AdvancedCriteriaRowValue.js index 8f6bc64..824af8c 100644 --- a/src/dialogs/AdvancedCriteriaRowValue.js +++ b/src/dialogs/AdvancedCriteriaRowValue.js @@ -33,6 +33,7 @@ const AdvancedCriteriaRowValue = ({ index, filters, setFilters, + readOnly, }) => { const onAttributeChange = (attribute) => (value) => { @@ -79,6 +80,7 @@ const AdvancedCriteriaRowValue = ({ return ( ); @@ -87,6 +89,7 @@ const AdvancedCriteriaRowValue = ({ ); @@ -96,12 +99,14 @@ const AdvancedCriteriaRowValue = ({ return ( ); } else { return ( );