Added "Delete all projects" button
This commit is contained in:
parent
0e7c846db3
commit
6be32a2161
4 changed files with 64 additions and 16 deletions
|
|
@ -26,7 +26,7 @@ import org.apache.commons.lang3.BooleanUtils;
|
|||
/**
|
||||
* This is a singleton that contains the compilation options passed from Maven.
|
||||
*
|
||||
* Currently we have three options:
|
||||
* Currently we have four options:
|
||||
* <ul>
|
||||
* <li>Enable/Disable the warning changing default password</li>
|
||||
* <li>
|
||||
|
|
@ -34,6 +34,7 @@ import org.apache.commons.lang3.BooleanUtils;
|
|||
* (such as wsreader, wswriter, wssubcontracting, manager, hresources, outsourcing and reports)
|
||||
* </li>
|
||||
* <li>Enable/Disable E-mail sending functionality</li>
|
||||
* <li>Enable/Disable "Delete all projects" button</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
|
|
@ -47,9 +48,11 @@ public class Configuration {
|
|||
|
||||
private Boolean defaultPasswordsControl;
|
||||
|
||||
private Boolean exampleUsersDisabled;
|
||||
private boolean exampleUsersDisabled;
|
||||
|
||||
private Boolean emailSendingEnabled;
|
||||
private boolean emailSendingEnabled;
|
||||
|
||||
private boolean deleteAllProjectsButtonDisabled;
|
||||
|
||||
private Configuration() {
|
||||
}
|
||||
|
|
@ -73,36 +76,35 @@ public class Configuration {
|
|||
this.defaultPasswordsControl = defaultPasswordsControl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the value of example users disabled compilation option.
|
||||
*/
|
||||
public static boolean isExampleUsersDisabled() {
|
||||
return BooleanUtils.isNotFalse(singleton.getExampleUsersDisabled());
|
||||
}
|
||||
|
||||
public Boolean getExampleUsersDisabled() {
|
||||
public boolean getExampleUsersDisabled() {
|
||||
return exampleUsersDisabled;
|
||||
}
|
||||
|
||||
public void setExampleUsersDisabled(Boolean exampleUsersDisabled) {
|
||||
public void setExampleUsersDisabled(boolean exampleUsersDisabled) {
|
||||
this.exampleUsersDisabled = exampleUsersDisabled;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the value of E-mail sending disabled compilation option.
|
||||
*/
|
||||
public static boolean isEmailSendingEnabled() {
|
||||
return BooleanUtils.isNotFalse(singleton.getEmailSendingEnabled());
|
||||
}
|
||||
|
||||
public Boolean getEmailSendingEnabled() {
|
||||
public boolean getEmailSendingEnabled() {
|
||||
return emailSendingEnabled;
|
||||
}
|
||||
|
||||
public void setEmailSendingEnabled(Boolean emailSendingEnabled) {
|
||||
public void setEmailSendingEnabled(boolean emailSendingEnabled) {
|
||||
this.emailSendingEnabled = emailSendingEnabled;
|
||||
}
|
||||
|
||||
public boolean isDeleteAllProjectsButtonDisabled() {
|
||||
return deleteAllProjectsButtonDisabled;
|
||||
}
|
||||
|
||||
public void setDeleteAllProjectsButtonDisabled(boolean deleteAllProjectsButtonDisabled) {
|
||||
this.deleteAllProjectsButtonDisabled = deleteAllProjectsButtonDisabled;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@
|
|||
<property name="defaultPasswordsControl" value="${default.passwordsControl}"/>
|
||||
<property name="exampleUsersDisabled" value="${default.exampleUsersDisabled}"/>
|
||||
<property name="emailSendingEnabled" value="${default.emailSendingEnabled}"/>
|
||||
<property name="deleteAllProjectsButtonDisabled" value="${default.deleteAllProjectsButtonDisabled}"/>
|
||||
</bean>
|
||||
|
||||
<bean id="scenarioManager" class="org.libreplan.business.scenarios.OnlyMainScenarioAwareManager"/>
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ package org.libreplan.web.orders;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.libreplan.business.calendars.entities.BaseCalendar;
|
||||
import org.libreplan.business.common.Configuration;
|
||||
import org.libreplan.business.common.Registry;
|
||||
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.libreplan.business.externalcompanies.entities.DeadlineCommunication;
|
||||
|
|
@ -77,7 +78,6 @@ import org.zkoss.zk.ui.event.Events;
|
|||
import org.zkoss.zk.ui.event.SelectEvent;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
import org.zkoss.zul.Button;
|
||||
import org.zkoss.zul.Checkbox;
|
||||
import org.zkoss.zul.Column;
|
||||
import org.zkoss.zul.Combobox;
|
||||
import org.zkoss.zul.Comboitem;
|
||||
|
|
@ -293,6 +293,22 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
|
||||
loadLabels();
|
||||
FilterUtils.writeProjectPlanningFilterChanged(false);
|
||||
|
||||
createDeleteAllProjectsButton();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is needed to create "Delete all projects" button,
|
||||
* that is visible only for developers on orders list page.
|
||||
*/
|
||||
private void createDeleteAllProjectsButton() {
|
||||
if (!isDeleteAllProjectsButtonDisabled()) {
|
||||
Button deleteAllProjectButton = new Button();
|
||||
deleteAllProjectButton.setLabel("Delete all projects");
|
||||
deleteAllProjectButton.setDisabled(isDeleteAllProjectsButtonDisabled());
|
||||
deleteAllProjectButton.addEventListener(Events.ON_CLICK, event -> deleteAllProjects());
|
||||
orderFilter.appendChild(deleteAllProjectButton);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadLabels() {
|
||||
|
|
@ -1798,4 +1814,29 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
return getOrder().getBudget().add(getResourcesBudget());
|
||||
}
|
||||
|
||||
private Boolean isDeleteAllProjectsButtonDisabled() {
|
||||
return Configuration.getInstance().isDeleteAllProjectsButtonDisabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be public!
|
||||
* Used in orders/_orderFilter.zul
|
||||
*/
|
||||
public void deleteAllProjects() {
|
||||
boolean canNotDelete = false;
|
||||
for (Order order : orderModel.getOrders()) {
|
||||
try {
|
||||
orderModel.remove(order);
|
||||
} catch (Exception ignored) {
|
||||
canNotDelete = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (canNotDelete) {
|
||||
messagesForUser.showMessage(Level.ERROR, "Not all projects were removed") ;
|
||||
}
|
||||
listing.setModel(new SimpleListModel<>(orderModel.getOrders()));
|
||||
listing.invalidate();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
4
pom.xml
4
pom.xml
|
|
@ -35,6 +35,7 @@
|
|||
<default.passwordsControl>true</default.passwordsControl>
|
||||
<default.exampleUsersDisabled>true</default.exampleUsersDisabled>
|
||||
<default.emailSendingEnabled>true</default.emailSendingEnabled>
|
||||
<default.deleteAllProjectsButtonDisabled>true</default.deleteAllProjectsButtonDisabled>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
|
|
@ -94,6 +95,9 @@
|
|||
<!-- Enable example users
|
||||
(wsreader, wswriter, wssubcontracting, manager, hresources, outsourcing and reports) -->
|
||||
<default.exampleUsersDisabled>false</default.exampleUsersDisabled>
|
||||
|
||||
<!-- Enabling "Delete all projects" button -->
|
||||
<default.deleteAllProjectsButtonDisabled>false</default.deleteAllProjectsButtonDisabled>
|
||||
</properties>
|
||||
</profile>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue