Skip to content

Commit

Permalink
#252 don't allow create/delete included document is parent document i…
Browse files Browse the repository at this point in the history
…s not active
  • Loading branch information
teosarca committed Mar 14, 2017
1 parent 53a608d commit 5823087
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main/java/de/metas/ui/web/window/model/Document.java
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,24 @@ public void assertNewDocumentAllowed(final DetailId detailId)

return false;
}

/* package */ boolean isActive()
{
final IDocumentFieldView isActiveField = getFieldOrNull(WindowConstants.FIELDNAME_IsActive);
if (isActiveField != null)
{
return isActiveField.getValueAsBoolean();
}

final Document parentDocument = getParentDocument();
if (parentDocument != null)
{
return parentDocument.isActive();
}

return false;
}


/**
* Set Dynamic Attribute.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@ public LogicExpressionResult getAllowCreateNewDocument()
return LOGICRESULT_FALSE_ParentDocumentProcessed;
}

if (!parentDocument.isActive())
{
return LogicExpressionResult.namedConstant("ParentDocumentNotActive", false);
}

if(parentDocument.isNew())
{
return LogicExpressionResult.namedConstant("ParentDocumentNew", false);
Expand Down Expand Up @@ -358,6 +363,11 @@ private LogicExpressionResult getAllowDeleteDocument()
{
return LOGICRESULT_FALSE_ParentDocumentProcessed;
}

if (!parentDocument.isActive())
{
return LogicExpressionResult.namedConstant("ParentDocumentNotActive", false);
}

final ILogicExpression allowDeleteLogic = entityDescriptor.getAllowDeleteLogic();
final LogicExpressionResult allowDelete = allowDeleteLogic.evaluateToResult(parentDocument.asEvaluatee(), OnVariableNotFound.ReturnNoResult);
Expand Down

0 comments on commit 5823087

Please sign in to comment.