<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../../xsltforms/xsltforms.xsl" type="text/xsl"?>
<?xsltforms-options debug="no"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://www.w3.org/1999/xhtml"
      xmlns:xf="http://www.w3.org/2002/xforms"
      xmlns:ev="http://www.w3.org/2001/xml-events"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<head>
	<title>To do</title>

	<style type="text/css">
	  body { font-family: sans-serif}
	  label { display: inline-block; width: 3em; margin: 0 1em }
          .xforms-repeat-item-selected { background: yellow}
	</style> 

	<model xmlns="http://www.w3.org/2002/xforms">
   		<instance src="todo-list.xml"/>
		<instance id="template">
			<items xmlns="">
				<todo><task/><status>unstarted</status><date/></todo>
			</items>
		</instance>
   		<submission id="save" method="put" action="todo.xml" replace="none"/>
   		<bind nodeset="todo/date" type="xsd:date"/>
	</model>
</head>
<body>
    <group xmlns="http://www.w3.org/2002/xforms">
	<repeat nodeset="todo" id="todo-repeat">
	   <input ref="date"><label>Date</label></input>
	   <select1 ref="status" selection="open">
	      <label>Status</label>
	      <item><label>Not started</label><value>unstarted</value></item>
	      <item><label>In Progress</label><value>started</value></item>
	      <item><label>Done</label><value>finished</value></item>
	   </select1>
	   <input ref="task"><label>Task</label></input>
	   <trigger>
	      <label>Delete</label>
	      <delete ev:event="DOMActivate" nodeset="." at="1" />
	   </trigger>
	</repeat>
	<trigger>
	   <label>New</label>
	   <action ev:event="DOMActivate">
		<insert context="/items" origin="instance('template')/todo" nodeset="todo" position="after" at="count(todo)"/>
		<setvalue ref="todo[last()]/date" value="substring-before(now(), 'T')"/>
	   </action>
	</trigger>
	<submit submission="save"><label>Save</label></submit>
    </group>
</body>
</html>
