diff --git a/scm-webapp/src/main/webapp/resources/js/sonia.group.js b/scm-webapp/src/main/webapp/resources/js/sonia.group.js index c609b5d73e..3d53d02992 100644 --- a/scm-webapp/src/main/webapp/resources/js/sonia.group.js +++ b/scm-webapp/src/main/webapp/resources/js/sonia.group.js @@ -16,15 +16,9 @@ Sonia.group.EditForm = new Ext.extend(Sonia.rest.EditForm, { var config = { title: 'Edit Group', - listeners: { - afterrender: function(){ - if ( ! update ){ - Ext.getCmp('nameField').focus(true, 500); - } - } - }, + focusField: 'groupName', items:[{ - id: 'nameField', + id: 'groupName', fieldLabel:'Name', name:'name', anchor: '100%', diff --git a/scm-webapp/src/main/webapp/resources/js/sonia.repository.js b/scm-webapp/src/main/webapp/resources/js/sonia.repository.js index 82d453efb1..0c2a82f59e 100644 --- a/scm-webapp/src/main/webapp/resources/js/sonia.repository.js +++ b/scm-webapp/src/main/webapp/resources/js/sonia.repository.js @@ -13,8 +13,9 @@ Sonia.repository.EditForm = Ext.extend(Sonia.rest.EditForm, { var config = { title: 'Edit Repository', + focusField: 'repositoryName', items:[ - {fieldLabel: 'Name', name: 'name', readOnly: update, allowBlank: false}, + { id: 'repositoryName', fieldLabel: 'Name', name: 'name', readOnly: update, allowBlank: false}, { fieldLabel: 'Type', name: 'type', diff --git a/scm-webapp/src/main/webapp/resources/js/sonia.rest.js b/scm-webapp/src/main/webapp/resources/js/sonia.rest.js index 446b517461..ece3bfa440 100644 --- a/scm-webapp/src/main/webapp/resources/js/sonia.rest.js +++ b/scm-webapp/src/main/webapp/resources/js/sonia.rest.js @@ -34,6 +34,7 @@ Sonia.rest.EditForm = Ext.extend(Ext.form.FormPanel, { title: 'Edit REST', data: null, + focusField: null, initComponent: function(){ @@ -45,6 +46,16 @@ Sonia.rest.EditForm = Ext.extend(Ext.form.FormPanel, { defaultType:'textfield', monitorValid: true, defaults: {width: 190}, + listeners: { + afterrender: { + fn: function(){ + if ( this.focusField != null && this.data == null ){ + Ext.getCmp(this.focusField).focus(true, 500); + } + }, + scope: this + } + }, buttons:[ {text: 'Ok', formBind: true, scope: this, handler: this.submit}, {text: 'Cancel', scope: this, handler: this.cancel}