Changed functional of logs page
Added saving of state between tab changes, code refactor
This commit is contained in:
parent
2d52ba4ddb
commit
d605ea1ae3
8 changed files with 149 additions and 2 deletions
|
|
@ -122,5 +122,8 @@ public interface IIssueLogModel {
|
|||
*/
|
||||
List<IssueLog> getByParent(Order order);
|
||||
|
||||
|
||||
/**
|
||||
* Setter for {@link IssueLog}
|
||||
*/
|
||||
void setIssueLog(IssueLog log);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,5 +122,9 @@ public interface IRiskLogModel {
|
|||
*/
|
||||
List<RiskLog> getByParent(Order order);
|
||||
|
||||
/**
|
||||
* Setter for {@link RiskLog}
|
||||
*/
|
||||
void setRisklog (RiskLog log);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,8 @@ public class IssueLogCRUDController extends BaseCRUDController<IssueLog> {
|
|||
|
||||
private Listbox status;
|
||||
|
||||
private boolean saved;
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
|
|
@ -436,6 +438,7 @@ public class IssueLogCRUDController extends BaseCRUDController<IssueLog> {
|
|||
}
|
||||
getIssueLog().setStatus(status.getSelectedItem().getLabel());
|
||||
issueLogModel.confirmSave();
|
||||
saved = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -448,5 +451,15 @@ public class IssueLogCRUDController extends BaseCRUDController<IssueLog> {
|
|||
issueLogModel.remove(entity);
|
||||
}
|
||||
|
||||
public void setIssueLogToModel (IssueLog log) {
|
||||
this.issueLogModel.setIssueLog(log);
|
||||
}
|
||||
|
||||
public Boolean isIssueLogSaved () {
|
||||
return saved;
|
||||
}
|
||||
|
||||
public void setDefaultStatus() {
|
||||
status.setSelectedIndex(0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,6 +144,11 @@ public class IssueLogModel extends IntegrationEntityModel implements IIssueLogMo
|
|||
return issueLogDAO.getByParent(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIssueLog(IssueLog log) {
|
||||
this.issueLog = log;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNameEnum getEntityName() {
|
||||
return EntityNameEnum.ISSUE_LOG;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@
|
|||
*/
|
||||
|
||||
package org.libreplan.web.logs;
|
||||
import org.libreplan.business.logs.entities.IssueLog;
|
||||
import org.libreplan.business.logs.entities.RiskLog;
|
||||
import org.libreplan.business.logs.entities.IssueTypeEnum;
|
||||
import org.libreplan.business.logs.entities.LowMediumHighEnum;
|
||||
import org.libreplan.business.logs.entities.RiskScoreStatesEnum;
|
||||
import org.libreplan.business.orders.entities.Order;
|
||||
import org.libreplan.web.common.Util;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
|
|
@ -50,6 +55,10 @@ public class LogsController extends GenericForwardComposer {
|
|||
|
||||
private static Order order = null;
|
||||
|
||||
private IssueLog issueLogInMemory = null;
|
||||
|
||||
private RiskLog riskLogInMemory = null;
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
|
|
@ -67,6 +76,28 @@ public class LogsController extends GenericForwardComposer {
|
|||
issueLogController = new IssueLogCRUDController();
|
||||
}
|
||||
try {
|
||||
// Saving risk log, if it was created, but not saved
|
||||
saveRiskLogState();
|
||||
|
||||
/*
|
||||
* Code below is needed to save issue log if it was created and changed, but not saved.
|
||||
* If the issue log was not saved - we set it to issue model and show when user go back to issue log tab.
|
||||
*/
|
||||
if (issueLogController.isIssueLogSaved()) {
|
||||
issueLogInMemory = null;
|
||||
}
|
||||
if (issueLogInMemory != null) {
|
||||
issueLogController.setIssueLogToModel(issueLogInMemory);
|
||||
issueLogController.doAfterCompose(issueLogWindow);
|
||||
issueLogController.goToEditForm(issueLogInMemory);
|
||||
issueLogController.setDefaultStatus();
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Normal logic flow: no issue log created, and not saved.
|
||||
* This will show to user issue log list.
|
||||
*/
|
||||
issueLogController.doAfterCompose(issueLogWindow);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
|
|
@ -81,6 +112,27 @@ public class LogsController extends GenericForwardComposer {
|
|||
riskLogController = new RiskLogCRUDController();
|
||||
}
|
||||
try {
|
||||
// Saving issue log, if it was created, but not saved.
|
||||
saveIssueLogState();
|
||||
|
||||
/*
|
||||
* Code below is needed to save risk log if it was created and changed, but not saved.
|
||||
* If the risk log was not saved - we set it to risk model and show when user go back to risk log tab.
|
||||
*/
|
||||
if (riskLogController.isRiskLogSaved()) {
|
||||
riskLogInMemory = null;
|
||||
}
|
||||
if (riskLogInMemory != null) {
|
||||
riskLogController.setRiskLogToModel(riskLogInMemory);
|
||||
riskLogController.doAfterCompose(riskLogWindow);
|
||||
riskLogController.goToEditForm(riskLogInMemory);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Normal logic flow: no risk log created, and not saved.
|
||||
* This will show to user risk log list.
|
||||
*/
|
||||
riskLogController.doAfterCompose(riskLogWindow);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
|
|
@ -104,4 +156,59 @@ public class LogsController extends GenericForwardComposer {
|
|||
public static Order getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
private boolean isIssueLogChanged() {
|
||||
if (issueLogController.getIssueLog() != null) {
|
||||
IssueLog issueLog = issueLogController.getIssueLog();
|
||||
|
||||
// "Date raised" and "Created by" are not handled
|
||||
if (!(issueLog.getOrder() == null &&
|
||||
issueLog.getType() == IssueTypeEnum.getDefault() &&
|
||||
"LOW".equals(issueLog.getStatus()) &&
|
||||
issueLog.getDescription() == null &&
|
||||
issueLog.getPriority() == LowMediumHighEnum.getDefault() &&
|
||||
issueLog.getSeverity() == LowMediumHighEnum.getDefault() &&
|
||||
issueLog.getAssignedTo() == null &&
|
||||
issueLog.getDeadline() == null &&
|
||||
issueLog.getDateResolved() == null &&
|
||||
issueLog.getNotes() == null)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isRiskLogChanged() {
|
||||
if (riskLogController.getRiskLog() != null) {
|
||||
RiskLog riskLog = riskLogController.getRiskLog();
|
||||
|
||||
// "Date created" and "Created by" are not handled
|
||||
if (!(riskLog.getProjectName() == null &&
|
||||
riskLog.getStatus() == null &&
|
||||
riskLog.getProbability() == LowMediumHighEnum.getDefault() &&
|
||||
riskLog.getImpact() == LowMediumHighEnum.getDefault() &&
|
||||
riskLog.getDescription() == null &&
|
||||
riskLog.getCounterMeasures() == null &&
|
||||
riskLog.getScoreAfterCM() == RiskScoreStatesEnum.ZERO &&
|
||||
riskLog.getContingency() == null &&
|
||||
riskLog.getActionWhen() == null &&
|
||||
riskLog.getResponsible() == null &&
|
||||
riskLog.getNotes() == null)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void saveIssueLogState() {
|
||||
if (issueLogController!=null && issueLogController.getIssueLog()!=null && isIssueLogChanged()) {
|
||||
issueLogInMemory = issueLogController.getIssueLog();
|
||||
}
|
||||
}
|
||||
|
||||
private void saveRiskLogState() {
|
||||
if (riskLogController!=null && riskLogController.getRiskLog()!=null && isRiskLogChanged()) {
|
||||
riskLogInMemory = riskLogController.getRiskLog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -67,6 +67,8 @@ public class RiskLogCRUDController extends BaseCRUDController<RiskLog> {
|
|||
|
||||
private Textbox riskScore;
|
||||
|
||||
private boolean saved;
|
||||
|
||||
/**
|
||||
* Renders LOW, MEDIUM, HIGH enums.
|
||||
*
|
||||
|
|
@ -416,6 +418,7 @@ public class RiskLogCRUDController extends BaseCRUDController<RiskLog> {
|
|||
}
|
||||
|
||||
riskLogModel.confirmSave();
|
||||
saved = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -428,4 +431,12 @@ public class RiskLogCRUDController extends BaseCRUDController<RiskLog> {
|
|||
riskLogModel.remove(entity);
|
||||
}
|
||||
|
||||
public Boolean isRiskLogSaved () {
|
||||
return saved;
|
||||
}
|
||||
|
||||
public void setRiskLogToModel (RiskLog log) {
|
||||
this.riskLogModel.setRisklog(log);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -145,6 +145,11 @@ public class RiskLogModel extends IntegrationEntityModel implements IRiskLogMode
|
|||
return riskLogDAO.getByParent(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRisklog(RiskLog log) {
|
||||
this.riskLog = log;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityNameEnum getEntityName() {
|
||||
return EntityNameEnum.RISK_LOG;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@
|
|||
visible="@{subController.sent}"/>
|
||||
</row>
|
||||
<row>
|
||||
<!--TODO Create tooltips like help link, from Bogdan)-->
|
||||
<hbox>
|
||||
<label value="${i18n:_('Work description')}" />
|
||||
<image height="15px" src="/common/img/axuda.gif" tooltip="subcontractor-description-popup" />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue