Updated Select2 template
authorThierry Florac <thierry.florac@onf.fr>
Fri, 13 Jul 2018 11:36:32 +0200
changeset 129 cb10938bb63f
parent 128 26852816c2c2
child 130 d02e4a8ad35a
Updated Select2 template
src/pyams_form/widget/templates/select-input.pt
--- a/src/pyams_form/widget/templates/select-input.pt	Thu Jul 12 18:18:58 2018 +0200
+++ b/src/pyams_form/widget/templates/select-input.pt	Fri Jul 13 11:36:32 2018 +0200
@@ -1,13 +1,25 @@
-<label class="input bordered with-icon"
-	   tal:omit-tag="view/required" i18n:domain="pyams_form">
+<label class="input bordered"
+	   tal:define="has_icon python:view.multiple or not view.required;
+				   has_icons python:view.multiple and not view.required;
+				   icons python:'with-icons' if has_icons else 'with-icon'"
+	   tal:omit-tag="python:(not view.multiple) and view.required"
+	   tal:attributes="class string:${default} ${icons}"
+	   i18n:domain="pyams_form">
 	<i class="icon-append fa fa-trash-o text-primary hint opaque"
 		title="Clear selected values" i18n:attributes="title"
-		tal:omit-tag="view/required"
 		data-ams-hint-gravity="se"
 		data-ams-click-handler="MyAMS.helpers.select2ClearSelection"
+		tal:condition="not:view/required"
 		tal:attributes="data-ams-select2-target string:${view/name}:list"></i>
+	<i class="icon-append fa fa-th-list text-primary hint opaque"
+		title="Select all values" i18n:attributes="title"
+		data-ams-url="MyAMS.helpers.select2SelectAllHelper"
+		tal:define="icons python:'icon-append-2' if has_icons else ''"
+		tal:condition="view/multiple"
+		tal:attributes="class string:${default} ${icons};
+						data-ams-select2-target string:${view/name}:list"></i>
 	<div class="select2-parent"
-		 tal:omit-tag="view/required">
+		 tal:omit-tag="not:has_icon">
 		<select class="select2"
 				tal:attributes='id view/id;
 								name string:${view/name}:list;