From e8572f7b694fd4388a0f12995a2b5e912623542b Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Thu, 11 Aug 2011 16:14:55 +0200 Subject: [PATCH] small improvements for history control --- scm-webapp/src/main/webapp/index.html | 33 ++++++++------ .../resources/js/group/sonia.group.grid.js | 6 +++ .../js/repository/sonia.repository.grid.js | 6 +++ .../main/webapp/resources/js/sonia.global.js | 3 ++ .../main/webapp/resources/js/sonia.history.js | 43 +++++++++++++++++++ .../src/main/webapp/resources/js/sonia.scm.js | 9 +++- .../resources/js/user/sonia.user.grid.js | 7 +++ 7 files changed, 93 insertions(+), 14 deletions(-) create mode 100644 scm-webapp/src/main/webapp/resources/js/sonia.history.js diff --git a/scm-webapp/src/main/webapp/index.html b/scm-webapp/src/main/webapp/index.html index 841c9b3960..b70d1c573a 100644 --- a/scm-webapp/src/main/webapp/index.html +++ b/scm-webapp/src/main/webapp/index.html @@ -62,11 +62,12 @@ - + + - + @@ -74,28 +75,28 @@ - + - + - + - + - + @@ -108,13 +109,13 @@ - + - + @@ -122,7 +123,7 @@ - + @@ -130,17 +131,17 @@ - + - + - + @@ -190,5 +191,11 @@ + +
+ + +
+ \ No newline at end of file diff --git a/scm-webapp/src/main/webapp/resources/js/group/sonia.group.grid.js b/scm-webapp/src/main/webapp/resources/js/group/sonia.group.grid.js index f61b6186db..9def9bd28c 100644 --- a/scm-webapp/src/main/webapp/resources/js/group/sonia.group.grid.js +++ b/scm-webapp/src/main/webapp/resources/js/group/sonia.group.grid.js @@ -115,6 +115,12 @@ Sonia.group.Grid = Ext.extend(Sonia.rest.Grid, { if ( debug ){ console.debug( group.name + ' selected' ); } + + var token = Ext.History.getToken(); + if ( token ){ + var parts = token.split('|'); + Ext.History.add(parts[0] + '|' + group.name); + } Ext.getCmp('groupRmButton').setDisabled(false); Sonia.group.setEditPanel([{ diff --git a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.grid.js b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.grid.js index 8f56477f21..bc6c23b9b7 100644 --- a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.grid.js +++ b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.grid.js @@ -102,6 +102,12 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, { if ( debug ){ console.debug( item.name + ' selected' ); } + + var token = Ext.History.getToken(); + if ( token ){ + var parts = token.split('|'); + Ext.History.add(parts[0] + '|' + item.name); + } var infoPanel = main.getInfoPanel(item.type); infoPanel.item = item; diff --git a/scm-webapp/src/main/webapp/resources/js/sonia.global.js b/scm-webapp/src/main/webapp/resources/js/sonia.global.js index 887d3a0de3..1a34379b05 100644 --- a/scm-webapp/src/main/webapp/resources/js/sonia.global.js +++ b/scm-webapp/src/main/webapp/resources/js/sonia.global.js @@ -87,3 +87,6 @@ var main = null; // enable extjs quicktips Ext.QuickTips.init(); + +// enable history +Ext.History.init(); \ No newline at end of file diff --git a/scm-webapp/src/main/webapp/resources/js/sonia.history.js b/scm-webapp/src/main/webapp/resources/js/sonia.history.js new file mode 100644 index 0000000000..3a11dd6250 --- /dev/null +++ b/scm-webapp/src/main/webapp/resources/js/sonia.history.js @@ -0,0 +1,43 @@ +/* * + * Copyright (c) 2010, Sebastian Sdorra + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of SCM-Manager; nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + +Ext.History.on('change', function(token){ + if(token){ + var parts = token.split('|'); + var tab = parts[0]; + if ( debug ){ + console.debug( 'handle history event for ' + tab ); + } + } else if (debug) { + console.debug('history token is empty'); + } +}); \ No newline at end of file diff --git a/scm-webapp/src/main/webapp/resources/js/sonia.scm.js b/scm-webapp/src/main/webapp/resources/js/sonia.scm.js index dbbde17dc1..f83dd01c54 100644 --- a/scm-webapp/src/main/webapp/resources/js/sonia.scm.js +++ b/scm-webapp/src/main/webapp/resources/js/sonia.scm.js @@ -442,7 +442,14 @@ Ext.onReady(function(){ id: 'mainTabPanel', region: 'center', deferredRender: false, - enableTabScroll: true + enableTabScroll: true, + listeners: { + tabchange: function(tabPanel, tab){ + if ( Ext.isDefined(tab) ){ + Ext.History.add(tab.id); + } + } + } }); new Ext.Viewport({ diff --git a/scm-webapp/src/main/webapp/resources/js/user/sonia.user.grid.js b/scm-webapp/src/main/webapp/resources/js/user/sonia.user.grid.js index 536214eb0f..630548dc9f 100644 --- a/scm-webapp/src/main/webapp/resources/js/user/sonia.user.grid.js +++ b/scm-webapp/src/main/webapp/resources/js/user/sonia.user.grid.js @@ -102,6 +102,13 @@ Sonia.user.Grid = Ext.extend(Sonia.rest.Grid, { if ( debug ){ console.debug( item.name + ' selected' ); } + + var token = Ext.History.getToken(); + if ( token ){ + var parts = token.split('|'); + Ext.History.add(parts[0] + '|' + item.name); + } + var panel = new Sonia.user.FormPanel({ item: item, region: 'south',