r2262 - in trunk/wao-web/src/main: java/fr/ifremer/wao/web java/fr/ifremer/wao/web/action webapp webapp/WEB-INF/content/obsmer
Author: bleny Date: 2014-09-30 17:59:39 +0200 (Tue, 30 Sep 2014) New Revision: 2262 Url: http://forge.codelutin.com/projects/wao/repository/revisions/2262 Log: Prototype pour le plan d'?\195?\169chantillonnage ObsMer, on sauve dans un cookie le choix de mode compact/?\195?\169tendu, par contre on a perdu la valeur par d?\195?\169faut (refs #5746) Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoJspActionSupport.java trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/AbstractSamplingPlanAction.java trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.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-09-30 08:41:01 UTC (rev 2261) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoJspActionSupport.java 2014-09-30 15:59:39 UTC (rev 2262) @@ -167,4 +167,10 @@ return WaoUtils.isFrench(getLocale()); } + public boolean isSamplingPlanFullView() { + // FIXME brendan 30/09/14 not used + boolean fullView = getAuthenticatedWaoUser().isAdmin() || getAuthenticatedWaoUser().isProfessional(); + return fullView; + } + } Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/AbstractSamplingPlanAction.java =================================================================== --- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/AbstractSamplingPlanAction.java 2014-09-30 08:41:01 UTC (rev 2261) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/AbstractSamplingPlanAction.java 2014-09-30 15:59:39 UTC (rev 2262) @@ -115,11 +115,6 @@ return filterValues; } - public boolean isFullView() { - boolean fullView = getAuthenticatedWaoUser().isAdmin() || getAuthenticatedWaoUser().isProfessional(); - return fullView; - } - protected SimpleDateFormat dateFormat = new SimpleDateFormat("MM/yyyy"); public boolean isCurrentMonth(Date month) { Modified: trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp =================================================================== --- trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp 2014-09-30 08:41:01 UTC (rev 2261) +++ trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp 2014-09-30 15:59:39 UTC (rev 2262) @@ -86,9 +86,12 @@ $('.estimated-differ-from-real').effect( "highlight", "slow" ) }); + var $views = $('#switch-compact-full-view, table.sampling-plan'); + $views.toggleCompactFullView(WAO.getCookie().samplingPlanFullView); + $('#switch-compact-full-view').click(function () { - $('#switch-compact-full-view').toggleClass('full-view').toggleClass('compact-view'); - $('table.sampling-plan').toggleClass('full-view').toggleClass('compact-view'); + WAO.getCookie().samplingPlanFullView = ! WAO.getCookie().samplingPlanFullView; + $views.toggleCompactFullView(WAO.getCookie().samplingPlanFullView); }); }); @@ -158,7 +161,7 @@ </s:form> <div class="sticky-buttons"> - <button type="button" id="switch-compact-full-view" class="btn <s:if test="fullView">full-view</s:if><s:else>compact-view</s:else>"> + <button type="button" id="switch-compact-full-view" class="btn"> <span class="only-in-compact-view"> <i class="fa fa-expand"></i><span class="only-on-hover"> <s:text name="wao.ui.action.switchToFullView" /></span> </span> @@ -180,7 +183,6 @@ </div> <s:set var="estimatedTides" value="true" /> -<s:set var="fullView" value="%{fullView}" /> <s:set var="displayTidesReal" value="true" /> <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> @@ -195,7 +197,7 @@ <s:set var="nbColumnsTotalInFullView" value="%{#nbColumnsForProfessionInFullView + #nbColumnsForMonths + #nbColumnsForOther}" /> <s:set var="nbColumnsTotalInCompactView" value="%{#nbColumnsForProfessionInCompactView + #nbColumnsForMonths + #nbColumnsForOther}" /> - <table id="sampling-plan" class="large-table sampling-plan show-estimated <s:if test="fullView">full-view</s:if><s:else>compact-view</s:else>"> + <table id="sampling-plan" class="large-table sampling-plan show-estimated"> <thead> <tr> <th colspan="<s:property value="#nbColumnsForProfessionInFullView" />" class="only-in-full-view firstline"> Modified: trunk/wao-web/src/main/webapp/wao.js =================================================================== --- trunk/wao-web/src/main/webapp/wao.js 2014-09-30 08:41:01 UTC (rev 2261) +++ trunk/wao-web/src/main/webapp/wao.js 2014-09-30 15:59:39 UTC (rev 2262) @@ -19,6 +19,9 @@ * #L% */ +/* + * Permet d'attacher un évènement à l'appui sur la touche entrée + */ $.fn.enterKey = function (fnc) { return this.each(function () { $(this).keypress(function (e) { @@ -31,6 +34,20 @@ }) } +/* + * Sur un élément permet d'ajouter et de retirer full-view et compact-view + * ou l'inverse selon la valeur de l'argument. + */ +$.fn.toggleCompactFullView = function (fullView) { + return this.each(function () { + if (fullView) { + $(this).addClass('full-view').removeClass('compact-view'); + } else { + $(this).addClass('compact-view').removeClass('full-view'); + } + }) +} + var FilterModel = function (filterValuesUrl) { var self = this; @@ -554,6 +571,7 @@ var self = this; this.notifications = new Notifications(); + this.cookie = null; this.getNestedPropertyValue = function(path, data) { return path.split('.').reduce(function(prev, prop){ @@ -598,13 +616,39 @@ data[parameterName] = parameterValues; }); 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 + self.cookie = $.cookie('wao') || this.newWaoCookie(); + } + return self.cookie; + }; + + this.saveCookie = function () { + if (self.cookie !== null) { + $.cookie('wao', self.cookie); + } } }; $(document).ready(function () { - $.cookie.json = true; + // 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(); @@ -618,4 +662,11 @@ WAO = new Wao(); -}); \ No newline at end of file +}); + +$(window).unload(function() { + + // en quittant la page, on sauvegarde le cookie + WAO.saveCookie(); + +});
participants (1)
-
bleny@users.forge.codelutin.com