Browse Source

Add date picker using webshim

master
piernov 9 years ago
parent
commit
3bef68914e
5 changed files with 31 additions and 5 deletions
  1. +1
    -1
      jm2l/forms.py
  2. +10
    -0
      jm2l/static/css/jm2l.css
  3. +15
    -0
      jm2l/templates/Staff/tasks.mako
  4. +4
    -4
      jm2l/templates/helpers.mako
  5. +1
    -0
      jm2l/views.py

+ 1
- 1
jm2l/forms.py View File

@@ -60,7 +60,7 @@ class StaffTasks(MyBaseForm):
name = TextField(u'Nom de la tâche', [validators.Required()]) name = TextField(u'Nom de la tâche', [validators.Required()])
area_uid = SelectField(u'Pôle concerné', coerce=int ) area_uid = SelectField(u'Pôle concerné', coerce=int )
closed_by = SelectField(u'Assigné à', 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)], description = TextAreaField('Description', [validators.optional(), validators.Length(max=1000000)],
filters=[strip_filter]) filters=[strip_filter])




+ 10
- 0
jm2l/static/css/jm2l.css View File

@@ -143,3 +143,13 @@ a {
text-align: right; text-align: right;
display: inline-block; 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;
}

+ 15
- 0
jm2l/templates/Staff/tasks.mako View File

@@ -5,6 +5,21 @@
<script src="/js/jm2l.js"></script> <script src="/js/jm2l.js"></script>
<script src="/vendor/ckeditor/ckeditor.js"></script> <script src="/vendor/ckeditor/ckeditor.js"></script>
<script src="/vendor/select2/js/select2.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>
<%def name="cssAddOn()"> <%def name="cssAddOn()">
<link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload.css"> <link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload.css">


+ 4
- 4
jm2l/templates/helpers.mako View File

@@ -39,12 +39,12 @@ TabJs = {'select':[], 'desc':[]}
<% <%
PlaceHolder = DicFormat[Field.name].get("PlaceHolder") PlaceHolder = DicFormat[Field.name].get("PlaceHolder")
FieldStyle = DicFormat[Field.name].get("FieldStyle") 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: % else:
${Field(style=FieldStyle, class_=Class)}
${Field(placeholder=PlaceHolder or False, style=FieldStyle, class_=Class)}
% endif % endif
% else: % else:
${Field()} ${Field()}


+ 1
- 0
jm2l/views.py View File

@@ -294,6 +294,7 @@ def tasks(request):
.order_by('nom').all() .order_by('nom').all()
form.closed_by.choices = [(u.uid, "%s %s" % (u.nom, u.prenom)) form.closed_by.choices = [(u.uid, "%s %s" % (u.nom, u.prenom))
for u in Users] for u in Users]
form.due_date.type = "date"
if request.method == 'POST' and form.validate(): if request.method == 'POST' and form.validate():
form.populate_obj(Task) form.populate_obj(Task)
Task.closed = False Task.closed = False


Loading…
Cancel
Save