<tal:block metal:use-macro="python:here.getFormsTool().getForm('site_admin_template').macros['page']">

<h1 metal:fill-slot="title" i18n:translate="">Edit selection list</h1>

<tal:block metal:fill-slot="section"
	tal:define="site_url here/getSitePath;
				id python:request.get('id', '');
				reflist python:here.getPortletsTool().getRefListById(id);
				item python:request.get('item', '')">
<tal:block tal:condition="python:reflist is not None">
[<a tal:attributes="href string:${site_url}/admin_reflists_html" i18n:translate="">Back to selection lists</a>]
<p i18n:translate="">&nbsp
</p>
<fieldset><legend i18n:translate="">Change the list properties</legend>
<form method="post" tal:attributes="action string:${site_url}/admin_editreflist">
<dl>
	<dt i18n:translate="">Title</dt>
	<dd><input type="title" name="title" tal:attributes="value reflist/title" /></dd>
	<dt i18n:translate="">Description</dt>
	<dd><textarea name="description" rows="5" cols="40" tal:content="reflist/description"></textarea></dd>
</dl>
<p><input type="submit" value="Update" i18n:attributes="value" /></p>
<p><input type="hidden" name="id" tal:attributes="value reflist/id" /></p>
</form>
</fieldset>
<br />
<tal:block tal:define="record_data python:reflist.get_item_data(item)">
<a name="edititem"></a>
<form method="post" tal:attributes="action python:test(record_data[0]=='add', '%s/admin_additem' % site_url, '%s/admin_edititem' % site_url)">
<fieldset><legend tal:condition="python:item==''" i18n:translate="">Add new item</legend>
<legend tal:condition="python:item!=''" i18n:translate="">Edit item</legend>
<dl>
	<dt i18n:translate="">ID</dt>
	<dd>
		<input tal:condition="python:record_data[0]=='add'" type="text" name="item" tal:attributes="value python:record_data[1]" />
		<strong tal:condition="python:record_data[0]!='add'" tal:content="item" />
		<input tal:condition="python:record_data[0]!='add'" type="hidden" name="item" tal:attributes="value item" />
	</dd>
	<dt i18n:translate="">Title</dt>
	<dd><input type="text" name="title" size="50" tal:attributes="value python:record_data[2]" /></dd>
</dl>
<p><input type="submit" tal:attributes="value python:test(record_data[0]=='add', 'Add', 'Update')" i18n:attributes="value" /></p>
</fieldset>
<input type="hidden" name="id" tal:attributes="value reflist/id" />
</form>
</tal:block>
<br />
<h2 i18n:translate="">Available items</h2>
<p i18n:translate="">Click on an item title to edit its attributes.</p>

<form method="post" tal:attributes="action string:${site_url}/admin_deleteitems">
	<table class="datatable">
	<thead>
		<tr>
			<th class="scope-col" scope="col">&nbsp;</th>
			<th class="scope-col" scope="col" i18n:translate="">Title</th>
		</tr>
	</thead>
	<tbody>
		<tr tal:repeat="record reflist/get_list">
			<td><input type="checkbox" name="ids" tal:attributes="value record/id" /></td>
			<td tal:define="quoted_id python:here.utUrlEncode(record.id)">
				<a tal:attributes="href string:${site_url}/admin_reflist_html?id=${reflist/id}&item=${quoted_id}#edititem" 
					tal:content="python:test(record.title.strip(), record.title, record.id)">title</a>
			</td>
		</tr>
	</tbody>
	</table>
	<input type="submit" name="delete" value="Delete" i18n:attributes="value" />
	<input type="hidden" name="id" tal:attributes="value reflist/id" />
</form>
<br />
</tal:block>
<tal:block tal:condition="python:reflist is None" i18n:translate="">
	Invalid selection list.
</tal:block>
</tal:block>

</tal:block>
