Skip to content

Commit

Permalink
1 .Task variable fixed for published forms and reworked some function (
Browse files Browse the repository at this point in the history
…AOT-Technologies#1996)

2. application id removed from task variable
  • Loading branch information
shuhaib-aot authored Apr 4, 2024
1 parent 47e3fa2 commit 2e7f128
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 29 deletions.
3 changes: 2 additions & 1 deletion forms-flow-web/src/apiManager/services/bpmFormServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export const fetchBPMFormList = (
};

export const fetchAllForms = ()=>{
return RequestService.httpGETRequest(`${API.FORM}`);
//isActive means published forms only : status = Active
return RequestService.httpGETRequest(`${API.FORM}?isActive=true`);
};

export const fetchFormByAlias = (path, ...rest) => {
Expand Down
6 changes: 6 additions & 0 deletions forms-flow-web/src/apiManager/services/processServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,12 @@ export const getFormProcesses = (formId, ...rest) => {
};
};

// fetching task variables
export const fetchTaskVariables = (formId) =>{
let url = `${API.FORM_PROCESSES}/${formId}`;
return RequestService.httpGETRequest(url);
};

export const fetchAllDmnProcessesCount = (tenant_key = null, searchKey) => {


Expand Down
8 changes: 6 additions & 2 deletions forms-flow-web/src/components/Form/Steps/WorkFlow.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ const WorkFlow = React.memo(
if (components[i.key]) {
delete components[i.key];
}
keys.push(i.key);
taskvariable.push({ ...i, checked: true });
//if ignore types already exist in db need to avoid that
if(!ignoredKeys.has(i.key) ) {
taskvariable.push({ ...i, checked: true });
keys.push(i.key);
}

});
setSelectedVariableKeys(keys);
taskvariable.push(...Object.values(components));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Drawer from "@material-ui/core/Drawer";
import List from "@material-ui/core/List";
import Divider from "@material-ui/core/Divider";
import Select from "react-select";
import { fetchAllBpmProcesses } from "../../../../apiManager/services/processServices";
import { fetchAllBpmProcesses, fetchTaskVariables } from "../../../../apiManager/services/processServices";
import { listProcess } from "../../../../apiManager/services/formatterService";

import {
Expand Down Expand Up @@ -48,10 +48,6 @@ import {
MULTITENANCY_ENABLED,
} from "../../../../constants/constants";
import { fetchAllForms } from "../../../../apiManager/services/bpmFormServices";
import {
getFormProcesses,
resetFormProcessData,
} from "../../../../apiManager/services/processServices";
import { fetchUserList } from "../../../../apiManager/services/bpmTaskServices";
import { filterSelectOptionByLabel } from "../../../../helper/helper";

Expand Down Expand Up @@ -89,6 +85,7 @@ export default function CreateNewFilterDrawer({
const [identifierId, setIdentifierId] = useState("");
const [selectUserGroupIcon, setSelectUserGroupIcon] = useState("");
const [specificUserGroup, setSpecificUserGroup] = useState("");
const [taskVariableFromMapperTable, setTaskVariableFromMapperTable] = useState([]);
const firstResult = useSelector((state) => state.bpmTasks.firstResult);
const tenantKey = useSelector((state) => state.tenants?.tenantId);
const process = useSelector((state) => state.process?.processList);
Expand Down Expand Up @@ -154,6 +151,18 @@ export default function CreateNewFilterDrawer({
return inputString;
};

const handleFetchTaskVariables = (formId)=>{
setProcessLoading(true);
fetchTaskVariables(formId).then((res)=>{
setTaskVariableFromMapperTable(res.data?.taskVariable || []);
setProcessLoading(false);
}).catch((err)=>{
console.err(err);
setProcessLoading(false);
});
};


const setTaskVariablesAndItsKeys = (variables = []) => {
setVariables(variables);
// taking variable names to check it is already exist or not
Expand Down Expand Up @@ -187,12 +196,7 @@ export default function CreateNewFilterDrawer({

if (selectedFilterData?.properties?.formId) {
setSelectedForm(selectedFilterData?.properties?.formId || null);
setProcessLoading(true);
dispatch(
getFormProcesses(selectedFilterData?.properties?.formId, () => {
setProcessLoading(false);
})
);
handleFetchTaskVariables(selectedFilterData?.properties?.formId);
}

setTaskVariablesAndItsKeys(selectedFilterData.variables);
Expand Down Expand Up @@ -283,20 +287,15 @@ export default function CreateNewFilterDrawer({

const onChangeSelectForm = (e) => {
if (e?.value) {
setProcessLoading(true);
dispatch(
getFormProcesses(e.value, () => {
setProcessLoading(false);
})
);
handleFetchTaskVariables(e?.value);
if (e?.value === selectedFilterData?.properties?.formId) {
setTaskVariablesAndItsKeys(selectedFilterData?.variables);
} else {
resetVariables();
}
} else {
resetVariables();
dispatch(resetFormProcessData());
setTaskVariableFromMapperTable([]);
}
setSelectedForm(e?.value);
};
Expand Down Expand Up @@ -352,7 +351,7 @@ export default function CreateNewFilterDrawer({
setIsTasksForCurrentUserGroupsEnabled(true);
setIsMyTasksEnabled(false);
setSelectedForm(null);
dispatch(resetFormProcessData());
setTaskVariableFromMapperTable([]);
setCheckboxes(initialValueOfTaskAttribute);
setForms({ data: [], isLoading: true });
};
Expand Down Expand Up @@ -973,6 +972,7 @@ export default function CreateNewFilterDrawer({
selectedTaskAttrbutes={checkboxes}
selectedTaskVariablesKeys={taskVariablesKeys}
selectedTaskVariables={variables}
taskVariableFromMapperTable={taskVariableFromMapperTable}
onSaveTaskAttribute={onSaveTaskAttribute}
showUndefinedVariable={showUndefinedVariable}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import Modal from "react-bootstrap/Modal";
import ModalTitle from "react-bootstrap/ModalTitle";
import Form from "react-bootstrap/Form";
import { Translation, useTranslation } from "react-i18next";
import { useSelector } from "react-redux";


function TaskAttributeComponent({
show,
selectedForm,
Expand All @@ -15,11 +14,10 @@ function TaskAttributeComponent({
selectedTaskVariables,
onSaveTaskAttribute,
processLoading,
taskVariableFromMapperTable
// showUndefinedVariable,
}) {
const taskVariables = useSelector(
(state) => state.process?.formProcessList?.taskVariable || []
);

const { t } = useTranslation();

const [variables, setVariables] = useState(selectedTaskVariables);
Expand Down Expand Up @@ -183,8 +181,8 @@ function TaskAttributeComponent({
/> */}
<div className="d-flex mt-3 px-2 flex-wrap">
{selectedForm ? (
taskVariables?.length > 0 ? (
taskVariables.map((variable) =>
taskVariableFromMapperTable?.length > 0 ? (
taskVariableFromMapperTable.map((variable) =>
variable.key !== "applicationId" ? (
<Col xs={12} md={6} key={variable.key}>
<Form.Check
Expand Down

0 comments on commit 2e7f128

Please sign in to comment.