<h2>{{with $.filter}}Edit filter{{else}}Create new{{end}}</h2>
<form id="wordfilterform" action="{{webPath `/manage/wordfilters`}}{{with $.filter}}?edit={{$.filter.ID}}{{end}}" method="POST">
	<table>
	<tr><th>Search for:</th><td><input type="text" name="searchfor" id="findfilter" value="{{with $.filter}}{{$.filter.Search}}{{end}}"/></td></tr>
	<tr><th>Replace with:</th><td><input type="text" name="replace" id="replacefilter" value="{{with $.filter}}{{$.filter.MatchDetail}}{{end}}"/></td></tr>
	<tr><th>Regular expression:</th><td><input type="checkbox" name="isregex" id="isregex" {{with $.filter}}{{if $.filter.IsRegex}}checked="checked"{{end}}{{end}}/></td></tr>
	<tr><th>Only on boards:</th><td id="boardslist">
		{{- range $_, $board := $.allBoards -}}
			{{- $onBoard := false -}}
			{{with $.filter}}
				{{- $onBoard = $.filter.OnBoard $board.Dir true -}}
			{{- end -}}
			<label for="board-{{$board.Dir}}">
				<input type="checkbox" name="board-{{$board.Dir}}" id="board-{{$board.Dir}}" {{if $onBoard}}checked{{end}}> /{{$board.Dir}}/ - {{$board.Title}}
			</label>
		{{- end -}}
	</td></tr>
	<tr><th>Staff note</th><td><input type="text" name="staffnote" value="{{with $.filter}}{{$.filter.StaffNote}}{{end}}"/></td></tr>
	<tr><th>
		<input type="submit" name="dowordfilter" value="{{with $.filter}}Edit{{else}}Create{{end}} wordfilter"/>
		<input type="button" onclick="document.getElementById('wordfilterform').reset()" value="Reset"/>
		{{with $.filter -}}
			<input type="button" onclick="window.location='{{webPath `manage/wordfilters`}}'" value="Cancel"/>
		{{- end}}
	</th></tr>
	</table>
</form>
<hr/>
<h2>Wordfilters</h2>
{{if eq 0 (len .wordfilters)}}<i>No wordfilters</i>{{else -}}
<table class="mgmt-table wordfilters">
	<colgroup><col width="10%"><col width="10%"><col width="10%"><col width="5%"><col width="15%"><col width="10%"></colgroup>
	<tr><th>Actions</th><th>Search</th><th>Replace with</th><th>Is regex</th><th>Dirs</th><th>Created by</th><th>Staff note</th></tr>
{{- range $f,$filter := .wordfilters}}
	<tr>
		<td><a href="{{webPath `manage/wordfilters`}}?edit={{$filter.ID}}">Edit</a> | <a href="{{webPath `manage/wordfilters`}}?{{if $filter.IsActive}}disable{{else}}enable{{end}}={{$filter.ID}}">{{if $filter.IsActive}}Disable{{else}}Enable{{end}}</a> </td>
		<td>{{index $.searchFields $f}}</td>
		<td>{{$filter.MatchDetail}}</td>
		<td>{{if $filter.IsRegex}}yes{{else}}no{{end}}</td>
		<td>{{$dirs := $filter.BoardsString -}}
			{{if eq $dirs "*" -}}
				<i>all boards</i>
			{{- else -}}
				{{$dirs}}
			{{- end -}}
		</td>
		<td>{{$filter.StaffName}}</td>
		<td>{{$filter.StaffNote}}</td>
	</tr>
{{end -}}
</table>
{{- end}}