Author: bleny Date: 2014-03-31 17:11:56 +0200 (Mon, 31 Mar 2014) New Revision: 1779 Url: http://forge.codelutin.com/projects/wao/repository/revisions/1779 Log: refs #4483 highligh recently modified sample row allow user to change company in filters only if authorized Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/AuthenticatedWaoUser.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp trunk/wao-web/src/main/webapp/wao.css Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/AuthenticatedWaoUser.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/AuthenticatedWaoUser.java 2014-03-31 13:27:37 UTC (rev 1778) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/AuthenticatedWaoUser.java 2014-03-31 15:11:56 UTC (rev 1779) @@ -216,4 +216,8 @@ return ! userProfile.isGuest(); } + public boolean isAuthorizedToViewOtherCompanies() { + return ! userProfile.isCoordinatorOrObserver(); + } + } Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java 2014-03-31 13:27:37 UTC (rev 1778) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java 2014-03-31 15:11:56 UTC (rev 1779) @@ -30,6 +30,7 @@ import fr.ifremer.wao.entity.SampleRowLog; import fr.ifremer.wao.entity.TerrestrialLocation; import org.apache.commons.collections4.CollectionUtils; +import org.nuiton.util.DateUtil; import java.io.Serializable; import java.text.NumberFormat; @@ -454,18 +455,10 @@ return sampleRowId; } - public Date getLatestSampleLogCreateDate() { - return latestSampleLogCreateDate; - } - public Range<Date> getSampleRowMonthPeriod() { return sampleRowMonthPeriod; } - public Date getLastSampleMonthEndOfMonth() { - return lastSampleMonthEndOfMonth; - } - public int getNbObservants() { return nbObservants; } @@ -618,6 +611,16 @@ boolean validMonth = month.before(current) || WaoUtils.isCurrentMonth(month); return validMonth && getNbTidesEstimated(month) != null; } + + public boolean isRecentlyUpdated() { + boolean isRecentlyUpdated = DateUtil.getDifferenceInDays(latestSampleLogCreateDate, new Date()) <= 2 * 7; + return isRecentlyUpdated; + } + + public boolean isNewContactCreatable() { + boolean isNewContactCreatable = new Date().before(lastSampleMonthEndOfMonth); + return isNewContactCreatable; + } } public static class ObsMerSamplingPlanStatistics implements Serializable { Modified: trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties =================================================================== --- trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties 2014-03-31 13:27:37 UTC (rev 1778) +++ trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties 2014-03-31 15:11:56 UTC (rev 1779) @@ -357,6 +357,7 @@ wao.ui.misc.other=Other wao.ui.misc.otherInfos=Others information wao.ui.misc.others=Others +wao.ui.misc.recentUpdate=Recent update wao.ui.misc.refused=Refused wao.ui.misc.since=since wao.ui.misc.total=Total Modified: trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties =================================================================== --- trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties 2014-03-31 13:27:37 UTC (rev 1778) +++ trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties 2014-03-31 15:11:56 UTC (rev 1779) @@ -357,6 +357,7 @@ wao.ui.misc.other=Autre wao.ui.misc.otherInfos=Autre information wao.ui.misc.others=Autres +wao.ui.misc.recentUpdate=MàJ récente wao.ui.misc.refused=Réfusé wao.ui.misc.since=depuis le wao.ui.misc.total=Total 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-03-31 13:27:37 UTC (rev 1778) +++ trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp 2014-03-31 15:11:56 UTC (rev 1779) @@ -76,14 +76,18 @@ <fieldset> - <s:select name="filter.companyIds" - label="%{getText('wao.ui.entity.Company')}" - list="filterValues.companies" - listKey="value" - listValue="label" - multiple="true" - dataBinding="companies" /> + <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> + <s:select name="filter.companyIds" + label="%{getText('wao.ui.entity.Company')}" + list="filterValues.companies" + listKey="value" + listValue="label" + multiple="true" + dataBinding="companies" /> + + </s:if> + <s:select name="filter.programNames" label="%{getText('wao.ui.field.SampleRow.programName')}" list="filterValues.programNames" @@ -186,7 +190,12 @@ <s:set var="fullView" value="%{fullView}" /> <s:set var="displayTidesReal" value="true" /> -<s:set var="nbColumnsForProfessionInFullView" value="13" /> +<s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> + <s:set var="nbColumnsForProfessionInFullView" value="13" /> +</s:if> +<s:else> + <s:set var="nbColumnsForProfessionInFullView" value="12" /> +</s:else> <s:set var="nbColumnsForProfessionInCompactView" value="5" /> <s:set var="nbColumnsForMonths" value="%{samplingPlan.months.size() + 1}" /> <s:set var="nbColumnsForOther" value="6" /> @@ -224,7 +233,11 @@ <!-- Profession columns --> <th><s:text name="wao.ui.field.SampleRow.code"/></th> <th><s:text name="wao.ui.samplingPlan.program"/></th> - <th class="only-in-full-view"><s:text name="wao.ui.entity.Company"/></th> + <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> + <th class="only-in-full-view"> + <s:text name="wao.ui.entity.Company"/> + </th> + </s:if> <th><s:text name="wao.ui.entity.FishingZone"/></th> <th class="only-in-full-view"><s:text name="wao.ui.samplingPlan.fishingZoneInfo"/></th> <th class="only-in-full-view"><s:text name="wao.ui.misc.METIER"/> <br/> <s:text name="wao.ui.field.SampleRow.dcf5Code"/></th> @@ -289,19 +302,32 @@ </tr> <%--Iterate on SampleRows --%> <s:iterator value="samplingPlanSector" var="samplingPlanRow"> - <tr class="sample-row-row<s:if test="sampleRowToHighlightId.equals(topiaId)"> highlight</s:if>"> + <tr class="sample-row-row<s:if test="sampleRowId.equals(sampleRowToHighlightId)"> highlight</s:if>"> <th> <s:property value="code" /> + <s:if test="recentlyUpdated"> + <span class="label label-important"> + <s:text name="wao.ui.misc.recentUpdate" /> + </span> + </s:if> </th> <td><s:property value="programName" /></td> - <td class="only-in-full-view"><s:property value="companyName" /></td> + <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> + <td class="only-in-full-view"> + <s:property value="companyName" /> + </td> + </s:if> <td class="only-in-full-view"><s:property value="fishingZones" /></td> <td class="only-in-compact-view"> <s:property value="fishingZones" /> - (<s:property value="fishingZonesInfos" />) + <s:if test=" ! fishingZonesInfos.empty"> + (<s:property value="fishingZonesInfos" />) + </s:if> </td> - <td class="only-in-full-view"><s:property value="fishingZonesInfos" /></td> <td class="only-in-full-view"> + <s:property value="fishingZonesInfos" /> + </td> + <td class="only-in-full-view"> <s:iterator value="dcf5CodesAndDescriptions"> <abbr title="<s:property value="value"/>"><s:property value="key"/></abbr> </s:iterator> @@ -348,7 +374,7 @@ <s:property value="totalTidesEstimated" /> </span> <span class="real<s:if test="totalTidesReal < totalTidesExpected"> lower-than-expected</s:if><s:if test="totalTidesReal > totalTidesExpected"> higher-than-expected</s:if>"> - <s:property value="totalTidesReal" /> (Total sur la période du ... au ...) + <s:property value="totalTidesReal" /> </span> / </s:if> @@ -439,7 +465,7 @@ <s:text name="wao.ui.action.viewAssociatedContacts" /> </s:a> </li> - <s:if test="authenticatedWaoUser.authorizedToCreateContact"> + <s:if test="authenticatedWaoUser.authorizedToCreateContact && isNewContactCreatable"> <li> <s:url action="contacts" id="createAssociatedContactUrl"> <s:param name="sampleRowIds" value="sampleRowId" /> Modified: trunk/wao-web/src/main/webapp/wao.css =================================================================== --- trunk/wao-web/src/main/webapp/wao.css 2014-03-31 13:27:37 UTC (rev 1778) +++ trunk/wao-web/src/main/webapp/wao.css 2014-03-31 15:11:56 UTC (rev 1779) @@ -243,6 +243,10 @@ background-color: #e6e6e6; } +table.sampling-plan tbody tr.sample-row-row.highlight { + background-color: #ffff99; +} + table.sampling-plan tbody tr.sample-row-row:hover { background-color: tan; background-color: antiquewhite;
participants (1)
-
bleny@users.forge.codelutin.com