mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Allow to specify special type - 'group' in schema for the browser node,
which allows to determine certain group to hide/show the whole tab/fieldset control in the properties, and create dialog. Using this functionality in the database for the 'default privileges - types', which is not allowed before PG < 9.2 using the version check.
This commit is contained in:
@@ -273,7 +273,7 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
|
|||||||
min_version: 90200
|
min_version: 90200
|
||||||
},{
|
},{
|
||||||
type: 'nested', control: 'tab', group: '{{ _('Default Privileges') }}',
|
type: 'nested', control: 'tab', group: '{{ _('Default Privileges') }}',
|
||||||
mode: ['edit', 'create'],
|
mode: ['edit'],
|
||||||
schema:[{
|
schema:[{
|
||||||
id: 'deftblacl', model: pgAdmin.Browser.Node.PrivilegeRoleModel.extend(
|
id: 'deftblacl', model: pgAdmin.Browser.Node.PrivilegeRoleModel.extend(
|
||||||
{privileges: ['a', 'r', 'w', 'd', 'D', 'x', 't']}), label: '{{ _('Default Privileges: Tables') }}',
|
{privileges: ['a', 'r', 'w', 'd', 'D', 'x', 't']}), label: '{{ _('Default Privileges: Tables') }}',
|
||||||
@@ -295,11 +295,15 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
|
|||||||
},{
|
},{
|
||||||
id: 'deftypeacl', model: pgAdmin.Browser.Node.PrivilegeRoleModel.extend(
|
id: 'deftypeacl', model: pgAdmin.Browser.Node.PrivilegeRoleModel.extend(
|
||||||
{privileges: ['U']}), label: '{{ _('Default Privileges: Types') }}',
|
{privileges: ['U']}), label: '{{ _('Default Privileges: Types') }}',
|
||||||
editable: false, type: 'collection', group: '{{ _('Types') }}',
|
editable: false, type: 'collection', group: 'deftypesacl_group',
|
||||||
mode: ['edit', 'create'], control: 'unique-col-collection',
|
mode: ['edit', 'create'], control: 'unique-col-collection',
|
||||||
canAdd: true, canDelete: true, uniqueCol : ['grantee', 'grantor'],
|
canAdd: true, canDelete: true, uniqueCol : ['grantee', 'grantor'],
|
||||||
min_version: 90200
|
min_version: 90200
|
||||||
}]
|
},{
|
||||||
|
id: 'deftypesacl_group', type: 'group', label: '{{ _('Types') }}',
|
||||||
|
mode: ['edit', 'create'], min_version: 90200
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
validate: function(keys) {
|
validate: function(keys) {
|
||||||
|
|||||||
@@ -464,7 +464,10 @@
|
|||||||
controls = this.controls,
|
controls = this.controls,
|
||||||
tmpls = this.template,
|
tmpls = this.template,
|
||||||
self = this,
|
self = this,
|
||||||
idx=(this.tabIndex * 100);
|
idx=(this.tabIndex * 100),
|
||||||
|
evalF = function(f, d, m) {
|
||||||
|
return (_.isFunction(f) ? !!f.apply(d, [m]) : !!f);
|
||||||
|
};
|
||||||
|
|
||||||
this.$el
|
this.$el
|
||||||
.empty()
|
.empty()
|
||||||
@@ -478,6 +481,10 @@
|
|||||||
.appendTo(this.$el);
|
.appendTo(this.$el);
|
||||||
|
|
||||||
_.each(this.schema, function(o) {
|
_.each(this.schema, function(o) {
|
||||||
|
idx++;
|
||||||
|
if (!o.version_compatible || !evalF(o.visible, o, m)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var el = $((tmpls['panel'])(_.extend(o, {'tabIndex': idx})))
|
var el = $((tmpls['panel'])(_.extend(o, {'tabIndex': idx})))
|
||||||
.appendTo(tabContent)
|
.appendTo(tabContent)
|
||||||
.removeClass('collapse').addClass('collapse'),
|
.removeClass('collapse').addClass('collapse'),
|
||||||
@@ -493,7 +500,6 @@
|
|||||||
el.append(cntr.render().$el);
|
el.append(cntr.render().$el);
|
||||||
controls.push(cntr);
|
controls.push(cntr);
|
||||||
});
|
});
|
||||||
idx++;
|
|
||||||
|
|
||||||
tabHead.find('a[data-toggle="tab"]').off(
|
tabHead.find('a[data-toggle="tab"]').off(
|
||||||
'shown.bs.tab'
|
'shown.bs.tab'
|
||||||
@@ -558,11 +564,20 @@
|
|||||||
'legendClass': _.result(this, 'legendClass'),
|
'legendClass': _.result(this, 'legendClass'),
|
||||||
'contentClass': _.result(this, 'contentClass'),
|
'contentClass': _.result(this, 'contentClass'),
|
||||||
'collapse': _.result(this, 'collapse')
|
'collapse': _.result(this, 'collapse')
|
||||||
|
},
|
||||||
|
idx=(this.tabIndex * 100),
|
||||||
|
evalF = function(f, d, m) {
|
||||||
|
return (_.isFunction(f) ? !!f.apply(d, [m]) : !!f);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$el.empty();
|
this.$el.empty();
|
||||||
|
|
||||||
_.each(this.schema, function(o) {
|
_.each(this.schema, function(o) {
|
||||||
|
idx++;
|
||||||
|
if (!o.version_compatible || !evalF(o.visible, o, m)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!o.fields)
|
if (!o.fields)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -573,7 +588,8 @@
|
|||||||
o.fields.each(function(f) {
|
o.fields.each(function(f) {
|
||||||
var cntr = new (f.get("control")) ({
|
var cntr = new (f.get("control")) ({
|
||||||
field: f,
|
field: f,
|
||||||
model: m
|
model: m,
|
||||||
|
tabIndex: idx
|
||||||
});
|
});
|
||||||
el.append(cntr.render().$el);
|
el.append(cntr.render().$el);
|
||||||
controls.push(cntr);
|
controls.push(cntr);
|
||||||
@@ -1412,7 +1428,8 @@
|
|||||||
) {
|
) {
|
||||||
var proto = (Model && Model.prototype) || Model,
|
var proto = (Model && Model.prototype) || Model,
|
||||||
schema = subschema || (proto && proto.schema),
|
schema = subschema || (proto && proto.schema),
|
||||||
pgBrowser = window.pgAdmin.Browser, fields = [];
|
pgBrowser = window.pgAdmin.Browser, fields = [],
|
||||||
|
groupInfo = {};
|
||||||
|
|
||||||
// 'schema' has the information about how to generate the form.
|
// 'schema' has the information about how to generate the form.
|
||||||
if (schema && _.isArray(schema)) {
|
if (schema && _.isArray(schema)) {
|
||||||
@@ -1427,6 +1444,24 @@
|
|||||||
_.each(schema, function(s) {
|
_.each(schema, function(s) {
|
||||||
// Do we understand - what control, we're creating
|
// Do we understand - what control, we're creating
|
||||||
// here?
|
// here?
|
||||||
|
if (s.type == 'group') {
|
||||||
|
var ver_in_limit = (_.isUndefined(server_info) ? true :
|
||||||
|
((_.isUndefined(s.server_type) ? true :
|
||||||
|
(server_info.type in s.server_type)) &&
|
||||||
|
(_.isUndefined(s.min_version) ? true :
|
||||||
|
(server_info.version >= s.min_version)) &&
|
||||||
|
(_.isUndefined(s.max_version) ? true :
|
||||||
|
(server_info.version <= s.max_version))));
|
||||||
|
groupInfo[s.id] = {
|
||||||
|
label: s.label || s.id,
|
||||||
|
version_compatible: ver_in_limit,
|
||||||
|
visible: !s.mode || (
|
||||||
|
s && s.mode && _.isObject(s.mode) &&
|
||||||
|
_.indexOf(s.mode, mode) != -1) && evalASFunc(s.visible) || true
|
||||||
|
};
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!s.mode || (s && s.mode && _.isObject(s.mode) &&
|
if (!s.mode || (s && s.mode && _.isObject(s.mode) &&
|
||||||
_.indexOf(s.mode, mode) != -1)) {
|
_.indexOf(s.mode, mode) != -1)) {
|
||||||
// Each field is kept in specified group, or in
|
// Each field is kept in specified group, or in
|
||||||
@@ -1516,7 +1551,9 @@
|
|||||||
// Create an array from the dictionary with proper required
|
// Create an array from the dictionary with proper required
|
||||||
// structure.
|
// structure.
|
||||||
_.each(groups, function(val, key) {
|
_.each(groups, function(val, key) {
|
||||||
fields.push({label: key, fields: val});
|
fields.push(_.extend({
|
||||||
|
label: key, fields: val
|
||||||
|
}, (groupInfo[key] || {version_compatible: true, visible: true})));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user