ItEr41S26CUListaSubcontratas: First revision of the web interface to list ExternalCompany objects

This commit is contained in:
Jacobo Aragunde Pérez 2010-01-04 15:58:24 +01:00 committed by Javier Moran Rua
parent 78b005d3f9
commit 4ea2c8c80a
7 changed files with 332 additions and 0 deletions

View file

@ -0,0 +1,90 @@
/*
* This file is part of ###PROJECT_NAME###
*
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
*
* 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.navalplanner.web.externalcompanies;
import java.util.List;
import org.navalplanner.business.externalcompanies.entities.ExternalCompany;
import org.navalplanner.business.users.entities.User;
import org.navalplanner.web.common.IMessagesForUser;
import org.navalplanner.web.common.MessagesForUser;
import org.navalplanner.web.common.OnlyOneVisible;
import org.navalplanner.web.common.Util;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Window;
/**
* Controller for CRUD actions over a {@link User}
*
* @author Jacobo Aragunde Perez <jaragunde@igalia.com>
*/
@SuppressWarnings("serial")
public class ExternalCompanyCRUDController extends GenericForwardComposer
implements IExternalCompanyCRUDController {
private IExternalCompanyModel externalCompanyModel;
private Window createWindow;
private Window listWindow;
private OnlyOneVisible visibility;
private IMessagesForUser messagesForUser;
private Component messagesContainer;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
comp.setVariable("controller", this, true);
messagesForUser = new MessagesForUser(messagesContainer);
getVisibility().showOnly(listWindow);
}
@Override
public void goToCreateForm() {
// TODO implement
}
@Override
public void goToEditForm(ExternalCompany company) {
// TODO implement
}
@Override
public void goToList() {
getVisibility().showOnly(listWindow);
Util.reloadBindings(listWindow);
}
public List<ExternalCompany> getCompanies() {
return externalCompanyModel.getCompanies();
}
private OnlyOneVisible getVisibility() {
return (visibility == null) ? new OnlyOneVisible(createWindow,
listWindow)
: visibility;
}
}

View file

@ -0,0 +1,49 @@
/*
* This file is part of ###PROJECT_NAME###
*
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
*
* 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.navalplanner.web.externalcompanies;
import java.util.List;
import org.navalplanner.business.externalcompanies.daos.IExternalCompanyDAO;
import org.navalplanner.business.externalcompanies.entities.ExternalCompany;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
/**
* Model for UI operations related to {@link ExternalCompany}
*
* @author Jacobo Aragunde Perez <jaragunde@igalia.com>
*/
@Service
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class ExternalCompanyModel implements IExternalCompanyModel {
@Autowired
private IExternalCompanyDAO externalCompanyDAO;
@Override
public List<ExternalCompany> getCompanies() {
return externalCompanyDAO.list(ExternalCompany.class);
}
}

View file

@ -0,0 +1,38 @@
/*
* This file is part of ###PROJECT_NAME###
*
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
*
* 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.navalplanner.web.externalcompanies;
import org.navalplanner.business.externalcompanies.entities.ExternalCompany;
import org.navalplanner.web.common.entrypoints.EntryPoint;
import org.navalplanner.web.common.entrypoints.EntryPoints;
@EntryPoints(page = "/externalcompanies/externalcompanies.zul", registerAs = "externalCompanyCRUD")
public interface IExternalCompanyCRUDController {
@EntryPoint("edit")
public abstract void goToEditForm(ExternalCompany company);
@EntryPoint("create")
public abstract void goToCreateForm();
@EntryPoint("list")
public abstract void goToList();
}

View file

@ -0,0 +1,40 @@
/*
* This file is part of ###PROJECT_NAME###
*
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
*
* 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.navalplanner.web.externalcompanies;
import java.util.List;
import org.navalplanner.business.externalcompanies.entities.ExternalCompany;
/**
* Model for UI operations related to {@link ExternalCompany}
*
* @author Jacobo Aragunde Perez <jaragunde@igalia.com>
*/
public interface IExternalCompanyModel {
/**
* Lists all the {@link ExternalCompany} objects available in the system.
*
* @return A list of {@link ExternalCompany} objects.
*/
List<ExternalCompany> getCompanies();
}

View file

@ -0,0 +1,25 @@
<!--
This file is part of ###PROJECT_NAME###
Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
Desenvolvemento Tecnolóxico de Galicia
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/>.
-->
<?taglib uri="/WEB-INF/tld/i18n.tld" prefix="i18n" ?>
<window id="${arg.top_id}" title="${i18n:_('Edit external company')}">
</window>

View file

@ -0,0 +1,52 @@
<!--
This file is part of ###PROJECT_NAME###
Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
Desenvolvemento Tecnolóxico de Galicia
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/>.
-->
<window id="${arg.top_id}" title="${i18n:_('External companies listing')}">
<newdatasortablegrid id="listing" model="@{controller.companies}" mold="paging"
pageSize="10">
<columns sizable="true">
<newdatasortablecolumn label="${i18n:_('Name')}" sort="auto(name)" />
<newdatasortablecolumn label="${i18n:_('NIF')}" />
<newdatasortablecolumn label="${i18n:_('Client')}" />
<newdatasortablecolumn label="${i18n:_('Subcontractor')}" />
<newdatasortablecolumn label="${i18n:_('Integrated user')}" />
<newdatasortablecolumn label="${i18n:_('Actions')}" />
</columns>
<rows>
<row self="@{each='company'}" value="@{company}">
<label value="@{company.name}" />
<label value="@{company.nif}" />
<checkbox checked="@{company.client}" disabled="true" />
<checkbox checked="@{company.subcontractor}" disabled="true" />
<label value="@{company.companyUser.loginName}" />
<hbox>
<button sclass="icono" image="/common/img/ico_editar1.png"
hoverImage="/common/img/ico_editar.png"
tooltiptext="${i18n:_('Edit')}"
onClick="">
</button>
</hbox>
</row>
</rows>
</newdatasortablegrid>
<button id="show_create_form" onClick=""
label="${i18n:_('Create')}" sclass="create-button global-action" >
</button>
</window>

View file

@ -0,0 +1,38 @@
<!--
This file is part of ###PROJECT_NAME###
Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
Desenvolvemento Tecnolóxico de Galicia
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/>.
-->
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<?page id="work_report_admin"?>
<?init class="org.zkoss.zk.ui.util.Composition" arg0="/common/layout/template.zul"?>
<?link rel="stylesheet" type="text/css" href="/common/css/navalpro_v01.css"?>
<?link rel="stylesheet" type="text/css" href="/common/css/navalpro_zk.css"?>
<?link rel="stylesheet" type="text/css" href="/resources/css/resources.css"?>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<?component name="list" inline="true" macroURI="_listExternalCompanies.zul"?>
<?component name="edition" inline="true" macroURI="_editExternalCompany.zul"?>
<zk>
<window self="@{define(content)}"
apply="org.navalplanner.web.externalcompanies.ExternalCompanyCRUDController">
<vbox id="messagesContainer"></vbox>
<list top_id="listWindow" />
<edition top_id="createWindow" />
</window>
</zk>