Working alpha
This commit is contained in:
parent
ed71fb44d1
commit
f9f6a75f54
6 changed files with 6842 additions and 0 deletions
77
webapp/src/main/webapp/js/search/query-builder.ru.js
Normal file
77
webapp/src/main/webapp/js/search/query-builder.ru.js
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
/*!
|
||||||
|
* jQuery QueryBuilder 2.5.2
|
||||||
|
* Locale: Russian (ru)
|
||||||
|
* Licensed under MIT (https://opensource.org/licenses/MIT)
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function(root, factory) {
|
||||||
|
if (typeof define == 'function' && define.amd) {
|
||||||
|
define(['jquery', 'query-builder'], factory);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
factory(root.jQuery);
|
||||||
|
}
|
||||||
|
}(this, function($) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var QueryBuilder = $.fn.queryBuilder;
|
||||||
|
|
||||||
|
QueryBuilder.regional['ru'] = {
|
||||||
|
"__locale": "Russian (ru)",
|
||||||
|
"add_rule": "Добавить условие",
|
||||||
|
"add_group": "Добавить группу",
|
||||||
|
"delete_rule": "Удалить",
|
||||||
|
"delete_group": "Удалить",
|
||||||
|
"conditions": {
|
||||||
|
"AND": "И",
|
||||||
|
"OR": "ИЛИ"
|
||||||
|
},
|
||||||
|
"operators": {
|
||||||
|
"equal": "равно",
|
||||||
|
"not_equal": "не равно",
|
||||||
|
"in": "из указанных",
|
||||||
|
"not_in": "не из указанных",
|
||||||
|
"less": "меньше",
|
||||||
|
"less_or_equal": "меньше или равно",
|
||||||
|
"greater": "больше",
|
||||||
|
"greater_or_equal": "больше или равно",
|
||||||
|
"between": "между",
|
||||||
|
"begins_with": "начинается с",
|
||||||
|
"not_begins_with": "не начинается с",
|
||||||
|
"contains": "содержит",
|
||||||
|
"not_contains": "не содержит",
|
||||||
|
"ends_with": "оканчивается на",
|
||||||
|
"not_ends_with": "не оканчивается на",
|
||||||
|
"is_empty": "пустая строка",
|
||||||
|
"is_not_empty": "не пустая строка",
|
||||||
|
"is_null": "пусто",
|
||||||
|
"is_not_null": "не пусто"
|
||||||
|
},
|
||||||
|
"errors": {
|
||||||
|
"no_filter": "Фильтр не выбран",
|
||||||
|
"empty_group": "Группа пуста",
|
||||||
|
"radio_empty": "Не выбранно значение",
|
||||||
|
"checkbox_empty": "Не выбранно значение",
|
||||||
|
"select_empty": "Не выбранно значение",
|
||||||
|
"string_empty": "Не заполненно",
|
||||||
|
"string_exceed_min_length": "Должен содержать больше {0} символов",
|
||||||
|
"string_exceed_max_length": "Должен содержать меньше {0} символов",
|
||||||
|
"string_invalid_format": "Неверный формат ({0})",
|
||||||
|
"number_nan": "Не число",
|
||||||
|
"number_not_integer": "Не число",
|
||||||
|
"number_not_double": "Не число",
|
||||||
|
"number_exceed_min": "Должно быть больше {0}",
|
||||||
|
"number_exceed_max": "Должно быть меньше, чем {0}",
|
||||||
|
"number_wrong_step": "Должно быть кратно {0}",
|
||||||
|
"datetime_empty": "Не заполненно",
|
||||||
|
"datetime_invalid": "Неверный формат даты ({0})",
|
||||||
|
"datetime_exceed_min": "Должно быть, после {0}",
|
||||||
|
"datetime_exceed_max": "Должно быть, до {0}",
|
||||||
|
"boolean_not_valid": "Не логическое",
|
||||||
|
"operator_not_multiple": "Оператор \"{1}\" не поддерживает много значений"
|
||||||
|
},
|
||||||
|
"invert": "Инвертировать"
|
||||||
|
};
|
||||||
|
|
||||||
|
QueryBuilder.defaults({ lang_code: 'ru' });
|
||||||
|
}));
|
6477
webapp/src/main/webapp/js/search/query-builder.standalone.js
Normal file
6477
webapp/src/main/webapp/js/search/query-builder.standalone.js
Normal file
File diff suppressed because it is too large
Load diff
7
webapp/src/main/webapp/js/search/query-builder.standalone.min.js
vendored
Normal file
7
webapp/src/main/webapp/js/search/query-builder.standalone.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,7 @@
|
||||||
<#-- $This file is distributed under the terms of the license in LICENSE$ -->
|
<#-- $This file is distributed under the terms of the license in LICENSE$ -->
|
||||||
|
|
||||||
<#-- Template for displaying search error message -->
|
<#-- Template for displaying search error message -->
|
||||||
|
<#include "queryBuilder.ftl">
|
||||||
|
|
||||||
<#if title??>
|
<#if title??>
|
||||||
<div class="errorPageTitle">
|
<div class="errorPageTitle">
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<#-- $This file is distributed under the terms of the license in LICENSE$ -->
|
<#-- $This file is distributed under the terms of the license in LICENSE$ -->
|
||||||
|
|
||||||
<#-- Template for displaying paged search results -->
|
<#-- Template for displaying paged search results -->
|
||||||
|
<#include "queryBuilder.ftl">
|
||||||
|
|
||||||
<h2 class="searchResultsHeader">
|
<h2 class="searchResultsHeader">
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,279 @@
|
||||||
|
<div id="querybuilder-container">
|
||||||
|
<div id="CounterSearchWrapper">
|
||||||
|
<div id="builder">
|
||||||
|
<div id="SearchTitle">${i18n().extended_search_label}</div>
|
||||||
|
</div>
|
||||||
|
<div class="btn-group-bottom">
|
||||||
|
<div id="settingsButtons">
|
||||||
|
<div id="OuterWrapperButtons">
|
||||||
|
<div id="wrapperButtons">
|
||||||
|
<button id="btn-set" class="btn btn-success set-json" data-target="basic">${i18n().extended_search_example}</button>
|
||||||
|
<button id="btn-reset-button" class="btn btn-warning reset" data-target="basic">${i18n().extended_search_clean}</button>
|
||||||
|
<!-- <button id="btn-get" class="btn btn-primary parse-json" data-target="basic">Get rules</button> -->
|
||||||
|
<div id="SelectResults">
|
||||||
|
<label style="display:inline;" for="hitsPerPage">${i18n().extended_search_results_on_page}</label>
|
||||||
|
<@selectHitsPerPage/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button id="btn-search-expand" class="btn btn-warning reset" data-target="basic">${i18n().extended_search_execute_search}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src= "js/search/query-builder.standalone.min.js"></script>
|
||||||
|
<script src= "js/search/query-builder.ru.js"></script>
|
||||||
|
<script>
|
||||||
|
var rules_example =
|
||||||
|
<#if searchFields?has_content>
|
||||||
|
{
|
||||||
|
"condition": "AND",
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"id": "titles",
|
||||||
|
"field": "titles",
|
||||||
|
"type": "string",
|
||||||
|
"input": "text",
|
||||||
|
"operator": "not_contains",
|
||||||
|
"value": "постмодернизм"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"condition": "OR",
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"id": "keywords",
|
||||||
|
"field": "keywords",
|
||||||
|
"type": "string",
|
||||||
|
"input": "text",
|
||||||
|
"operator": "contains",
|
||||||
|
"value": "постмодернизм"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "bibliography",
|
||||||
|
"field": "bibliography",
|
||||||
|
"type": "string",
|
||||||
|
"input": "text",
|
||||||
|
"operator": "contains",
|
||||||
|
"value": "постмодернизм"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"valid": true
|
||||||
|
};
|
||||||
|
<#else>
|
||||||
|
{
|
||||||
|
"condition": "AND",
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"id": "ALLTEXT",
|
||||||
|
"field": "everywhere",
|
||||||
|
"type": "string",
|
||||||
|
"input": "text",
|
||||||
|
"operator": "contains",
|
||||||
|
"value": "publication"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"valid": true
|
||||||
|
};
|
||||||
|
</#if>
|
||||||
|
var rules_start;
|
||||||
|
<#if queryBuilderRules??>
|
||||||
|
rules_start = ${queryBuilderRules};
|
||||||
|
<#else>
|
||||||
|
if (localStorage.getItem('queryBuilderFormSaved') === true || localStorage.getItem('queryBuilderFormSaved') === 'true') {
|
||||||
|
rules_start = JSON.parse(localStorage.getItem('queryBuilderForm'));
|
||||||
|
} else {
|
||||||
|
rules_start = rules_example;
|
||||||
|
}
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
|
||||||
|
$('#builder').queryBuilder({
|
||||||
|
filters: [
|
||||||
|
<#if searchFields?has_content>
|
||||||
|
<#list searchFields as field>
|
||||||
|
<#if field.hasFilters == "true">
|
||||||
|
<@multivalueField field=field />
|
||||||
|
<#else>
|
||||||
|
<@freeField field=field />
|
||||||
|
</#if>
|
||||||
|
</#list>
|
||||||
|
<#else>
|
||||||
|
{
|
||||||
|
id: 'ALLTEXT',
|
||||||
|
label: 'Everywhere',
|
||||||
|
type: 'string',
|
||||||
|
operators: ['contains', 'not_contains']
|
||||||
|
},
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
],
|
||||||
|
lang_code: 'ru',
|
||||||
|
rules: rules_start
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#btn-reset-button').on('click', function() {
|
||||||
|
$('#builder').queryBuilder('reset');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#btn-set').on('click', function() {
|
||||||
|
$('#builder').queryBuilder('setRules', rules_example);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$('#btn-search-expand').on('click', function() {
|
||||||
|
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)) {
|
||||||
|
localStorage.setItem('queryBuilderForm',JSON.stringify(json_result));
|
||||||
|
localStorage.setItem('queryBuilderFormSaved',true);
|
||||||
|
var queryURL = "${urls.extendedsearch}?querytext=" + query_string;
|
||||||
|
if (hits !== null){
|
||||||
|
queryURL = queryURL.concat("&hitsPerPage=",hits.text());
|
||||||
|
}
|
||||||
|
window.open(queryURL,"_self")
|
||||||
|
}
|
||||||
|
//if (!$.isEmptyObject(json_result)) {
|
||||||
|
// alert(JSON.stringify(json_result, null, 2));
|
||||||
|
// alert(query_string);
|
||||||
|
//}
|
||||||
|
});
|
||||||
|
|
||||||
|
function format_query_string(json_query, string_query, htmlEncode = true){
|
||||||
|
if ('condition' in json_query && 'rules' in json_query ){
|
||||||
|
if (json_query.rules.length > 1 ) {
|
||||||
|
string_query +=" ( ";
|
||||||
|
var i;
|
||||||
|
for (i = 0; i < json_query.rules.length; i++) {
|
||||||
|
string_query = format_query_string(json_query.rules[i], string_query, htmlEncode);
|
||||||
|
if (i + 1 < json_query.rules.length){
|
||||||
|
string_query += " " + json_query.condition + " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
string_query +=" ) ";
|
||||||
|
} else {
|
||||||
|
string_query = format_query_string(json_query.rules[0], string_query, htmlEncode);
|
||||||
|
}
|
||||||
|
} else if ( 'field' in json_query && 'value' in json_query ){
|
||||||
|
if ('operator' in json_query && json_query.operator.startsWith("not_")){
|
||||||
|
string_query += "NOT ";
|
||||||
|
}
|
||||||
|
if (json_query.hasOwnProperty('data') && json_query.data.hasOwnProperty('value')){
|
||||||
|
var value = "\"" + json_query.data.value.toString()+ "\"";
|
||||||
|
} else {
|
||||||
|
var value = json_query.value.toString();
|
||||||
|
}
|
||||||
|
if (htmlEncode){
|
||||||
|
string_query += json_query.field + ":" + value.replace(/[']+/g,'').replace(/#/g,'%23') ;
|
||||||
|
} else {
|
||||||
|
string_query += json_query.field + ":" + value.replace(/[']+/g,'');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return string_query;
|
||||||
|
}
|
||||||
|
|
||||||
|
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.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;
|
||||||
|
}
|
||||||
|
$('#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, "'")
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<#macro freeField field >
|
||||||
|
{
|
||||||
|
id: '${field.field}',
|
||||||
|
label: '${field.name}',
|
||||||
|
type: 'string',
|
||||||
|
operators: ['contains', 'not_contains']
|
||||||
|
},
|
||||||
|
</#macro>
|
||||||
|
|
||||||
|
<#macro multivalueField field >
|
||||||
|
{
|
||||||
|
id: '${field.field}',
|
||||||
|
label: '${field.name}',
|
||||||
|
type: 'string',
|
||||||
|
input: 'select',
|
||||||
|
values: {
|
||||||
|
|
||||||
|
<#if searchFields??>
|
||||||
|
<#list searchFilters as filter>
|
||||||
|
<#if filter.field == field.field>
|
||||||
|
'"${filter.id}"':'${filter.name}',
|
||||||
|
</#if>
|
||||||
|
</#list>
|
||||||
|
<#else>
|
||||||
|
{
|
||||||
|
id: 'ALLTEXT',
|
||||||
|
label: 'Everywhere',
|
||||||
|
type: 'string',
|
||||||
|
operators: ['contains', 'not_contains']
|
||||||
|
},
|
||||||
|
</#if>
|
||||||
|
},
|
||||||
|
operators: ['contains', 'not_contains']
|
||||||
|
},
|
||||||
|
</#macro>
|
||||||
|
|
||||||
|
<#macro selectHitsPerPage>
|
||||||
|
<#if !hitsPerPage?? >
|
||||||
|
<#assign hitsPerPage = 20 >
|
||||||
|
</#if>
|
||||||
|
<#assign hitsValues= [20,40,60,80,100]>
|
||||||
|
<select name="hitsPerPage" id="hitsPerPageSelect">
|
||||||
|
<option value="${hitsPerPage}" selected="selected">${hitsPerPage}</option>
|
||||||
|
<#list hitsValues as hppValue>
|
||||||
|
<#if hppValue != hitsPerPage>
|
||||||
|
<option value="${hppValue}">${hppValue}</option>
|
||||||
|
</#if>
|
||||||
|
</#list>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</#macro>
|
Loading…
Add table
Reference in a new issue