Skip to content

Commit

Permalink
Don't display "remove related" button on owned relationships.
Browse files Browse the repository at this point in the history
  • Loading branch information
fbarthez committed Jan 6, 2016
1 parent 04f0b92 commit 28cb3c8
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
*/
public class ERMDRemoveRelatedButton extends ERMDDeleteButton {

@SuppressWarnings("unused")
private static final long serialVersionUID = 1L;

@SuppressWarnings("unused")
private static final Logger log = Logger.getLogger(ERMDRemoveRelatedButton.class);

public interface Keys extends ERMDActionButton.Keys {
Expand Down Expand Up @@ -176,10 +178,11 @@ public String removeButtonClass() {
}

/**
* Boolean used to hide/show the confirmation dialog's remove button.
* Boolean used to hide/show the confirmation dialog's remove button.
*
* The remove button show only be displayed if the reverse relationship for the related eo is not
* mandatory and isEntityRemoveable returns true.
* The remove button should only be displayed if the relationship is not
* owned, the reverse relationship for the related EO not mandatory and
* isEntityRemoveable returns true.
*/
public Boolean showRemoveButton() {
if (_showRemoveButton == null) {
Expand All @@ -191,12 +194,14 @@ public Boolean showRemoveButton() {
EOEntity masterEntity = ERXEOAccessUtilities.entityForEo(masterObj);
EORelationship relationship = masterEntity.relationshipNamed(dds.detailKey());
EORelationship reverseRelationship = relationship.inverseRelationship();
if(isRemoveable) {
if(reverseRelationship == null) {
_showRemoveButton = Boolean.TRUE;
} else {
_showRemoveButton = !reverseRelationship.isMandatory();
}
if(isRemoveable && !relationship.ownsDestination()) {
if (!relationship.ownsDestination()) {
if (reverseRelationship == null) {
_showRemoveButton = Boolean.TRUE;
} else {
_showRemoveButton = !reverseRelationship.isMandatory();
}
}
} else {
_showRemoveButton = Boolean.FALSE;
}
Expand Down

0 comments on commit 28cb3c8

Please sign in to comment.