This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository scmwebeditor. See http://git.nuiton.org/scmwebeditor.git commit 4b91ac48becab29f3263456cd5b9e1a63d822594 Author: Hugo PIGEON <hpigeon@codelutin.com> Date: Thu May 28 14:50:44 2015 +0200 Add a shortcut on the edit page to open another file --- .../scmwebeditor/uiweb/actions/EditAction.java | 9 +++ .../i18n/scmwebeditor-ui-web_en_GB.properties | 1 + .../i18n/scmwebeditor-ui-web_fr_FR.properties | 1 + .../webapp/WEB-INF/content/modificationViewer.jsp | 88 +++++++++++++++++++--- .../WEB-INF/content/popups/createDirectoryForm.jsp | 2 +- swe-ui-web/src/main/webapp/css/main.css | 33 ++++++-- 6 files changed, 117 insertions(+), 17 deletions(-) diff --git a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/EditAction.java b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/EditAction.java index dd4460a..f695d2d 100644 --- a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/EditAction.java +++ b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/EditAction.java @@ -55,6 +55,9 @@ public class EditAction extends ScmWebEditorMainAction { /** equals true if the SCM allows to choose when the commits are pushed to the server */ protected boolean scmSupportsPush; + /** the full path to the directory which contains the editoed file */ + protected String directoryPath; + public String getSelectedBranch() { return selectedBranch; } @@ -68,6 +71,10 @@ public class EditAction extends ScmWebEditorMainAction { public void setScmSupportsPush(boolean scmSupportsPush) { this.scmSupportsPush = scmSupportsPush; } + public String getDirectoryPath() { return directoryPath; } + + public void setDirectoryPath(String directoryPath) { this.directoryPath = directoryPath; } + /** * Execution of the edit action * @return a code interpreted in the file struts.xml @@ -95,6 +102,8 @@ public class EditAction extends ScmWebEditorMainAction { repositoryUUID = address.replace(' ', '_'); } + directoryPath = address.substring(0, address.lastIndexOf('/')); + if (log.isDebugEnabled()) { log.debug("Login : " + username); } diff --git a/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_en_GB.properties b/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_en_GB.properties index c258af4..fa31fb5 100644 --- a/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_en_GB.properties +++ b/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_en_GB.properties @@ -45,6 +45,7 @@ scm.modificationViewer.previewPosition.side=On the side scm.mustBeLog=You must be login to see this repository. scm.newDirectoryName=Name of the new directory\: scm.no=No +scm.openAnotherFile=Open another file scm.outConnection.branches=List of branches scm.outConnection.enterRepo=Please enter your repository address. scm.outConnection.headBranch=Current branch\: diff --git a/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_fr_FR.properties b/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_fr_FR.properties index bc053ca..364b0ed 100644 --- a/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_fr_FR.properties +++ b/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_fr_FR.properties @@ -45,6 +45,7 @@ scm.modificationViewer.previewPosition.side=Sur le côté scm.mustBeLog=Vous devez vous identifier pour parcourir ce dépôt. scm.newDirectoryName=Nom du nouveau répertoire \: scm.no=Non +scm.openAnotherFile=Ouvrir un autre fichier scm.outConnection.branches=Liste des branches scm.outConnection.enterRepo=Entrez l'adresse de votre dépôt. scm.outConnection.headBranch=Branche courante \: diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/modificationViewer.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/modificationViewer.jsp index fe3509d..68fffd1 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/modificationViewer.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/modificationViewer.jsp @@ -23,6 +23,7 @@ <%@page contentType="text/html" pageEncoding="UTF-8" %> <%@ taglib prefix="s" uri="/struts-tags" %> <%@ taglib prefix="sj" uri="/struts-jquery-tags" %> +<%@ taglib prefix="sjt" uri="/struts-jquery-tree-tags" %> <sj:head jquerytheme="default"/> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" @@ -87,14 +88,14 @@ } /* Opens the popin for the commit */ - function openCommitPopin() { - document.getElementById("commitPopin").style.display = "block"; + function openPopin(popinId) { + document.getElementById(popinId).style.display = "block"; document.getElementById("popinBackground").style.display = "block"; } /* Closes the popin for the commit */ - function closeCommitPopin() { - document.getElementById("commitPopin").style.display = "none"; + function closePopin(popinId) { + document.getElementById(popinId).style.display = "none"; document.getElementById("popinBackground").style.display = "none"; } @@ -124,6 +125,43 @@ } }); + /* + Functions related to the browsing tree + */ + $.subscribe('treeClicked', function(event, data) { + var item = event.originalEvent.data.rslt.obj; + + if (item.length == 1) { + var classAttr = item[0].getAttribute("class"); + + if (classAttr.contains("jstree-leaf")) { + var scmType = $("#scmType").val(); + var selectedBranch = $("#selectedBranchDisplay").text().trim(); + + document.location.href = ("edit.action?address=" + item.attr("id") + "&scmType=" + scmType + + '&selectedBranch=<s:property value="selectedBranch"/>'); + } + } + + }); + + // automatically expand the directory when there is no other file + $.subscribe('treeChanged', function(event, data) { + + var json = event.originalEvent.data.responseJSON; + + if (json.length == 1) { + var object = json[0]; + + if (object.state == "closed") { + var htmlObject = document.getElementById(object.id); + var children = htmlObject.children; + children.item('ins').click(); + } + } + }); + + window.onbeforeunload = confirmExitOnUnload; </script> @@ -187,6 +225,12 @@ <h1 id="editorTitle">SCMWebEditor</h1> +<s:set id="openAnotherFile"> + <s:text name="scm.openAnotherFile"/> +</s:set> + +<s:submit id="openAnotherFile" value="%{openAnotherFile}" onclick="openPopin('openFilePopin'); return false;"/> + <!-- authentication --> @@ -199,7 +243,7 @@ <s:text name="scm.saveAndContinueTitle"/> </s:set> - <s:div id="saveButton" onclick="loadChange(); openCommitPopin();" title="%{scm.saveAndContinueTitle}"></s:div> + <s:div id="saveButton" onclick="loadChange(); openPopin('commitPopin');" title="%{scm.saveAndContinueTitle}"></s:div> <!--END Save and continue --> <!--BEGIN preview --> @@ -448,8 +492,8 @@ </div> <!-- popin for commit message and authentication information --> -<div id="commitPopin"> - <span id="closeCommitPopin" onclick="closeCommitPopin()"> +<div class="popin" id="commitPopin"> + <span class="closePopin" onclick="closePopin('commitPopin')"> X </span> @@ -497,11 +541,37 @@ </div> </div> + +<!-- popin to open another file --> +<div class="popin" id="openFilePopin"> + <span class="closePopin" onclick="closePopin('openFilePopin')"> + X + </span> + + <h1><s:text name="scm.openAnotherFile"/></h1> + + <div id="searchTree"> + + <s:url id="searchTreeUrl" + action="browse?address=%{directoryPath}&username=%{username}&pw=%{pw}&selectedBranch=%{selectedBranch}&scmType=%{scmType}"/> + <sjt:tree id="scmTree" + htmlTitles="true" + jstreetheme="classic" + href="%{searchTreeUrl}" + onClickTopics="treeClicked" + onSuccessTopics="treeChanged" + /> + + </div> + +</div> + + <div id="popinBackground"></div> <script type="text/javascript"> - document.getElementById("commitPopin").style.display = "none"; - document.getElementById("popinBackground").style.display = "none"; + closePopin("commitPopin"); + closePopin("openFilePopin"); </script> </body> diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/popups/createDirectoryForm.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/createDirectoryForm.jsp index 52482b9..cdd7302 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/popups/createDirectoryForm.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/popups/createDirectoryForm.jsp @@ -125,7 +125,7 @@ <s:else> <img src="struts/js/jstree/themes/classic/throbber.gif" alt="loading" id="loadingIndicator"/> </s:else> - + <input type="submit" onclick="document.getElementById('loadingIndicator').style.display = 'block'"/> </form> diff --git a/swe-ui-web/src/main/webapp/css/main.css b/swe-ui-web/src/main/webapp/css/main.css index 341c4c9..f3a1738 100644 --- a/swe-ui-web/src/main/webapp/css/main.css +++ b/swe-ui-web/src/main/webapp/css/main.css @@ -196,7 +196,7 @@ ul.flags li { position: fixed; width: 90%; top: 0; - z-index: 5; + z-index: 9; } #headLogin { @@ -325,7 +325,7 @@ ul.flags li { margin:auto; width:198px; position:relative; - top:40px; + top:20px; right:10px; } @@ -406,16 +406,26 @@ ul.flags li { display: inline; } -#commitPopin { +.popin { position: fixed; width: 50%; - height: 350px; background-color: white; border: 1px solid black; z-index: 11; + padding: 10px; +} + +#commitPopin { + height: 350px; top: 20%; left: 25%; - padding: 10px; +} + +#openFilePopin { + height: 75%; + top: 12%; + left: 25%; + overflow: scroll; } #popinBackground { @@ -428,11 +438,11 @@ ul.flags li { left: 0; } -#closeCommitPopin { +.closePopin { float: right; } -#closeCommitPopin:hover { +.closePopin:hover { cursor: pointer; color: red; } @@ -443,4 +453,13 @@ ul.flags li { #loadingIndicator { display: none; +} + +#openAnotherFile { + position: relative; + top: 40px; +} + +#wwctrl_openAnotherFile { + text-align: center; } \ No newline at end of file -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.