Update representation of personal timesheets in the UI depending on periodicity

FEA: ItEr77S07PersonalTimesheetsPeriodictyConfiguration
This commit is contained in:
Manuel Rego Casasnovas 2012-08-28 11:15:24 +02:00
parent 7e24ddb8ac
commit 6ce91d6da9
6 changed files with 41 additions and 22 deletions

View file

@ -211,4 +211,10 @@ public interface IMonthlyTimesheetModel {
*/
PersonalTimesheetsPeriodicityEnum getPersonalTimesheetsPeriodicity();
/**
* Returns the string that represents the personal timesheet depending on
* the configured periodicity.
*/
String getTimesheetString();
}

View file

@ -598,8 +598,8 @@ public class MonthlyTimesheetController extends GenericForwardComposer
columns.appendChild(total);
}
public String getDate() {
return monthlyTimesheetModel.getDate().toString("MMMM y");
public String getTimesheetString() {
return monthlyTimesheetModel.getTimesheetString();
}
public String getResource() {

View file

@ -92,13 +92,17 @@ public class MonthlyTimesheetDTO {
}
public String toString(PersonalTimesheetsPeriodicityEnum periodicity) {
return toString(periodicity, date);
}
public static String toString(PersonalTimesheetsPeriodicityEnum periodicity, LocalDate date) {
switch (periodicity) {
case WEEKLY:
return _("Week {0}", date.toString("w"));
case TWICE_MONTHLY:
return (date.getDayOfMonth() <= 15) ?
_("{0} 1st fortnight",date.toString("MMMM")) :
_("{0} 2nd fortnight",date.toString("MMMM"));
_("{0} 1st fortnight", date.toString("MMMM")) :
_("{0} 2nd fortnight", date.toString("MMMM"));
case MONTHLY:
default:
return date.toString("MMMM y");

View file

@ -566,4 +566,9 @@ public class MonthlyTimesheetModel implements IMonthlyTimesheetModel {
.getPersonalTimesheetsPeriodicity();
}
@Override
public String getTimesheetString() {
return MonthlyTimesheetDTO.toString(periodicity, date);
}
}

View file

@ -23,6 +23,7 @@ import static org.libreplan.web.I18nHelper._;
import org.apache.commons.lang.StringUtils;
import org.joda.time.LocalDate;
import org.libreplan.business.common.Registry;
import org.libreplan.web.common.IMessagesForUser;
import org.libreplan.web.common.Level;
import org.libreplan.web.common.MessagesForUser;
@ -54,8 +55,11 @@ public class UserDashboardController extends GenericForwardComposer {
String timesheetSave = Executions.getCurrent().getParameter(
"timesheet_saved");
if (!StringUtils.isBlank(timesheetSave)) {
String monthlyTimesheet = new LocalDate(timesheetSave)
.toString("MMMM y");
String monthlyTimesheet = MonthlyTimesheetDTO.toString(Registry
.getConfigurationDAO()
.getConfigurationWithReadOnlyTransaction()
.getPersonalTimesheetsPeriodicity(), new LocalDate(
timesheetSave));
messagesForUser.showMessage(Level.INFO,
_("Personal timesheet \"{0}\" saved", monthlyTimesheet));
}

View file

@ -48,22 +48,22 @@
<rows>
<row>
<label value="${i18n:_('Date')}" />
<hbox align="pack">
<div visible="@{controller.currentUser}">
<button id="previousMonth"
image="/common/img/ico_step_left.png" sclass="icono"
onClick="controller.previousMonth();"
tooltiptext="${i18n:_('Previous')}"
disabled="@{controller.firstMonth}" />
</div>
<label value="@{controller.date}" />
<div visible="@{controller.currentUser}">
<button id="nextMonth"
onClick="controller.nextMonth();" image="/common/img/ico_step_right.png"
tooltiptext="${i18n:_('Next')}" sclass="icono"
disabled="@{controller.lastMonth}" />
</div></hbox>
<hbox align="pack">
<div visible="@{controller.currentUser}">
<button id="previousMonth"
image="/common/img/ico_step_left.png" sclass="icono"
onClick="controller.previousMonth();"
tooltiptext="${i18n:_('Previous')}"
disabled="@{controller.firstMonth}" />
</div>
<label value="@{controller.timesheetString}" />
<div visible="@{controller.currentUser}">
<button id="nextMonth"
onClick="controller.nextMonth();" image="/common/img/ico_step_right.png"
tooltiptext="${i18n:_('Next')}" sclass="icono"
disabled="@{controller.lastMonth}" />
</div>
</hbox>
</row>
<row>
<label value="${i18n:_('Resource')}" />