aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2015-03-01 01:25:09 +0100
committerpiernov <piernov@piernov.org>2015-03-01 01:25:09 +0100
commit3bef68914eeda2605ea1fbf7cad2d99ed3cbfb79 (patch)
tree835432b4526db8be1cb0d0175ea6b20665b65b68
parent4d448b614e0e84b3c8ad004744601bf19728ea19 (diff)
downloadjm2l-3bef68914eeda2605ea1fbf7cad2d99ed3cbfb79.tar.gz
jm2l-3bef68914eeda2605ea1fbf7cad2d99ed3cbfb79.tar.bz2
jm2l-3bef68914eeda2605ea1fbf7cad2d99ed3cbfb79.tar.xz
jm2l-3bef68914eeda2605ea1fbf7cad2d99ed3cbfb79.zip
Add date picker using webshim
-rw-r--r--jm2l/forms.py2
-rw-r--r--jm2l/static/css/jm2l.css10
-rw-r--r--jm2l/templates/Staff/tasks.mako15
-rw-r--r--jm2l/templates/helpers.mako8
-rw-r--r--jm2l/views.py1
5 files changed, 31 insertions, 5 deletions
diff --git a/jm2l/forms.py b/jm2l/forms.py
index 304a060..4109527 100644
--- a/jm2l/forms.py
+++ b/jm2l/forms.py
@@ -60,7 +60,7 @@ class StaffTasks(MyBaseForm):
name = TextField(u'Nom de la tâche', [validators.Required()])
area_uid = SelectField(u'Pôle concerné', coerce=int )
closed_by = SelectField(u'Assigné à', coerce=int )
- due_date = DateField(u'Date prévue', format='%d/%m/%Y')
+ due_date = DateField(u'Date prévue', format='%Y-%m-%d')
description = TextAreaField('Description', [validators.optional(), validators.Length(max=1000000)],
filters=[strip_filter])
diff --git a/jm2l/static/css/jm2l.css b/jm2l/static/css/jm2l.css
index 016073c..33df5da 100644
--- a/jm2l/static/css/jm2l.css
+++ b/jm2l/static/css/jm2l.css
@@ -143,3 +143,13 @@ a {
text-align: right;
display: inline-block;
}
+
+/* Fix calendar button vertical pos */
+.date-input-buttons {
+ margin-bottom: 0.7em;
+}
+
+/* Calendar button looks better without that gray background */
+.ws-popover-opener {
+ background: none;
+}
diff --git a/jm2l/templates/Staff/tasks.mako b/jm2l/templates/Staff/tasks.mako
index 375d241..0f26c54 100644
--- a/jm2l/templates/Staff/tasks.mako
+++ b/jm2l/templates/Staff/tasks.mako
@@ -5,6 +5,21 @@
<script src="/js/jm2l.js"></script>
<script src="/vendor/ckeditor/ckeditor.js"></script>
<script src="/vendor/select2/js/select2.js"></script>
+
+ <script src="//cdn.jsdelivr.net/webshim/1.15.7/polyfiller.js"></script>
+ <script type="text/javascript">
+ webshim.setOptions('forms-ext', {
+ replaceUI: 'auto',
+ types: 'date',
+ date: {
+ startView: 2,
+ classes: 'hide-spinbtns',
+ }
+ });
+
+ //start polyfilling
+ webshim.polyfill('forms-ext');
+ </script>
</%def>
<%def name="cssAddOn()">
<link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload.css">
diff --git a/jm2l/templates/helpers.mako b/jm2l/templates/helpers.mako
index 525ea62..a8623d7 100644
--- a/jm2l/templates/helpers.mako
+++ b/jm2l/templates/helpers.mako
@@ -39,12 +39,12 @@ TabJs = {'select':[], 'desc':[]}
<%
PlaceHolder = DicFormat[Field.name].get("PlaceHolder")
FieldStyle = DicFormat[Field.name].get("FieldStyle")
- Class = [None,"ckeditor"][ DicFormat[Field.name].has_key("ckeditor") ]
+ Class = [False,"ckeditor"][ "ckeditor" in DicFormat[Field.name] ]
%>
- % if PlaceHolder:
- ${Field(placeholder=PlaceHolder, style=FieldStyle, class_=Class)}
+ % if Field.type == "DateField":
+ ${Field(placeholder=PlaceHolder or False, style=FieldStyle, class_=Class, type = "date")}
% else:
- ${Field(style=FieldStyle, class_=Class)}
+ ${Field(placeholder=PlaceHolder or False, style=FieldStyle, class_=Class)}
% endif
% else:
${Field()}
diff --git a/jm2l/views.py b/jm2l/views.py
index e3485ae..7c89c40 100644
--- a/jm2l/views.py
+++ b/jm2l/views.py
@@ -294,6 +294,7 @@ def tasks(request):
.order_by('nom').all()
form.closed_by.choices = [(u.uid, "%s %s" % (u.nom, u.prenom))
for u in Users]
+ form.due_date.type = "date"
if request.method == 'POST' and form.validate():
form.populate_obj(Task)
Task.closed = False