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