r1888 - in trunk/wao-web/src/main: java/fr/ifremer/wao/web java/fr/ifremer/wao/web/action/obsmer webapp/WEB-INF/content/obsmer
Author: tchemit Date: 2014-04-15 11:42:54 +0200 (Tue, 15 Apr 2014) New Revision: 1888 Url: http://forge.codelutin.com/projects/wao/repository/revisions/1888 Log: refs #4483 add filters in session Added: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ResetBoatsFilterAction.java trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ResetContactsFilterAction.java trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ResetSampleRowsFilterAction.java Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoSession.java trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsAction.java trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ContactsAction.java trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/SamplingPlanAction.java trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boats.jsp trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/contacts.jsp trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoSession.java =================================================================== --- trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoSession.java 2014-04-15 09:08:27 UTC (rev 1887) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoSession.java 2014-04-15 09:42:54 UTC (rev 1888) @@ -22,6 +22,9 @@ */ import com.google.common.collect.Lists; +import fr.ifremer.wao.BoatsFilter; +import fr.ifremer.wao.ContactsFilter; +import fr.ifremer.wao.SampleRowsFilter; import fr.ifremer.wao.services.AuthenticatedWaoUser; import java.io.Serializable; @@ -45,6 +48,12 @@ protected String startBoatSelectionForSampleRowId; + protected SampleRowsFilter sampleRowsFilter; + + protected BoatsFilter boatsFilter; + + protected ContactsFilter contactsFilter; + public Collection<String> getMessages() { if (messages == null) { messages = Lists.newLinkedList(); @@ -103,4 +112,28 @@ public String getStartBoatSelectionForSampleRowId() { return startBoatSelectionForSampleRowId; } + + public SampleRowsFilter getSampleRowsFilter() { + return sampleRowsFilter; + } + + public void setSampleRowsFilter(SampleRowsFilter sampleRowsFilter) { + this.sampleRowsFilter = sampleRowsFilter; + } + + public BoatsFilter getBoatsFilter() { + return boatsFilter; + } + + public void setBoatsFilter(BoatsFilter boatsFilter) { + this.boatsFilter = boatsFilter; + } + + public ContactsFilter getContactsFilter() { + return contactsFilter; + } + + public void setContactsFilter(ContactsFilter contactsFilter) { + this.contactsFilter = contactsFilter; + } } Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsAction.java =================================================================== --- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsAction.java 2014-04-15 09:08:27 UTC (rev 1887) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/BoatsAction.java 2014-04-15 09:42:54 UTC (rev 1888) @@ -122,8 +122,13 @@ @Override public void prepare() { - filter = service.newBoatsFilter(getAuthenticatedWaoUser()); + filter = getSession().getBoatsFilter(); + if (filter == null) { + filter = service.newBoatsFilter(getAuthenticatedWaoUser()); + getSession().setBoatsFilter(filter); + } + if (StringUtils.isNotBlank(startBoatSelectionForSampleRowId)) { session.setStartBoatSelectionForSampleRowId(startBoatSelectionForSampleRowId); Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ContactsAction.java =================================================================== --- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ContactsAction.java 2014-04-15 09:08:27 UTC (rev 1887) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ContactsAction.java 2014-04-15 09:42:54 UTC (rev 1888) @@ -104,7 +104,12 @@ @Override public void prepare() { - filter = service.newContactFilter(getAuthenticatedWaoUser()); + filter = getSession().getContactsFilter(); + if (filter == null) { + filter = service.newContactFilter(getAuthenticatedWaoUser()); + getSession().setContactsFilter(filter); + } + } @Override Added: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ResetBoatsFilterAction.java =================================================================== --- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ResetBoatsFilterAction.java (rev 0) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ResetBoatsFilterAction.java 2014-04-15 09:42:54 UTC (rev 1888) @@ -0,0 +1,46 @@ +package fr.ifremer.wao.web.action.obsmer; + +/* + * #%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% + */ + +import fr.ifremer.wao.web.WaoJspActionSupport; +import org.apache.struts2.convention.annotation.Result; +import org.apache.struts2.convention.annotation.Results; + +/** + * Created on 4/15/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +@Results({@Result(name = WaoJspActionSupport.SUCCESS, type = "redirectAction", params = {"actionName", "boats"})}) +public class ResetBoatsFilterAction extends WaoJspActionSupport { + + private static final long serialVersionUID = 1L; + + @Override + public String execute() throws Exception { + + // clean boats filter from session + getSession().setBoatsFilter(null); + return SUCCESS; + } +} Property changes on: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ResetBoatsFilterAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ResetContactsFilterAction.java =================================================================== --- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ResetContactsFilterAction.java (rev 0) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ResetContactsFilterAction.java 2014-04-15 09:42:54 UTC (rev 1888) @@ -0,0 +1,46 @@ +package fr.ifremer.wao.web.action.obsmer; + +/* + * #%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% + */ + +import fr.ifremer.wao.web.WaoJspActionSupport; +import org.apache.struts2.convention.annotation.Result; +import org.apache.struts2.convention.annotation.Results; + +/** + * Created on 4/15/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +@Results({@Result(name = WaoJspActionSupport.SUCCESS, type = "redirectAction", params = {"actionName", "contacts"})}) +public class ResetContactsFilterAction extends WaoJspActionSupport { + + private static final long serialVersionUID = 1L; + + @Override + public String execute() throws Exception { + + // clean contacts filter from session + getSession().setContactsFilter(null); + return SUCCESS; + } +} Property changes on: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ResetContactsFilterAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ResetSampleRowsFilterAction.java =================================================================== --- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ResetSampleRowsFilterAction.java (rev 0) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ResetSampleRowsFilterAction.java 2014-04-15 09:42:54 UTC (rev 1888) @@ -0,0 +1,46 @@ +package fr.ifremer.wao.web.action.obsmer; + +/* + * #%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% + */ + +import fr.ifremer.wao.web.WaoJspActionSupport; +import org.apache.struts2.convention.annotation.Result; +import org.apache.struts2.convention.annotation.Results; + +/** + * Created on 4/15/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 4.0 + */ +@Results({@Result(name = WaoJspActionSupport.SUCCESS, type = "redirectAction", params = {"actionName", "sampling-plan"})}) +public class ResetSampleRowsFilterAction extends WaoJspActionSupport { + + private static final long serialVersionUID = 1L; + + @Override + public String execute() throws Exception { + + // clean sampling plan filter from session + getSession().setSampleRowsFilter(null); + return SUCCESS; + } +} Property changes on: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ResetSampleRowsFilterAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/SamplingPlanAction.java =================================================================== --- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/SamplingPlanAction.java 2014-04-15 09:08:27 UTC (rev 1887) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/SamplingPlanAction.java 2014-04-15 09:42:54 UTC (rev 1888) @@ -59,8 +59,14 @@ public void prepare() { now = new Date(); - filter = service.newSampleRowsFilter(getAuthenticatedWaoUser()); + + filter = getSession().getSampleRowsFilter(); + if (filter == null) { + filter = service.newSampleRowsFilter(getAuthenticatedWaoUser()); + getSession().setSampleRowsFilter(filter); + } + } @Override Modified: trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boats.jsp =================================================================== --- trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boats.jsp 2014-04-15 09:08:27 UTC (rev 1887) +++ trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boats.jsp 2014-04-15 09:42:54 UTC (rev 1888) @@ -35,10 +35,6 @@ var boatsFilterController = new FilterController(WAO.OBSMER_BOATS_FILTER_VALUES_JSON_URL, $('#boats-filters-form')); boatsFilterController.init(); - $('#reset-filters').click(function () { - boatsFilterController.reset(); - }); - var $boatDetails = $('#boat-details'); var $companyId = $('#companyId'); @@ -156,9 +152,9 @@ <div class="form-actions"> - <button type="button" id="reset-filters" class="btn"> + <s:submit action="reset-boats-filter" type="button" cssClass="btn"> <i class="icon-reset"></i> <s:text name="wao.ui.action.reset" /> - </button> + </s:submit> <s:submit type="button" cssClass="btn"> <i class="icon-filter"></i> <s:text name="wao.ui.action.filter"/> Modified: trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/contacts.jsp =================================================================== --- trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/contacts.jsp 2014-04-15 09:08:27 UTC (rev 1887) +++ trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/contacts.jsp 2014-04-15 09:42:54 UTC (rev 1888) @@ -40,10 +40,6 @@ $('table.contacts-list').toggleClass('full-view').toggleClass('compact-view'); }); - $('#reset-filters').click(function () { - contactsFilterController.reset(); - }); - $('.validation-action').click(function() { var $action = $(this); var url = $action.attr('data'); @@ -254,9 +250,9 @@ <div class="form-actions"> - <button type="button" id="reset-filters" class="btn"> + <s:submit action="reset-contacts-filter" type="button" cssClass="btn"> <i class="icon-reset"></i> <s:text name="wao.ui.action.reset"/> - </button> + </s:submit> <s:submit type="button" cssClass="btn"> <i class="icon-filter"></i> <s:text name="wao.ui.action.filter"/> 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-04-15 09:08:27 UTC (rev 1887) +++ trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp 2014-04-15 09:42:54 UTC (rev 1888) @@ -46,10 +46,6 @@ $('table.sampling-plan').toggleClass('full-view').toggleClass('compact-view'); }); - $('#reset-filters').click(function () { - sampleRowsFilterController.reset(); - }); - }); </script> @@ -145,9 +141,9 @@ <div class="form-actions"> - <button type="button" id="reset-filters" class="btn"> - <i class="icon-reset"></i> <s:text name="wao.ui.action.reset" /> - </button> + <s:submit action="reset-sample-rows-filter" type="button" cssClass="btn"> + <i class="icon-reset"></i> <s:text name="wao.ui.action.reset"/> + </s:submit> <s:submit type="button" cssClass="btn"> <i class="icon-filter"></i> <s:text name="wao.ui.action.filter" />
participants (1)
-
tchemit@users.forge.codelutin.com