mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-09 09:02:10 +01:00
improve null checks
This commit is contained in:
@@ -73,7 +73,7 @@ Sonia.config.ConfigForm = Ext.extend(Ext.form.FormPanel, {
|
||||
},
|
||||
listeners: {
|
||||
render: function(){
|
||||
if ( this.onLoad !== null && Ext.isFunction( this.onLoad ) ){
|
||||
if ( this.onLoad && Ext.isFunction( this.onLoad ) ){
|
||||
this.onLoad(this.el);
|
||||
}
|
||||
},
|
||||
@@ -108,7 +108,7 @@ Sonia.config.ConfigForm = Ext.extend(Ext.form.FormPanel, {
|
||||
|
||||
submitForm: function(){
|
||||
var form = this.getForm();
|
||||
if ( this.onSubmit !== null && Ext.isFunction( this.onSubmit ) ){
|
||||
if ( this.onSubmit && Ext.isFunction( this.onSubmit ) ){
|
||||
this.onSubmit( form.getValues() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ Sonia.group.Grid = Ext.extend(Sonia.rest.Grid, {
|
||||
|
||||
renderMembers: function(members){
|
||||
var out = '';
|
||||
if ( members !== null ){
|
||||
if ( members ){
|
||||
var s = members.length;
|
||||
for ( var i=0; i<s; i++ ){
|
||||
out += members[i];
|
||||
|
||||
@@ -69,9 +69,9 @@ Sonia.group.MemberFormPanel = Ext.extend(Sonia.group.FormPanel, {
|
||||
singleSelect: true
|
||||
});
|
||||
|
||||
if ( this.item !== null ){
|
||||
if ( this.item ){
|
||||
var data = [];
|
||||
if ( this.item.members !== null ){
|
||||
if ( this.item.members ){
|
||||
for ( var i=0; i<this.item.members.length; i++ ){
|
||||
var a = [];
|
||||
a.push( this.item.members[i] );
|
||||
|
||||
@@ -49,7 +49,7 @@ Sonia.navigation.NavPanel = Ext.extend(Ext.Panel, {
|
||||
},
|
||||
|
||||
renderSections: function(){
|
||||
if ( this.sections !== null ){
|
||||
if ( this.sections ){
|
||||
this.addSections( this.sections );
|
||||
}
|
||||
},
|
||||
|
||||
@@ -44,10 +44,10 @@ Sonia.navigation.NavSection = Ext.extend(Ext.Panel, {
|
||||
|
||||
|
||||
initComponent: function(){
|
||||
if ( this.links === null ){
|
||||
if ( ! this.links ){
|
||||
this.links = this.items;
|
||||
}
|
||||
if ( this.links === null ){
|
||||
if ( ! this.links ){
|
||||
this.links = [];
|
||||
}
|
||||
|
||||
|
||||
@@ -33,9 +33,9 @@ Ext.apply(Ext.util.Format, {
|
||||
|
||||
formatTimestamp: function(value){
|
||||
var result = '';
|
||||
if ( value !== null && (value > 0 || value.length > 0)){
|
||||
if ( value && (value > 0 || value.length > 0)){
|
||||
var df = state.clientConfig.dateFormat;
|
||||
if ( df === null || df.length === 0 || ! Ext.isDefined(value) ){
|
||||
if ( ! df || df.length === 0 || ! Ext.isDefined(value) ){
|
||||
df = "YYYY-MM-DD HH:mm:ss";
|
||||
}
|
||||
result = moment(value).format(df);
|
||||
|
||||
@@ -96,7 +96,7 @@ Sonia.repository.BlamePanel = Ext.extend(Ext.grid.GridPanel, {
|
||||
|
||||
onClick: function(e){
|
||||
var el = e.getTarget('.blame-link');
|
||||
if ( el !== null ){
|
||||
if ( el ){
|
||||
var revision = el.rel;
|
||||
if (debug){
|
||||
console.debug('load content for ' + revision);
|
||||
|
||||
@@ -167,18 +167,18 @@ Sonia.repository.ChangesetViewerGrid = Ext.extend(Ext.grid.GridPanel, {
|
||||
|
||||
renderChangesetMetadata: function(author, p, record){
|
||||
var authorValue = '';
|
||||
if ( author !== null ){
|
||||
if ( author ){
|
||||
authorValue = author.name;
|
||||
if ( author.mail !== null ){
|
||||
if ( author.mail ){
|
||||
authorValue += ' ' + String.format(this.mailTemplate, author.mail);
|
||||
}
|
||||
}
|
||||
var description = record.data.description;
|
||||
// if ( description != null ){
|
||||
// if ( description ){
|
||||
// description = Ext.util.Format.htmlEncode(description);
|
||||
// }
|
||||
var date = record.data.date;
|
||||
if ( date !== null ){
|
||||
if ( date ){
|
||||
date = Ext.util.Format.formatTimestamp(date);
|
||||
}
|
||||
return String.format(
|
||||
@@ -198,7 +198,7 @@ Sonia.repository.ChangesetViewerGrid = Ext.extend(Ext.grid.GridPanel, {
|
||||
|
||||
getLabeledValue: function(label, array){
|
||||
var result = '';
|
||||
if ( array !== null && array.length > 0 ){
|
||||
if ( array && array.length > 0 ){
|
||||
result = label + ': ' + Sonia.util.getStringFromArray(array);
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -172,7 +172,7 @@ Sonia.repository.ContentPanel = Ext.extend(Ext.Panel, {
|
||||
|
||||
appendRepositoryProperties: function(bar){
|
||||
bar.push('->',this.repository.name);
|
||||
if ( this.revision !== null ){
|
||||
if ( this.revision ){
|
||||
bar.push(': ', this.revision);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -45,7 +45,7 @@ Sonia.repository.ExtendedInfoPanel = Ext.extend(Sonia.repository.InfoPanel,{
|
||||
|
||||
modifyDefaultConfig: function(config){
|
||||
var items = config.items;
|
||||
if ( items === null ){
|
||||
if ( ! items ){
|
||||
items = [];
|
||||
}
|
||||
items.push({
|
||||
|
||||
@@ -47,7 +47,7 @@ Sonia.repository.InfoPanel = Ext.extend(Ext.Panel, {
|
||||
initComponent: function(){
|
||||
|
||||
var contact = '';
|
||||
if ( this.item.contact !== null ){
|
||||
if ( this.item.contact ){
|
||||
contact = String.format(this.mailTemplate, this.item.contact);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ Sonia.repository.createContentId = function(repository, path, revision){
|
||||
};
|
||||
|
||||
Sonia.repository.isOwner = function(repository){
|
||||
return admin || repository.permissions !== null;
|
||||
return admin || repository.permissions;
|
||||
};
|
||||
|
||||
Sonia.repository.setEditPanel = function(panels){
|
||||
|
||||
@@ -121,8 +121,8 @@ Sonia.repository.PermissionFormPanel = Ext.extend(Sonia.repository.FormPanel, {
|
||||
}
|
||||
});
|
||||
|
||||
if ( this.item !== null ){
|
||||
if ( this.item.permissions === null ){
|
||||
if ( this.item ){
|
||||
if ( !this.item.permissions ){
|
||||
this.item.permissions = [];
|
||||
}
|
||||
this.permissionStore.loadData( this.item );
|
||||
|
||||
@@ -207,7 +207,7 @@ Sonia.repository.RepositoryBrowser = Ext.extend(Ext.grid.GridPanel, {
|
||||
|
||||
loadStore: function(store, records, extra){
|
||||
var path = extra.params.path;
|
||||
if ( path !== null && path.length > 0 ){
|
||||
if ( path && path.length > 0 ){
|
||||
|
||||
var index = path.lastIndexOf('/');
|
||||
if ( index > 0 ){
|
||||
@@ -240,7 +240,7 @@ Sonia.repository.RepositoryBrowser = Ext.extend(Ext.grid.GridPanel, {
|
||||
onClick: function(e){
|
||||
var el = e.getTarget('.scm-browser');
|
||||
|
||||
if ( el !== null ){
|
||||
if ( el ){
|
||||
|
||||
var rel = el.rel;
|
||||
var index = rel.indexOf(':');
|
||||
@@ -288,7 +288,7 @@ Sonia.repository.RepositoryBrowser = Ext.extend(Ext.grid.GridPanel, {
|
||||
|
||||
appendRepositoryProperties: function(bar){
|
||||
bar.push('->',this.repository.name);
|
||||
if ( this.revision !== null ){
|
||||
if ( this.revision ){
|
||||
bar.push(': ', this.revision);
|
||||
}
|
||||
},
|
||||
@@ -381,7 +381,7 @@ Sonia.repository.RepositoryBrowser = Ext.extend(Ext.grid.GridPanel, {
|
||||
}
|
||||
|
||||
items.push('->', this.repository.name);
|
||||
if ( this.revision !== null ){
|
||||
if ( this.revision ){
|
||||
items.push(':', this.revision);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ Sonia.rest.FormPanel = Ext.extend(Ext.form.FormPanel,{
|
||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||
Sonia.rest.FormPanel.superclass.initComponent.apply(this, arguments);
|
||||
|
||||
if ( this.item !== null ){
|
||||
if ( this.item ){
|
||||
this.loadData(this.item);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -119,7 +119,7 @@ Sonia.rest.Grid = Ext.extend(Ext.grid.GridPanel, {
|
||||
|
||||
renderUrl: function(url){
|
||||
var result = '';
|
||||
if ( url !== null ){
|
||||
if ( url ){
|
||||
result = String.format( this.urlTemplate, url );
|
||||
}
|
||||
return result;
|
||||
@@ -127,7 +127,7 @@ Sonia.rest.Grid = Ext.extend(Ext.grid.GridPanel, {
|
||||
|
||||
renderMailto: function(mail){
|
||||
var result = '';
|
||||
if ( mail !== null ){
|
||||
if ( mail ){
|
||||
result = String.format( this.mailtoTemplate, mail );
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -99,7 +99,7 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
||||
getInfoPanel: function(type){
|
||||
var rp = null;
|
||||
var panel = this.infoPanels[type];
|
||||
if ( panel === null ){
|
||||
if ( ! panel ){
|
||||
rp = {
|
||||
xtype: 'repositoryInfoPanel'
|
||||
};
|
||||
@@ -224,7 +224,7 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
||||
}]
|
||||
}]);
|
||||
|
||||
if ( securitySection === null ){
|
||||
if ( ! securitySection ){
|
||||
securitySection = {
|
||||
id: 'securityConfig',
|
||||
title: this.sectionSecurityText,
|
||||
@@ -243,7 +243,7 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
||||
});
|
||||
}
|
||||
|
||||
if ( securitySection !== null ){
|
||||
if ( securitySection ){
|
||||
panel.addSection( securitySection );
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
||||
|
||||
addTab: function(panel){
|
||||
var tab = this.mainTabPanel.findById(panel.id);
|
||||
if ( tab === null ){
|
||||
if ( !tab ){
|
||||
this.mainTabPanel.add(panel);
|
||||
}
|
||||
this.mainTabPanel.setActiveTab(panel.id);
|
||||
@@ -362,10 +362,10 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
||||
|
||||
var s = null;
|
||||
var text = response.responseText;
|
||||
if ( text !== null && text.length > 0 ){
|
||||
if ( text && text.length > 0 ){
|
||||
s = Ext.decode( text );
|
||||
}
|
||||
if ( s !== null && s.success ){
|
||||
if ( s && s.success ){
|
||||
this.loadState(s);
|
||||
} else {
|
||||
// show login window
|
||||
@@ -428,10 +428,10 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
||||
buttons: Ext.Msg.OKCANCEL
|
||||
});
|
||||
} else {
|
||||
if ( title === null ){
|
||||
if ( ! title ){
|
||||
title = this.errorTitle;
|
||||
}
|
||||
if ( message === null ){
|
||||
if ( ! message ){
|
||||
message = this.errorMessage;
|
||||
}
|
||||
|
||||
@@ -454,7 +454,7 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
||||
|
||||
message = String.format(message, status);
|
||||
|
||||
if ( text === null ){
|
||||
if ( ! text ){
|
||||
|
||||
Ext.MessageBox.show({
|
||||
title: title,
|
||||
|
||||
@@ -75,7 +75,7 @@ Sonia.user.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
||||
helpText: this.mailHelpText
|
||||
}];
|
||||
|
||||
if ( this.item === null || this.item.type === state.defaultUserType ){
|
||||
if ( ! this.item || this.item.type === state.defaultUserType ){
|
||||
items.push({
|
||||
fieldLabel: this.passwordText,
|
||||
id: 'pwd',
|
||||
@@ -115,7 +115,7 @@ Sonia.user.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
||||
},
|
||||
|
||||
isReadOnly: function(){
|
||||
return this.item !== null && this.item.type !== state.defaultUserType;
|
||||
return this.item && this.item.type !== state.defaultUserType;
|
||||
},
|
||||
|
||||
fixRequest: function(user){
|
||||
|
||||
@@ -182,7 +182,7 @@ if (!Array.prototype.filter) {
|
||||
|
||||
Sonia.util.getProperty = function(properties, key){
|
||||
var value = null;
|
||||
if ( properties !== null ){
|
||||
if ( properties ){
|
||||
for (var i=0; i<properties.length; i++){
|
||||
var property = properties[i];
|
||||
if ( property.key === key ){
|
||||
|
||||
Reference in New Issue
Block a user