From 8784a043ed860d360d45f1fd611f421fe1aa02c4 Mon Sep 17 00:00:00 2001 From: shuhaib-aot Date: Tue, 29 Oct 2024 14:23:10 +0530 Subject: [PATCH 1/3] FWF-3818 [bugifx] fixed modal issues --- .../apiManager/services/processServices.js | 11 ++- .../CustomComponents/MultiSelect.js | 3 +- .../src/components/Form/EditForm/FlowEdit.js | 7 -- .../components/Form/EditForm/FormSettings.js | 96 +++++++------------ 4 files changed, 47 insertions(+), 70 deletions(-) diff --git a/forms-flow-web/src/apiManager/services/processServices.js b/forms-flow-web/src/apiManager/services/processServices.js index 5df1767ec6..6694b04dff 100644 --- a/forms-flow-web/src/apiManager/services/processServices.js +++ b/forms-flow-web/src/apiManager/services/processServices.js @@ -28,6 +28,7 @@ import { StorageService } from "@formsflow/service"; import { toast } from "react-toastify"; import { Translation } from "react-i18next"; import { setFormStatusLoading } from "../../actions/processActions"; +import { setFormAuthorizationDetails } from "../../actions/formActions"; export const getProcessStatusList = (processId, taskId) => { return (dispatch) => { dispatch(setProcessStatusLoading(true)); @@ -418,9 +419,13 @@ export const saveFormProcessMapperPut = (data, ...rest) => { RequestService.httpPUTRequest(`${API.FORM}/${data.mapper.id}`, data) .then(async (res) => { if (res.data) { - dispatch(getApplicationCount(res.data.mapper.id)); - dispatch(setFormPreviosData(res.data.mapper)); - dispatch(setFormProcessesData(res.data.mapper)); + const {data} = res; + dispatch(getApplicationCount(data.mapper.id)); + dispatch(setFormPreviosData(data.mapper)); + dispatch(setFormProcessesData(data.mapper)); + if(data.authorizations){ + dispatch(setFormAuthorizationDetails(data.authorizations)); + } done(null, res.data); } else { dispatch(setFormProcessesData([])); diff --git a/forms-flow-web/src/components/CustomComponents/MultiSelect.js b/forms-flow-web/src/components/CustomComponents/MultiSelect.js index 7d495a58a2..8a0df0b95b 100644 --- a/forms-flow-web/src/components/CustomComponents/MultiSelect.js +++ b/forms-flow-web/src/components/CustomComponents/MultiSelect.js @@ -3,7 +3,7 @@ import { ListGroup } from "react-bootstrap"; import { CustomPill } from "@formsflow/components"; import PropTypes from 'prop-types'; -const RoleSelector = ({ allRoles = [], selectedRoles = [], setSelectedRoles }) => { +const RoleSelector = ({ allRoles = [], selectedRoles = [], setSelectedRoles }) => { const [roleInput, setRoleInput] = useState(""); const [filteredRoles, setFilteredRoles] = useState([]); const [isDropdownOpen, setIsDropdownOpen] = useState(false); // To control dropdown visibility @@ -82,6 +82,7 @@ const RoleSelector = ({ allRoles = [], selectedRoles = [], setSelectedRoles }) = {filteredRoles.map((role, index) => ( handleRoleSelect(role)} > diff --git a/forms-flow-web/src/components/Form/EditForm/FlowEdit.js b/forms-flow-web/src/components/Form/EditForm/FlowEdit.js index 1adc834119..33517fccbf 100644 --- a/forms-flow-web/src/components/Form/EditForm/FlowEdit.js +++ b/forms-flow-web/src/components/Form/EditForm/FlowEdit.js @@ -23,9 +23,6 @@ const FlowEdit = forwardRef(({isPublished = false}, ref) => { const handleHistoryModal = () => setHistoryModalShow(!historyModalShow); const handleHanldeDisacardModal = () => setShowDiscardModal(!showDiscardModal); - - - const saveFlow = async () => { try{ const bpmnModeler = bpmnRef.current?.getBpmnModeler(); @@ -60,14 +57,10 @@ const FlowEdit = forwardRef(({isPublished = false}, ref) => { } }; - - useImperativeHandle(ref, () => ({ saveFlow, })); - - return ( { /* --------------------------- useState Variables --------------------------- */ const [userRoles, setUserRoles] = useState([]); - const [copied, setCopied] = useState(false); - const [editIndexValue, setEditIndexValue] = useState(0); - const [createIndexValue, setCreateIndexValue] = useState(0); - const [viewIndexValue, setViewIndexValue] = useState(0); + const [copied, setCopied] = useState(false); const [formDetails, setFormDetails] = useState({ title: processListData.formName, path: path, description: processListData.description, display: display, }); - const [isAnonymous, setIsAnonymous] = useState(processListData.anonymous); + const [isAnonymous, setIsAnonymous] = useState(processListData.anonymous || false); const [errors, setErrors] = useState({ name: "", path: "", @@ -66,22 +63,22 @@ const FormSettings = forwardRef((props, ref) => { ); const publicUrlPath = `${window.location.origin}/public/form/`; - + const setSelectedOption = (roles, option)=> roles.length ? "specifiedRoles" : option; /* ------------------------- authorization variables ------------------------ */ const [rolesState, setRolesState] = useState({ DESIGN: { selectedRoles: formAuthorization.DESIGNER?.roles, - selectedOption: "onlyYou", + selectedOption: setSelectedOption(formAuthorization.DESIGNER?.roles,"onlyYou"), }, FORM: { roleInput: "", selectedRoles: formAuthorization.FORM?.roles, - selectedOption: "registeredUsers", + selectedOption: setSelectedOption(formAuthorization.FORM?.roles,"registeredUsers"), }, APPLICATION: { roleInput: "", selectedRoles: formAuthorization.APPLICATION?.roles, - selectedOption: "submitter", + selectedOption: setSelectedOption(formAuthorization.APPLICATION?.roles, "submitter"), }, }); @@ -238,7 +235,7 @@ const FormSettings = forwardRef((props, ref) => { { items={[ { label: t("Only You"), - onClick: () => { - handleRoleStateChange(DESIGN, "selectedOption", "onlyYou"); - setEditIndexValue(0); - }, + value:"onlyYou", }, { label: t("You and specified roles"), - onClick: () => { - handleRoleStateChange( - DESIGN, - "selectedOption", - "specifiedRoles" - ); - setEditIndexValue(1); - }, + value: "specifiedRoles", }, ]} - dataTestid="edit-submission-role" - ariaLabel={t("Edit Submission Role")} - indexValue={editIndexValue} + onChange={ + (value) => { + handleRoleStateChange(DESIGN, "selectedOption", value); + } + } + dataTestid="who-can-edit-this-form" + id="who-can-edit-this-form" + ariaLabel={t("Edit Submission Role")} + selectedValue={rolesState.DESIGN.selectedOption} /> {rolesState.DESIGN.selectedOption === "onlyYou" && ( @@ -299,7 +292,7 @@ const FormSettings = forwardRef((props, ref) => { { @@ -312,28 +305,22 @@ const FormSettings = forwardRef((props, ref) => { items={[ { label: t("Registered users"), - onClick: () => { - handleRoleStateChange( - FORM, - "selectedOption", - "registeredUsers" - ); - - setCreateIndexValue(0); - // Set index value for Registered users - }, + value:"registeredUsers", }, { label: t("Specific roles"), - onClick: () => { - handleRoleStateChange(FORM, "selectedOption", "specifiedRoles"); - setCreateIndexValue(1); // Set index value for Specific roles - }, + value:"specifiedRoles" }, ]} + id="who-can-create-submission" dataTestid="create-submission-role" ariaLabel={t("Create Submission Role")} - indexValue={createIndexValue} + onChange={ + (value) => { + handleRoleStateChange(FORM, "selectedOption", value); + } + } + selectedValue={rolesState.FORM.selectedOption} /> {rolesState.FORM.selectedOption === "registeredUsers" && ( @@ -355,31 +342,22 @@ const FormSettings = forwardRef((props, ref) => { items={[ { label: t("Submitter"), - onClick: () => { - handleRoleStateChange( - APPLICATION, - "selectedOption", - "submitter" - ); - - setViewIndexValue(0); // Set index value for Submitter - }, + value:"submitter" }, { label: t("Submitter and specified roles"), - onClick: () => { - handleRoleStateChange( - APPLICATION, - "selectedOption", - "specifiedRoles" - ); - setViewIndexValue(0); - }, + value:"specifiedRoles" }, ]} + id="who-can-view-submission" dataTestid="view-submission-role" ariaLabel={t("View Submission Role")} - indexValue={viewIndexValue} + onChange={ + (value) => { + handleRoleStateChange(APPLICATION, "selectedOption", value); + } + } + selectedValue={rolesState.APPLICATION.selectedOption} /> {rolesState.APPLICATION.selectedOption === "submitter" && ( From 9a008da4e4cfb144f2bb9b47992a3bcfbc3aca24 Mon Sep 17 00:00:00 2001 From: shuhaib-aot Date: Tue, 29 Oct 2024 15:35:25 +0530 Subject: [PATCH 2/3] Changed function name --- .../src/components/Form/EditForm/FlowEdit.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/forms-flow-web/src/components/Form/EditForm/FlowEdit.js b/forms-flow-web/src/components/Form/EditForm/FlowEdit.js index 33517fccbf..2217c05a02 100644 --- a/forms-flow-web/src/components/Form/EditForm/FlowEdit.js +++ b/forms-flow-web/src/components/Form/EditForm/FlowEdit.js @@ -21,7 +21,7 @@ const FlowEdit = forwardRef(({isPublished = false}, ref) => { const [showDiscardModal, setShowDiscardModal] = useState(false); // handle history modal const handleHistoryModal = () => setHistoryModalShow(!historyModalShow); - const handleHanldeDisacardModal = () => setShowDiscardModal(!showDiscardModal); + const handleDiscardModal = () => setShowDiscardModal(!showDiscardModal); const saveFlow = async () => { try{ @@ -53,7 +53,7 @@ const FlowEdit = forwardRef(({isPublished = false}, ref) => { if(bpmnRef.current){ //import the existing process data to bpmn bpmnRef.current?.handleImport(processData?.processData); - handleHanldeDisacardModal(); + handleDiscardModal(); } }; @@ -69,10 +69,10 @@ const FlowEdit = forwardRef(({isPublished = false}, ref) => { message={t("Are you sure you want to discard all the changes of the Flow?")} messageSecondary={t("This action cannot be undone.")} primaryBtnAction={handleDiscardConfirm} - onClose={handleHanldeDisacardModal} + onClose={handleDiscardModal} primaryBtnText={t("Discard Changes")} secondaryBtnText={t("Cancel")} - secondayBtnAction={handleHanldeDisacardModal} + secondayBtnAction={handleDiscardModal} size="sm" /> @@ -117,7 +117,7 @@ const FlowEdit = forwardRef(({isPublished = false}, ref) => { variant="secondary" size="md" label={t("Discard Changes")} - onClick={handleHanldeDisacardModal} + onClick={handleDiscardModal} dataTestid="discard-flow-changes-testid" ariaLabel={t("Discard Flow Changes")} /> From ecb99160a6402755280e3d4060ab98e27d2d8b91 Mon Sep 17 00:00:00 2001 From: shuhaib-aot Date: Wed, 30 Oct 2024 11:02:14 +0530 Subject: [PATCH 3/3] used data instead of res.data --- forms-flow-web/src/apiManager/services/processServices.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forms-flow-web/src/apiManager/services/processServices.js b/forms-flow-web/src/apiManager/services/processServices.js index 6694b04dff..4d2b9994db 100644 --- a/forms-flow-web/src/apiManager/services/processServices.js +++ b/forms-flow-web/src/apiManager/services/processServices.js @@ -426,7 +426,7 @@ export const saveFormProcessMapperPut = (data, ...rest) => { if(data.authorizations){ dispatch(setFormAuthorizationDetails(data.authorizations)); } - done(null, res.data); + done(null, data); } else { dispatch(setFormProcessesData([])); dispatch(setFormPreviosData([]));