mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Replace if-then-else statement by a single return statement, issue reported by SonarQube.
This commit is contained in:
parent
a278e8b1e6
commit
905be1d894
@ -527,8 +527,7 @@ define('pgadmin.node.primary_key', [
|
|||||||
select2:{allowClear:false},
|
select2:{allowClear:false},
|
||||||
filter: function(m) {
|
filter: function(m) {
|
||||||
// Don't show pg_global tablespace in selection.
|
// Don't show pg_global tablespace in selection.
|
||||||
if (m.label == 'pg_global') return false;
|
return (m.label != 'pg_global');
|
||||||
else return true;
|
|
||||||
},
|
},
|
||||||
disabled: function(m) {
|
disabled: function(m) {
|
||||||
// Disable if index is selected.
|
// Disable if index is selected.
|
||||||
|
@ -517,8 +517,7 @@ define('pgadmin.node.unique_constraint', [
|
|||||||
select2:{allowClear:false},
|
select2:{allowClear:false},
|
||||||
filter: function(m) {
|
filter: function(m) {
|
||||||
// Don't show pg_global tablespace in selection.
|
// Don't show pg_global tablespace in selection.
|
||||||
if (m.label == 'pg_global') return false;
|
return (m.label != 'pg_global');
|
||||||
else return true;
|
|
||||||
},
|
},
|
||||||
disabled: function(m) {
|
disabled: function(m) {
|
||||||
// Disable if index is selected.
|
// Disable if index is selected.
|
||||||
|
@ -192,11 +192,7 @@ define('pgadmin.node.index', [
|
|||||||
inSchemaWithModelCheck: function(m) {
|
inSchemaWithModelCheck: function(m) {
|
||||||
if(m.top.node_info && 'schema' in m.top.node_info) {
|
if(m.top.node_info && 'schema' in m.top.node_info) {
|
||||||
// We will disable control if it's in 'edit' mode
|
// We will disable control if it's in 'edit' mode
|
||||||
if (m.top.isNew()) {
|
return !m.top.isNew();
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
@ -419,20 +415,12 @@ define('pgadmin.node.index', [
|
|||||||
group: gettext('Definition'), model: ColumnModel, mode: ['edit', 'create'],
|
group: gettext('Definition'), model: ColumnModel, mode: ['edit', 'create'],
|
||||||
canAdd: function(m) {
|
canAdd: function(m) {
|
||||||
// We will disable it if it's in 'edit' mode
|
// We will disable it if it's in 'edit' mode
|
||||||
if (m.isNew()) {
|
return m.isNew();
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
canEdit: false,
|
canEdit: false,
|
||||||
canDelete: function(m) {
|
canDelete: function(m) {
|
||||||
// We will disable it if it's in 'edit' mode
|
// We will disable it if it's in 'edit' mode
|
||||||
if (m.isNew()) {
|
return m.isNew();
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
control: 'unique-col-collection', uniqueCol : ['colname'],
|
control: 'unique-col-collection', uniqueCol : ['colname'],
|
||||||
columns: ['colname', 'op_class', 'sort_order', 'nulls', 'collspcname'],
|
columns: ['colname', 'op_class', 'sort_order', 'nulls', 'collspcname'],
|
||||||
@ -532,11 +520,7 @@ define('pgadmin.node.index', [
|
|||||||
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;
|
||||||
},
|
},
|
||||||
|
@ -1204,22 +1204,14 @@ function(
|
|||||||
canCreate_with_trigger_enable: function(itemData, item, data) {
|
canCreate_with_trigger_enable: function(itemData, item, data) {
|
||||||
if(this.canCreate.apply(this, [itemData, item, data])) {
|
if(this.canCreate.apply(this, [itemData, item, data])) {
|
||||||
// We are here means we can create menu, now let's check condition
|
// We are here means we can create menu, now let's check condition
|
||||||
if(itemData.tigger_count > 0) {
|
return (itemData.tigger_count > 0);
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Check to whether table has enable trigger(s)
|
// Check to whether table has enable trigger(s)
|
||||||
canCreate_with_trigger_disable: function(itemData, item, data) {
|
canCreate_with_trigger_disable: function(itemData, item, data) {
|
||||||
if(this.canCreate.apply(this, [itemData, item, data])) {
|
if(this.canCreate.apply(this, [itemData, item, data])) {
|
||||||
// We are here means we can create menu, now let's check condition
|
// We are here means we can create menu, now let's check condition
|
||||||
if(itemData.tigger_count > 0 && itemData.has_enable_triggers > 0) {
|
return (itemData.tigger_count > 0 && itemData.has_enable_triggers > 0);
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -385,11 +385,7 @@ define('pgadmin.node.type', [
|
|||||||
group: gettext('Definition'), mode: ['edit', 'create'],
|
group: gettext('Definition'), mode: ['edit', 'create'],
|
||||||
canAdd: true, canEdit: false, canDelete: function(m) {
|
canAdd: true, canEdit: false, canDelete: function(m) {
|
||||||
// We will disable it if it's in 'edit' mode
|
// We will disable it if it's in 'edit' mode
|
||||||
if (m.isNew()) {
|
return m.isNew();
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
disabled: 'inSchema', deps: ['typtype'],
|
disabled: 'inSchema', deps: ['typtype'],
|
||||||
control: 'unique-col-collection', uniqueCol : ['label'],
|
control: 'unique-col-collection', uniqueCol : ['label'],
|
||||||
|
@ -201,8 +201,7 @@ define('pgadmin.node.mview', [
|
|||||||
type: 'text', group: gettext('Storage'), first_empty: false,
|
type: 'text', group: gettext('Storage'), first_empty: false,
|
||||||
control: 'node-list-by-name', node: 'tablespace', select2: { allowClear: false },
|
control: 'node-list-by-name', node: 'tablespace', 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: 'fillfactor', label: gettext('Fill factor'),
|
id: 'fillfactor', label: gettext('Fill factor'),
|
||||||
|
Loading…
Reference in New Issue
Block a user