extends vibenews.admin.layout

block title
	- import std.algorithm;
	
	- title = "Edit category " ~ category.caption;
	
block vibenews.navigation
	ul
		li
			a(href="../../") Admin panel
		li
			a(href="./show")= title

block vibenews.body
	p
		a(href="#{req.rootDir}") Back to overview

	form(method="POST", action="/categories/#{category._id}/update")
		table 
			col.caption
			tr
				td
					label(for="caption") Caption
				td
					input#caption(type="text", name="caption", value="#{category.caption}")
			tr
				td
					label(for="index") Index
				td
					input#index(type="text", name="index", value="#{category.index}")
			tr
				td Groups
				td
					- foreach( grp; groups )
						p
							- if( canFind(category.groups, grp._id) )
								input.checkbox(id="#{grp._id}", type="checkbox", name="#{grp._id}", checked)
							- else
								input.checkbox(id="#{grp._id}", type="checkbox", name="#{grp._id}")
							label(for="#{grp._id}")= grp.name
			tr
				td
				td
					input(type="submit", value="Apply changes")

	form(method="POST", action="/categories/#{category._id}/delete")
		input(type="submit", value="Delete category")