git-svn-id: svn://svn.dsv.su.se/scipro/scipro/trunk@500 73ecded7-942e-4092-bab0-0e58ef0ee984
This commit is contained in:
parent
df519b40d3
commit
0109d53c3b
src/main
java/se/su/dsv/scipro/schedule
forms
models
panels
webapp/css
@ -66,7 +66,7 @@ public class ProjectEventForm extends EventForm<ProjectEventFormModel> {
|
||||
invalid();
|
||||
}
|
||||
|
||||
if(isValid()){
|
||||
if(!form.hasError()){
|
||||
model.persist();
|
||||
target.addComponent(WiQueryCoreEffectsHelper.fadeIn(parent.getListContainer(), EffectSpeed.FAST));
|
||||
parent.getDialog().close(target);
|
||||
|
@ -26,7 +26,7 @@ public abstract class EventFormModel<T extends Event> implements IClusterable {
|
||||
public EventFormModel(T e) {
|
||||
this.event = e;
|
||||
if(event.getDueDate() == null){
|
||||
event.setDueDate(new DateMidnight(new Date()).plusDays(1).toDate());
|
||||
event.setDueDate(new DateMidnight().plusDays(1).toDateTime().minusSeconds(1).toDate());
|
||||
}
|
||||
setTitle(event.getTitle());
|
||||
setDescription(event.getDescription());
|
||||
|
@ -7,6 +7,7 @@ import org.apache.wicket.injection.web.InjectorHolder;
|
||||
import org.apache.wicket.model.LoadableDetachableModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import org.joda.time.DateMidnight;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.EventDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Event;
|
||||
@ -20,63 +21,35 @@ public class EventListModel extends LoadableDetachableModel<List<Event>> {
|
||||
@SpringBean
|
||||
private EventDao eventDao;
|
||||
|
||||
private DateMidnight firstDateOfTimeSpan;
|
||||
private DateMidnight lastDateOfTimeSpan;
|
||||
private DateTime firstDateOfTimeSpan;
|
||||
private DateTime lastDateOfTimeSpan;
|
||||
|
||||
private Project project;
|
||||
|
||||
private User user;
|
||||
private User user = null;
|
||||
|
||||
private int count = 0;
|
||||
|
||||
public EventListModel(User u, Project p){
|
||||
this.user = u;
|
||||
public EventListModel(Project p){
|
||||
this.project = p;
|
||||
this.firstDateOfTimeSpan = new DateMidnight().withDayOfMonth(1);
|
||||
lastDateOfTimeSpan = firstDateOfTimeSpan.plusMonths(1).minusDays(1);
|
||||
this.firstDateOfTimeSpan = new DateMidnight().withDayOfMonth(1).toDateTime();
|
||||
lastDateOfTimeSpan = firstDateOfTimeSpan.plusMonths(1).minusSeconds(1);
|
||||
InjectorHolder.getInjector().inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Event> load() {
|
||||
System.out.println("Loading model");
|
||||
System.out.println("Start date:" + firstDateOfTimeSpan.toDate());
|
||||
System.out.println("End date:" + lastDateOfTimeSpan.toDate());
|
||||
System.out.println("Project id:" + project.getTitle());
|
||||
System.out.println("User:" + user);
|
||||
List<Event> list = eventDao.getEventsByUserAndProject(user, project, null,
|
||||
firstDateOfTimeSpan.toDate(), lastDateOfTimeSpan.toDate(), null);
|
||||
setCount(list.size());
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the first date of the time span the model is working with, don't forget to reload the model
|
||||
* @param firstDateOfTimeSpan
|
||||
*/
|
||||
public void setFirstDateOfTimeSpan(DateMidnight firstDateOfTimeSpan) {
|
||||
this.firstDateOfTimeSpan = firstDateOfTimeSpan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first date of the time span the model is working with
|
||||
* @return
|
||||
*/
|
||||
public DateMidnight getFirstDateOfTimeSpan() {
|
||||
return firstDateOfTimeSpan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the last date of the time span the model is working with, don't forget to reload the model
|
||||
* @param lastDateOfTimeSpan
|
||||
*/
|
||||
public void setLastDateOfTimeSpan(DateMidnight lastDateOfTimeSpan) {
|
||||
this.lastDateOfTimeSpan = lastDateOfTimeSpan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last date of the time span the model is working with
|
||||
* @return
|
||||
*/
|
||||
public DateMidnight getLastDateOfTimeSpan() {
|
||||
return lastDateOfTimeSpan;
|
||||
}
|
||||
|
||||
private void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
@ -96,8 +69,8 @@ public class EventListModel extends LoadableDetachableModel<List<Event>> {
|
||||
*/
|
||||
public void plusMonths(int numMonths){
|
||||
firstDateOfTimeSpan = firstDateOfTimeSpan.plusMonths(numMonths);
|
||||
lastDateOfTimeSpan = firstDateOfTimeSpan.plusMonths(1);
|
||||
setObject(load());
|
||||
lastDateOfTimeSpan = firstDateOfTimeSpan.plusMonths(1).minusSeconds(1);
|
||||
reload();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,8 +80,8 @@ public class EventListModel extends LoadableDetachableModel<List<Event>> {
|
||||
*/
|
||||
public void minusMonths(int numMonths){
|
||||
firstDateOfTimeSpan = firstDateOfTimeSpan.minusMonths(numMonths);
|
||||
lastDateOfTimeSpan = firstDateOfTimeSpan.plusMonths(1);
|
||||
setObject(load());
|
||||
lastDateOfTimeSpan = firstDateOfTimeSpan.plusMonths(1).minusSeconds(1);
|
||||
reload();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -124,8 +97,9 @@ public class EventListModel extends LoadableDetachableModel<List<Event>> {
|
||||
* @param date
|
||||
*/
|
||||
public void setMonthFromDate(Date date){
|
||||
firstDateOfTimeSpan = new DateMidnight(date).withDayOfMonth(1);
|
||||
lastDateOfTimeSpan = firstDateOfTimeSpan.plusMonths(1);
|
||||
firstDateOfTimeSpan = new DateMidnight(date).withDayOfMonth(1).toDateTime();
|
||||
lastDateOfTimeSpan = firstDateOfTimeSpan.plusMonths(1).minusSeconds(1);
|
||||
reload();
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
@ -134,7 +108,7 @@ public class EventListModel extends LoadableDetachableModel<List<Event>> {
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
setObject(load());
|
||||
reload();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public class SchedulePlannerPanel extends Panel implements ISchedulePlannerPanel
|
||||
|
||||
public void setup(){
|
||||
|
||||
eventsModel = new EventListModel(user, project);
|
||||
eventsModel = new EventListModel(project);
|
||||
|
||||
dialogContainer = new WebMarkupContainer("dialogContainer");
|
||||
dialogContainer.setOutputMarkupId(true);
|
||||
@ -235,6 +235,7 @@ public class SchedulePlannerPanel extends Panel implements ISchedulePlannerPanel
|
||||
}
|
||||
|
||||
public WebMarkupContainer getListContainer(){
|
||||
eventsModel.reload();
|
||||
return eventListContainer;
|
||||
}
|
||||
|
||||
|
@ -423,6 +423,10 @@ form.dialogForm {
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.action-icon {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.icon-64 {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
|
Loading…
x
Reference in New Issue
Block a user