Fix broken js on empty search configuration
This commit is contained in:
parent
2c57765929
commit
c4a168f31b
1 changed files with 78 additions and 43 deletions
|
@ -22,41 +22,58 @@
|
|||
<script src="themes/iph/js/query-builder.ru.js"></script>
|
||||
<script>
|
||||
var rules_example =
|
||||
{
|
||||
"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
|
||||
};
|
||||
<#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 (localStorage.getItem('queryBuilderFormSaved') === true || localStorage.getItem('queryBuilderFormSaved') === 'true') {
|
||||
rules_start = JSON.parse(localStorage.getItem('queryBuilderForm'));
|
||||
|
@ -66,13 +83,22 @@
|
|||
|
||||
$('#builder').queryBuilder({
|
||||
filters: [
|
||||
<#list searchFields as field>
|
||||
<#if field.hasFilters == "true">
|
||||
<@multivalueField field=field />
|
||||
<#else>
|
||||
<@freeField field=field />
|
||||
</#if>
|
||||
</#list>
|
||||
<#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',
|
||||
|
@ -162,12 +188,21 @@
|
|||
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']
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue