diff --git a/mir-it/src/test/java/org/mycore/mir/it/controller/MIRSearchController.java b/mir-it/src/test/java/org/mycore/mir/it/controller/MIRSearchController.java
index bebfb23cb7..cd5b830e77 100644
--- a/mir-it/src/test/java/org/mycore/mir/it/controller/MIRSearchController.java
+++ b/mir-it/src/test/java/org/mycore/mir/it/controller/MIRSearchController.java
@@ -177,42 +177,49 @@ public void searchBy(String title) {
public void searchByPublication(String title, String subTitle, String author, String name, String nameIdentifier,
String metadata, String content) {
+ // select mods (filter query) is 'all'
if (title != null) {
driver.waitAndFindElement(By.id("search_type_label")).click();
driver.waitAndFindElement(MCRBy.partialLinkText("Alles")).click();
qry(title);
}
+ // select mods (filter query) is 'mods.title'
if (subTitle != null) {
driver.waitAndFindElement(By.id("search_type_label")).click();
driver.waitAndFindElement(MCRBy.partialLinkText("Titel")).click();
qry(subTitle);
}
+ // select mods (filter query) is 'mods.author'
if (author != null) {
driver.waitAndFindElement(By.id("search_type_label")).click();
driver.waitAndFindElement(MCRBy.partialLinkText("Autor")).click();
qry(author);
}
+ // select mods (filter query) is 'mods.name.top'
if (name != null) {
driver.waitAndFindElement(By.id("search_type_label")).click();
driver.waitAndFindElement(MCRBy.partialLinkText("Name")).click();
qry(name);
}
+ // select mods (filter query) is 'mods.nameIdentifier'
if (nameIdentifier != null) {
driver.waitAndFindElement(By.id("search_type_label")).click();
driver.waitAndFindElement(MCRBy.partialLinkText("Namens Identifikator")).click();
qry(nameIdentifier);
}
+ // select mods (filter query) is 'allMeta'
if (metadata != null) {
driver.waitAndFindElement(By.id("search_type_label")).click();
driver.waitAndFindElement(MCRBy.partialLinkText("Alle Metadaten")).click();
qry(metadata);
}
+ // select mods (filter query) is 'content'
if (content != null) {
driver.waitAndFindElement(By.id("search_type_label")).click();
driver.waitAndFindElement(MCRBy.partialLinkText("Volltext")).click();
diff --git a/mir-layout/src/main/resources/xsl/mir-flatmir-layout-utils.xsl b/mir-layout/src/main/resources/xsl/mir-flatmir-layout-utils.xsl
index 5a023acd5a..8f4ba8230a 100644
--- a/mir-layout/src/main/resources/xsl/mir-flatmir-layout-utils.xsl
+++ b/mir-layout/src/main/resources/xsl/mir-flatmir-layout-utils.xsl
@@ -66,6 +66,9 @@
action="{$WebApplicationBaseURL}servlets/solr/find"
class="searchfield_box form-inline my-2 my-lg-0"
role="search">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -81,6 +98,7 @@
+
diff --git a/mir-module/src/main/resources/META-INF/resources/js/mir/base.js b/mir-module/src/main/resources/META-INF/resources/js/mir/base.js
index b5c9f006fd..733a046974 100644
--- a/mir-module/src/main/resources/META-INF/resources/js/mir/base.js
+++ b/mir-module/src/main/resources/META-INF/resources/js/mir/base.js
@@ -293,42 +293,137 @@
});
});
- //for select box in search field on hit list page
- $( ".search_type a" ).click(function() {
- $( "#search_type_label" ).html( $( this ).html() );
- $( "#search_type_button" ).attr( 'value', $( this ).attr('value') );
+ // Input element in the mir-flatmir-layout-utils.xsl search
+ const mirFlatmirLayoutSearchInputElement = "#searchInput";
+ // Selector for the second search form
+ const subSearchFormName = "form.search_form";
+ // The submit button in the second search form
+ const secondSearchFormSubmitButtonElement = subSearchFormName + ' button[type="submit"]';
+ // ID of the input field for the second search text
+ const qrySelector = "#qry";
+ // ID of the dropdown element with the filter query key
+ const selectMods = "#select_mods";
+ // ID of the dropdown element with the filter query key
+ const selectModsLabel = "#select_mods_label";
+ // Selector of a dropdown-menu item
+ const selectModsItem = ".select_mods_type .dropdown-item";
+ // ID of the hidden element with the fq parameter
+ const fqElement = "#fq";
+ // ID of the hidden element with the initial condQuery parameter in the mir-flatmir-layout-utils.xsl search form
+ const initialCondQueryMirFlatmirLayout = "#initialCondQueryMirFlatmirLayout";
+ // ID of the hidden element with the initial condQuery parameter in the second search form
+ const initialCondQuerySecond = "#initialCondQuerySecond";
+ // ID of the hidden element 'condQuery' for the query parameter 'condQuery'
+ const condQuery = "#condQuery";
+
+ // Input element's changes in the mir-flatmir-layout-utils.xsl search
+ $(mirFlatmirLayoutSearchInputElement).change(() => {
+ if ($(initialCondQueryMirFlatmirLayout).length) {
+ let initialCondQueryValue = $(mirFlatmirLayoutSearchInputElement).val().trim();
+ if (initialCondQueryValue === '') {
+ initialCondQueryValue = '*';
+ }
+ $(initialCondQueryMirFlatmirLayout).attr('value', initialCondQueryValue);
+ }
});
- // filter for result lists
- // modify search query
- // TODO: modify? add why and how
- // do nothing if a query is missing
- $( ".search_box form" ).submit( function( event ) {
- if($(this).find("input[name='qry']").val().trim() != '') {
- var origSearchAction = $(this).attr('action');
- var addValue = encodeURIComponent(solrEscapeSearchValue($('.search_box input').val().trim()));
- if (origSearchAction.includes('servlets/solr/find')) {
- var replAction = origSearchAction.replace(/(.*[&|\?])(condQuery=.*?)&(.*)/,'$1$3');
- if ($('#search_type_button').attr('value') == 'all') {
- var newAction = replAction + "&condQuery=" + addValue;
- } else {
- var newAction = replAction + "&condQuery=" + addValue + "&df=" + $('#search_type_button').attr('value');
- }
- } else {
- var replAction = origSearchAction.replace(/(.*[&|\?])(condQuery=.*?)&(.*)/,'$1$3&$2');
- if ($('#search_type_button').attr('value') == 'all') {
- var newAction = replAction + "+%2BallMeta:" + addValue;
- } else {
- var newAction = replAction + "+%2B" + $('#search_type_button').attr('value') + ":" + addValue;
- }
- }
- $(this).attr('action', newAction);
- } else {
- // nothing to do if a value is missing
- event.preventDefault();
+ // Select one of the dropdown-menu items
+ $(selectModsItem).click(function() {
+ if ($(selectModsLabel).length) {
+ // Change the dropdowns label
+ $(selectModsLabel).html( $( this ).html() );
+ }
+ if ($(selectMods).length) {
+ // Change the dropdowns value
+ $(selectMods).attr( 'value', $( this ).attr('value') );
+
+ setFQAndCondQueryElementsValues('selectMods');
}
});
+ // Changes in the input field of the filter query
+ $(qrySelector).change(() => {
+ setFQAndCondQueryElementsValues('changeQry');
+ });
+
+ // Key up changes in the second search input element
+ $(qrySelector).keyup(() => {
+ if ($(selectMods).length) {
+ const queryText = $(qrySelector).val().trim();
+ const selectModsValue = $(selectMods).val();
+ // Case if selectMods is 'all' - 'everything'
+ if (selectModsValue !== 'all') {
+ if (queryText !== '') {
+ // Enable the submit button in the second search form
+ enableButton(secondSearchFormSubmitButtonElement);
+ } else {
+ // Disable the submit button in the second search form
+ disableButton(secondSearchFormSubmitButtonElement);
+ }
+ }
+ }
+ });
+
+ // Changes for the fq element and condQuery element
+ function setFQAndCondQueryElementsValues(eventType = 'selectMods') {
+ if ($(selectMods).length && $(qrySelector).length && $(fqElement).length && $(initialCondQuerySecond).length
+ && $(condQuery).length) {
+ let queryText = '';
+ queryText = $(qrySelector).val().trim();
+ // Remove all duplicate spaces, tabs, newlines etc
+ queryText = queryText.replace(/\s\s+/g, ' ');
+ const initialCondQueryValue = $(initialCondQuerySecond).val().trim();
+ const selectModsValue = $(selectMods).val();
+ // Case if selectMods is 'all' - 'everything'
+ if (selectModsValue === 'all') {
+ $(fqElement).attr('value', '');
+ let condQueryValue = initialCondQueryValue;
+ if (queryText !== '') {
+ condQueryValue += ' AND ' + preparingQueryStringForSolr(queryText);
+ } else {
+ condQueryValue += queryText;
+ }
+ $(condQuery).attr('value', condQueryValue);
+ if (eventType === 'selectMods') {
+ // Enable the submit button in the second search form
+ enableButton(secondSearchFormSubmitButtonElement);
+ }
+ } else {
+ const filterQuery = selectModsValue + ':' + preparingQueryStringForSolr(queryText);
+ $(fqElement).attr('value', filterQuery);
+ $(condQuery).attr('value', initialCondQueryValue);
+ if (eventType === 'selectMods') {
+ if (queryText !== '') {
+ // Enable the submit button in the second search form
+ enableButton(secondSearchFormSubmitButtonElement);
+ } else {
+ // Disable the submit button in the second search form
+ disableButton(secondSearchFormSubmitButtonElement);
+ }
+ }
+ }
+ }
+ }
+
+ // Add special characters to the query string for the SOLR request and remove all quotes from the query string
+ function preparingQueryStringForSolr(queryStr) {
+ return queryStr ? '"' + queryStr.replace(/"|%22/g, '') + '"' : queryStr;
+ }
+
+ // Disable the button
+ function disableButton(element) {
+ if (element) {
+ $(element).attr('disabled','disabled');
+ }
+ }
+
+ // Enable the button
+ function enableButton(element) {
+ if (element) {
+ $(element).removeAttr('disabled');
+ }
+ }
+
var languageList = jQuery('#topnav .languageList');
jQuery('#topnav .languageSelect').click(function() {
languageList.toggleClass('hide');
diff --git a/mir-module/src/main/resources/xsl/response-mir.xsl b/mir-module/src/main/resources/xsl/response-mir.xsl
index f8f6b32d84..b9ddd7e656 100644
--- a/mir-module/src/main/resources/xsl/response-mir.xsl
+++ b/mir-module/src/main/resources/xsl/response-mir.xsl
@@ -60,17 +60,129 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+