{% extends g.theme.master %}
{% do g.register_app_css('css/tracker.css') %}
{% block title %}{{c.project.name}} / {{c.app.config.options.mount_label}} / Search{% endblock %}
{% block header %}Search {{c.app.config.options.mount_point}}: {{q}}{% endblock %}
{% block head %}
<link rel="alternate" type="application/rss+xml" title="RSS" href="feed.rss"/>
<link rel="alternate" type="application/atom+xml" title="Atom" href="feed.atom"/>
{% endblock %}
{% block actions %}
<a href="{{tg.url(c.app.url+'search_feed/', dict(q=q, limit=limit, sort=sort))}}" title="Feed"><b data-icon="{{g.icons['feed'].char}}" class="ico {{g.icons['feed'].css}}"></b></a>
{% if allow_edit and count != 0 %}
<a href="{{tg.url(c.app.url+'edit/', dict(q=q, limit=limit, sort=sort, page=page))}}" title="Bulk Edit"><b data-icon="{{g.icons['pencil'].char}}" class="ico {{g.icons['pencil'].css}}"></b></a>
{% endif %}
{% endblock %}
{% if q and h.has_access(c.app, 'save_searches')() %}
{% block edit_box %}
<div class="editbox" style="display:none">
{{c.bin_form.display(
value=dict(summary=q,terms=q,sort=sort,_id=bin and bin._id or None),
action=c.project.url()+'admin/'+c.app.config.options.mount_point+'/bins/save_bin'
)}}
</div>
{% endblock %}
{% endif %}
{% block content %}
{% if help_msg %}
<div id="search-ticket-help-msg" class="grid-19 info">{{g.markdown.convert(help_msg)}}</div>
{% endif %}
<div class="grid-19">
{% if bin %}
<input type="text" id="bin_summary" value="{{bin.summary}}" style="width: 125px; float: left; margin-right: .5em">
{% endif %}
<form method="GET">
<input type="text" name="q" value="{{q}}" style="width: 280px; float: left; margin-right: .5em" id="bin_terms">
</form>
{% if bin and h.has_access(c.app, 'save_searches')() %}
<input type="button" value="Update Search" id="save_search"/>
{% endif %}
<input type="submit" value="Search"/> <a href="#" class="btn search_help_modal"><b data-icon="{{g.icons['help'].char}}" class="ico {{g.icons['help'].css}}"></b> Help</a>
</div>
<div style="clear:both"></div>
{{c.ticket_search_results.display(solr_error=solr_error,
count=count,
limit=limit,
query=q,
tickets=tickets,
sortable_custom_fields=sortable_custom_fields,
columns=columns,
page=page,
sort=sort)}}
{{c.search_help_modal.display()}}
{% endblock %}
{% block extra_js %}
{% if q and h.has_access(c.app, 'save_searches')() %}
<script type="text/javascript">
$('#save_search').click(function(){
$('div.editbox input[name=summary]').val($('#bin_summary').val());
$('div.editbox input[name=terms]').val($('#bin_terms').val());
$('div.editbox form').submit();
});
$('#cancel_new_bin').click(function(){
$('div.editbox').hide();
});
</script>
{% endif %}
{% endblock %}