extends layout

block content
	- if (locals.topic)
		p Editing topic "#{topic.title}".
		- faction = "/topics/" + topic.key + "/edit"
		form.col-10(method="POST", action=)
	- else 
		p Add a topic for discussion at 
			a(href="/agendas/#{agenda.key}")= agenda.title
			.
		- faction = "/agendas/" + agenda.key + "/topics/new"
	form.col-10(method="POST", action=faction)
		input(type="hidden", name="_csrf", value="#{_csrf}")
		.form-group
			- if (locals.ititle)
				input.form-control.input-lg(type="text", name="ititle", value="#{locals.ititle}")
			- else
				input.form-control.input-lg(type="text", placeholder="A summary of your topic", name="ititle")
		.form-group
			textarea.form-control(rows='5', name="idesc", placeholder="More about your topic (optional)")
				= locals.idesc
			span.help-block You can use Markdown or html in the description.
		.form-group
			- if (locals.topic)
				a.btn.btn-danger.pull-right(href="#deleteModal", data-toggle="modal") Delete
			button.btn.color2(type="cancel") Cancel
			&nbsp;
			button.btn.color2a(type="submit") Save
	- if (locals.topic)
		#deleteModal.modal.fade.col-4(tabindex="-1", role="dialog", aria-labelledby="deleteModelLabel", aria-hidden="true")
			.modal-dialog
				.modal-content
					.modal-header
						button.close(data-dismiss="modal", type="button", aria-hidden="true") &times;
						h3.modal-title Delete this topic?
					.modal-body
						p This will also delete all the topic's votes. You cannot undo this action. 
					.modal-footer
						form(method="POST", action="/topics/#{topic.key}/delete")
							button.btn.color2(data-dismiss="modal", type="button") Cancel
							button.btn.btn-danger(type="submit") Delete
