mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
parent
381f5edbd5
commit
1632e5287a
@ -14,7 +14,7 @@ import SecLabelSchema from '../../../../../static/js/sec_label.ui';
|
|||||||
import { getNodeAjaxOptions } from '../../../../../../../static/js/node_ajax';
|
import { getNodeAjaxOptions } from '../../../../../../../static/js/node_ajax';
|
||||||
import _ from 'underscore';
|
import _ from 'underscore';
|
||||||
import getApiInstance from 'sources/api_instance';
|
import getApiInstance from 'sources/api_instance';
|
||||||
import { isEmptyString, integerValidator } from 'sources/validators';
|
import { isEmptyString } from 'sources/validators';
|
||||||
|
|
||||||
|
|
||||||
function getCompositeSchema(nodeObj, treeNodeInfo, itemNodeData) {
|
function getCompositeSchema(nodeObj, treeNodeInfo, itemNodeData) {
|
||||||
@ -69,9 +69,9 @@ function getRangeSchema(nodeObj, treeNodeInfo, itemNodeData) {
|
|||||||
null, 'get_canonical', itemNodeData, false,
|
null, 'get_canonical', itemNodeData, false,
|
||||||
treeNodeInfo,
|
treeNodeInfo,
|
||||||
]);
|
]);
|
||||||
var data;
|
var data = [];
|
||||||
|
|
||||||
if(!_.isUndefined(name) && name != ''){
|
if(!_.isUndefined(name) && name != '' && name != null){
|
||||||
api.get(_url, {
|
api.get(_url, {
|
||||||
params: {
|
params: {
|
||||||
'name' : name
|
'name' : name
|
||||||
@ -1051,35 +1051,10 @@ class CompositeSchema extends BaseUISchema {
|
|||||||
setError('type', errmsg);
|
setError('type', errmsg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(state.is_tlength) {
|
|
||||||
|
|
||||||
if (state.tlength < state.min_val) {
|
|
||||||
errmsg = gettext('Length/Precision should not be less than %s.', state.min_val);
|
|
||||||
}
|
|
||||||
else if (state.tlength > state.max_val) {
|
|
||||||
errmsg = gettext('Length/Precision should not be greater than %s.', state.max_val);
|
|
||||||
}
|
|
||||||
if(_.isUndefined(errmsg) || errmsg == null)
|
|
||||||
errmsg = integerValidator('Length/Precision', state.tlength);
|
|
||||||
// If we have any error set then throw it to user
|
|
||||||
if(!_.isUndefined(errmsg) && errmsg != null) {
|
|
||||||
setError('tlength', errmsg);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(state.is_precision) {
|
|
||||||
errmsg = integerValidator('Scale', state.precision);
|
|
||||||
if(!_.isUndefined(errmsg) && errmsg != null) {
|
|
||||||
setError('precision', errmsg);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(_.isUndefined(errmsg) || errmsg == null) {
|
if(_.isUndefined(errmsg) || errmsg == null) {
|
||||||
errmsg = null;
|
errmsg = null;
|
||||||
setError('member_name', errmsg);
|
setError('member_name', errmsg);
|
||||||
setError('type', errmsg);
|
setError('type', errmsg);
|
||||||
setError('tlength', errmsg);
|
|
||||||
setError('precision', errmsg);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1122,7 +1097,7 @@ class DataTypeSchema extends BaseUISchema {
|
|||||||
id: 'type',
|
id: 'type',
|
||||||
label: gettext('Data Type'),
|
label: gettext('Data Type'),
|
||||||
group: gettext('Definition'),
|
group: gettext('Definition'),
|
||||||
mode: ['edit', 'create','properties'],
|
mode: ['edit', 'create'],
|
||||||
disabled: false,
|
disabled: false,
|
||||||
readonly: function (state) {
|
readonly: function (state) {
|
||||||
return !dataTypeObj.isNew(state);
|
return !dataTypeObj.isNew(state);
|
||||||
@ -1158,7 +1133,7 @@ class DataTypeSchema extends BaseUISchema {
|
|||||||
type: 'int',
|
type: 'int',
|
||||||
deps: ['typtype'],
|
deps: ['typtype'],
|
||||||
cell: 'int',
|
cell: 'int',
|
||||||
mode: ['create', 'edit','properties'],
|
mode: ['create', 'edit'],
|
||||||
readonly: function (state) {
|
readonly: function (state) {
|
||||||
return !dataTypeObj.isNew(state);
|
return !dataTypeObj.isNew(state);
|
||||||
},
|
},
|
||||||
@ -1172,7 +1147,7 @@ class DataTypeSchema extends BaseUISchema {
|
|||||||
id: 'tlength',
|
id: 'tlength',
|
||||||
group: gettext('Data Type'),
|
group: gettext('Data Type'),
|
||||||
label: gettext('Length/Precision'),
|
label: gettext('Length/Precision'),
|
||||||
mode: ['edit', 'create','properties'],
|
mode: ['edit', 'create'],
|
||||||
deps: ['type'],
|
deps: ['type'],
|
||||||
type: 'text',
|
type: 'text',
|
||||||
cell: 'int',
|
cell: 'int',
|
||||||
@ -1234,7 +1209,7 @@ class DataTypeSchema extends BaseUISchema {
|
|||||||
id: 'precision',
|
id: 'precision',
|
||||||
group: gettext('Data Type'),
|
group: gettext('Data Type'),
|
||||||
label: gettext('Scale'),
|
label: gettext('Scale'),
|
||||||
mode: ['edit', 'create','properties'],
|
mode: ['edit', 'create'],
|
||||||
deps: ['type'],
|
deps: ['type'],
|
||||||
type: 'text',
|
type: 'text',
|
||||||
readonly: function (state) {
|
readonly: function (state) {
|
||||||
@ -1465,7 +1440,7 @@ export default class TypeSchema extends BaseUISchema {
|
|||||||
group: gettext('Definition'),
|
group: gettext('Definition'),
|
||||||
label: '',
|
label: '',
|
||||||
deps: ['typtype'],
|
deps: ['typtype'],
|
||||||
mode: ['edit', 'create', 'properties'],
|
mode: ['edit', 'create'],
|
||||||
visible: function(state) {
|
visible: function(state) {
|
||||||
return state.typtype === 'N' || state.typtype === 'V';
|
return state.typtype === 'N' || state.typtype === 'V';
|
||||||
},
|
},
|
||||||
@ -1594,6 +1569,50 @@ export default class TypeSchema extends BaseUISchema {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'type', label: gettext('Data Type'), cell: 'string',
|
||||||
|
type: 'text', mode: ['properties'], group: gettext('Definition'),
|
||||||
|
disabled: () => obj.inCatalog(),
|
||||||
|
visible: function(state) {
|
||||||
|
if(state.typtype === 'N' || state.typtype === 'V') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'tlength', label: gettext('Length/Precision'), cell: 'string',
|
||||||
|
type: 'text', mode: ['properties'], group: gettext('Definition'),
|
||||||
|
disabled: () => obj.inCatalog(),
|
||||||
|
visible: function(state) {
|
||||||
|
if(state.typtype === 'N') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'precision', label: gettext('Scale'), cell: 'string',
|
||||||
|
type: 'text', mode: ['properties'], group: gettext('Definition'),
|
||||||
|
disabled: () => obj.inCatalog(),
|
||||||
|
visible: function(state) {
|
||||||
|
if(state.typtype === 'N') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'maxsize', label: gettext('Size'), cell: 'string',
|
||||||
|
type: 'text', mode: ['properties'], group: gettext('Definition'),
|
||||||
|
disabled: () => obj.inCatalog(),
|
||||||
|
visible: function(state) {
|
||||||
|
if(state.typtype === 'V') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'type_acl', label: gettext('Privileges'), cell: 'string',
|
id: 'type_acl', label: gettext('Privileges'), cell: 'string',
|
||||||
type: 'text', mode: ['properties'], group: gettext('Security'),
|
type: 'text', mode: ['properties'], group: gettext('Security'),
|
||||||
|
@ -15,8 +15,6 @@ import {messages} from '../fake_messages';
|
|||||||
import { createMount } from '@material-ui/core/test-utils';
|
import { createMount } from '@material-ui/core/test-utils';
|
||||||
import SchemaView from '../../../pgadmin/static/js/SchemaView';
|
import SchemaView from '../../../pgadmin/static/js/SchemaView';
|
||||||
import * as nodeAjax from '../../../pgadmin/browser/static/js/node_ajax';
|
import * as nodeAjax from '../../../pgadmin/browser/static/js/node_ajax';
|
||||||
import gettext from 'sources/gettext';
|
|
||||||
import { integerValidator } from 'sources/validators';
|
|
||||||
import { getNodePrivilegeRoleSchema } from '../../../pgadmin/browser/server_groups/servers/static/js/privilege.ui';
|
import { getNodePrivilegeRoleSchema } from '../../../pgadmin/browser/server_groups/servers/static/js/privilege.ui';
|
||||||
|
|
||||||
import TypeSchema, { EnumerationSchema, getCompositeSchema, getExternalSchema, getRangeSchema, getDataTypeSchema } from '../../../pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.ui';
|
import TypeSchema, { EnumerationSchema, getCompositeSchema, getExternalSchema, getRangeSchema, getDataTypeSchema } from '../../../pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.ui';
|
||||||
@ -105,32 +103,6 @@ describe('TypeSchema', ()=>{
|
|||||||
state.member_name = 'demo_member';
|
state.member_name = 'demo_member';
|
||||||
compositeCollObj.validate(state, setError);
|
compositeCollObj.validate(state, setError);
|
||||||
expect(setError).toHaveBeenCalledWith('type', 'Please specify the type.');
|
expect(setError).toHaveBeenCalledWith('type', 'Please specify the type.');
|
||||||
|
|
||||||
state.type = 'char';
|
|
||||||
state.min_val = 10;
|
|
||||||
state.max_val = 100;
|
|
||||||
state.is_tlength = true;
|
|
||||||
state.tlength = 9;
|
|
||||||
compositeCollObj.validate(state, setError);
|
|
||||||
expect(setError).toHaveBeenCalledWith('tlength', gettext('Length/Precision should not be less than %s.', state.min_val));
|
|
||||||
|
|
||||||
state.tlength = 200;
|
|
||||||
compositeCollObj.validate(state, setError);
|
|
||||||
expect(setError).toHaveBeenCalledWith('tlength', gettext('Length/Precision should not be greater than %s.', state.max_val));
|
|
||||||
|
|
||||||
state.tlength = 'ert';
|
|
||||||
compositeCollObj.validate(state, setError);
|
|
||||||
expect(setError).toHaveBeenCalledWith('tlength', integerValidator('Length/Precision', state.tlength));
|
|
||||||
|
|
||||||
state.tlength = 90;
|
|
||||||
state.is_precision = true;
|
|
||||||
state.precision = 'ert';
|
|
||||||
compositeCollObj.validate(state, setError);
|
|
||||||
expect(setError).toHaveBeenCalledWith('precision', integerValidator('Scale', state.precision));
|
|
||||||
|
|
||||||
state.precision = 9;
|
|
||||||
compositeCollObj.validate(state, setError);
|
|
||||||
expect(setError).toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('tlength editable', ()=>{
|
it('tlength editable', ()=>{
|
||||||
|
Loading…
Reference in New Issue
Block a user