Author: Bavencoff Date: 2013-05-22 09:02:15 +0200 (Wed, 22 May 2013) New Revision: 174 Url: http://forge.codelutin.com/projects/franciaflex-magalie/repository/revisions... Log: refs #2431 : shortcuts Modified: trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/MagalieActionSupport.java trunk/magalie-web/src/main/webapp/WEB-INF/content/choose-activity.jsp trunk/magalie-web/src/main/webapp/WEB-INF/content/deliver-requested-article-input.jsp trunk/magalie-web/src/main/webapp/WEB-INF/content/fulfil-kanban-input.jsp trunk/magalie-web/src/main/webapp/WEB-INF/content/prepare-article-reception-input.jsp trunk/magalie-web/src/main/webapp/WEB-INF/content/prepare-article-reception.jsp trunk/magalie-web/src/main/webapp/WEB-INF/content/receive-article-input.jsp trunk/magalie-web/src/main/webapp/WEB-INF/content/withdraw-item-input.jsp trunk/magalie-web/src/main/webapp/WEB-INF/decorators/layout.jsp trunk/magalie-web/src/main/webapp/js/magalie.js trunk/magalie-web/src/main/webapp/js/receive-article-input.js trunk/magalie-web/src/main/webapp/js/withdraw-item-input.js Modified: trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/MagalieActionSupport.java =================================================================== --- trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/MagalieActionSupport.java 2013-05-21 15:20:38 UTC (rev 173) +++ trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/MagalieActionSupport.java 2013-05-22 07:02:15 UTC (rev 174) @@ -27,10 +27,19 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import java.util.Arrays; +import java.util.List; + public class MagalieActionSupport extends ActionSupport { private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(MagalieActionSupport.class); + public static final List<String> SHORTCUTS = Arrays.asList(new String[]{ "0", "1", "2", "3", "5", "6", "7", "8", "9", + "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", + "w", "x", "y", "z" }); + public List<String> getShortcuts () { + return SHORTCUTS; + } } Modified: trunk/magalie-web/src/main/webapp/WEB-INF/content/choose-activity.jsp =================================================================== --- trunk/magalie-web/src/main/webapp/WEB-INF/content/choose-activity.jsp 2013-05-21 15:20:38 UTC (rev 173) +++ trunk/magalie-web/src/main/webapp/WEB-INF/content/choose-activity.jsp 2013-05-22 07:02:15 UTC (rev 174) @@ -33,9 +33,13 @@ <head> <script> -$(document).keydown(function(event) { -alert('Touche :' + event.which); +$(document).ready(function() { + bindKey('1', function(){ redirectTo($('#fulfilKanbanlink'));}); + bindKey('2', function(){ redirectTo($('#deliverRequestedArticlelink'));}); + bindKey('3', function(){ redirectTo($('#prepareArticleReceptionlink'));}); + bindKey('Esc', function(){ redirectTo($('#logoutlink'));}); }); + </script> </head> @@ -49,7 +53,7 @@ </dl> </header> -<s:a href="%{fulfilKanbanUrl}" cssClass="btn btn-block">Traiter kanbans</s:a> -<s:a href="%{deliverRequestedArticleUrl}" cssClass="btn btn-block">Traiter listes à servir</s:a> -<s:a href="%{prepareArticleReceptionUrl}" cssClass="btn btn-block">Traiter les réceptions fournisseurs</s:a> -<s:a href="%{logoutUrl}" cssClass="btn btn-block">Déconnexion</s:a> +<s:a href="%{fulfilKanbanUrl}" cssClass="btn btn-block" id="fulfilKanbanlink">Traiter kanbans (1)</s:a> +<s:a href="%{deliverRequestedArticleUrl}" cssClass="btn btn-block" id="deliverRequestedArticlelink">Traiter listes à servir (2)</s:a> +<s:a href="%{prepareArticleReceptionUrl}" cssClass="btn btn-block" id="prepareArticleReceptionlink" >Traiter les réceptions fournisseurs (3)</s:a> +<s:a href="%{logoutUrl}" cssClass="btn btn-block" id="logoutlink" >Déconnexion (Esc)</s:a> Modified: trunk/magalie-web/src/main/webapp/WEB-INF/content/deliver-requested-article-input.jsp =================================================================== --- trunk/magalie-web/src/main/webapp/WEB-INF/content/deliver-requested-article-input.jsp 2013-05-21 15:20:38 UTC (rev 173) +++ trunk/magalie-web/src/main/webapp/WEB-INF/content/deliver-requested-article-input.jsp 2013-05-22 07:02:15 UTC (rev 174) @@ -24,13 +24,12 @@ <%@ taglib prefix="s" uri="/struts-tags" %> <s:if test="requestedList"> - <head> <script type="text/javascript"> $(document).ready(function () { $("#requestedArticle").focus(); + bindKey('0', function(){ redirectTo($('#requestedArticle'));}); }); - </script> - </head> + </script> <p> Vous êtes affecté à la liste <s:property value="requestedList.code" /> @@ -38,18 +37,40 @@ <s:url namespace="/" action="deliver-requested-article" id="deliverRequestedArticleUrl"> <s:param name="listType" value="%{requestedList.listType}" /> </s:url> - <s:a href="%{deliverRequestedArticleUrl}" cssClass="btn btn-block" id="requestedArticle" >Demander un article à servir</s:a> + <s:a href="%{deliverRequestedArticleUrl}" cssClass="btn btn-block" id="requestedArticle" >Demander un article à servir (0)</s:a> </s:if> <s:else> - <s:iterator value="listTypes" var="listType"> + <s:iterator value="listTypes" var="listType" status="stat"> + <s:set var="deliverRequestedArticleId">prepareArticleReceptionId<s:property value="#stat.index" /></s:set> <s:url namespace="/" action="deliver-requested-article" id="deliverRequestedArticleUrl"> <s:param name="listType" value="#listType" /> </s:url> - <s:a href="%{deliverRequestedArticleUrl}" cssClass="btn btn-block"> - Commencer à traiter une liste « <s:property value="#listType" /> » - </s:a> + <s:if test="#stat.index < shortcuts.size()"> + <script type="text/javascript"> + $(document).ready(function () { + var id = '<s:property value="deliverRequestedArticleId" />'; + bindKey(<s:property value="shortcuts.get(#stat.index)" />, function(){ redirectTo($('#' + id));}); + }); + </script> + <s:a href="%{deliverRequestedArticleUrl}" cssClass="btn btn-block" id="%{deliverRequestedArticleId}"> + Commencer à traiter une liste « <s:property value="#listType" /> » + (<s:property value="shortcuts.get(#stat.index)" />) + </s:a> + </s:if> + <s:else> + <s:a href="%{deliverRequestedArticleUrl}" cssClass="btn btn-block"> + Commencer à traiter une liste « <s:property value="#listType" /> » + </s:a> + </s:else> </s:iterator> </s:else> +<script type="text/javascript"> + $(document).ready(function () { + $("#requestedArticle").focus(); + bindKey('Esc', function(){ redirectTo($('#removeUserAffectationLink'));}); + }); +</script> + <s:url namespace="/" action="remove-user-affectation" id="removeUserAffectationUrl"/> -<s:a href="%{removeUserAffectationUrl}" cssClass="btn btn-block">Changer d'activité</s:a> +<s:a href="%{removeUserAffectationUrl}" cssClass="btn btn-block" id="removeUserAffectationLink">Changer d'activité (Esc)</s:a> Modified: trunk/magalie-web/src/main/webapp/WEB-INF/content/fulfil-kanban-input.jsp =================================================================== --- trunk/magalie-web/src/main/webapp/WEB-INF/content/fulfil-kanban-input.jsp 2013-05-21 15:20:38 UTC (rev 173) +++ trunk/magalie-web/src/main/webapp/WEB-INF/content/fulfil-kanban-input.jsp 2013-05-22 07:02:15 UTC (rev 174) @@ -28,6 +28,7 @@ <script type="text/javascript"> $(document).ready(function () { $("#fulfil-kanban_articleBarcode").focus(); + bindKey('Esc', function(){ redirectTo($('#chooseActivityLink'));}); }); </script> </head> @@ -50,7 +51,7 @@ </s:if> <div class="btn-group"> - <s:a href="%{chooseActivityUrl}" cssClass="btn">Changer d'activité</s:a> + <s:a href="%{chooseActivityUrl}" cssClass="btn" id="chooseActivityLink" >Changer d'activité (Esc)</s:a> <s:submit name="next" value="Suivant" cssClass="btn btn-primary" /> </div> </s:form> \ No newline at end of file Modified: trunk/magalie-web/src/main/webapp/WEB-INF/content/prepare-article-reception-input.jsp =================================================================== --- trunk/magalie-web/src/main/webapp/WEB-INF/content/prepare-article-reception-input.jsp 2013-05-21 15:20:38 UTC (rev 173) +++ trunk/magalie-web/src/main/webapp/WEB-INF/content/prepare-article-reception-input.jsp 2013-05-22 07:02:15 UTC (rev 174) @@ -23,24 +23,57 @@ <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %> <%@ taglib prefix="s" uri="/struts-tags" %> + + +<head> + <script type="text/javascript"> + $(document).ready(function () { + bindKey('Esc', function(){ redirectTo($('#chooseActivityLink'));}); + }); + </script> +</head> + <s:if test="suppliersToReceive.somethingToReceive"> <ul> - <s:iterator value="suppliersToReceive.suppliers"> + <li> + <script type="text/javascript"> + $(document).ready(function () { + bindKey(<s:property value="shortcuts.get(0)" />, function(){ redirectTo($('#prepareArticleReceptionLink'));}); + }); + </script> + <s:url namespace="/" action="prepare-article-reception" id="prepareArticleReceptionUrl" /> + <s:a href="%{prepareArticleReceptionUrl}" id="prepareArticleReceptionLink"> + Tous les fournisseurs (<s:property value="shortcuts.get(0)" />) + </s:a> + </li> + + <s:iterator value="suppliersToReceive.suppliers" status="stat"> <li> + <s:set var="prepareArticleReceptionId">prepareArticleReceptionId<s:property value="#stat.index" /></s:set> <s:url namespace="/" action="prepare-article-reception" id="prepareArticleReceptionUrl"> - <s:param name="supplierId" value="%{id}" /> - </s:url> - <s:a href="%{prepareArticleReceptionUrl}"><s:property value="name" /></s:a> + <s:param name="supplierId" value="%{id}" /> + </s:url> + <s:if test="#stat.index + 1 < shortcuts.size()"> + <script type="text/javascript"> + $(document).ready(function () { + var id = '<s:property value="prepareArticleReceptionId" />'; + bindKey(<s:property value="shortcuts.get(#stat.index + 1)" />, function(){ redirectTo($('#' + id));}); + }); + </script> + <s:a href="%{prepareArticleReceptionUrl}" id="%{prepareArticleReceptionId}"> + <s:property value="name" /> (<s:property value="shortcuts.get(#stat.index + 1)" />) + </s:a> + </s:if> + <s:else> + <s:a href="%{prepareArticleReceptionUrl}" > + <s:property value="name" /> + </s:a> + </s:else> </li> </s:iterator> - <li> - <s:url namespace="/" action="prepare-article-reception" id="prepareArticleReceptionUrl" /> - <s:a href="%{prepareArticleReceptionUrl}"> - Tous les fournisseurs - </s:a> - </li> + </ul> </s:if> <s:url namespace="/" action="choose-activity" id="chooseActivityUrl"/> -<s:a href="%{chooseActivityUrl}" cssClass="btn">Changer d'activité</s:a> +<s:a href="%{chooseActivityUrl}" cssClass="btn" id="chooseActivityLink">Changer d'activité (Esc)</s:a> Modified: trunk/magalie-web/src/main/webapp/WEB-INF/content/prepare-article-reception.jsp =================================================================== --- trunk/magalie-web/src/main/webapp/WEB-INF/content/prepare-article-reception.jsp 2013-05-21 15:20:38 UTC (rev 173) +++ trunk/magalie-web/src/main/webapp/WEB-INF/content/prepare-article-reception.jsp 2013-05-22 07:02:15 UTC (rev 174) @@ -24,17 +24,37 @@ <%@ taglib prefix="s" uri="/struts-tags" %> <ul> - <s:iterator value="receivedArticles"> - <li> - <s:url namespace="/" action="receive-article!input" id="receiveArticleUrl"> - <s:param name="storedArticleId" value="%{id}" /> - </s:url> - <s:a href="%{receiveArticleUrl}"> - <s:property value="quantity" /> - <s:property value="article.unit" /> - <s:property value="article.description" /> - (Réf <s:property value="article.code" />) - </s:a> - </li> + <s:iterator value="receivedArticles" status="stat" > + <s:set var="receiveArticleId">prepareArticleReceptionId<s:property value="#stat.index" /></s:set> + <s:url namespace="/" action="receive-article!input" id="receiveArticleUrl"> + <s:param name="storedArticleId" value="%{id}" /> + </s:url> + <s:if test="#stat.index < shortcuts.size()"> + <script type="text/javascript"> + $(document).ready(function () { + var id = '<s:property value="receiveArticleId" />'; + bindKey(<s:property value="shortcuts.get(#stat.index)" />, function(){ redirectTo($('#' + id));}); + }); + </script> + <li> + <s:a href="%{receiveArticleUrl}" id="%{receiveArticleId}"> + <s:property value="quantity" /> + <s:property value="article.unit" /> + <s:property value="article.description" /> + (Réf <s:property value="article.code" />) + (<s:property value="shortcuts.get(#stat.index)" />) + </s:a> + </li> + </s:if> + <s:else> + <li> + <s:a href="%{receiveArticleUrl}"> + <s:property value="quantity" /> + <s:property value="article.unit" /> + <s:property value="article.description" /> + (Réf <s:property value="article.code" />) + </s:a> + </li> + </s:else> </s:iterator> </ul> Modified: trunk/magalie-web/src/main/webapp/WEB-INF/content/receive-article-input.jsp =================================================================== --- trunk/magalie-web/src/main/webapp/WEB-INF/content/receive-article-input.jsp 2013-05-21 15:20:38 UTC (rev 173) +++ trunk/magalie-web/src/main/webapp/WEB-INF/content/receive-article-input.jsp 2013-05-22 07:02:15 UTC (rev 174) @@ -24,7 +24,6 @@ <%@ taglib prefix="s" uri="/struts-tags" %> <head> - <script src="<s:url value='/js/magalie.js' />"></script> <script> var model = <s:property value="modelAsJson" escapeHtml="false" />; </script> @@ -51,7 +50,7 @@ <s:hidden name="confirmation" /> <div class="btn-group"> - <s:submit name="full" value="Plein" cssClass="btn btn-danger btn-small" /> + <input type="button" name="full" value="Plein (F5)" class="btn btn-danger btn-small" id="receive-article_full" /> <s:submit name="next" value="Suivant" cssClass="btn btn-primary btn-small" /> </div> </s:form> Modified: trunk/magalie-web/src/main/webapp/WEB-INF/content/withdraw-item-input.jsp =================================================================== --- trunk/magalie-web/src/main/webapp/WEB-INF/content/withdraw-item-input.jsp 2013-05-21 15:20:38 UTC (rev 173) +++ trunk/magalie-web/src/main/webapp/WEB-INF/content/withdraw-item-input.jsp 2013-05-22 07:02:15 UTC (rev 174) @@ -24,7 +24,6 @@ <%@ taglib prefix="s" uri="/struts-tags" %> <head> - <script src="<s:url value='/js/magalie.js' />"></script> <script> var model = <s:property value="modelAsJson" escapeHtml="false" />; </script> @@ -51,7 +50,7 @@ <s:hidden name="confirmation" /> <div class="btn-group"> - <input type="button" id="reportError" value="Anomalie" class="btn btn-danger btn-small" /> + <input type="button" id="reportError" value="Anomalie (F5)" class="btn btn-danger btn-small" /> <s:submit name="next" value="Suivant" cssClass="btn btn-primary btn-small" /> </div> </s:form> Modified: trunk/magalie-web/src/main/webapp/WEB-INF/decorators/layout.jsp =================================================================== --- trunk/magalie-web/src/main/webapp/WEB-INF/decorators/layout.jsp 2013-05-21 15:20:38 UTC (rev 173) +++ trunk/magalie-web/src/main/webapp/WEB-INF/decorators/layout.jsp 2013-05-22 07:02:15 UTC (rev 174) @@ -33,6 +33,7 @@ <sj:head locale="fr" jqueryui="false" jquerytheme="start" /> <sb:head /> <title><decorator:title default="MagaLiE"/> - MagaLiE</title> + <script src="<s:url value='/js/magalie.js' />"></script> <link rel="stylesheet" href="<s:url value='/css/magalie.css' />"/> <link rel="stylesheet" href="<s:url value='/css/magalie-ck3x.css' />"/> <!--link rel="icon" type="image/png" href="<s:url value='/favicon.png' />" --> Modified: trunk/magalie-web/src/main/webapp/js/magalie.js =================================================================== --- trunk/magalie-web/src/main/webapp/js/magalie.js 2013-05-21 15:20:38 UTC (rev 173) +++ trunk/magalie-web/src/main/webapp/js/magalie.js 2013-05-22 07:02:15 UTC (rev 174) @@ -20,6 +20,71 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ + +// declaration des constantes de touche clavier + +KEYS = {"F1": 112, + "F2": 113, + "F3" : 114 , + "F4" : 115 , + "F5" : 116 , + "tab" : 9 , + "del" : 8 , + "Esc" : 27 , + "0" : 48, + "1" : 49, + "2" : 50, + "3" : 51, + "4" : 52, + "5" : 53, + "6" : 54, + "7" : 55, + "8" : 56, + "9" : 57, + "." : 190, + "a" : 65, + "b" : 66, + "c" : 67, + "d" : 68, + "e" : 69, + "f" : 70, + "g" : 71, + "h" : 72, + "i" : 73, + "j" : 74, + "k" : 75, + "l" : 76, + "m" : 77, + "n" : 78, + "o" : 79, + "p" : 80, + "q" : 81, + "r" : 82, + "s" : 83, + "t" : 84, + "u" : 85, + "v" : 86, + "w" : 87, + "x" : 88, + "y" : 89, + "z" : 90 }; + +SHORTCUTS = ["1", "2", "3", "5", "6", "7", "8", "9", "O", "a", "b", "c", "d", "e", "f", "g", "h", "i", + "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]; + +function bindKey(key, handler) { + $(document).keydown(function(event) { + if (event.which == KEYS[key]) { + handler(); + } + }) + +} + +function redirectTo(a) { + window.location = a.attr('href'); +} + function processTemplate(templateId, model) { var processing = $('#' + templateId).clone().children(); var elementsWithData = $(processing).find('*[data]'); Modified: trunk/magalie-web/src/main/webapp/js/receive-article-input.js =================================================================== --- trunk/magalie-web/src/main/webapp/js/receive-article-input.js 2013-05-21 15:20:38 UTC (rev 173) +++ trunk/magalie-web/src/main/webapp/js/receive-article-input.js 2013-05-22 07:02:15 UTC (rev 174) @@ -242,6 +242,6 @@ $('#receive-article').submit(controller.onSubmit); $('#receive-article_full').click(controller.onReportError); $('#receive-article_next').click(controller.onNext); - + bindKey('F5', controller.onReportError); view.refresh(); }); Modified: trunk/magalie-web/src/main/webapp/js/withdraw-item-input.js =================================================================== --- trunk/magalie-web/src/main/webapp/js/withdraw-item-input.js 2013-05-21 15:20:38 UTC (rev 173) +++ trunk/magalie-web/src/main/webapp/js/withdraw-item-input.js 2013-05-22 07:02:15 UTC (rev 174) @@ -270,6 +270,6 @@ $('#withdraw-item').submit(controller.onSubmit); $('#reportError').click(controller.onReportError); $('#withdraw-item_next').click(controller.onNext); - + bindKey('F5', controller.onReportError); view.refresh(); });