From 6de88bfc8580f7eddd0a72c7c4cd95b8991aa3a9 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sun, 19 Sep 2010 17:14:42 +0200 Subject: [PATCH] improve remove method --- .../webapp/resources/js/sonia.repository.js | 1 + .../src/main/webapp/resources/js/sonia.rest.js | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) 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 81caac785b..e4cda289e5 100644 --- a/scm-webapp/src/main/webapp/resources/js/sonia.repository.js +++ b/scm-webapp/src/main/webapp/resources/js/sonia.repository.js @@ -72,6 +72,7 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, { store: repositoryStore, colModel: repositoryColModel, idField: 'id', + nameField: 'name', searchField: 'name', editForm: 'repositoryEditForm', restAddUrl: restUrl + 'repositories.json', 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 1a34303025..f0df2f5601 100644 --- a/scm-webapp/src/main/webapp/resources/js/sonia.rest.js +++ b/scm-webapp/src/main/webapp/resources/js/sonia.rest.js @@ -104,6 +104,7 @@ Sonia.rest.Grid = Ext.extend(Ext.grid.GridPanel, { restEditUrlPattern: null, restRemoveUrlPattern: null, idField: null, + nameField: null, searchField: null, editForm: null, editWindowWidth: 300, @@ -247,23 +248,24 @@ Sonia.rest.Grid = Ext.extend(Ext.grid.GridPanel, { removeItem: function(){ if ( this.selModel.hasSelection() ){ - var id = this.selModel.getSelected().data[this.idField]; - + var selected = this.selModel.getSelected(); + var id = selected.data[this.idField] var store = this.store; var url = String.format( this.restRemoveUrlPattern, id ); + var name = this.nameField != null ? selected.data[this.nameField] : id; Ext.MessageBox.show({ title: 'Remove Item', - msg: 'Remove Item "' + id + '"?', + msg: 'Remove Item "' + name + '"?', buttons: Ext.MessageBox.OKCANCEL, icon: Ext.MessageBox.QUESTION, fn: function(result){ - - if ( debug ){ - console.debug( 'remove item ' + id ); - } - if ( result == 'ok' ){ + + if ( debug ){ + console.debug( 'remove item' ); + } + Ext.Ajax.request({ url: url, method: 'DELETE',