Table node related fixes:

1. File select control sets the value for all other to last selected file. Fixes #6814
2. Vacuum parameters-related issues. Fixes #6777
3. Exclusion removes all columns if one row is removed. Fixes #6771
This commit is contained in:
Aditya Toshniwal
2021-10-01 12:57:04 +05:30
committed by Akshay Joshi
parent 5e0c113c7b
commit 357a020828
7 changed files with 32 additions and 29 deletions

View File

@@ -29,6 +29,7 @@ import { confirmDeleteRow } from '../helpers/legacyConnector';
import CustomPropTypes from 'sources/custom_prop_types';
import { evalFunc } from 'sources/utils';
import { DepListenerContext } from './DepListener';
import { useIsMounted } from '../custom_hooks';
const useStyles = makeStyles((theme)=>({
grid: {
@@ -179,17 +180,19 @@ function DataTableRow({row, totalRows, isResizing, schema, schemaRef, accessPath
}, []);
useEffect(()=>{
schema.fields.forEach((field)=>{
schemaRef.current.fields.forEach((field)=>{
/* Self change is also dep change */
if(field.depChange) {
depListener?.addDepListener(accessPath.concat(field.id), accessPath.concat(field.id), field.depChange);
if(field.depChange || field.deferredDepChange) {
depListener.addDepListener(accessPath.concat(field.id), accessPath.concat(field.id), field.depChange, field.deferredDepChange);
}
(evalFunc(null, field.deps) || []).forEach((dep)=>{
let source = accessPath.concat(dep);
if(_.isArray(dep)) {
source = dep;
}
depListener?.addDepListener(source, accessPath.concat(field.id), field.depChange);
if(field.depChange) {
depListener.addDepListener(source, accessPath.concat(field.id), field.depChange);
}
});
});
return ()=>{
@@ -244,6 +247,7 @@ export default function DataGridView({
fixedRows, ...props}) {
const classes = useStyles();
const stateUtils = useContext(StateUtilsContext);
const checkIsMounted = useIsMounted();
/* Using ref so that schema variable is not frozen in columns closure */
const schemaRef = useRef(schema);
@@ -432,7 +436,7 @@ export default function DataGridView({
);
useEffect(()=>{
let rowsPromise = fixedRows, umounted=false;
let rowsPromise = fixedRows;
/* If fixedRows is defined, fetch the details */
if(typeof rowsPromise === 'function') {
@@ -442,12 +446,11 @@ export default function DataGridView({
Promise.resolve(rowsPromise)
.then((res)=>{
/* If component unmounted, dont update state */
if(!umounted) {
if(checkIsMounted()) {
stateUtils.initOrigData(accessPath, res);
}
});
}
return ()=>umounted=true;
}, []);
const isResizing = _.flatMap(headerGroups, headerGroup => headerGroup.headers.map(col=>col.isResizing)).includes(true);

View File

@@ -237,7 +237,6 @@ export default function FormView({
);
} else if(field.type === 'collection') {
/* If its a collection, let data grid view handle it */
let depsMap = [value[field.id]];
/* Pass on the top schema */
if(isNested) {
field.schema.top = schemaRef.current.top;
@@ -245,8 +244,6 @@ export default function FormView({
field.schema.top = schemaRef.current;
}
depsMap.push(canAdd, canEdit, canDelete, visible);
if(!_.isUndefined(field.fixedRows)) {
canAdd = false;
canDelete = false;

View File

@@ -121,6 +121,7 @@ function getChangedData(topSchema, viewHelperProps, sessData, stringify=false) {
/* Will be called recursively as data can be nested */
const parseChanges = (schema, origVal, sessVal)=>{
let levelChanges = {};
parseChanges.depth = _.isUndefined(parseChanges.depth) ? 0 : parseChanges.depth+1;
/* The comparator and setter */
const attrChanged = (id, change, force=false)=>{
@@ -131,8 +132,9 @@ function getChangedData(topSchema, viewHelperProps, sessData, stringify=false) {
if(stringify && (_.isArray(change) || _.isObject(change))) {
change = JSON.stringify(change);
}
/* Null values are not passed in URL params, pass it as an empty string */
if(_.isNull(change)) {
/* Null values are not passed in URL params, pass it as an empty string
Nested values does not need this */
if(_.isNull(change) && parseChanges.depth === 0) {
change = '';
}
return levelChanges[id] = change;
@@ -234,6 +236,7 @@ function getChangedData(topSchema, viewHelperProps, sessData, stringify=false) {
}
});
parseChanges.depth--;
return levelChanges;
};
@@ -480,7 +483,7 @@ function SchemaDialogView({
/* tell the callbacks the data has changed */
props.onDataChange && props.onDataChange(isDataChanged, changedData);
}, [sessData]);
}, [sessData, formReady]);
useEffect(()=>{
if(sessData.__deferred__?.length > 0) {
@@ -488,7 +491,6 @@ function SchemaDialogView({
type: SCHEMA_STATE_ACTIONS.CLEAR_DEFERRED_QUEUE,
});
// let deferredDepChang = sessData.__deferred__[0];
let item = sessData.__deferred__[0];
item.promise.then((resFunc)=>{
sessDispatch({
@@ -526,7 +528,6 @@ function SchemaDialogView({
});
setFormReady(true);
setLoaderText('');
});
} else {
/* Use the defaults as the initital data */