From 60bab69b2a86fb05332ef23e08cd4cfd636c1492 Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Thu, 15 Jul 2021 23:01:42 +0200 Subject: [PATCH] Added buttons to remove document from search results --- .../body/search/search-pagedResults.ftl | 3 +- webapp/src/main/webapp/themes/iph/css/iph.css | 13 ++ .../themes/iph/i18n/all_en_US.properties | 115 ++++++++++++++++++ .../themes/iph/i18n/all_ru_RU.properties | 2 +- .../themes/iph/templates/queryBuilder.ftl | 60 +++++++-- 5 files changed, 180 insertions(+), 13 deletions(-) create mode 100644 webapp/src/main/webapp/themes/iph/i18n/all_en_US.properties diff --git a/webapp/src/main/webapp/templates/freemarker/body/search/search-pagedResults.ftl b/webapp/src/main/webapp/templates/freemarker/body/search/search-pagedResults.ftl index 1bbae3c6..ac3161f4 100644 --- a/webapp/src/main/webapp/templates/freemarker/body/search/search-pagedResults.ftl +++ b/webapp/src/main/webapp/templates/freemarker/body/search/search-pagedResults.ftl @@ -164,7 +164,7 @@ function fillOutForm(compilationName){ var iframeDoc = document.getElementById('newCompilationIframe').contentWindow.document; - var rules = $('#builder').queryBuilder('getRules'); + var rules = $('#builder').queryBuilder('getRules', { get_flags: true }); var query = format_query_string(rules,""); iframeDoc.getElementById('queryBuilderRules').value = JSON.stringify(rules); iframeDoc.getElementById('rawQueryString').value = query; @@ -235,6 +235,7 @@ } }); } + createRemoveButtons(); } diff --git a/webapp/src/main/webapp/themes/iph/css/iph.css b/webapp/src/main/webapp/themes/iph/css/iph.css index 66a0f6f3..637c7189 100644 --- a/webapp/src/main/webapp/themes/iph/css/iph.css +++ b/webapp/src/main/webapp/themes/iph/css/iph.css @@ -3511,6 +3511,19 @@ label.switch >.collapseTextControl >img { text-decoration: none; cursor: pointer; } + +.removeDocFromSearch { + border-inline-width: thin; + border-top-width: thin; + border-bottom-width: thin; + border-color: #8B4513; + border-inline-style: solid; + border-top-style: solid; + border-bottom-style: solid; + margin-left: 0.4em; + padding: 0.0em 0.2em 0.1em 0.2em; +} + /* -------------------------------------------------> */ /* FONTS --------------------------------> */ /* -------------------------------------------------> */ diff --git a/webapp/src/main/webapp/themes/iph/i18n/all_en_US.properties b/webapp/src/main/webapp/themes/iph/i18n/all_en_US.properties new file mode 100644 index 00000000..406a7b63 --- /dev/null +++ b/webapp/src/main/webapp/themes/iph/i18n/all_en_US.properties @@ -0,0 +1,115 @@ +menu_contactus = Contact Us +menu_welcomestart = Welcome +menu_copyright = copyright +menu_support = Support +menu_logout = Log out +menu_loginfull = Log in to manage this site +menu_login = Log in +menu_version = Version +menu_about = About +menu_termuse = Terms of Use +menu_powered = Powered by + +intro_title = Welcome to VIVO +intro_para1 = VIVO is a research-focused discovery tool that enables collaboration among scholars of all disciplines. +intro_para2 = Browse or search information on people, departments, courses, grants, and publications. +intro_searchvivo = Search VIVO +intro_filtersearch = Filter search + +identity_title = VIVO | connect share discover +identity_index = Index +identity_edit = Edit Page +identity_admin = Site Admin +identity_myprofile = My profile +identity_myaccount = My account +identity_user = user + +collection_capitalized = Collection +place_of_grant = Place of grant +email_address = Email Address + +# +# menupage templates ( /templates/freemarker/body/menupage ) +# +grants_text_one = This body is from the the template file \ + vivo/productMods/templates/freemarker/body/menupage/grants.ftl. \ + In the display model, the grants page has a display:requiresBodyTemplate \ + property that defines that the grants page overrides the default template. \ + The default template for these pages is at /vitro/webapp/web/templates/freemarker/body/menupage/menupage.ftl +grants_two = This technique could be used to define pages without menu items, that get \ + their content from a freemarker template. An example would be the about page. +grants_text_three = This would create a page that would use about.ftl as the body. The page would be \ + accessed via /about and would override all servlet mappings in web.xml. + +address_street_one = address street one +address_street_two = address street two +address_street_three = address street three +address_label = address label + +loading_website_image = Loading website image + +researchers_in = researchers in +view = view +grant_type = grant Type +grant_entry_for = grant entry for +regions = regions +grant_date = grant Date +map_states_string = states. +map_state_string = state. +unable_to_handle_grant_editing = This form is unable to handle the editing of this grant because it is associated with multiple grant individuals. +unable_to_handle_position_editing = This form is unable to handle the editing of this position because it is associated with multiple Position individuals. +currently_no_papers_for = Currently there are no {0} papers for +change_selection = change selection +view_all_departments = view all academic departments +first_name = First name +last_name = Last name +first_grant = First Grant +last_grant = Last Grant +currently_no_researchers = There are currently no researchers with a defined geographic focus. +reviewer_role = Reviewer Role +vivo_profile = VIVO profile +loading_data = loading data +select_award = Selected Award +grants_in_vivo = grants in VIVO +service_provider_role = Service Provider Role +view_all_faculty = view all faculty +no_grants_for = Currently there are no grants for +statewide_locations = state-wide locations. +faculty_who_are_members_of_org = Here are the faculty in the {0} department who are members of this organization. +indiv_foafperson_for = for +indiv_foafperson_return = return to +no_departments_found = No academic departments found. +leadership_role = Leadership Role +countries = countries +first_publication = First publication +last_publication = Last publication +research_area = individuals in the department with this research area +password = password +limit_search = limit search +placeholder_image = placeholder image +view_all_members_of_org = View all the members of this organization. +display_more = more +create_entry = Create Entry +attendee_capitalized = Attendee +no_faculty_found = No faculty members found. +create_capitalized = Create +to = to +enter_new_role_value = Please enter a new value in the Role field. +countries_and_regions = countries and regions. +province_or_region = Province or Region +full_name = Full name +researchers = researchers +years_participation_in = Years of Participation in +return_to_grant = Return to grant +profile_capitalized = Profile +organizer_role = Organizer Role +faculty_memberships = Faculty Memberships +edit_mailing_address = Edit Mailing Address +add_capitalized = Add + +literature_excerpt_button_text = Bibliography +literature_all_button_text = All bibliorgraphy +sources_excerpt_button_text = Sources +sources_all_button_text = All sources +remove_doc_from_search_results = Remove from search results + diff --git a/webapp/src/main/webapp/themes/iph/i18n/all_ru_RU.properties b/webapp/src/main/webapp/themes/iph/i18n/all_ru_RU.properties index 67434d96..ae45b193 100644 --- a/webapp/src/main/webapp/themes/iph/i18n/all_ru_RU.properties +++ b/webapp/src/main/webapp/themes/iph/i18n/all_ru_RU.properties @@ -106,4 +106,4 @@ organizer_role = Organizer Role faculty_memberships = Faculty Memberships edit_mailing_address = Edit Mailing Address add_capitalized = Add - +remove_doc_from_search_results=Удалить из результатов поиска diff --git a/webapp/src/main/webapp/themes/iph/templates/queryBuilder.ftl b/webapp/src/main/webapp/themes/iph/templates/queryBuilder.ftl index 0a008d82..681d3719 100644 --- a/webapp/src/main/webapp/themes/iph/templates/queryBuilder.ftl +++ b/webapp/src/main/webapp/themes/iph/templates/queryBuilder.ftl @@ -132,7 +132,7 @@ $('#btn-search-expand').on('click', function() { - var json_result = $('#builder').queryBuilder('getRules'); + var json_result = $('#builder').queryBuilder('getRules', { get_flags: true }); var query_string = format_query_string(json_result,""); var hits = $("#hitsPerPageSelect :selected"); if (!$.isEmptyObject(query_string)) { @@ -171,29 +171,67 @@ if ('operator' in json_query && json_query.operator.startsWith("not_")){ string_query += "NOT "; } - string_query += json_query.field + ":" + json_query.value.toString().replace(/[']+/g,'').replace(/#/g,'%23') ; + if (json_query.hasOwnProperty('data') && json_query.data.hasOwnProperty('value')){ + var value = "\"" + json_query.data.value.toString()+ "\""; + } else { + var value = json_query.value.toString(); + } + string_query += json_query.field + ":" + value.replace(/[']+/g,'').replace(/#/g,'%23') ; } return string_query; } - function excludeDocByURI(uri){ - var allRules = $('#builder').queryBuilder('getRules'); - var excludeRuleString = '{ "id": "URI", "field": "URI", "type": "string", "input": "text", "operator": "not_contains", "value": "" }'; + function excludeDocByURI(name, uri){ + var allRules = $('#builder').queryBuilder('getRules', { get_flags: true }); + var excludeRuleString = '{ "id": "URI", "field": "URI", "type": "string", "flags":{}, "input": "text", "operator": "not_contains", "data":{} }'; var excludeRule = JSON.parse(excludeRuleString); - excludeRule.value = uri; + excludeRule.data.value = uri; + excludeRule.flags.value_readonly = true; + excludeRule.flags.filter_readonly = true; + excludeRule.flags.operator_readonly = true; + excludeRule.value = name; if (allRules !== null){ if (allRules.condition === "AND"){ allRules.rules.push(excludeRule); } else { - var outerRulesString = '{ "condition": "AND", "rules": [] }'; - var outerRules = JSON.parse(outerRulesString); - outerRules.rules.push(allRules); - outerRules.rules.push(excludeRule); - allRules = outerRules; + var outerRulesString = '{ "condition": "AND", "rules": [] }'; + var outerRules = JSON.parse(outerRulesString); + outerRules.rules.push(allRules); + outerRules.rules.push(excludeRule); + allRules = outerRules; } $('#builder').queryBuilder('setRules', allRules); + var elements = document.querySelectorAll('[parturi="' + uri + '"]'); + var i; + for (i = 0; i < elements.length; i++) { + elements[i].parentElement.remove(); + } } } + + function createRemoveButtons(){ + $('.compilationDraftExcerpt').each(function(index){ createRemoveButton(this)}); + } + + function createRemoveButton(element){ + var uri = element.getAttribute('parturi'); + var button = element.querySelector('button'); + var name = button.textContent; + var a = document.createElement('a'); + a.setAttribute('href',"javascript:excludeDocByURI(\'" + escapeQutes(name) + "\',\'" + escapeQutes(uri) + "\');"); + a.setAttribute('class',"removeDocFromSearch"); + + a.textContent = "${i18n().remove_doc_from_search_results}" ; + + button.appendChild(a); + } + + function escapeQutes(input) { + return input + .replace(/"/g, """) + .replace(/'/g, "'") + } + <#macro freeField field > {