fix: Global Search fixes
- Update title, route and published in sync_value - Update search_template for BS4
This commit is contained in:
parent
3e4b6cfb58
commit
5d1ecb2e47
3 changed files with 32 additions and 17 deletions
|
|
@ -1,15 +1,15 @@
|
|||
<h1>{{ title }}</h1>
|
||||
|
||||
{%- macro search_results_section(results, title, has_more) -%}
|
||||
<div class='search-result col-sm-6'>
|
||||
<div class="search-result col-sm-6">
|
||||
{% if title %}
|
||||
<h3 style="margin-bottom: 30px">{{ title }}</h3>
|
||||
<h3 class="mb-4">{{ title }}</h3>
|
||||
{% endif %}
|
||||
|
||||
{% for d in results %}
|
||||
<div class="search-result-item" style="padding-bottom: 15px;">
|
||||
<div class="search-result-item mb-4">
|
||||
<a href="{{ d.route }}"><b>{{ d.title }}</b></a>
|
||||
<p>{{ d.preview }}</p>
|
||||
<p class="m-0">{{ d.preview }}</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if has_more %}
|
||||
|
|
@ -19,15 +19,20 @@
|
|||
</div>
|
||||
{%- endmacro %}
|
||||
|
||||
<div style="margin-bottom: 30px">
|
||||
<form action='{{ route }}'>
|
||||
<input name='q' class='form-control' type='text'
|
||||
style='max-width: 400px; display: inline-block; margin-right: 10px;'
|
||||
value='{{ query or ''}}'
|
||||
{% if not query %}placeholder="{{ _("Search...") }}"{% endif %}>
|
||||
<input type='submit'
|
||||
class='btn btn-sm btn-primary btn-search' value="{{ _("Search") }}">
|
||||
</form>
|
||||
<div class="row mb-5">
|
||||
<div class="col-sm-6">
|
||||
<form action="{{ route }}">
|
||||
<div class="input-group">
|
||||
<input name="q" class="form-control" type="text" value="{{ query or ''}}"
|
||||
placeholder="{{ _('Search...') }}">
|
||||
<div class="input-group-append">
|
||||
<button type="submit" class="btn btn-sm btn-primary btn-search">
|
||||
{{ _('Search') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if results %}
|
||||
|
|
|
|||
|
|
@ -311,16 +311,26 @@ def sync_value(value):
|
|||
Sync a given document to global search
|
||||
:param value: dict of { doctype, name, content, published, title, route }
|
||||
'''
|
||||
|
||||
|
||||
frappe.db.multisql({
|
||||
'mariadb': '''INSERT INTO `__global_search`
|
||||
(`doctype`, `name`, `content`, `published`, `title`, `route`)
|
||||
VALUES (%(doctype)s, %(name)s, %(content)s, %(published)s, %(title)s, %(route)s)
|
||||
ON DUPLICATE key UPDATE `content`=%(content)s''',
|
||||
ON DUPLICATE key UPDATE
|
||||
`content`=%(content)s,
|
||||
`published`=%(published)s,
|
||||
`title`=%(title)s,
|
||||
`route`=%(route)s
|
||||
''',
|
||||
'postgres': '''INSERT INTO `__global_search`
|
||||
(`doctype`, `name`, `content`, `published`, `title`, `route`)
|
||||
VALUES (%(doctype)s, %(name)s, %(content)s, %(published)s, %(title)s, %(route)s)
|
||||
ON CONFLICT("doctype", "name") DO UPDATE SET `content`=%(content)s'''
|
||||
ON CONFLICT("doctype", "name") DO UPDATE SET
|
||||
`content`=%(content)s,
|
||||
`published`=%(published)s,
|
||||
`title`=%(title)s,
|
||||
`route`=%(route)s
|
||||
'''
|
||||
}, value)
|
||||
|
||||
def delete_for_document(doc):
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ def get_search_results(text, start=0, as_html=False):
|
|||
for d in results:
|
||||
d.content = html2text(d.content)
|
||||
index = d.content.lower().index(text.lower())
|
||||
d.content = d.content[:index] + '<b>' + d.content[index:][:len(text)] + '</b>' + d.content[index + len(text):]
|
||||
d.content = d.content[:index] + '<mark>' + d.content[index:][:len(text)] + '</mark>' + d.content[index + len(text):]
|
||||
|
||||
if index < 40:
|
||||
start = 0
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue