mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-25 10:10:19 -06:00
1) Make default values column read-only for inherited columns when creating table.
2) Default values not populated for inherited columns. The existing issue, API changed. 3) Options are not populated for Name in Column > Variable tab. 4) The empty check error message is changed from Label cannot be empty to Label in Collection cannot be empty for collections. Fixes #6763
This commit is contained in:
parent
b60bd73f88
commit
08009f8edc
@ -379,7 +379,13 @@ export default class ColumnSchema extends BaseUISchema {
|
||||
if (isDisabled && obj.isNew(state)) {
|
||||
return {defval: undefined};
|
||||
}
|
||||
}
|
||||
}, editable: function(state) {
|
||||
// inheritedfrom has value then we should disable it
|
||||
if (!isEmptyString(state.inheritedfrom)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
},{
|
||||
id: 'attnotnull', label: gettext('Not NULL?'), cell: 'switch',
|
||||
type: 'switch', minWidth: 80,
|
||||
@ -509,7 +515,10 @@ export default class ColumnSchema extends BaseUISchema {
|
||||
},{
|
||||
id: 'attoptions', label: gettext('Variables'), type: 'collection',
|
||||
group: gettext('Variables'),
|
||||
schema: new VariableSchema([], null, null, ['name', 'value']),
|
||||
schema: new VariableSchema([
|
||||
{label: 'n_distinct', value: 'n_distinct', vartype: 'string'},
|
||||
{label: 'n_distinct_inherited', value: 'n_distinct_inherited', vartype: 'string'}
|
||||
], null, null, ['name', 'value']),
|
||||
uniqueCol : ['name'], mode: ['edit', 'create'],
|
||||
canAdd: true, canEdit: false, canDelete: true,
|
||||
}, {
|
||||
|
@ -1,5 +1,6 @@
|
||||
SELECT
|
||||
a.attname AS name, pg_catalog.format_type(a.atttypid, NULL) AS cltype, a.attidentity as clidentity,
|
||||
a.attname AS name, pg_catalog.format_type(a.atttypid, NULL) AS cltype,
|
||||
pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS defval, a.attidentity as clidentity,
|
||||
pg_catalog.quote_ident(n.nspname)||'.'||pg_catalog.quote_ident(c.relname) as inheritedfrom,
|
||||
c.oid as inheritedid
|
||||
FROM
|
||||
@ -8,6 +9,8 @@ JOIN
|
||||
pg_catalog.pg_namespace n ON c.relnamespace=n.oid
|
||||
JOIN
|
||||
pg_catalog.pg_attribute a ON a.attrelid = c.oid AND NOT a.attisdropped AND a.attnum > 0
|
||||
LEFT OUTER JOIN
|
||||
pg_catalog.pg_attrdef def ON adrelid=a.attrelid AND adnum=a.attnum
|
||||
WHERE
|
||||
{% if tid %}
|
||||
c.oid = {{tid}}::OID
|
||||
|
@ -1,5 +1,6 @@
|
||||
SELECT
|
||||
a.attname AS name, pg_catalog.format_type(a.atttypid, NULL) AS cltype,
|
||||
pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS defval,
|
||||
pg_catalog.quote_ident(n.nspname)||'.'||pg_catalog.quote_ident(c.relname) as inheritedfrom,
|
||||
c.oid as inheritedid
|
||||
FROM
|
||||
@ -8,6 +9,8 @@ JOIN
|
||||
pg_catalog.pg_namespace n ON c.relnamespace=n.oid
|
||||
JOIN
|
||||
pg_catalog.pg_attribute a ON a.attrelid = c.oid AND NOT a.attisdropped AND a.attnum > 0
|
||||
LEFT OUTER JOIN
|
||||
pg_catalog.pg_attrdef def ON adrelid=a.attrelid AND adnum=a.attnum
|
||||
WHERE
|
||||
{% if tid %}
|
||||
c.oid = {{tid}}::OID
|
||||
|
@ -246,7 +246,7 @@ define('pgadmin.browser', [
|
||||
isPrivate: true,
|
||||
elContainer: true,
|
||||
limit: 1,
|
||||
content: '<div class="obj_properties container-fluid"><div role="status" class="pg-panel-message">' + select_object_msg + '</div></div>',
|
||||
content: '<div class="obj_properties container-fluid h-100"><div role="status" class="pg-panel-message">' + select_object_msg + '</div></div>',
|
||||
events: panelEvents,
|
||||
onCreate: function(myPanel, $container) {
|
||||
$container.addClass('pg-no-overflow');
|
||||
|
@ -233,7 +233,7 @@ function getChangedData(topSchema, viewHelperProps, sessData, stringify=false) {
|
||||
return changedData;
|
||||
}
|
||||
|
||||
function validateSchema(schema, sessData, setError, accessPath=[]) {
|
||||
function validateSchema(schema, sessData, setError, accessPath=[], collLabel=null) {
|
||||
sessData = sessData || {};
|
||||
for(let field of schema.fields) {
|
||||
/* Skip id validation */
|
||||
@ -261,7 +261,7 @@ function validateSchema(schema, sessData, setError, accessPath=[]) {
|
||||
}
|
||||
/* Loop through data */
|
||||
for(const [rownum, row] of rows.entries()) {
|
||||
if(validateSchema(field.schema, row, setError, currPath.concat(rownum))) {
|
||||
if(validateSchema(field.schema, row, setError, currPath.concat(rownum), field.label)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -276,7 +276,14 @@ function validateSchema(schema, sessData, setError, accessPath=[]) {
|
||||
let value = sessData[field.id];
|
||||
let message = null;
|
||||
if(field.noEmpty) {
|
||||
message = emptyValidator(field.label, value);
|
||||
let label = field.label;
|
||||
if(collLabel) {
|
||||
label = gettext('%s in %s', field.label, collLabel);
|
||||
}
|
||||
if(field.noEmptyLabel) {
|
||||
label = field.noEmptyLabel;
|
||||
}
|
||||
message = emptyValidator(label, value);
|
||||
}
|
||||
if(!message && (field.type == 'int' || field.type == 'numeric')) {
|
||||
message = minMaxValidator(field.label, value, field.min, field.max);
|
||||
|
Loading…
Reference in New Issue
Block a user