Commit a9a7c785 authored by Michael Becker's avatar Michael Becker
Browse files

add please select option to search field select

parent e33eb85a
Pipeline #12131 passed with stage
in 2 minutes and 59 seconds
......@@ -297,6 +297,7 @@ public class SearchFormBuilderServlet extends MCRServlet {
final String[] props = MCRConfiguration2.getString(CONFIG_PREFIX_FIELDS + objectType).orElse("").split(",");
final List<FieldDTO> fields = new ArrayList<>(props.length);
fields.add(FieldDTO.blank());
for (String prop : props) {
if (StringUtils.isBlank(prop)) {
......@@ -473,6 +474,17 @@ public class SearchFormBuilderServlet extends MCRServlet {
", classificationId='" + classificationId + '\'' +
'}';
}
/**
* Returns a blank field with the text please select.
*
* @return a blank field with the text please select
*/
public static FieldDTO blank() {
final String displayName = MCRTranslation.translate("module.dptbase.common.editor.choose");
return new FieldDTO(displayName, null, null, null);
}
}
public static class OperatorDTO {
......
......@@ -27,7 +27,9 @@ public class SearchFormBuilderServletTest extends MyMssSolrTest {
// check without any configuration set
List<SearchFormBuilderServlet.FieldDTO> result = servlet.buildFieldList("manuscript");
assertThat(result.size(), is(0));
assertThat(result.size(), is(1));
assertThat(result.get(0).getDisplayName(),
is(SearchFormBuilderServlet.FieldDTO.blank().getDisplayName()));
// set configuration and check again
MCRConfiguration2.set("MCR.SearchFormBuilder.Fields.manuscript",
......@@ -46,31 +48,36 @@ public class SearchFormBuilderServletTest extends MyMssSolrTest {
"mymss_mssTitle_de;mymss_mssTitle_en;mymss_mssTitle_id:module.mymss.manuscript.mss39.labels");
result = servlet.buildFieldList("manuscript");
assertThat(result.size(), is(4));
assertThat(result.get(0).getField(), is("category"));
assertThat(result.get(0).getType(), is("classification"));
assertThat(result.get(0).getClassificationId(), is("MyMssAlphabet"));
assertThat(result.get(0).getDisplayName(), is("???module.mymss.manuscript.mss64.labels???"));
assertThat(result.size(), is(5));
assertThat(result.get(0).getDisplayName(),
is(SearchFormBuilderServlet.FieldDTO.blank().getDisplayName()));
assertThat(result.get(1).getField(), is("category"));
assertThat(result.get(1).getType(), is("classification"));
assertThat(result.get(1).getClassificationId(), is("MyMssAlphabet"));
assertThat(result.get(1).getDisplayName(), is("???module.mymss.manuscript.mss64.labels???"));
assertThat(result.get(1).getField(), is("mymss_mss01"));
assertThat(result.get(1).getType(), is("text"));
assertThat(result.get(1).getDisplayName(), is("???module.mymss.manuscript.mss01.label???"));
assertThat(result.get(2).getField(), is("mymss_mss01"));
assertThat(result.get(2).getType(), is("text"));
assertThat(result.get(2).getDisplayName(), is("???module.mymss.manuscript.mss01.label???"));
assertThat(result.get(2).getField(), is("mymss_mssHasDerivate"));
assertThat(result.get(2).getType(), is("bool"));
assertThat(result.get(2).getDisplayName(), is("???module.mymss.manuscript.mss63.search???"));
assertThat(result.get(3).getField(), is("mymss_mssHasDerivate"));
assertThat(result.get(3).getType(), is("bool"));
assertThat(result.get(3).getDisplayName(), is("???module.mymss.manuscript.mss63.search???"));
assertThat(result.get(3).getField(), is(
assertThat(result.get(4).getField(), is(
"mymss_mssTitle_general_orig,mymss_mssTitle_general_diacr," +
"mymss_mssTitle_ar,mymss_mssTitle_de,mymss_mssTitle_en,mymss_mssTitle_id"));
assertThat(result.get(3).getType(), is("text"));
assertThat(result.get(3).getDisplayName(), is("???module.mymss.manuscript.mss39.labels???"));
assertThat(result.get(4).getType(), is("text"));
assertThat(result.get(4).getDisplayName(), is("???module.mymss.manuscript.mss39.labels???"));
result = servlet.buildFieldList("agent");
assertThat(result.size(), is(1));
assertThat(result.get(0).getField(), is("agent_firstdate_from,agent_firstdate_to"));
assertThat(result.get(0).getType(), is("daterange"));
assertThat(result.get(0).getDisplayName(), is("???module.dptbase.agent.firstDate.labels???"));
assertThat(result.size(), is(2));
assertThat(result.get(0).getDisplayName(),
is(SearchFormBuilderServlet.FieldDTO.blank().getDisplayName()));
assertThat(result.get(1).getField(), is("agent_firstdate_from,agent_firstdate_to"));
assertThat(result.get(1).getType(), is("daterange"));
assertThat(result.get(1).getDisplayName(), is("???module.dptbase.agent.firstDate.labels???"));
}
@Test
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment