mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed issue related to reducing the if-else statement to single return expression. Reported by SonarQube.
This commit is contained in:
parent
6620f9263d
commit
daad16ea93
@ -403,11 +403,7 @@ define('pgadmin.node.unique_constraint', [
|
|||||||
disabled: function(m) {
|
disabled: function(m) {
|
||||||
// Disable if index is selected.
|
// Disable if index is selected.
|
||||||
var index = m.get('index');
|
var index = m.get('index');
|
||||||
if(_.isUndefined(index) || index == '') {
|
return (!_.isUndefined(index) && index != '');
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},{
|
},{
|
||||||
id: 'include', label: gettext('Include columns'),
|
id: 'include', label: gettext('Include columns'),
|
||||||
|
@ -533,11 +533,7 @@ define('pgadmin.node.index', [
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
// if we are in edit mode
|
// if we are in edit mode
|
||||||
if (!_.isUndefined(m.get('attnum')) && m.get('attnum') >= 1 ) {
|
return (_.isUndefined(m.get('attnum')) || m.get('attnum') < 1 );
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1048,16 +1048,12 @@ function(
|
|||||||
},
|
},
|
||||||
isInheritedTable: function(m) {
|
isInheritedTable: function(m) {
|
||||||
if(!m.inSchema.apply(this, [m])) {
|
if(!m.inSchema.apply(this, [m])) {
|
||||||
if(
|
// Either of_types or coll_inherits has value
|
||||||
(!_.isUndefined(m.get('coll_inherits')) && m.get('coll_inherits').length != 0)
|
return (
|
||||||
||
|
(_.isUndefined(m.get('coll_inherits')) || m.get('coll_inherits').length == 0)
|
||||||
(!_.isUndefined(m.get('typname')) && String(m.get('typname')).replace(/^\s+|\s+$/g, '') !== '')
|
&&
|
||||||
) {
|
(_.isUndefined(m.get('typname')) || String(m.get('typname')).replace(/^\s+|\s+$/g, '') === '')
|
||||||
// Either of_types or coll_inherits has value
|
);
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
@ -1137,11 +1133,7 @@ function(
|
|||||||
if(this.node_info && 'schema' in this.node_info)
|
if(this.node_info && 'schema' in this.node_info)
|
||||||
{
|
{
|
||||||
// We will disbale control if it's in 'edit' mode
|
// We will disbale control if it's in 'edit' mode
|
||||||
if (m.isNew()) {
|
return !m.isNew();
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
@ -57,19 +57,11 @@ define('pgadmin.node.rule', [
|
|||||||
hasDepends: true,
|
hasDepends: true,
|
||||||
canDrop: function(itemData, item){
|
canDrop: function(itemData, item){
|
||||||
SchemaChildTreeNode.isTreeItemOfChildOfSchema.apply(this, [itemData, item]);
|
SchemaChildTreeNode.isTreeItemOfChildOfSchema.apply(this, [itemData, item]);
|
||||||
if(_.has(itemData, 'label') && itemData.label === '_RETURN')
|
return (!_.has(itemData, 'label') || itemData.label !== '_RETURN');
|
||||||
return false;
|
|
||||||
else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
canDropCascade: function(itemData, item){
|
canDropCascade: function(itemData, item){
|
||||||
SchemaChildTreeNode.isTreeItemOfChildOfSchema.apply(this, [itemData, item]);
|
SchemaChildTreeNode.isTreeItemOfChildOfSchema.apply(this, [itemData, item]);
|
||||||
if(_.has(itemData, 'label') && itemData.label === '_RETURN')
|
return (!_.has(itemData, 'label') || itemData.label !== '_RETURN');
|
||||||
return false;
|
|
||||||
else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
url_jump_after_node: 'schema',
|
url_jump_after_node: 'schema',
|
||||||
Init: function() {
|
Init: function() {
|
||||||
@ -247,11 +239,7 @@ define('pgadmin.node.rule', [
|
|||||||
prev_e = prev_j ? t.itemData(prev_j) : null,
|
prev_e = prev_j ? t.itemData(prev_j) : null,
|
||||||
prev_k = t.hasParent(prev_j) ? t.parent(prev_j) : null,
|
prev_k = t.hasParent(prev_j) ? t.parent(prev_j) : null,
|
||||||
prev_f = prev_k ? t.itemData(prev_k) : null;
|
prev_f = prev_k ? t.itemData(prev_k) : null;
|
||||||
if(!_.isNull(prev_f) && prev_f._type == 'catalog') {
|
return (_.isNull(prev_f) || prev_f._type != 'catalog');
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -262,11 +250,7 @@ define('pgadmin.node.rule', [
|
|||||||
prev_i = t.hasParent(i) ? t.parent(i) : null;
|
prev_i = t.hasParent(i) ? t.parent(i) : null;
|
||||||
prev_j = t.hasParent(prev_i) ? t.parent(prev_i) : null;
|
prev_j = t.hasParent(prev_i) ? t.parent(prev_i) : null;
|
||||||
prev_e = prev_j ? t.itemData(prev_j) : null;
|
prev_e = prev_j ? t.itemData(prev_j) : null;
|
||||||
if(!_.isNull(prev_e) && prev_e._type == 'schema') {
|
return (!_.isNull(prev_e) && prev_e._type == 'schema');
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
i = t.hasParent(i) ? t.parent(i) : null;
|
i = t.hasParent(i) ? t.parent(i) : null;
|
||||||
d = i ? t.itemData(i) : null;
|
d = i ? t.itemData(i) : null;
|
||||||
|
@ -1274,16 +1274,12 @@ define('pgadmin.node.table', [
|
|||||||
},
|
},
|
||||||
isInheritedTable: function(m) {
|
isInheritedTable: function(m) {
|
||||||
if(!m.inSchema.apply(this, [m])) {
|
if(!m.inSchema.apply(this, [m])) {
|
||||||
if(
|
// Either of_types or coll_inherits has value
|
||||||
(!_.isUndefined(m.get('coll_inherits')) && m.get('coll_inherits').length != 0)
|
return (
|
||||||
||
|
(_.isUndefined(m.get('coll_inherits')) || m.get('coll_inherits').length == 0)
|
||||||
(!_.isUndefined(m.get('typname')) && String(m.get('typname')).replace(/^\s+|\s+$/g, '') !== '')
|
&&
|
||||||
) {
|
(_.isUndefined(m.get('typname')) || String(m.get('typname')).replace(/^\s+|\s+$/g, '') === '')
|
||||||
// Either of_types or coll_inherits has value
|
);
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
@ -1374,11 +1370,7 @@ define('pgadmin.node.table', [
|
|||||||
if(this.node_info && 'schema' in this.node_info)
|
if(this.node_info && 'schema' in this.node_info)
|
||||||
{
|
{
|
||||||
// We will disbale control if it's in 'edit' mode
|
// We will disbale control if it's in 'edit' mode
|
||||||
if (m.isNew()) {
|
return !m.isNew();
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
@ -442,15 +442,11 @@ define('pgadmin.node.trigger', [
|
|||||||
if(!m.inSchemaWithModelCheck.apply(this, [m])) {
|
if(!m.inSchemaWithModelCheck.apply(this, [m])) {
|
||||||
// We will enabale truncate only for EDB PPAS
|
// We will enabale truncate only for EDB PPAS
|
||||||
// and both triggers row & constarint are set to false
|
// and both triggers row & constarint are set to false
|
||||||
if(server_type === 'ppas' &&
|
return (server_type !== 'ppas' ||
|
||||||
!_.isUndefined(is_constraint_trigger) &&
|
_.isUndefined(is_constraint_trigger) ||
|
||||||
!_.isUndefined(is_row_trigger) &&
|
_.isUndefined(is_row_trigger) ||
|
||||||
is_constraint_trigger === false &&
|
is_constraint_trigger !== false ||
|
||||||
is_row_trigger === false) {
|
is_row_trigger !== false);
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Disable it
|
// Disable it
|
||||||
return true;
|
return true;
|
||||||
@ -506,12 +502,9 @@ define('pgadmin.node.trigger', [
|
|||||||
var tfunction = m.get('tfunction'),
|
var tfunction = m.get('tfunction'),
|
||||||
server_type = m.node_info['server']['server_type'];
|
server_type = m.node_info['server']['server_type'];
|
||||||
|
|
||||||
if(server_type === 'ppas' &&
|
return (server_type !== 'ppas' ||
|
||||||
!_.isUndefined(tfunction) &&
|
_.isUndefined(tfunction) ||
|
||||||
tfunction === 'Inline EDB-SPL')
|
tfunction !== 'Inline EDB-SPL');
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
},
|
},
|
||||||
},{
|
},{
|
||||||
id: 'is_sys_trigger', label: gettext('System trigger?'), cell: 'string',
|
id: 'is_sys_trigger', label: gettext('System trigger?'), cell: 'string',
|
||||||
@ -575,11 +568,7 @@ define('pgadmin.node.trigger', [
|
|||||||
inSchemaWithModelCheck: function(m) {
|
inSchemaWithModelCheck: function(m) {
|
||||||
if(this.node_info && 'schema' in this.node_info) {
|
if(this.node_info && 'schema' in this.node_info) {
|
||||||
// We will disable control if it's in 'edit' mode
|
// We will disable control if it's in 'edit' mode
|
||||||
if (m.isNew()) {
|
return !m.isNew();
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
@ -592,11 +581,7 @@ define('pgadmin.node.trigger', [
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
// if we are in edit mode
|
// if we are in edit mode
|
||||||
if (!_.isUndefined(m.get('attnum')) && m.get('attnum') >= 1 ) {
|
return (_.isUndefined(m.get('attnum')) || m.get('attnum') < 1 );
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -376,8 +376,7 @@ define('pgadmin.node.database', [
|
|||||||
control: 'node-list-by-name', node: 'tablespace',
|
control: 'node-list-by-name', node: 'tablespace',
|
||||||
select2: { allowClear: false },
|
select2: { allowClear: false },
|
||||||
filter: function(m) {
|
filter: function(m) {
|
||||||
if (m.label == 'pg_global') return false;
|
return (m.label != 'pg_global');
|
||||||
else return true;
|
|
||||||
},
|
},
|
||||||
},{
|
},{
|
||||||
id: 'datcollate', label: gettext('Collation'),
|
id: 'datcollate', label: gettext('Collation'),
|
||||||
|
@ -315,11 +315,7 @@ define([
|
|||||||
if (m instanceof Backbone.Collection) {
|
if (m instanceof Backbone.Collection) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (m.isNew() && !m.get('authOnlyInternal')) {
|
return (m.isNew() && !m.get('authOnlyInternal'));
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
id: 'username',
|
id: 'username',
|
||||||
@ -395,11 +391,7 @@ define([
|
|||||||
if (m instanceof Backbone.Collection) {
|
if (m instanceof Backbone.Collection) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (m.get('id') == userInfo['id']) {
|
return (m.get('id') != userInfo['id']);
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
id: 'active',
|
id: 'active',
|
||||||
@ -412,11 +404,7 @@ define([
|
|||||||
if (m instanceof Backbone.Collection) {
|
if (m instanceof Backbone.Collection) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (m.get('id') == userInfo['id']) {
|
return (m.get('id') != userInfo['id']);
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
id: 'newPassword',
|
id: 'newPassword',
|
||||||
@ -429,11 +417,7 @@ define([
|
|||||||
deps: ['auth_source'],
|
deps: ['auth_source'],
|
||||||
sortable: false,
|
sortable: false,
|
||||||
editable: function(m) {
|
editable: function(m) {
|
||||||
if (m.get('auth_source') == DEFAULT_AUTH_SOURCE) {
|
return (m.get('auth_source') == DEFAULT_AUTH_SOURCE);
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
id: 'confirmPassword',
|
id: 'confirmPassword',
|
||||||
@ -446,11 +430,7 @@ define([
|
|||||||
deps: ['auth_source'],
|
deps: ['auth_source'],
|
||||||
sortable: false,
|
sortable: false,
|
||||||
editable: function(m) {
|
editable: function(m) {
|
||||||
if (m.get('auth_source') == DEFAULT_AUTH_SOURCE) {
|
return (m.get('auth_source') == DEFAULT_AUTH_SOURCE);
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
validate: function() {
|
validate: function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user