diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/Util.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/Util.java
index 7b26862c5..8fbbacb36 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/common/Util.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/Util.java
@@ -708,13 +708,18 @@ public class Util {
* {@link Row} for the edit operation.
*
* The edit button will call the editButtonListener when
- * clicked and the remove button the removeButtonListener.
+ * clicked and the remove button the removeButtonListener.
+ *
+ * If removeButtonListener is null, it only adds the edit
+ * button and the ON_CLICK event.
*/
public static void appendOperationsAndOnClickEvent(Row row,
EventListener editButtonListener, EventListener removeButtonListener) {
Hbox hbox = new Hbox();
hbox.appendChild(Util.createEditButton(editButtonListener));
- hbox.appendChild(Util.createRemoveButton(removeButtonListener));
+ if (removeButtonListener != null) {
+ hbox.appendChild(Util.createRemoveButton(removeButtonListener));
+ }
row.appendChild(hbox);
row.addEventListener(Events.ON_CLICK, editButtonListener);
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/LocalDateConverter.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/LocalDateConverter.java
new file mode 100644
index 000000000..c209aedf5
--- /dev/null
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/converters/LocalDateConverter.java
@@ -0,0 +1,58 @@
+/*
+ * This file is part of LibrePlan
+ *
+ * Copyright (C) 2012 Igalia, S.L.
+ *
+ * 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 Affero 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 .
+ */
+
+package org.libreplan.web.common.converters;
+
+import org.joda.time.LocalDate;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * A {@link IConverter} for {@link LocalDate} objects.
+ *
+ * @author Manuel Rego Casasnovas
+ */
+@Component
+@Scope(BeanDefinition.SCOPE_SINGLETON)
+public class LocalDateConverter implements IConverter {
+
+ @Override
+ @Transactional(readOnly = true)
+ public LocalDate asObject(String stringRepresentation) {
+ return new LocalDate(stringRepresentation);
+ }
+
+ @Override
+ public String asString(LocalDate entity) {
+ return entity.toString();
+ }
+
+ @Override
+ public Class getType() {
+ return LocalDate.class;
+ }
+
+ @Override
+ public String asStringUngeneric(Object entity) {
+ return asString(getType().cast(entity));
+ }
+
+}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/dashboard/IMonthlyTimesheetController.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/dashboard/IMonthlyTimesheetController.java
new file mode 100644
index 000000000..a84637d5a
--- /dev/null
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/dashboard/IMonthlyTimesheetController.java
@@ -0,0 +1,37 @@
+/*
+ * This file is part of LibrePlan
+ *
+ * Copyright (C) 2012 Igalia, S.L.
+ *
+ * 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 Affero 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 .
+ */
+
+package org.libreplan.web.users.dashboard;
+
+import org.joda.time.LocalDate;
+import org.libreplan.web.common.entrypoints.EntryPoint;
+import org.libreplan.web.common.entrypoints.EntryPoints;
+
+/**
+ * Entry points for monthly timesheet creation/edition window
+ *
+ * @author Manuel Rego Casasnovas
+ */
+@EntryPoints(page = "/myaccount/monthlyTimesheet.zul", registerAs = "monthlyTimesheetController")
+public interface IMonthlyTimesheetController {
+
+ @EntryPoint("edit")
+ void goToCreateOrEditForm(LocalDate date);
+
+}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/dashboard/IMonthlyTimesheetModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/dashboard/IMonthlyTimesheetModel.java
new file mode 100644
index 000000000..f4b764266
--- /dev/null
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/dashboard/IMonthlyTimesheetModel.java
@@ -0,0 +1,39 @@
+/*
+ * This file is part of LibrePlan
+ *
+ * Copyright (C) 2012 Igalia, S.L.
+ *
+ * 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 Affero 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 .
+ */
+
+package org.libreplan.web.users.dashboard;
+
+import org.joda.time.LocalDate;
+
+/**
+ * Interface for creation/edition of a monthly timesheet model
+ *
+ * @author Manuel Rego Casasnovas
+ */
+public interface IMonthlyTimesheetModel {
+
+ /**
+ * Edits the monthly timesheet for the specified date and resource bound to
+ * current user or creates a new one if it doesn't exist yet.
+ */
+ void initCreateOrEdit(LocalDate date);
+
+ LocalDate getDate();
+
+}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/dashboard/MonthlyTimesheetController.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/dashboard/MonthlyTimesheetController.java
new file mode 100644
index 000000000..1ad3920d7
--- /dev/null
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/dashboard/MonthlyTimesheetController.java
@@ -0,0 +1,58 @@
+/*
+ * This file is part of LibrePlan
+ *
+ * Copyright (C) 2012 Igalia, S.L.
+ *
+ * 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 Affero 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 .
+ */
+
+package org.libreplan.web.users.dashboard;
+
+import org.joda.time.LocalDate;
+import org.libreplan.web.common.entrypoints.IURLHandlerRegistry;
+import org.zkoss.zk.ui.Component;
+import org.zkoss.zk.ui.util.GenericForwardComposer;
+
+/**
+ * Controller for creation/edition of a monthly timesheet
+ *
+ * @author Manuel Rego Casasnovas
+ */
+@SuppressWarnings("serial")
+public class MonthlyTimesheetController extends GenericForwardComposer
+ implements IMonthlyTimesheetController {
+
+ private IMonthlyTimesheetModel monthlyTimesheetModel;
+
+ private IURLHandlerRegistry URLHandlerRegistry;
+
+ @Override
+ public void doAfterCompose(Component comp) throws Exception {
+ super.doAfterCompose(comp);
+ comp.setAttribute("controller", this);
+
+ URLHandlerRegistry.getRedirectorFor(IMonthlyTimesheetController.class)
+ .register(this, page);
+ }
+
+ @Override
+ public void goToCreateOrEditForm(LocalDate date) {
+ monthlyTimesheetModel.initCreateOrEdit(date);
+ }
+
+ public LocalDate getDate() {
+ return monthlyTimesheetModel.getDate();
+ }
+
+}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/dashboard/MonthlyTimesheetModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/dashboard/MonthlyTimesheetModel.java
new file mode 100644
index 000000000..7c02ef9a8
--- /dev/null
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/dashboard/MonthlyTimesheetModel.java
@@ -0,0 +1,50 @@
+/*
+ * This file is part of LibrePlan
+ *
+ * Copyright (C) 2012 Igalia, S.L.
+ *
+ * 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 Affero 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 .
+ */
+
+package org.libreplan.web.users.dashboard;
+
+import org.joda.time.LocalDate;
+import org.libreplan.web.common.concurrentdetection.OnConcurrentModification;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+/**
+ * Model for creation/edition of a monthly timesheet
+ *
+ * @author Manuel Rego Casasnovas
+ */
+@Service
+@Scope(BeanDefinition.SCOPE_PROTOTYPE)
+@OnConcurrentModification(goToPage = "/myaccount/userDashboard.zul")
+public class MonthlyTimesheetModel implements IMonthlyTimesheetModel {
+
+ private LocalDate date;
+
+ @Override
+ public void initCreateOrEdit(LocalDate date) {
+ this.date = date;
+ }
+
+ @Override
+ public LocalDate getDate() {
+ return date;
+ }
+
+}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/dashboard/MonthlyTimesheetsAreaController.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/dashboard/MonthlyTimesheetsAreaController.java
index 8dd423b21..6e8037c0e 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/users/dashboard/MonthlyTimesheetsAreaController.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/dashboard/MonthlyTimesheetsAreaController.java
@@ -21,10 +21,14 @@ package org.libreplan.web.users.dashboard;
import java.util.List;
+import javax.annotation.Resource;
+
import org.joda.time.LocalDate;
import org.libreplan.business.workreports.entities.WorkReport;
import org.libreplan.web.common.Util;
import org.zkoss.zk.ui.Component;
+import org.zkoss.zk.ui.event.Event;
+import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Row;
import org.zkoss.zul.RowRenderer;
@@ -39,14 +43,26 @@ public class MonthlyTimesheetsAreaController extends GenericForwardComposer {
private IMonthlyTimesheetsAreaModel monthlyTimesheetsAreaModel;
+ @Resource
+ private IMonthlyTimesheetController monthlyTimesheetController;
+
private RowRenderer monthlyTimesheetsRenderer = new RowRenderer() {
@Override
public void render(Row row, Object data) throws Exception {
- MonthlyTimesheet monthlyTimesheet = (MonthlyTimesheet) data;
+ final MonthlyTimesheet monthlyTimesheet = (MonthlyTimesheet) data;
row.setValue(monthlyTimesheet);
Util.appendLabel(row, monthlyTimesheet.getDate().toString("MMMM y"));
+
+ Util.appendOperationsAndOnClickEvent(row, new EventListener() {
+
+ @Override
+ public void onEvent(Event event) throws Exception {
+ monthlyTimesheetController.goToCreateOrEditForm(monthlyTimesheet
+ .getDate());
+ }
+ }, null);
}
};
diff --git a/libreplan-webapp/src/main/webapp/myaccount/_monthlyTimesheetsArea.zul b/libreplan-webapp/src/main/webapp/myaccount/_monthlyTimesheetsArea.zul
index 5a489f85e..439bb137e 100644
--- a/libreplan-webapp/src/main/webapp/myaccount/_monthlyTimesheetsArea.zul
+++ b/libreplan-webapp/src/main/webapp/myaccount/_monthlyTimesheetsArea.zul
@@ -25,6 +25,7 @@
pageSize="10" rowRenderer="@{controller.monthlyTimesheetsRenderer}">
+
diff --git a/libreplan-webapp/src/main/webapp/myaccount/monthlyTimesheet.zul b/libreplan-webapp/src/main/webapp/myaccount/monthlyTimesheet.zul
new file mode 100644
index 000000000..99e3a97a7
--- /dev/null
+++ b/libreplan-webapp/src/main/webapp/myaccount/monthlyTimesheet.zul
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file