Skip to content

Commit

Permalink
Always hide the "query related" button when the relationship is owned.
Browse files Browse the repository at this point in the history
  • Loading branch information
fbarthez authored and darkv committed Jan 6, 2016
1 parent 106fe10 commit 7410579
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,5 @@ ListNotEmpty: WOConditional {
}

ShowFind: WOConditional {
condition = d2wContext.shouldShowQueryRelatedButton;
condition = shouldShowQueryRelatedButton;
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public interface Keys extends ERD2WEditRelationshipPage.Keys {
public static String displayPropertyKeys = "displayPropertyKeys";
public static String subTask = "subTask";
public static String isEntityCreatable = "isEntityCreatable";
public static String shouldShowQueryRelatedButton = "shouldShowQueryRelatedButton";

}

Expand Down Expand Up @@ -349,17 +350,17 @@ public void setMasterObjectAndRelationshipKey(EOEnterpriseObject eo, String rela
* @see er.directtoweb.pages.ERD2WPage#settings()
*/
@Override
public NSDictionary settings() {
public NSDictionary<String,Object> settings() {
String pc = d2wContext().dynamicPage();
if (pc != null) {
if (d2wContext().valueForKey("currentRelationship") != null) {
// set parentRelationship key to allow subcomponents to
// reference the correct ID (wonder-140)
return new NSDictionary(new Object[] { pc,
d2wContext().valueForKey("currentRelationship") }, new Object[] {
return new NSDictionary<String,Object>(new Object[] { pc,
d2wContext().valueForKey("currentRelationship") }, new String[] {
"parentPageConfiguration", "parentRelationship" });
} else {
return new NSDictionary(pc, "parentPageConfiguration");
return new NSDictionary<String,Object>(pc, "parentPageConfiguration");
}
}
return null;
Expand Down Expand Up @@ -539,6 +540,24 @@ public boolean isEntityCreatable() {
return ERXValueUtilities.booleanValue(d2wContext().valueForKey(Keys.isEntityCreatable)) && !isEntityReadOnly();
}

public boolean shouldShowQueryRelatedButton() {
boolean shouldShowQueryRelatedButton = ERXValueUtilities
.booleanValue(d2wContext().valueForKey(Keys.shouldShowQueryRelatedButton));
if (isRelationshipOwned()) {
// if the relationship is owned, search makes no sense
shouldShowQueryRelatedButton = false;
}
return shouldShowQueryRelatedButton;
}

public boolean isRelationshipOwned() {
boolean isRelationshipOwned = false;
if (masterObject().allPropertyKeys().contains(relationshipKey())) {
isRelationshipOwned = masterObject().classDescription().ownsDestinationObjectsForRelationshipKey(relationshipKey());
}
return isRelationshipOwned;
}

private void writeObject(ObjectOutputStream out) throws IOException {
out.writeObject(_masterObject);
out.writeObject(_objectToAddToRelationship);
Expand Down

0 comments on commit 7410579

Please sign in to comment.