Fixed global variables not setting on EditNodeModal

This commit is contained in:
Lucas Oliveira 2024-06-10 19:39:15 -03:00
commit 40f42db9a8
3 changed files with 19 additions and 7 deletions

View file

@ -28,7 +28,7 @@ export default function TableNodeCellRender({
value, value,
nodeClass, nodeClass,
handleOnNewValue: handleOnNewValueNode, handleOnNewValue: handleOnNewValueNode,
handleOnChangeDb, handleOnChangeDb: handleOnChangeDbNode,
}, },
}: CustomCellRendererProps) { }: CustomCellRendererProps) {
const handleOnNewValue = (newValue: any, name: string) => { const handleOnNewValue = (newValue: any, name: string) => {
@ -41,6 +41,15 @@ export default function TableNodeCellRender({
setTemplateValue(newValue); setTemplateValue(newValue);
}; };
const handleOnChangeDb = (newValue: boolean, name: string) => {
handleOnChangeDbNode(newValue, name);
setTemplateData((old) => {
let newData = cloneDeep(old);
newData.load_from_db = newValue;
return newData;
});
};
const [templateValue, setTemplateValue] = useState(value); const [templateValue, setTemplateValue] = useState(value);
const [templateData, setTemplateData] = useState(data); const [templateData, setTemplateData] = useState(data);

View file

@ -6,6 +6,7 @@ import TableToggleCellRender from "../../../components/tableComponent/components
const useColumnDefs = ( const useColumnDefs = (
myData: any, myData: any,
handleOnNewValue: (newValue: any, name: string) => void, handleOnNewValue: (newValue: any, name: string) => void,
handleOnChangeDb: (value: boolean, key: string) => void,
changeAdvanced: (n: string) => void, changeAdvanced: (n: string) => void,
open: boolean, open: boolean,
) => { ) => {
@ -47,9 +48,7 @@ const useColumnDefs = (
value: params.data.value, value: params.data.value,
nodeClass: myData.node, nodeClass: myData.node,
handleOnNewValue: handleOnNewValue, handleOnNewValue: handleOnNewValue,
handleOnChangeDb: (value, key) => { handleOnChangeDb: handleOnChangeDb,
myData.node!.template[key].load_from_db = value;
},
}; };
}, },
minWidth: 340, minWidth: 340,

View file

@ -39,9 +39,12 @@ const EditNodeModal = forwardRef(
!myData.current.node!.template[n]?.advanced; !myData.current.node!.template[n]?.advanced;
} }
const handleOnNewValue = (newValue: any, name) => { const handleOnNewValue = (newValue: any, key: string) => {
console.log(newValue); myData.current.node!.template[key].value = newValue;
myData.current.node!.template[name].value = newValue; };
const handleOnChangeDb = (newValue: boolean, key: string) => {
myData.current.node!.template[key].load_from_db = newValue;
}; };
const rowData = useRowData(data, open); const rowData = useRowData(data, open);
@ -49,6 +52,7 @@ const EditNodeModal = forwardRef(
const columnDefs: ColDef[] = useColumnDefs( const columnDefs: ColDef[] = useColumnDefs(
data, data,
handleOnNewValue, handleOnNewValue,
handleOnChangeDb,
changeAdvanced, changeAdvanced,
open, open,
); );