Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
solr-frontend
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
06223e05
authored
2016-06-23 18:14:28 -0500
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add a buildQueryParameters method, called just before a search request
is dispatched.
1 parent
471a6435
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
src/scripts/solr/model/Solr.js
src/scripts/solr/model/Solr.js
View file @
06223e0
...
...
@@ -101,6 +101,48 @@ define(function(require) {
this
.
set
(
pagination
,
skipOptions
);
}
},
buildQueryParameters
:
function
()
{
var
result
=
{};
_
.
each
(
this
.
get
(
'formNameMap'
),
function
(
impl
,
key
)
{
if
(
impl
instanceof
QueryTextField
)
{
var
query
=
impl
.
get
(
'query'
);
if
(
query
)
{
result
[
key
]
=
query
;
}
}
else
if
(
impl
.
facetType
===
'field'
||
impl
.
facetType
===
'year'
)
{
var
min
=
impl
.
get
(
'queryMin'
);
var
max
=
impl
.
get
(
'queryMax'
);
if
(
min
!==
undefined
)
{
result
[
key
+
'.min'
]
=
min
;
}
if
(
max
!==
undefined
)
{
result
[
key
+
'.min'
]
=
max
;
}
var
checkedItems
=
[];
impl
.
get
(
'items'
).
each
(
function
(
item
)
{
if
(
item
.
get
(
'checked'
))
{
checkedItems
.
push
(
item
.
get
(
'key'
));
}
});
if
(
checkedItems
.
length
)
{
result
[
key
+
'.items'
]
=
checkedItems
;
}
}
});
result
[
'p'
]
=
this
.
get
(
'currentPage'
);
result
[
'sz'
]
=
this
.
get
(
'pageSize'
);
var
serializedQuery
=
_
.
map
(
result
,
function
(
value
,
key
)
{
if
(
_
.
isArray
(
value
))
{
return
_
.
map
(
value
,
function
(
item
,
index
)
{
return
key
+
'='
+
item
;
}).
join
(
'&'
);
}
else
{
return
key
+
'='
+
value
;
}
}).
join
(
'&'
);
this
.
set
(
'serializedQuery'
,
serializedQuery
);
return
this
;
},
initialize
:
function
(
data
,
options
)
{
options
=
(
options
||
{});
this
.
set
(
'options'
,
new
Backbone
.
Model
({
...
...
@@ -109,6 +151,7 @@ define(function(require) {
showAll
:
!!
options
.
showAll
,
}));
this
.
_doSearchImmediately
=
_
.
bind
(
function
(
options
)
{
this
.
buildQueryParameters
();
this
.
fetch
(
_
.
extend
({},
options
,
{
data
:
this
.
toJSON
(),
merge
:
false
,
...
...
Please
register
or
sign in
to post a comment