{% load extra_filters %}
<form id="id_form_case_runs">
<div class="mixbar">
	<span class="tit" style='float:left'>Cases: {{ test_case_runs_count }}</span>
	<ul class="btnBlue btnBlueFilter" id="showFilterBtn">
		<li class="btnBlueL"></li>
		<li class="btnBlueC"><a title="Click to show filter case-run options" id='filter_case_run'>Show filter options</a></li>
		<li class="btnBlueR"></li>
	</ul>
	<div class='right_float tit'>
		<input id="id_check_box_auto_blinddown" type="checkbox" />
		<label for="id_check_box_auto_blinddown" title="Automatically display next text case">Automatically</label>
		<input id="id_check_box_highlight" type="checkbox" />
		<label for="id_check_box_highlight" title="Highlight my assigned runs">Highlight</label>
	</div>
	<div>
		<div class="btnBlueCaserun">
			<span>Cases</span>
			<ul>
				{% if perms.testruns.add_testcaserun %}
				<li><a href="{% url "add-cases-to-run" test_run.run_id %}" class="addBlue9">Add</a></li>
				{% endif %}
				{% if perms.testruns.delete_testcaserun %}
				<li><a href="javascript:void(0)" title="Remove selected cases form this test run" data-param="{{ test_run.run_id }}" class="removeBlue9 js-del-case">Remove</a></li>
				{% endif %}
				{% if perms.testruns.change_testcaserun %}
				<li><a id="id_sort" title="Click me,then Drag and drop the rows to adjust the order,and click 'Done Sorting' link to submit your changes" href="javascript:void(0)" class="reorderBlue9">Re-order</a></li>
				<li><a href="javascript:void(0)" title="Update the IDLE case runs to newest case text" href="javascript:void(0)" data-param="{% url 'run-update' test_run.pk %}" class="updateBlue9 js-update-case">Update</a></li>
				{% endif %}
				{% if perms.testruns.change_testcaserun %}
				<li><a href="javascript:void(0)" title="Assignee this case(s) to other people" class="assigneeBlue9 js-change-assignee">Assignee</a></li>
				{% endif %}
			</ul>
		</div>
		<div class="btnBlueCaserun">
			<span>Status</span>
			<ul class="statusOptions">
				{% for tcrs in test_case_run_status %}
				<li><a href="javascript:void(0)" class="{{ tcrs|lower }}Blue9" data-statusid="{{ tcrs.pk }}">{{ tcrs }}</a></li>
				{% endfor %}
			</ul>
		</div>
		<div class="btnBlueCaserun">
			<span>Issues</span>
			<ul>
				<li><a href="javascript:void(0);" class="addBlue9 js-add-issues" data-add-issue-info='{"runId": {{ test_run.pk }}}'>Add</a></li>
				<li><a href="javascript:void(0);" class="removeBlue9 js-remove-issues" data-remove-issue-info='{"runId": {{ test_run.pk }}}'>Remove</a></li>
			</ul>
		</div>
		<div class="btnBlueCaserun">
			<span>Comment</span>
			<ul>
				<li><a href="javascript:void(0)" class="addBlue9 js-show-commentdialog">Add</a></li>
			</ul>
		</div>
	</div>
	<div class="clear"></div>
</div>
</form>
<form id="id_filter" action="." method="get" style='display:none'>
	<div style="border:1px solid #235D9F; margin:2px; padding:8px; background:#DEEAF7;">
		<input type="hidden" name="order_by" value="{{ REQUEST_CONTENTS.order_by }}" />
		<div class="leftlistinfo">
			<div class="listinfo">
				<span class="title"><label for="id_summary">Summary&nbsp;:</label></span>
				<input id="id_summary" type="text" name="case__summary__icontains" value="{{ REQUEST_CONTENTS.case__summary__icontains }}" />
			</div>
			<div class="listinfo">
				<span class="title"><label for="id_default_tester">Default tester&nbsp;:</label></span>
				<input id="id_default_tester" type="text" name="tested_by__email__startswith" value="{{ REQUEST_CONTENTS.tested_by__email__startswith }}" />
			</div>
			<div class="listinfo">
				<span class="title"><label for="id_assignee">Assignee&nbsp;:</label></span>
				<input id="id_assignee" type="text" name="assignee__email__startswith" value="{{ REQUEST_CONTENTS.assignee__email__startswith }}" />
			</div>
			<div class="listinfo">
				<span class="title"><label for="id_is_automated">Automated&nbsp;:</label></span>
				<select id="id_is_automated" name="case__is_automated">
					<option value="">--------</option>
					<option value="0">Manual</option>
					<option value="1">Auto</option>
				</select>
			</div>
		</div>
		<div class="rightlistinfo">
			<div class="listinfo">
				<span class="title"><label for="id_issue">Issue&nbsp;:</label></span>
				<input id="id_issue" type="text" name="issues__issue_key__in" value="{{ REQUEST_CONTENTS.issues__issue_key__in }}" />
				<span class='grey'>You can type multiple issue keys separated by comma.</span>
			</div>
			<div class="listinfo">
				<span class="title"><label for="id_case_run_status">Status&nbsp;:</label></span>
				<select id="id_case_run_status" name="case_run_status__name">
					<option value="">--------</option>
					{% for case_run_status in test_case_run_status %}
					<option value="{{ case_run_status.name }}"{% if case_run_status.name == REQUEST_CONTENTS.case_run_status__name %} selected{% endif %}>
						{{ case_run_status }}
					</option>
					{% endfor %}
				</select>
			</div>
			<div class="listinfo">
				<span class="title"><label for="id_priority">Priority&nbsp;:</label></span>
				<select id="id_priority" name="case__priority__pk">
					<option value="">--------</option>
					{% for priority in priorities %}
					<option value="{{ priority.pk }}"{% if priority.pk == REQUEST_CONTENTS.case__priority__pk %} selected{% endif %}>{{ priority }}</option>
					{% endfor %}
				</select>
			</div>
			<div class="listinfo">
				<span class="title"><label for="id_tags">Tag&nbsp;:</label></span>
				<input id="id_tag" type="text" name="case__tag__name" value="{{ REQUEST_CONTENTS.case_tag__name }}" />
			</div>
		</div>
		<div class='clear'></div>
		<div class='button_box2'>
		<input type="submit" value='Search' />
		<input type="reset" value='Reset' />
	</div>
	</div>
</form>

<div class="mixbar fixed">
	<div class="tit" style="width: 50px; float: left; height: 100%; margin: 0px; text-align: center;">Tags:</div>
	<div style="margin-left: 50px; line-height:22px;" class="taglist">
		{% for tag in case_own_tags %}
		{{ tag }}&nbsp;&nbsp;<span class="grey">-</span>&nbsp;&nbsp;
		{% empty %}
		<span class="grey">No tags in cases</span>
		{% endfor %}
	</div>
</div>

{% include "run/table_caseruns.html" %}

<div id="addlink_dialog" title="Add Test Log">
	<p>All these fields are required.</p>
	<form>
		<fieldset style="padding:0; border:0; margin-top:25px;">
			<label for="testlog_name" style="display:block">Name <span style="color:red">*</span> (64 characters at most)</label>
			<input type="text" id="testlog_name" name="testlog_name" size="64"
				class="text ui-widget-content ui-corner-all"
				style="margin-bottom:12px; width:95%; padding: .4em; display:block"/>
			<label for="testlog_url" style="display:block">URL <span style="color:red">*</span></label>
			<textarea id="testlog_url" name="testlog_url" rows="3"
				class="text ui-widget-content ui-corner-all"
				style="width:95%; display:block"></textarea>
		</fieldset>
	</form>
</div>

{% comment %}
If no issue tracker is associated with the product, or no issue tracker is enabled,
no need to render this dialog for adding an issue.
{% endcomment %}
{% if issue_trackers %}
<div id="add-issue-dialog" title="Add issue to case run" style="display: none">
	<form onsubmit="return false">
	<fieldset>
		<div class="bug_type" id="id_issue_tracker">Issue Tracker</div>
		<select name="issue_tracker_id" id="issue_tracker_id">
			{% for tracker in issue_trackers %}
			<option {% if forloop.counter == 1 %}selected{% endif %}
                    value="{{ tracker.pk }}"
                    data-tab="issue-tracker-{{ tracker.code_name }}"
                    data-validate-regex="{{ tracker.validate_regex }}">{{ tracker.name }}</option>
			{% endfor %}
		</select>
		{% for tracker in issue_trackers %}
		<div id="issue-tracker-{{ tracker.code_name }}" style="{% if forloop.counter == 1 %}line-height:30px;{% else %}display:none;{% endif %}">
			<div>Issue ID</div>
			<input type="text" name="issue_key" />
			{% if tracker.allow_add_case_to_issue %}
			</br>
			<input type="checkbox" name="link_external_tracker" />&nbsp;
			<span class="use_bz_external_track">Check to add Test Cases to issue</span>
			{% endif %}
		</div>
		{% endfor %}
	</fieldset>
	</form>
</div>
{% endif %}

{# Dialog for selecting an issue tracker to file an issue. #}
{% if issue_trackers %}
<div id="select-tracker-dialog" title="Select an issue tracker" style="display: none">
	<form name="issueTrackerSelectionForm" target="_blank">
		<label for="issueTrackersForFileIssue">Issue Tracker</label>
		<select name="issueTrackers" id="issueTrackersForFileIssue" style="width: 100%">
		{% for tracker in issue_trackers %}
			<option{% if forloop.counter == 1 %} selected{% endif %} value="{{ tracker.pk }}">{{ tracker.name }}</option>
		{% endfor %}
		</select>
	</form>
</div>
{% endif %}

<div id="addCommentDialog" title="Add Comment" style="display:none">
	<textarea name="newCommnentText" id="newCommentText" style="width:100%;height:100%;"></textarea>
</div>
