[gen] Calendar field: allow automatic check/uncheck of validation checkboxes within calendars (month and timeline views).

This commit is contained in:
Gaetan Delannay 2015-03-05 16:35:04 +01:00
parent 9b9853e570
commit a4a9acfcfb
11 changed files with 82 additions and 7 deletions

View file

@ -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 ""

View file

@ -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 ""

View file

@ -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."

View file

@ -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."

View file

@ -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."

View file

@ -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."

View file

@ -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."

View file

@ -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."

View file

@ -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 }

View file

@ -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;
}
}