Merge pull request #1829 from OpenRefine/issue1827
Fix issue of empty list facet choices disappearing.
This commit is contained in:
commit
3431a9ee1e
@ -305,6 +305,7 @@ public class ListFacet implements Facet {
|
|||||||
*/
|
*/
|
||||||
NominalFacetChoice choice = new NominalFacetChoice(decoratedValue);
|
NominalFacetChoice choice = new NominalFacetChoice(decoratedValue);
|
||||||
choice.count = 0;
|
choice.count = 0;
|
||||||
|
choice.selected = true;
|
||||||
_choices.add(choice);
|
_choices.add(choice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,18 @@ public class ListFacetTests extends RefineTest {
|
|||||||
+ " {\"v\":{\"v\":\"barbar\",\"l\":\"barbar\"},\"c\":1,\"s\":false}"
|
+ " {\"v\":{\"v\":\"barbar\",\"l\":\"barbar\"},\"c\":1,\"s\":false}"
|
||||||
+ "]}";
|
+ "]}";
|
||||||
|
|
||||||
|
private static String selectedEmptyChoiceFacet = "{"
|
||||||
|
+ "\"name\":\"facet A\","
|
||||||
|
+ "\"expression\":\"value+\\\"bar\\\"\","
|
||||||
|
+ "\"columnName\":\"Column A\","
|
||||||
|
+ "\"invert\":false,"
|
||||||
|
+ "\"choices\":["
|
||||||
|
+ " {\"v\":{\"v\":\"ebar\",\"l\":\"ebar\"},\"c\":1,\"s\":false},"
|
||||||
|
+ " {\"v\":{\"v\":\"cbar\",\"l\":\"cbar\"},\"c\":1,\"s\":false},"
|
||||||
|
+ " {\"v\":{\"v\":\"abar\",\"l\":\"abar\"},\"c\":1,\"s\":false},"
|
||||||
|
+ " {\"v\":{\"v\":\"foobar\",\"l\":\"true\"},\"c\":0,\"s\":true}"
|
||||||
|
+ "]}";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void serializeListFacetConfig() {
|
public void serializeListFacetConfig() {
|
||||||
ListFacetConfig facetConfig = new ListFacetConfig();
|
ListFacetConfig facetConfig = new ListFacetConfig();
|
||||||
@ -77,4 +89,19 @@ public class ListFacetTests extends RefineTest {
|
|||||||
Facet facet = facetConfig.apply(project);
|
Facet facet = facetConfig.apply(project);
|
||||||
TestUtils.isSerializedTo(facet, jsonFacetError);
|
TestUtils.isSerializedTo(facet, jsonFacetError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSelectedEmptyChoice() {
|
||||||
|
Project project = createCSVProject("Column A\n" +
|
||||||
|
"a\n" +
|
||||||
|
"c\n" +
|
||||||
|
"e");
|
||||||
|
Engine engine = new Engine(project);
|
||||||
|
|
||||||
|
ListFacetConfig facetConfig = new ListFacetConfig();
|
||||||
|
facetConfig.initializeFromJSON(new JSONObject(jsonConfig));
|
||||||
|
Facet facet = facetConfig.apply(project);
|
||||||
|
facet.computeChoices(project, engine.getAllFilteredRows());
|
||||||
|
TestUtils.isSerializedTo(facet, selectedEmptyChoiceFacet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user