Add edit button in monthly timesheets list
For the moment the edit button just send the user to a page that shows the monthly timesheet date using entry points. FEA: ItEr76S28UserDashboard
This commit is contained in:
parent
7261ab856b
commit
64f8f83c05
9 changed files with 303 additions and 3 deletions
|
|
@ -708,13 +708,18 @@ public class Util {
|
|||
* {@link Row} for the edit operation.<br />
|
||||
*
|
||||
* The edit button will call the <code>editButtonListener</code> when
|
||||
* clicked and the remove button the <code>removeButtonListener</code>.
|
||||
* clicked and the remove button the <code>removeButtonListener</code>.<br />
|
||||
*
|
||||
* If <code>removeButtonListener</code> is null, it only adds the edit
|
||||
* button and the <code>ON_CLICK</code> 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);
|
||||
|
|
|
|||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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 <mrego@igalia.com>
|
||||
*/
|
||||
@Component
|
||||
@Scope(BeanDefinition.SCOPE_SINGLETON)
|
||||
public class LocalDateConverter implements IConverter<LocalDate> {
|
||||
|
||||
@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<LocalDate> getType() {
|
||||
return LocalDate.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asStringUngeneric(Object entity) {
|
||||
return asString(getType().cast(entity));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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 <mrego@igalia.com>
|
||||
*/
|
||||
@EntryPoints(page = "/myaccount/monthlyTimesheet.zul", registerAs = "monthlyTimesheetController")
|
||||
public interface IMonthlyTimesheetController {
|
||||
|
||||
@EntryPoint("edit")
|
||||
void goToCreateOrEditForm(LocalDate date);
|
||||
|
||||
}
|
||||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.libreplan.web.users.dashboard;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
/**
|
||||
* Interface for creation/edition of a monthly timesheet model
|
||||
*
|
||||
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
||||
*/
|
||||
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();
|
||||
|
||||
}
|
||||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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 <mrego@igalia.com>
|
||||
*/
|
||||
@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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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 <mrego@igalia.com>
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
pageSize="10" rowRenderer="@{controller.monthlyTimesheetsRenderer}">
|
||||
<columns sizable="true">
|
||||
<column label="${i18n:_('Date')}" />
|
||||
<column label="${i18n:_('Operations')}" />
|
||||
</columns>
|
||||
</grid>
|
||||
</groupbox>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
<!--
|
||||
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
|
||||
<http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<?page id="exceptionDayTypesList" title="${i18n:_('LibrePlan: Monthly timesheet')}" ?>
|
||||
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
|
||||
<?init class="org.zkoss.zk.ui.util.Composition" arg0="/common/layout/template.zul"?>
|
||||
|
||||
<?link rel="shortcut icon" href="/common/img/favicon.ico" type="image/x-icon"?>
|
||||
<?link rel="stylesheet" type="text/css" href="/common/css/libreplan.css"?>
|
||||
<?link rel="stylesheet" type="text/css" href="/common/css/libreplan_zk.css"?>
|
||||
|
||||
<zk>
|
||||
<window apply="org.libreplan.web.users.dashboard.MonthlyTimesheetController"
|
||||
self="@{define(content)}" title="${i18n:_('Monthly timesheet')}">
|
||||
|
||||
<label value="@{controller.date}" />
|
||||
|
||||
</window>
|
||||
</zk>
|
||||
Loading…
Add table
Reference in a new issue