changed node id, bug: not displaying changes
This commit is contained in:
parent
2988821828
commit
9a12d6e43a
3 changed files with 19 additions and 7 deletions
|
|
@ -9,6 +9,8 @@ type TabsContextType={
|
||||||
removeFlow:(id:string)=>void;
|
removeFlow:(id:string)=>void;
|
||||||
addFlow:()=>void;
|
addFlow:()=>void;
|
||||||
updateFlow:(newFlow:flow)=>void;
|
updateFlow:(newFlow:flow)=>void;
|
||||||
|
setNodeId:(newState:any)=>void;
|
||||||
|
nodeId:number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TabsContextInitialValue = {
|
const TabsContextInitialValue = {
|
||||||
|
|
@ -17,7 +19,9 @@ const TabsContextInitialValue = {
|
||||||
flows:[],
|
flows:[],
|
||||||
removeFlow:(id:string)=>{},
|
removeFlow:(id:string)=>{},
|
||||||
addFlow:()=>{},
|
addFlow:()=>{},
|
||||||
updateFlow:(newFlow:flow)=>{}
|
updateFlow:(newFlow:flow)=>{},
|
||||||
|
setNodeId:(newState:any)=>{},
|
||||||
|
nodeId:0,
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -28,10 +32,11 @@ export function TabsProvider({children}){
|
||||||
const [tabIndex,setTabIndex] = useState(0)
|
const [tabIndex,setTabIndex] = useState(0)
|
||||||
const [flows,setFlows] = useState<Array<flow>>([])
|
const [flows,setFlows] = useState<Array<flow>>([])
|
||||||
const [id, setId] = useState(0);
|
const [id, setId] = useState(0);
|
||||||
|
const [nodeId, setNodeId] = useState(0);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(flows.length !== 0)
|
if(flows.length !== 0)
|
||||||
window.localStorage.setItem('tabsData', JSON.stringify({tabIndex, flows, id}));
|
window.localStorage.setItem('tabsData', JSON.stringify({tabIndex, flows, id, nodeId}));
|
||||||
}, [flows, id, tabIndex]);
|
}, [flows, id, nodeId, tabIndex]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let cookie = window.localStorage.getItem('tabsData');
|
let cookie = window.localStorage.getItem('tabsData');
|
||||||
|
|
@ -40,6 +45,7 @@ export function TabsProvider({children}){
|
||||||
setTabIndex(cookieObject.tabIndex);
|
setTabIndex(cookieObject.tabIndex);
|
||||||
setFlows(cookieObject.flows)
|
setFlows(cookieObject.flows)
|
||||||
setId(cookieObject.id)
|
setId(cookieObject.id)
|
||||||
|
setNodeId(cookieObject.nodeId)
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
@ -83,7 +89,7 @@ export function TabsProvider({children}){
|
||||||
}
|
}
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<TabsContext.Provider value={{tabIndex,setTabIndex,flows,removeFlow,addFlow,updateFlow}}>
|
<TabsContext.Provider value={{tabIndex,setTabIndex,flows,setNodeId, nodeId,removeFlow,addFlow,updateFlow}}>
|
||||||
{children}
|
{children}
|
||||||
</TabsContext.Provider>
|
</TabsContext.Provider>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ type typesContextType=
|
||||||
deleteNode:(idx:number)=>void;
|
deleteNode:(idx:number)=>void;
|
||||||
types: {};
|
types: {};
|
||||||
setTypes:(newState:{})=>void;
|
setTypes:(newState:{})=>void;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialValue= {
|
const initialValue= {
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,16 @@ const nodeTypes = {
|
||||||
var _ = require("lodash");
|
var _ = require("lodash");
|
||||||
|
|
||||||
export default function FlowPage({ flow }) {
|
export default function FlowPage({ flow }) {
|
||||||
const { updateFlow } = useContext(TabsContext);
|
const { updateFlow, nodeId, setNodeId } = useContext(TabsContext);
|
||||||
const { types, reactFlowInstance, setReactFlowInstance } = useContext(typesContext);
|
const { types, reactFlowInstance, setReactFlowInstance } =
|
||||||
|
useContext(typesContext);
|
||||||
const reactFlowWrapper = useRef(null);
|
const reactFlowWrapper = useRef(null);
|
||||||
|
|
||||||
const getId = () => `dndnode_${_.uniqueId()}`;
|
const getId = () => {
|
||||||
|
console.log(nodeId);
|
||||||
|
setNodeId(old => old + 1);
|
||||||
|
return `dndnode_${nodeId}`;
|
||||||
|
};
|
||||||
|
|
||||||
const { setExtraComponent, setExtraNavigation } = useContext(locationContext);
|
const { setExtraComponent, setExtraNavigation } = useContext(locationContext);
|
||||||
const { setErrorData } = useContext(alertContext);
|
const { setErrorData } = useContext(alertContext);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue