Author: bleny Date: 2014-10-07 10:56:34 +0200 (Tue, 07 Oct 2014) New Revision: 2279 Url: http://forge.codelutin.com/projects/wao/repository/revisions/2279 Log: R?\195?\169cup?\195?\169ration du cookie par d?\195?\169faut depuis struts (refs #5746) Added: trunk/wao-web/src/main/resources/fr/ifremer/wao/web/WaoJspActionSupport-conversion.properties Removed: trunk/wao-web/src/main/webapp/endpoints-js.jsp Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoJspActionSupport.java trunk/wao-web/src/main/webapp/WEB-INF/decorators/layout-login.jsp trunk/wao-web/src/main/webapp/WEB-INF/decorators/layout.jsp trunk/wao-web/src/main/webapp/wao.js Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoJspActionSupport.java =================================================================== --- trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoJspActionSupport.java 2014-10-06 09:39:32 UTC (rev 2278) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoJspActionSupport.java 2014-10-07 08:56:34 UTC (rev 2279) @@ -21,6 +21,7 @@ * #L% */ +import com.google.common.collect.ImmutableMap; import fr.ifremer.wao.WaoUtils; import fr.ifremer.wao.entity.ObsProgram; import fr.ifremer.wao.services.AuthenticatedWaoUser; @@ -167,10 +168,16 @@ return WaoUtils.isFrench(getLocale()); } - public boolean isSamplingPlanFullView() { - // FIXME brendan 30/09/14 not used + protected boolean isSamplingPlanFullViewByDefault() { boolean fullView = getAuthenticatedWaoUser().isAdmin() || getAuthenticatedWaoUser().isProfessional(); return fullView; } + public ImmutableMap<String, Object> getDefaultCookie() { + return ImmutableMap.of( + "version", (Object) "4.2", + "samplingPlanFullView", isSamplingPlanFullViewByDefault() + ); + } + } Added: trunk/wao-web/src/main/resources/fr/ifremer/wao/web/WaoJspActionSupport-conversion.properties =================================================================== --- trunk/wao-web/src/main/resources/fr/ifremer/wao/web/WaoJspActionSupport-conversion.properties (rev 0) +++ trunk/wao-web/src/main/resources/fr/ifremer/wao/web/WaoJspActionSupport-conversion.properties 2014-10-07 08:56:34 UTC (rev 2279) @@ -0,0 +1 @@ +defaultCookie=org.nuiton.web.struts2.converters.JsonConverter Modified: trunk/wao-web/src/main/webapp/WEB-INF/decorators/layout-login.jsp =================================================================== --- trunk/wao-web/src/main/webapp/WEB-INF/decorators/layout-login.jsp 2014-10-06 09:39:32 UTC (rev 2278) +++ trunk/wao-web/src/main/webapp/WEB-INF/decorators/layout-login.jsp 2014-10-07 08:56:34 UTC (rev 2279) @@ -30,8 +30,6 @@ <title><decorator:title default="Wao"/> - Wao</title> <sj:head locale="fr" jqueryui="true" loadAtOnce="true" jquerytheme="start" /> <sb:head /> - <script type="text/javascript" src="<s:url value='/wao.js'/>"></script> - <script type="text/javascript" src="<s:url value='/endpoints-js.jsp'/>"></script> <link rel="stylesheet" type="text/css" href="<s:url value='/wao.css'/>" media="all" /> <link rel="stylesheet" type="text/css" href="<s:url value='/wao-screen.css'/>" media="screen"> <decorator:head /> Modified: trunk/wao-web/src/main/webapp/WEB-INF/decorators/layout.jsp =================================================================== --- trunk/wao-web/src/main/webapp/WEB-INF/decorators/layout.jsp 2014-10-06 09:39:32 UTC (rev 2278) +++ trunk/wao-web/src/main/webapp/WEB-INF/decorators/layout.jsp 2014-10-07 08:56:34 UTC (rev 2279) @@ -50,7 +50,56 @@ </s:if> <script src="<s:url value="/jquery-cookie-1.4.1/jquery.cookie.js" />"></script> <script src="<s:url value="/wao.js" />"></script> - <script src="<s:url value='/endpoints-js.jsp'/>"></script> + <script> + + $(document).ready(function () { + + // si la lib est chargée, on la configure + if ($.cookie) { + // on sérialise/désérialise en JSON pour stocker le cookie + $.cookie.json = true; + } + + // $('a[data-toggle="popover"]').popover(); + $('span[data-toggle="tooltip"]').tooltip(); + + // FIXME brendan 07/04/14 cannot enable select2 because we can't bind blur event without driving the application crazy, see https://github.com/ivaynberg/select2/issues/2193 + //$('select').addClass('input-xlarge').select2(); + var $select2Inputs = $('select.select2'); + if ($select2Inputs.length > 0) { + $select2Inputs.select2(); + } + + var newWaoCookie = function () { + var newWaoCookie = <s:property value="defaultCookie" escapeHtml="false"/>; + return newWaoCookie; + }; + + WAO = new Wao(newWaoCookie); + + // on ajoute les endpoints + // json + WAO.SAMPLE_ROWS_FILTER_VALUES_JSON_URL = '<s:url namespace="/" action="sample-rows-filter-values-json"/>'; + + WAO.UPDATE_BOAT_INFOS_JSON_URL = '<s:url namespace="/" action="update-boat-infos-json"/>'; + WAO.BOATS_FILTER_VALUES_JSON_URL = '<s:url namespace="/" action="boats-filter-values-json"/>'; + WAO.GET_BOAT_CONTACTS_COUNT_JSON_URL = '<s:url namespace="/" action="get-boat-contacts-count-json"/>'; + WAO.SEARCH_BOAT_JSON_URL = '<s:url namespace="/" action="search-boat-json"/>'; + + WAO.CONTACTS_FILTER_VALUES_JSON_URL = '<s:url namespace="/" action="contacts-filter-values-json"/>'; + + // fragments + WAO.BOAT_DETAILS_URL = '<s:url namespace="/" action="boat-details"/>'; + + }); + + $(window).unload(function() { + + // en quittant la page, on sauvegarde le cookie + WAO.saveCookie(); + + }); + </script> <link rel="stylesheet" type="text/css" href="<s:url value="/select2-3.4.5/select2.css" />" /> <link rel="stylesheet" type="text/css" href="<s:url value="/select2-3.4.5/select2-bootstrap.css" />" /> <link rel="stylesheet" type="text/css" href="<s:url value="/wao.css" />" media="all" /> Deleted: trunk/wao-web/src/main/webapp/endpoints-js.jsp =================================================================== --- trunk/wao-web/src/main/webapp/endpoints-js.jsp 2014-10-06 09:39:32 UTC (rev 2278) +++ trunk/wao-web/src/main/webapp/endpoints-js.jsp 2014-10-07 08:56:34 UTC (rev 2279) @@ -1,39 +0,0 @@ -<%-- - #%L - Wao :: Web - %% - Copyright (C) 2009 - 2014 Ifremer - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - #L% - --%> -<%@ page language="java" contentType="text/javascript; charset=utf-8" pageEncoding="utf-8"%> -<%@ taglib uri="/struts-tags" prefix="s" %> - -$(document).ready(function () { - - // json - WAO.SAMPLE_ROWS_FILTER_VALUES_JSON_URL = '<s:url namespace="/" action="sample-rows-filter-values-json"/>'; - - WAO.UPDATE_BOAT_INFOS_JSON_URL = '<s:url namespace="/" action="update-boat-infos-json"/>'; - WAO.BOATS_FILTER_VALUES_JSON_URL = '<s:url namespace="/" action="boats-filter-values-json"/>'; - WAO.GET_BOAT_CONTACTS_COUNT_JSON_URL = '<s:url namespace="/" action="get-boat-contacts-count-json"/>'; - WAO.SEARCH_BOAT_JSON_URL = '<s:url namespace="/" action="search-boat-json"/>'; - - WAO.CONTACTS_FILTER_VALUES_JSON_URL = '<s:url namespace="/" action="contacts-filter-values-json"/>'; - - // fragments - WAO.BOAT_DETAILS_URL = '<s:url namespace="/" action="boat-details"/>'; - -}); Modified: trunk/wao-web/src/main/webapp/wao.js =================================================================== --- trunk/wao-web/src/main/webapp/wao.js 2014-10-06 09:39:32 UTC (rev 2278) +++ trunk/wao-web/src/main/webapp/wao.js 2014-10-07 08:56:34 UTC (rev 2279) @@ -566,12 +566,13 @@ }; -var Wao = function () { +var Wao = function (newWaoCookie) { var self = this; this.notifications = new Notifications(); this.cookie = null; + this.newWaoCookie = newWaoCookie; this.getNestedPropertyValue = function(path, data) { return path.split('.').reduce(function(prev, prop){ @@ -618,14 +619,6 @@ return data; }; - this.newWaoCookie = function () { - var newWaoCookie = { - version: 1, - samplingPlanFullView: false - }; - return newWaoCookie; - }; - this.getCookie = function () { if (self.cookie === null) { // on charge le cookie, s'il n'est pas définit, on en crée un avec les valeur par défaut @@ -641,32 +634,3 @@ } }; - -$(document).ready(function () { - - // si la lib est chargée, on la configure - if ($.cookie) { - // on sérialise/désérialise en JSON pour stocker le cookie - $.cookie.json = true; - } - - // $('a[data-toggle="popover"]').popover(); - $('span[data-toggle="tooltip"]').tooltip(); - - // FIXME brendan 07/04/14 cannot enable select2 because we can't bind blur event without driving the application crazy, see https://github.com/ivaynberg/select2/issues/2193 - //$('select').addClass('input-xlarge').select2(); - var $select2Inputs = $('select.select2'); - if ($select2Inputs.length > 0) { - $select2Inputs.select2(); - } - - WAO = new Wao(); - -}); - -$(window).unload(function() { - - // en quittant la page, on sauvegarde le cookie - WAO.saveCookie(); - -});