Add new field to configure seconds for planning warning
FEA: ItEr77S03Community
This commit is contained in:
parent
c4f8dc9f50
commit
805f65b9ea
8 changed files with 95 additions and 25 deletions
|
|
@ -23,6 +23,7 @@ package org.libreplan.business.common.entities;
|
|||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.hibernate.validator.AssertTrue;
|
||||
import org.hibernate.validator.Min;
|
||||
import org.hibernate.validator.NotEmpty;
|
||||
import org.hibernate.validator.NotNull;
|
||||
import org.libreplan.business.calendars.entities.BaseCalendar;
|
||||
|
|
@ -113,6 +114,8 @@ public class Configuration extends BaseEntity {
|
|||
|
||||
private PersonalTimesheetsPeriodicityEnum personalTimesheetsPeriodicity = PersonalTimesheetsPeriodicityEnum.MONTHLY;
|
||||
|
||||
private Integer secondsPlanningWarning = 30;
|
||||
|
||||
/**
|
||||
* Maximum users configurable directly in database for SaaS products. If
|
||||
* zero it means that there isn't any limitation.
|
||||
|
|
@ -490,4 +493,14 @@ public class Configuration extends BaseEntity {
|
|||
return maxResources;
|
||||
}
|
||||
|
||||
@Min(value = 0, message = "seconds planning warning cannot be negative")
|
||||
@NotNull(message = "seconds planning warning not specified")
|
||||
public Integer getSecondsPlanningWarning() {
|
||||
return secondsPlanningWarning;
|
||||
}
|
||||
|
||||
public void setSecondsPlanningWarning(Integer secondsPlanningWarning) {
|
||||
this.secondsPlanningWarning = secondsPlanningWarning;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,4 +193,19 @@
|
|||
constraintName="order_element_code_key" />
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="add-seconds_planning_warning-column-to-configuration"
|
||||
author="mrego">
|
||||
<comment>Add seconds_planning_warning column to configuration</comment>
|
||||
<addColumn tableName="configuration">
|
||||
<column name="seconds_planning_warning" type="INTEGER" />
|
||||
</addColumn>
|
||||
<update tableName="configuration">
|
||||
<column name="seconds_planning_warning" value="30" />
|
||||
</update>
|
||||
<addNotNullConstraint tableName="configuration"
|
||||
columnName="seconds_planning_warning"
|
||||
defaultNullValue="30"
|
||||
columnDataType="INTEGER" />
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
|
|
|
|||
|
|
@ -91,6 +91,9 @@
|
|||
<property name="maxUsers" column="max_users" />
|
||||
<property name="maxResources" column="max_resources" />
|
||||
|
||||
<property name="secondsPlanningWarning" not-null="true"
|
||||
column="seconds_planning_warning" />
|
||||
|
||||
<component name="ldapConfiguration" class="org.libreplan.business.common.entities.LDAPConfiguration">
|
||||
<property name="ldapHost" column="ldap_host"/>
|
||||
<property name="ldapPort" column="ldap_port"/>
|
||||
|
|
|
|||
|
|
@ -915,4 +915,12 @@ public class ConfigurationController extends GenericForwardComposer {
|
|||
return "";
|
||||
}
|
||||
|
||||
public Integer getSecondsPlanningWarning() {
|
||||
return configurationModel.getSecondsPlanningWarning();
|
||||
}
|
||||
|
||||
public void setSecondsPlanningWarning(Integer secondsPlanningWarning) {
|
||||
configurationModel.setSecondsPlanningWarning(secondsPlanningWarning);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -657,4 +657,14 @@ public class ConfigurationModel implements IConfigurationModel {
|
|||
return !workReportDAO.isAnyPersonalTimesheetAlreadySaved();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getSecondsPlanningWarning() {
|
||||
return configuration.getSecondsPlanningWarning();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecondsPlanningWarning(Integer secondsPlanningWarning) {
|
||||
configuration.setSecondsPlanningWarning(secondsPlanningWarning);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.libreplan.web.common;
|
||||
|
||||
import org.libreplan.business.common.Registry;
|
||||
import org.zkoss.ganttz.util.LongOperationFeedback;
|
||||
import org.zkoss.ganttz.util.LongOperationFeedback.IBackGroundOperation;
|
||||
import org.zkoss.ganttz.util.LongOperationFeedback.IDesktopUpdate;
|
||||
|
|
@ -32,37 +33,41 @@ import org.zkoss.zk.ui.util.Clients;
|
|||
*/
|
||||
public class ConfirmCloseUtil {
|
||||
|
||||
private static final int WARNING_ON_EXIT_MS = 30000; // 30 seconds
|
||||
|
||||
public static void resetConfirmClose() {
|
||||
Clients.confirmClose(null);
|
||||
}
|
||||
|
||||
public static void setConfirmClose(Desktop desktop, final String message) {
|
||||
LongOperationFeedback
|
||||
.progressive(
|
||||
desktop,
|
||||
new IBackGroundOperation<LongOperationFeedback.IDesktopUpdate>() {
|
||||
final Integer seconds = Registry.getConfigurationDAO()
|
||||
.getConfigurationWithReadOnlyTransaction()
|
||||
.getSecondsPlanningWarning();
|
||||
|
||||
@Override
|
||||
public void doOperation(
|
||||
IDesktopUpdatesEmitter<IDesktopUpdate> desktopUpdateEmitter) {
|
||||
try {
|
||||
Thread.sleep(WARNING_ON_EXIT_MS);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
if (seconds > 0) {
|
||||
LongOperationFeedback
|
||||
.progressive(
|
||||
desktop,
|
||||
new IBackGroundOperation<LongOperationFeedback.IDesktopUpdate>() {
|
||||
|
||||
@Override
|
||||
public void doOperation(
|
||||
IDesktopUpdatesEmitter<IDesktopUpdate> desktopUpdateEmitter) {
|
||||
try {
|
||||
Thread.sleep(seconds * 1000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
desktopUpdateEmitter
|
||||
.doUpdate(new IDesktopUpdate() {
|
||||
|
||||
@Override
|
||||
public void doUpdate() {
|
||||
resetConfirmClose();
|
||||
Clients.confirmClose(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
desktopUpdateEmitter
|
||||
.doUpdate(new IDesktopUpdate() {
|
||||
|
||||
@Override
|
||||
public void doUpdate() {
|
||||
resetConfirmClose();
|
||||
Clients.confirmClose(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -180,4 +180,9 @@ public interface IConfigurationModel {
|
|||
|
||||
boolean isAnyPersonalTimesheetAlreadySaved();
|
||||
|
||||
Integer getSecondsPlanningWarning();
|
||||
|
||||
void setSecondsPlanningWarning(
|
||||
Integer planningWarningExitWithoutSavingSeconds);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,6 +209,17 @@
|
|||
label="${i18n:_('MonteCarlo method')}"
|
||||
checked="@{configurationController.monteCarloMethodTabVisible}" />
|
||||
</row>
|
||||
<row>
|
||||
<label
|
||||
value="${i18n:_('Seconds planning warning')}" />
|
||||
<hbox>
|
||||
<intbox width="50px"
|
||||
value="@{configurationController.secondsPlanningWarning}"
|
||||
constraint="no empty,no negative:${i18n:_('cannot be negative or empty')}" />
|
||||
<label
|
||||
value="${i18n:_('Defines the time since last saving operation at project planning perspectives after which a warning is raised on leaving. Set to 0 in order to disable the warning.')}" />
|
||||
</hbox>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</tabpanel>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue