Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Goethes Farbenlehre
gfl-app-new
Commits
1ae81f4d
Commit
1ae81f4d
authored
May 10, 2022
by
pestov
Browse files
Add Ganzes Wort search option
parent
1b5dc88f
Pipeline
#296318
passed with stages
in 13 minutes
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
assets/js/modules/searcn.js
View file @
1ae81f4d
...
...
@@ -10,7 +10,7 @@ class Search {
let
queryArr
=
[];
Object
.
keys
(
entries
).
forEach
(
key
=>
{
let
index
=
key
.
match
(
/
\d
+/g
)?.[
0
];
let
attribute
=
key
.
match
(
/field|operator|value/g
)?.[
0
];
let
attribute
=
key
.
match
(
/field|operator|value
|phrase
/g
)?.[
0
];
const
value
=
entries
[
key
];
if
(
index
===
undefined
&&
!
attribute
)
{
...
...
@@ -24,6 +24,7 @@ class Search {
operator
:
''
,
field
:
''
,
value
:
''
,
phrase
:
''
})
}
...
...
@@ -40,7 +41,8 @@ class Search {
queryArr
=
[{
operator
:
''
,
field
:
''
,
value
:
''
value
:
''
,
phrase
:
''
}];
}
...
...
@@ -93,13 +95,15 @@ class Search {
return
this
.
getTextField
(
data
);
}
else
if
(
type
===
'
select
'
)
{
return
this
.
getSelectField
(
data
);
}
else
if
(
type
===
'
switch
'
)
{
return
this
.
getSwitchField
(
data
);
}
else
if
(
type
===
'
remove
'
)
{
return
this
.
getRemoveButton
(
data
);
}
}).
join
(
''
);
this
.
appendTemplate
(
`<div class="search-field-group input-group
align-items-center
mb-2">
${
fields
}
</div>`
`<div class="search-field-group input-group mb-2">
${
fields
}
</div>`
);
this
.
lastFieldGroupIndex
++
;
...
...
@@ -107,8 +111,8 @@ class Search {
getRemoveButton
({
disabled
})
{
return
`<button type="button" class="
btn btn-close ms-2
${
disabled
?
'
disabled invisible
'
:
''
}
" aria-label="Close"
onclick="this.parentElement.parentElement.removeChild(this.parentElement)">
return
`<button type="button" class="
remove-button btn btn-outline-primary ms-2 mt-auto
${
disabled
?
'
disabled invisible
'
:
''
}
" aria-label="Close"
onclick="this.parentElement.parentElement.removeChild(this.parentElement)">
Entfernen
</button>`
;
}
...
...
@@ -130,6 +134,13 @@ class Search {
</div>`
;
}
getSwitchField
({
name
,
label
,
checked
})
{
return
`<div class="d-flex flex-column flex-grow-0 flex-shrink-0 ms-2 form-switch">
<label class="small fw-bold">
${
label
}
</label>
<input class="form-check-input" role="switch" type="checkbox"
${
checked
?
'
checked
'
:
''
}
name="
${
name
}
">
</div>`
}
convertToElement
(
template
)
{
const
wrapper
=
document
.
createElement
(
'
div
'
);
wrapper
.
innerHTML
=
template
;
...
...
@@ -148,7 +159,8 @@ class Search {
getFieldGroupData
(
index
,
query
=
{
operator
:
''
,
field
:
''
,
value
:
''
value
:
''
,
phrase
:
''
})
{
const
operatorQuery
=
query
[
'
operator
'
];
...
...
@@ -197,6 +209,14 @@ class Search {
value
:
valueQuery
};
const
phraseQuery
=
query
[
'
phrase
'
];
const
wholeWordData
=
{
type
:
'
switch
'
,
name
:
`q[
${
index
}
][phrase]`
,
label
:
'
Ganzes Wort
'
,
checked
:
phraseQuery
===
'
on
'
}
const
removeButtonData
=
{
type
:
'
remove
'
,
disabled
:
index
===
0
,
...
...
@@ -206,6 +226,7 @@ class Search {
operatorData
,
fieldData
,
valueData
,
wholeWordData
,
removeButtonData
];
}
...
...
assets/scss/pages/_search.scss
View file @
1ae81f4d
.search-field-group
{
&
:not
(
:first-child
)
{
label
{
display
:
none
;
visibility
:
hidden
;
height
:
0
;
}
}
label
{
padding-left
:
0
.75rem
;
margin-bottom
:
0
.2rem
;
}
input
[
type
=
checkbox
]
{
margin-left
:
0
.75rem
;
margin-top
:
0
.75rem
;
}
.form-switch
{
padding
:
0
;
}
.remove-button
{
border-radius
:
4px
!
important
;
}
}
src/Service/SolrSearchService.php
View file @
1ae81f4d
...
...
@@ -263,6 +263,7 @@ class SolrSearchService implements SearchServiceInterface
$operator
=
$queryItem
[
'operator'
]
??
null
;
$field
=
$queryItem
[
'field'
]
??
null
;
$value
=
$queryItem
[
'value'
]
??
null
;
$phrase
=
$queryItem
[
'phrase'
]
??
null
;
if
(
isset
(
$operator
)
&&
!
empty
(
$operator
)
&&
$operator
!==
'none'
)
{
if
(
$operator
===
'NOT'
)
{
...
...
@@ -278,7 +279,11 @@ class SolrSearchService implements SearchServiceInterface
if
(
$value
===
''
||
$value
===
'*'
)
{
$value
=
'*'
;
}
else
{
$value
=
$containsSpecialChars
>
0
?
$value
:
"*
$value
*"
;
$isPhrase
=
isset
(
$phrase
)
&&
$phrase
===
'on'
;
$valueTemp
=
$isPhrase
?
'"'
:
''
;
$valueTemp
.
=
$containsSpecialChars
>
0
||
$isPhrase
?
$value
:
"*
$value
*"
;
$valueTemp
.
=
$isPhrase
?
'"'
:
''
;
$value
=
$valueTemp
;
}
$queryString
.
=
"
$field
:
$value
"
;
}
...
...
@@ -287,7 +292,7 @@ class SolrSearchService implements SearchServiceInterface
$queryString
.
=
')'
;
}
}
$queryString
.
=
' AND doctype:article'
;
$select
->
setQuery
(
$queryString
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment