diff --git a/fields/calendar.py b/fields/calendar.py
index 00b58bf..4be33f0 100644
--- a/fields/calendar.py
+++ b/fields/calendar.py
@@ -212,7 +212,8 @@ class Calendar(Field):
var2="events=field.getOtherEventsAt(zobj, date, other, \
allEventNames, render, colors)"
style=":field.getCellStyle(zobj, date, render, \
- events)">::field.getTimelineCell(date, other, events, mayValidate)
+ events)">::field.getTimelineCell(date, other, events, \
+ mayValidate, ajaxHookId)
::tlName |
@@ -289,8 +290,7 @@ class Calendar(Field):
-
+
+ event.timeslot)"
+ onclick=":'onCheckCbCell(this,%s)' % q(ajaxHookId)"/>
::event.getName(allEventNames)
+
+
:getattr(field, 'pxView%s' % render.capitalize())
''')
@@ -683,7 +687,7 @@ class Calendar(Field):
return '%s' % (other.obj.url, other.obj.title)
return self.timelineName(self, other)
- def getTimelineCell(self, date, other, events, mayValidate):
+ def getTimelineCell(self, date, other, events, mayValidate, hook):
'''Gets the content of a cell in a timeline calendar'''
if events and mayValidate:
# If at least one event from p_events is in the validation schema,
@@ -694,7 +698,8 @@ class Calendar(Field):
cbId = '%s_%s_%s' % (other.obj.id, other.field.name,
date.strftime('%Y%m%d'))
return '' % cbId
+ 'class="smallbox" id="%s" onclick="onCheckCbCell' \
+ '(this,\'%s\')"/>' % (cbId, hook)
return ''
# When there are multiple events, a background image is already shown
if not events or (len(events) > 1): return ''
diff --git a/gen/tr/Appy.pot b/gen/tr/Appy.pot
index 9a338be..5241818 100644
--- a/gen/tr/Appy.pot
+++ b/gen/tr/Appy.pot
@@ -195,6 +195,10 @@ msgstr ""
msgid "select_delesect"
msgstr ""
+#. Default: "Automatic (de)selection"
+msgid "select_auto"
+msgstr ""
+
#. Default: "You must select at least one element."
msgid "no_elem_selected"
msgstr ""
diff --git a/gen/tr/ar.po b/gen/tr/ar.po
index 7dfb33f..2e5be2f 100644
--- a/gen/tr/ar.po
+++ b/gen/tr/ar.po
@@ -195,6 +195,10 @@ msgstr ""
msgid "select_delesect"
msgstr ""
+#. Default: "Automatic (de)selection"
+msgid "select_auto"
+msgstr ""
+
#. Default: "You must select at least one element."
msgid "no_elem_selected"
msgstr ""
diff --git a/gen/tr/de.po b/gen/tr/de.po
index a849676..7a04182 100644
--- a/gen/tr/de.po
+++ b/gen/tr/de.po
@@ -195,6 +195,10 @@ msgstr "Dieser Wert wird in diesem Feld nicht akzeptiert."
msgid "select_delesect"
msgstr "Alle aus- oder abwählen"
+#. Default: "Automatic (de)selection"
+msgid "select_auto"
+msgstr ""
+
#. Default: "You must select at least one element."
msgid "no_elem_selected"
msgstr "Sie müssen mindestens ein Element auswählen."
diff --git a/gen/tr/en.po b/gen/tr/en.po
index aa89635..a6c8431 100644
--- a/gen/tr/en.po
+++ b/gen/tr/en.po
@@ -196,6 +196,10 @@ msgstr "The value is not among possible values for this field."
msgid "select_delesect"
msgstr "(Un)select all"
+#. Default: "Automatic (de)selection"
+msgid "select_auto"
+msgstr "Automatic (de)selection"
+
#. Default: "You must select at least one element."
msgid "no_elem_selected"
msgstr "You must select at least one element."
diff --git a/gen/tr/es.po b/gen/tr/es.po
index ae36095..5f78dd6 100644
--- a/gen/tr/es.po
+++ b/gen/tr/es.po
@@ -195,6 +195,10 @@ msgstr "Este valor no es permitido para este campo."
msgid "select_delesect"
msgstr "(des)seleccionar todo"
+#. Default: "Automatic (de)selection"
+msgid "select_auto"
+msgstr ""
+
#. Default: "You must select at least one element."
msgid "no_elem_selected"
msgstr "Debe elegir al menos un elemento."
diff --git a/gen/tr/fr.po b/gen/tr/fr.po
index f9e8ff0..73072f1 100644
--- a/gen/tr/fr.po
+++ b/gen/tr/fr.po
@@ -196,6 +196,10 @@ msgstr "Cette valeur n'est pas permise pour ce champ."
msgid "select_delesect"
msgstr "Tout (dé)sélectionner"
+#. Default: "Automatic (de)selection"
+msgid "select_auto"
+msgstr "(dé)sélection automatique"
+
#. Default: "You must select at least one element."
msgid "no_elem_selected"
msgstr "Vous devez choisir au moins un élément."
diff --git a/gen/tr/it.po b/gen/tr/it.po
index 5542c1a..7d04fc2 100644
--- a/gen/tr/it.po
+++ b/gen/tr/it.po
@@ -195,6 +195,10 @@ msgstr "Il valore digitato non è possibile per questo campo."
msgid "select_delesect"
msgstr "Eliminare tutte le selezioni"
+#. Default: "Automatic (de)selection"
+msgid "select_auto"
+msgstr ""
+
#. Default: "You must select at least one element."
msgid "no_elem_selected"
msgstr "Deve selezionare almeno un elemento."
diff --git a/gen/tr/nl.po b/gen/tr/nl.po
index 34d3527..11e6e4c 100644
--- a/gen/tr/nl.po
+++ b/gen/tr/nl.po
@@ -195,6 +195,10 @@ msgstr "Deze waarde wordt niet geaccepteerd voor dit veld."
msgid "select_delesect"
msgstr "Alles (de)selecteren"
+#. Default: "Automatic (de)selection"
+msgid "select_auto"
+msgstr ""
+
#. Default: "You must select at least one element."
msgid "no_elem_selected"
msgstr "U moet minstens één element selecteren."
diff --git a/gen/ui/appy.css b/gen/ui/appy.css
index 0db0ab9..4f7eba5 100644
--- a/gen/ui/appy.css
+++ b/gen/ui/appy.css
@@ -142,6 +142,7 @@ td.search { padding-top: 8px }
.cellDashed { border: 1px dashed grey !important }
.noStyle { border: 0 !important; padding: 0 !important; margin: 0 !important }
.noStyle td { border:0 !important; padding:0 !important; margin:0 !important }
+.simpleLabel { text-transform: none }
.translationLabel { background-color: #EAEAEA; border-bottom: 1px dashed grey;
margin-top: 0.5em; margin-bottom: 0.5em }
.section1 { font-size: 120%; margin: 0.45em 0em 0.1em 0;
@@ -198,4 +199,4 @@ td.search { padding-top: 8px }
.highlight { background-color: yellow }
.globalActions { margin-bottom: 4px }
.objectActions { margin: 2px 0 }
-.smallbox { margin: 0 }
+.smallbox { margin: 0; vertical-align: middle }
diff --git a/gen/ui/calendar.js b/gen/ui/calendar.js
index 334c0f1..663c740 100644
--- a/gen/ui/calendar.js
+++ b/gen/ui/calendar.js
@@ -124,3 +124,40 @@ function validateEvents(hookId) {
'discarded': discarded, 'mode': 'POST'};
askAjax(hookId, null, params);
}
+
+// Function for (un)-checking checkboxes automatically
+function onCheckCbCell(cb, hook) {
+ // Is automatic selection on/off?
+ var auto = document.getElementById(hook + '_auto');
+ if (!auto.checked) return;
+ // Get the current render mode
+ var render = document.getElementById(hook)['ajax'].params['render'];
+ // Change the state of every successive checkbox
+ var timeline = render == 'timeline'; // Else, render is "month"
+ // From the checkbox id, extract the date and the remaining part
+ var elems = cb.id.split('_');
+ if (timeline) { var date = elems[2], part = elems[0] + '_' + elems[1] + '_'; }
+ else { var date = elems[0], part = '_' + elems[1] + '_' + elems[2]; }
+ // Create a Date instance
+ var year = parseInt(date.slice(0,4)), month = parseInt(date.slice(4,6))-1,
+ day = parseInt(date.slice(6,8));
+ var next = new Date(year, month, day);
+ // Change the status of successive checkboxes if found
+ var checked = cb.checked;
+ var nextId = nextCb = null;
+ while (true) {
+ // Compute the date at the next day
+ next.setDate(next.getDate() + 1);
+ month = (next.getMonth() + 1).toString();
+ if (month.length == 1) month = '0' + month;
+ day = next.getDate().toString();
+ if (day.length == 1) day = '0' + day;
+ date = next.getFullYear().toString() + month + day;
+ // Find the next checkbox
+ if (timeline) nextId = part + date;
+ else nextId = date + part;
+ nextCb = document.getElementById(nextId);
+ if (!nextCb) break;
+ nextCb.checked = checked;
+ }
+}