mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-08-08 04:05:00 -05:00
Some changes to the core code that will be helpful for other nodes.
This commit is contained in:
committed by
Akshay Joshi
parent
764677431f
commit
b20558cb99
@@ -257,16 +257,16 @@ export default function DataGridView({
|
||||
(viewHelperProps.serverInfo.version <= field.max_version))));
|
||||
let _readonly = viewHelperProps.inCatalog || (viewHelperProps.mode == 'properties');
|
||||
if(!_readonly) {
|
||||
_readonly = evalFunc(readonly, row.original || {});
|
||||
_readonly = evalFunc(schema, readonly, row.original || {});
|
||||
}
|
||||
|
||||
let _visible = true;
|
||||
if(visible) {
|
||||
_visible = evalFunc(visible, row.original || {});
|
||||
_visible = evalFunc(schema, visible, row.original || {});
|
||||
}
|
||||
_visible = _visible && verInLimit;
|
||||
|
||||
disabled = evalFunc(disabled, row.original || {});
|
||||
disabled = evalFunc(schema, disabled, row.original || {});
|
||||
|
||||
return <MappedCellControl rowIndex={row.index} value={value}
|
||||
row={row.original} {..._field}
|
||||
|
||||
@@ -105,17 +105,17 @@ export default function FormView({
|
||||
|
||||
let _readonly = viewHelperProps.inCatalog || (viewHelperProps.mode == 'properties');
|
||||
if(!_readonly) {
|
||||
_readonly = evalFunc(readonly, value);
|
||||
_readonly = evalFunc(schema, readonly, value);
|
||||
}
|
||||
|
||||
let _visible = true;
|
||||
|
||||
if(visible) {
|
||||
_visible = evalFunc(visible, value);
|
||||
_visible = evalFunc(schema, visible, value);
|
||||
}
|
||||
_visible = _visible && verInLimit;
|
||||
|
||||
disabled = evalFunc(disabled, value);
|
||||
disabled = evalFunc(schema, disabled, value);
|
||||
|
||||
|
||||
if(!tabs[group]) tabs[group] = [];
|
||||
@@ -151,6 +151,7 @@ export default function FormView({
|
||||
firstEleRef.current = ele;
|
||||
}
|
||||
}}
|
||||
state={value}
|
||||
key={field.id}
|
||||
viewHelperProps={viewHelperProps}
|
||||
name={field.id}
|
||||
|
||||
@@ -158,7 +158,7 @@ const ALLOWED_PROPS_FIELD_COMMON = [
|
||||
];
|
||||
|
||||
const ALLOWED_PROPS_FIELD_FORM = [
|
||||
'type', 'onChange'
|
||||
'type', 'onChange', 'state',
|
||||
];
|
||||
|
||||
const ALLOWED_PROPS_FIELD_CELL = [
|
||||
@@ -168,7 +168,7 @@ const ALLOWED_PROPS_FIELD_CELL = [
|
||||
|
||||
export const MappedFormControl = (props)=>{
|
||||
let newProps = {...props};
|
||||
let typeProps = evalFunc(newProps.type, newProps.value);
|
||||
let typeProps = evalFunc(null, newProps.type, newProps.state);
|
||||
if(typeof(typeProps) === 'object') {
|
||||
newProps = {
|
||||
...newProps,
|
||||
@@ -184,7 +184,7 @@ export const MappedFormControl = (props)=>{
|
||||
|
||||
export const MappedCellControl = (props)=>{
|
||||
let newProps = {...props};
|
||||
let cellProps = evalFunc(newProps.cell, newProps.row);
|
||||
let cellProps = evalFunc(null, newProps.cell, newProps.row);
|
||||
if(typeof(cellProps) === 'object') {
|
||||
newProps = {
|
||||
...newProps,
|
||||
|
||||
@@ -17,6 +17,7 @@ export default class BaseUISchema {
|
||||
this._defaults = defaults;
|
||||
|
||||
this.keys = null; // If set, other fields except keys will be filtered
|
||||
this.filterGroups = []; // If set, these groups will be filtered out
|
||||
this.informText = null; // Inform text to show after save, this only saves it
|
||||
this._top = null;
|
||||
}
|
||||
@@ -59,13 +60,26 @@ export default class BaseUISchema {
|
||||
concat base fields with extraFields.
|
||||
*/
|
||||
get fields() {
|
||||
/* Select only keys if specified */
|
||||
return this.baseFields
|
||||
.filter((field)=>this.keys ? this.keys.indexOf(field.id) > -1 : true);
|
||||
.filter((field)=>{
|
||||
let retval;
|
||||
|
||||
/* If any groups are to be filtered */
|
||||
retval = this.filterGroups.indexOf(field.group) == -1;
|
||||
|
||||
/* Select only keys, if specified */
|
||||
if(this.keys) {
|
||||
retval = retval && this.keys.indexOf(field.id) > -1;
|
||||
}
|
||||
return retval;
|
||||
});
|
||||
}
|
||||
|
||||
/* Check if current data is new or existing */
|
||||
isNew(state) {
|
||||
if(_.isUndefined(state)) {
|
||||
state = this.origData;
|
||||
}
|
||||
if(_.has(state, this.idAttribute)) {
|
||||
return _.isUndefined(state[this.idAttribute])
|
||||
|| _.isNull(state[this.idAttribute]);
|
||||
|
||||
@@ -85,7 +85,10 @@ function getChangedData(topSchema, mode, sessData, stringify=false) {
|
||||
return;
|
||||
} else {
|
||||
change = change || _.get(sessData, currPath);
|
||||
_.set(changedData, currPath, stringify ? JSON.stringify(change) : change);
|
||||
if(stringify && (_.isArray(change) || _.isObject(change))) {
|
||||
change = JSON.stringify(change);
|
||||
}
|
||||
_.set(changedData, currPath, change);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -104,8 +107,8 @@ function getChangedData(topSchema, mode, sessData, stringify=false) {
|
||||
/* Use diffArray package to get the array diff and extract the info
|
||||
cid is used to identify the rows uniquely */
|
||||
const changeDiff = diffArray(
|
||||
_.get(topSchema.origData, currPath),
|
||||
_.get(sessData, currPath),
|
||||
_.get(topSchema.origData, currPath) || [],
|
||||
_.get(sessData, currPath) || [],
|
||||
'cid'
|
||||
);
|
||||
change = {};
|
||||
@@ -437,7 +440,13 @@ function SchemaDialogView({
|
||||
/* Called when SQL tab is active */
|
||||
if(dirty) {
|
||||
if(!formErr.name) {
|
||||
let changeData = getChangedData(schema, viewHelperProps.mode, sessData, true);
|
||||
let changeData = {};
|
||||
if(viewHelperProps.mode === 'edit') {
|
||||
changeData = getChangedData(schema, viewHelperProps.mode, sessData, true);
|
||||
} else {
|
||||
/* If new then merge the changed data with origData */
|
||||
changeData = _.merge(schema.origData, sessData);
|
||||
}
|
||||
/* Call the passed incoming getSQLValue func to get the SQL
|
||||
return of getSQLValue should be a promise.
|
||||
*/
|
||||
@@ -566,10 +575,10 @@ function SchemaPropertiesView({
|
||||
_visible = (field.mode.indexOf(viewHelperProps.mode) > -1);
|
||||
}
|
||||
if(_visible && visible) {
|
||||
_visible = evalFunc(visible, origData);
|
||||
_visible = evalFunc(schema, visible, origData);
|
||||
}
|
||||
|
||||
disabled = evalFunc(disabled, origData);
|
||||
disabled = evalFunc(schema, disabled, origData);
|
||||
readonly = true;
|
||||
if(_visible && verInLimit) {
|
||||
if(!tabs[group]) tabs[group] = [];
|
||||
|
||||
Reference in New Issue
Block a user