Implement navigation between personal timesheets depending on periodicity
FEA: ItEr77S07PersonalTimesheetsPeriodictyConfiguration
This commit is contained in:
parent
6ce91d6da9
commit
425a16d093
4 changed files with 67 additions and 2 deletions
|
|
@ -52,6 +52,16 @@ public enum PersonalTimesheetsPeriodicityEnum {
|
|||
public LocalDate getDateForItemFromDate(int item, LocalDate fromDate) {
|
||||
return fromDate.plusMonths(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate previous(LocalDate date) {
|
||||
return getStart(date).minusMonths(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate next(LocalDate date) {
|
||||
return getStart(date).plusMonths(1);
|
||||
}
|
||||
},
|
||||
TWICE_MONTHLY(_("Twice-monthly")) {
|
||||
@Override
|
||||
|
|
@ -90,6 +100,25 @@ public enum PersonalTimesheetsPeriodicityEnum {
|
|||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate previous(LocalDate date) {
|
||||
if (date.getDayOfMonth() <= 15) {
|
||||
return date.minusMonths(1).dayOfMonth().withMinimumValue()
|
||||
.plusDays(15);
|
||||
} else {
|
||||
return date.dayOfMonth().withMinimumValue();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate next(LocalDate date) {
|
||||
if (date.getDayOfMonth() <= 15) {
|
||||
return date.dayOfMonth().withMinimumValue().plusDays(15);
|
||||
} else {
|
||||
return date.plusMonths(1).dayOfMonth().withMinimumValue();
|
||||
}
|
||||
}
|
||||
},
|
||||
WEEKLY(_("Weekly")) {
|
||||
@Override
|
||||
|
|
@ -111,6 +140,16 @@ public enum PersonalTimesheetsPeriodicityEnum {
|
|||
public LocalDate getDateForItemFromDate(int item, LocalDate fromDate) {
|
||||
return fromDate.plusWeeks(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate previous(LocalDate date) {
|
||||
return getStart(date).minusWeeks(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate next(LocalDate date) {
|
||||
return getStart(date).plusWeeks(1);
|
||||
}
|
||||
};
|
||||
|
||||
private String name;
|
||||
|
|
@ -132,4 +171,8 @@ public enum PersonalTimesheetsPeriodicityEnum {
|
|||
public abstract LocalDate getDateForItemFromDate(int item,
|
||||
LocalDate fromDate);
|
||||
|
||||
public abstract LocalDate previous(LocalDate date);
|
||||
|
||||
public abstract LocalDate next(LocalDate date);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,4 +217,16 @@ public interface IMonthlyTimesheetModel {
|
|||
*/
|
||||
String getTimesheetString();
|
||||
|
||||
/**
|
||||
* Returns the previous personal timesheet to the current one depending on
|
||||
* the configured periodicity.
|
||||
*/
|
||||
LocalDate getPrevious();
|
||||
|
||||
/**
|
||||
* Returns the next personal timesheet to the current one depending on the
|
||||
* configured periodicity.
|
||||
*/
|
||||
LocalDate getNext();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -679,7 +679,7 @@ public class MonthlyTimesheetController extends GenericForwardComposer
|
|||
previousMonth,
|
||||
_("There are unsaved changes in the current personal timesheet, please save before moving"));
|
||||
}
|
||||
sendToMonthlyTimesheet(monthlyTimesheetModel.getDate().minusMonths(1));
|
||||
sendToMonthlyTimesheet(monthlyTimesheetModel.getPrevious());
|
||||
}
|
||||
|
||||
public void nextMonth() {
|
||||
|
|
@ -689,7 +689,7 @@ public class MonthlyTimesheetController extends GenericForwardComposer
|
|||
_("There are unsaved changes in the current personal timesheet, please save before moving"));
|
||||
}
|
||||
|
||||
sendToMonthlyTimesheet(monthlyTimesheetModel.getDate().plusMonths(1));
|
||||
sendToMonthlyTimesheet(monthlyTimesheetModel.getNext());
|
||||
}
|
||||
|
||||
private void sendToMonthlyTimesheet(final LocalDate date) {
|
||||
|
|
|
|||
|
|
@ -571,4 +571,14 @@ public class MonthlyTimesheetModel implements IMonthlyTimesheetModel {
|
|||
return MonthlyTimesheetDTO.toString(periodicity, date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate getPrevious() {
|
||||
return periodicity.previous(date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate getNext() {
|
||||
return periodicity.next(date);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue