Skip to content

Commit

Permalink
Merge pull request #1381 from dimagi/riese/field_border
Browse files Browse the repository at this point in the history
Add flag if to show borders on case list fields
  • Loading branch information
MartinRiese authored Nov 28, 2023
2 parents 3c18391 + 3a0750a commit eca503b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/org/commcare/suite/model/DetailField.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public class DetailField implements Externalizable {
@Nullable
private EndpointAction endpointAction;

private boolean showBorder;

/**
* Optional hint which provides a hint for whether rich media should be
* displayed based on <text> returning a URI. May be either 'image' or
Expand Down Expand Up @@ -207,6 +209,7 @@ public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOExcep
verticalAlign = ExtUtil.nullIfEmpty(ExtUtil.readString(in));
cssID = ExtUtil.nullIfEmpty(ExtUtil.readString(in));
endpointAction = (EndpointAction)ExtUtil.read(in, new ExtWrapNullable(EndpointAction.class), pf);
showBorder = ExtUtil.readBool(in);
}

@Override
Expand Down Expand Up @@ -237,6 +240,7 @@ public void writeExternal(DataOutputStream out) throws IOException {
ExtUtil.writeString(out, ExtUtil.emptyIfNull(verticalAlign));
ExtUtil.writeString(out, ExtUtil.emptyIfNull(cssID));
ExtUtil.write(out, new ExtWrapNullable(endpointAction));
ExtUtil.writeBool(out, showBorder);
}

public int getGridX() {
Expand Down Expand Up @@ -276,6 +280,10 @@ public String getCssId() {
return cssID;
}

public boolean getShowBorder() {
return showBorder;
}

public static class Builder {
final DetailField field;

Expand Down Expand Up @@ -398,5 +406,9 @@ public void setCssID(String id) {
public void setEndpointAction(EndpointAction endpointAction) {
field.endpointAction = endpointAction;
}

public void setShowBorder(boolean showBorder) {
field.showBorder = showBorder;
}
}
}
7 changes: 7 additions & 0 deletions src/main/java/org/commcare/suite/model/Style.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class Style {
private String horizontalAlign;
private String verticalAlign;

private boolean showBorder;

public Style(){}

public Style(DetailField detail){
Expand All @@ -35,6 +37,7 @@ public Style(DetailField detail){

verticalAlign = detail.getVerticalAlign();
horizontalAlign = detail.getHorizontalAlign();
showBorder = detail.getShowBorder();
}

enum DisplayFormat {
Expand Down Expand Up @@ -118,4 +121,8 @@ public String getHorizontalAlign() {
public String getVerticalAlign() {
return verticalAlign;
}

public boolean getShowBorder() {
return showBorder;
}
}
3 changes: 3 additions & 0 deletions src/main/java/org/commcare/xml/StyleParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public Integer parse() throws InvalidStructureException, IOException, XmlPullPar
String cssID = parser.getAttributeValue(null, "css-id");
builder.setCssID(cssID);

String showBorder = parser.getAttributeValue(null, "show-border");
builder.setShowBorder(Boolean.parseBoolean(showBorder));

parser.nextTag();

return Integer.valueOf(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,13 @@ public void testDetailWithFieldAction() {
assertFalse(endpoint.isRespectRelevancy());
}

@Test
public void testDetailWithBorder() {
Detail detail = mApp.getSession().getPlatform().getDetail("m0_case_short");
DetailField field1 = detail.getFields()[0];
assertTrue(field1.getShowBorder());
}

@Test
public void testDefaultEndpointRelevancy_shouldBeTrue() {
Endpoint endpoint = mApp.getSession().getPlatform().getEndpoint("endpoint_with_no_relevancy");
Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/app_structure/suite.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
</field>
</lookup>
<field>
<style horz-align="left" vert-align="center" font-size="small" show-border="true">
<grid grid-height="2" grid-width="3" grid-x="3" grid-y="5"/>
</style>
<header>
<text>Name</text>
</header>
Expand Down

0 comments on commit eca503b

Please sign in to comment.