From 69d95de054809e0a59d5cef5deec6d8c363cf296 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sat, 13 Jun 2015 20:43:49 +0200 Subject: [PATCH] link modification to files on commit panel, see issue #356 --- .../src/main/webapp/resources/css/style.css | 2 +- .../sonia.repository.commitpanel.js | 58 +++++++++++++++++-- 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/scm-webapp/src/main/webapp/resources/css/style.css b/scm-webapp/src/main/webapp/resources/css/style.css index 355e8afcbe..deb968f35e 100644 --- a/scm-webapp/src/main/webapp/resources/css/style.css +++ b/scm-webapp/src/main/webapp/resources/css/style.css @@ -153,7 +153,7 @@ a.scm-link:hover { } .scm-commit { - margin-bottom: 50px; + margin-bottom: 65px; } .scm-commit h1 { diff --git a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.commitpanel.js b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.commitpanel.js index b711a477d3..52761771ad 100644 --- a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.commitpanel.js +++ b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.commitpanel.js @@ -73,10 +73,16 @@ Sonia.repository.CommitPanel = Ext.extend(Ext.Panel, { ', templateModifications: '', + \n\ +
  • {.}
  • \n\ +
    \n\ + \n\ +
  • {.}
  • \n\ +
    \n\ + \n\ +
  • {.}
  • \n\ +
    \n\ + ', // header panel commitPanel: null, @@ -84,7 +90,15 @@ Sonia.repository.CommitPanel = Ext.extend(Ext.Panel, { initComponent: function(){ this.commitPanel = new Ext.Panel({ - tpl: new Ext.XTemplate(this.templateCommit + this.templateModifications) + tpl: new Ext.XTemplate(this.templateCommit + this.templateModifications), + listeners: { + render: { + fn: function(panel){ + panel.body.on('click', this.onClick, this); + }, + scope: this + } + } }); this.diffPanel = new Sonia.panel.SyntaxHighlighterPanel({ @@ -132,7 +146,39 @@ Sonia.repository.CommitPanel = Ext.extend(Ext.Panel, { ); } }); - } + }, + + onClick: function(e){ + var el = e.getTarget('a.scm-link'); + if (el){ + var path = el.rel; + if (path){ + this.openFile(path); + } + } + }, + + openFile: function(path){ + if ( debug ){ + console.debug( 'open file: ' + path ); + } + + var id = Sonia.repository.createContentId( + this.repository, + path, + this.revision + ); + + main.addTab({ + id: id, + path: path, + revision: this.revision, + repository: this.repository, + xtype: 'contentPanel', + closable: true, + autoScroll: true + }); + }, });