include mixins
include mixins_pentryedit

form(class="form-horizontal subroot", role="form", id="form", method="POST", action="#{todo_href}/commit")
	.new_flex_zero(style="margin-bottom: 20px;")
		.container-fluid
			button(class="btn btn-success btn-sm", type="submit") 
				span(class="glyphicon glyphicon-ok", aria-hidden="true")
				span 
				span Übernehmen
			
			+messageview(messages.other)
				
	.new_flex_one
		.container-fluid

			.form-group
				label(for='edit_kontext', class="col-sm-2 control-label") Kontext
				.col-sm-10
					.input-group
						input(id="edit_kontext_dn", type="hidden", name="punit_dn", value="#{todo.punit.dn}")
						input(id="edit_kontext", type="text", name="punit_name", class="form-control", value="#{todo.punit.name}", readonly)
						span(class="input-group-btn")
							button(class="btn btn-default", type="button", onclick="save_and_goto('select_pastoralunit', {})") Ändern
			.form-group
				label(for='edit_name', class="col-sm-2 control-label") Kurzbeschreibung
				.col-sm-10
					input(id='edit_name', type="text", class="form-control noEnterSubmit", name="edit_name", value="#{todo.name}", required)
					.help-block.with-errors
			.row
				fieldset(class="col-sm-12", style="margin-top: 10px;")
					legend(style="font-size: 150%") Beschreibung
					textarea(class="form-control", rows="5", id="area_description", name="area_description").
						#{todo.description}
			.row(style="margin-bottom: 75px;")
				div(class="col-sm-12", style="margin-top: 20px;", id="involved")
					fieldset
						+involved_list_label("Beteiligte", "font-size: 150%; margin-bottom: 5px;", "font-style: italic;", "")
						+involved_list(todo.involved, "Beteiligte", "")
					#messageview_involved_primary
						if messages.involved.primary.length > 0
							+messageview(messages.involved.primary)

	script.
		$('.noEnterSubmit').keypress(function(e){
			if ( e.which == 13 ) e.prtodoDefault();
		});
		
		$('#form').validator().on('invalid.bs.validator', function (e) {
			console.log("INVALID");
			console.log(e);
		}).on('valid.bs.validator', function (e) {
			console.log("VALID");
			console.log(e);
		});
		
