Support search model selection
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -294,6 +294,7 @@
|
||||
* Use select2 for the content type filed of the access
|
||||
grant and remove action.
|
||||
* Add Latvian translation.
|
||||
* Support search model selection.
|
||||
|
||||
3.1.11 (2019-04-XX)
|
||||
===================
|
||||
|
||||
@@ -723,6 +723,8 @@ Other changes
|
||||
- Use select2 for the content type filed of the access
|
||||
grant and remove action.
|
||||
- Add Latvian translation.
|
||||
- Support search model selection.
|
||||
|
||||
|
||||
Removals
|
||||
--------
|
||||
|
||||
@@ -42,31 +42,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="well center-block">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<form action="{% url 'search:results' search_model='documents.DocumentPageResult' %}" method="get" role="search">
|
||||
<div class="input-group">
|
||||
<input class="form-control" name="q" placeholder="{% trans 'Search pages' %}" type="text" value="{{ search_terms|default:'' }}">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" type="submit">{% trans 'Search' %}</button>
|
||||
<a class="btn btn-primary" href="{% url 'search:search_advanced' search_model='documents.DocumentPageResult' %}">{% trans 'Advanced' %}</a>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
<br/>
|
||||
<form action="{% url 'search:results' search_model='documents.Document' %}" method="get" role="search">
|
||||
<div class="input-group">
|
||||
<input class="form-control" name="q" placeholder="{% trans 'Search documents' %}" type="text" value="{{ search_terms|default:'' }}">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" type="submit">{% trans 'Search' %}</button>
|
||||
<a class="btn btn-primary" href="{% url 'search:search_advanced' search_model='documents.Document' %}">{% trans 'Advanced' %}</a>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% include 'dynamic_search/search_box.html' %}
|
||||
|
||||
{% render_dashboard 'main' %}
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
{% load i18n %}
|
||||
|
||||
{% load search_tags %}
|
||||
{% get_search_models as search_models %}
|
||||
|
||||
<div class="well center-block">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<form action="{% url 'search:results' %}" class="form-horizontal" id="formSearch" method="get" role="search">
|
||||
<div class="col-sm-2">
|
||||
<select class="form-control" id="selectSearchModel" name="_search_model">
|
||||
{% for search_model in search_models %}
|
||||
{{ search_model.self.get_full_name }}
|
||||
<option {% if search_model.get_full_name == 'documents.Document' %}selected{% endif %} value="{{ search_model.get_full_name }}">{{ search_model }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-10">
|
||||
<div class="input-group">
|
||||
<input class="form-control" name="q" placeholder="{% trans 'Search terms' %}" type="text" value="{{ search_terms|default:'' }}">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" type="submit">{% trans 'Search' %}</button>
|
||||
<a class="btn btn-primary" href="" id="btnSearchAdvanced" >{% trans 'Advanced' %}</a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
jQuery(document).ready(function() {
|
||||
var $selectSearchModel = $('#selectSearchModel');
|
||||
var $btnSearchAdvanced = $('#btnSearchAdvanced');
|
||||
$btnSearchAdvanced.attr('href', "{% url 'search:search_advanced' %}?_search_model=" + $selectSearchModel.val());
|
||||
$selectSearchModel.change(function () {
|
||||
$btnSearchAdvanced.attr('href', "{% url 'search:search_advanced' %}?_search_model=" + $(this).val());
|
||||
});
|
||||
});
|
||||
</script>
|
||||
0
mayan/apps/dynamic_search/templatetags/__init__.py
Normal file
0
mayan/apps/dynamic_search/templatetags/__init__.py
Normal file
14
mayan/apps/dynamic_search/templatetags/search_tags.py
Normal file
14
mayan/apps/dynamic_search/templatetags/search_tags.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.template import Library
|
||||
from django.utils.module_loading import import_string
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
register = Library()
|
||||
|
||||
from ..classes import SearchModel
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def get_search_models():
|
||||
return SearchModel.all()
|
||||
Reference in New Issue
Block a user