Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flag if to show borders on case list fields #1381

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
MartinRiese marked this conversation as resolved.
Show resolved Hide resolved

/**
* 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