{% extends "base.html" %}

{% block title %}
&raquo; Connection Agreements &raquo; {{ca.id}} {{ca.start_date|date_format}} &raquo; Edit
{% endblock %}

{% block nav %}
	<a href="/e/cas">Connection Agreements</a> &raquo; 
	<a href="/e/cas/{{ca.id}}">{{ca.id}} {{ca.start_date|date_format}}</a> &raquo; Edit
{% endblock %}

{% block content %}

	<form action="/e/cas/{{ca.id}}/edit" method="post">
		<fieldset>
			<legend>Update This Connection Agreement</legend>	
			<label>Start Date</label> {{input_date('start', ca.start_date)}}

			<label>Finish Date</label> {{input_date('finish', finish_date, has_is_ended=True)}}

			<label>Title</label> {{input_text('title', initial=ca.properties.get('title'))}}

			<label>URL</label> {{input_text('url', initial=ca.properties.get('url'))}}

			<label>Element → Primary Supply Id</label>

			<div>
				{{input_textarea('properties_elements', ca.properties.get('elements', {})|tojson(indent=2), 10, 40, show_pos=True)}}
				<h5>Example</h5>
				<pre>{
  "tnuos": 774,
  "duos-availability": 774
}</pre>
			</div>

			<input type="submit" name="update" value="Update">
		</fieldset>
	</form>

	<form hx-delete="/e/cas/{{ca.id}}/edit"
	 		hx-confirm="Are you sure you want to delete this connection agreement?">
		<fieldset>
			<legend>Delete This Connection Agreement</legend>
			<input type="submit" name="delete" value="Delete">
		</fieldset>
	</form>

{% endblock %}
