Added ordered select input
authorThierry Florac <thierry.florac@onf.fr>
Wed, 20 May 2015 12:24:32 +0200
changeset 14 759944b2a12d
parent 13 2418b64d1433
child 15 6c594e84ec05
Added ordered select input
src/pyams_form/widget/configure.zcml
src/pyams_form/widget/templates/orderedselect-input.pt
--- a/src/pyams_form/widget/configure.zcml	Wed May 20 12:24:04 2015 +0200
+++ b/src/pyams_form/widget/configure.zcml	Wed May 20 12:24:32 2015 +0200
@@ -72,4 +72,10 @@
 		layer="pyams_form.interfaces.form.IFormLayer"
 		template="templates/select-input.pt" />
 
+	<z3c:widgetTemplate
+		mode="input"
+		widget="z3c.form.interfaces.IOrderedSelectWidget"
+		layer="pyams_form.interfaces.form.IFormLayer"
+		template="templates/orderedselect-input.pt" />
+
 </configure>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_form/widget/templates/orderedselect-input.pt	Wed May 20 12:24:32 2015 +0200
@@ -0,0 +1,44 @@
+<label class="input bordered with-icon"
+	   tal:omit-tag="view/required" i18n:domain="pyams_security">
+	<i class="icon-append fa fa-trash-o hint opaque"
+		title="Clear selected values" i18n:attributes="title"
+		tal:omit-tag="view/required"
+		data-ams-click-handler="MyAMS.helpers.select2ClearSelection"
+		tal:attributes="data-ams-select2-target string:${view/name}:list"></i>
+	<div class="select2-parent"
+		 tal:omit-tag="view/required">
+		<select class="select2 ordered"
+				tal:attributes="id view/id;
+								name string:${view/name}:list;
+								class string:${view/klass} select2 ordered;
+								style view/style;
+								title view/title;
+								lang view/lang;
+								onclick view/onclick;
+								ondblclick view/ondblclick;
+								onmousedown view/onmousedown;
+								onmouseup view/onmouseup;
+								onmouseover view/onmouseover;
+								onmousemove view/onmousemove;
+								onmouseout view/onmouseout;
+								onkeypress view/onkeypress;
+								onkeydown view/onkeydown;
+								onkeyup view/onkeyup;
+								disabled view/disabled;
+								tabindex view/tabindex;
+								onfocus view/onfocus;
+								onblur view/onblur;
+								onchange view/onchange;
+								multiple view/multiple;
+								size view/size">
+			<option tal:repeat="entry view/selectedItems"
+					tal:attributes="value entry/value;
+									selected python:entry['value'] in view.value;"
+					tal:content="entry/content"></option>
+			<option tal:repeat="entry view/notselectedItems"
+					tal:attributes="value entry/value;
+									selected python:entry['value'] in view.value;"
+					tal:content="entry/content"></option>
+		</select>
+	</div>
+</label>