extends vibenews.admin.layout

block title
	- title = "Edit group " ~ group.name;
	
block vibenews.navigation
	ul
		li
			a(href="../../") Admin panel
		li
			a(href="./show")= title

block vibenews.body
	- import std.array : join;
	- auto stripPrefix(string[] tags)
		- import vibenews.controller;
		- import std.algorithm : map, startsWith;
		- return tags.map!(t => t.startsWith(authGroupPrefix) ? t[authGroupPrefix.length .. $] : t);

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

	form(method="POST", action="/groups/#{group.name}/update")
		table 
			col.caption
			tr
				td
					label(for="caption") Caption
				td
					input#caption(type="text", name="caption", value="#{group.caption}")
			tr
				td
					label(for="description") Description
				td
					input#description(type="text", name="description", value="#{group.description}")
			tr
				td
					label(for="active") Active
				td
					- if( group.active )
						input#active.checkbox(type="checkbox", name="active", value="yes", checked)
					- else
						input#active.checkbox(type="checkbox", name="active", value="yes")
			tr
				td
					label(for="roauthtags") Read-only auth tags
				td
					input#roauthtags(type="text", name="roauthtags", value='#{join(stripPrefix(group.readOnlyAuthTags), ", ")}')
			tr
				td
					label(for="rwauthtags") Read-write auth tags
				td
					input#rwauthtags(type="text", name="rwauthtags", value='#{join(stripPrefix(group.readWriteAuthTags), ", ")}')
			tr
				td
				td
					input(type="submit", value="Apply changes")
		p Note: Auth tags are separated by commas, leave blank if group is public

	form(method="GET", action="/groups/#{group.name}/articles")
		input(type="submit", value="Manage articles")

	form(method="POST", action="/groups/#{group.name}/purge")
		input(type="submit", value="Purge inactive articles")
		