[gen] Calendar field: allow to have several events at the same day via the concept of timeslots (ongoing work).

This commit is contained in:
Gaetan Delannay 2015-02-27 15:57:42 +01:00
parent 0c706c695e
commit da8f7a5bcd
10 changed files with 350 additions and 144 deletions

View file

@ -715,6 +715,14 @@ msgstr ""
msgid "del_next_events"
msgstr ""
#. Default: "Timeslot"
msgid "timeslot"
msgstr ""
#. Default: "All day"
msgid "timeslot_main"
msgstr ""
#. Default: "Inserted by ${userName}"
msgid "history_insert"
msgstr ""

View file

@ -715,6 +715,14 @@ msgstr ""
msgid "del_next_events"
msgstr ""
#. Default: "Timeslot"
msgid "timeslot"
msgstr ""
#. Default: "All day"
msgid "timeslot_main"
msgstr ""
#. Default: "Inserted by ${userName}"
msgid "history_insert"
msgstr ""

View file

@ -715,6 +715,14 @@ msgstr ""
msgid "del_next_events"
msgstr ""
#. Default: "Timeslot"
msgid "timeslot"
msgstr ""
#. Default: "All day"
msgid "timeslot_main"
msgstr ""
#. Default: "Inserted by ${userName}"
msgid "history_insert"
msgstr ""

View file

@ -716,6 +716,14 @@ msgstr "Extend the event on the following number of days (leave blank to create
msgid "del_next_events"
msgstr "Also delete successive events of the same type."
#. Default: "Timeslot"
msgid "timeslot"
msgstr "Timeslot"
#. Default: "All day"
msgid "timeslot_main"
msgstr "All day"
#. Default: "Inserted by ${userName}"
msgid "history_insert"
msgstr "Inserted by ${userName}"

View file

@ -715,6 +715,14 @@ msgstr ""
msgid "del_next_events"
msgstr ""
#. Default: "Timeslot"
msgid "timeslot"
msgstr ""
#. Default: "All day"
msgid "timeslot_main"
msgstr ""
#. Default: "Inserted by ${userName}"
msgid "history_insert"
msgstr ""

View file

@ -716,6 +716,14 @@ msgstr "Étendre l'événement sur le nombre de jours suivants (laissez vide pou
msgid "del_next_events"
msgstr "Supprimer aussi les événements successifs de même type"
#. Default: "Timeslot"
msgid "timeslot"
msgstr "Plage horaire"
#. Default: "All day"
msgid "timeslot_main"
msgstr "Toute la journée"
#. Default: "Inserted by ${userName}"
msgid "history_insert"
msgstr "Inséré par ${userName}"

View file

@ -715,6 +715,14 @@ msgstr ""
msgid "del_next_events"
msgstr ""
#. Default: "Timeslot"
msgid "timeslot"
msgstr ""
#. Default: "All day"
msgid "timeslot_main"
msgstr ""
#. Default: "Inserted by ${userName}"
msgid "history_insert"
msgstr ""

View file

@ -715,6 +715,14 @@ msgstr "Het event uitbreiden naar de volgende dagen (leeg laten om een event aan
msgid "del_next_events"
msgstr "Verwijder ook alle opeenvolgende events van hetzelfde type"
#. Default: "Timeslot"
msgid "timeslot"
msgstr ""
#. Default: "All day"
msgid "timeslot_main"
msgstr ""
#. Default: "Inserted by ${userName}"
msgid "history_insert"
msgstr "Ingevuld door ${userName}"

View file

@ -14,26 +14,28 @@ function askCalendar(hookId, objectUrl, render, fieldName, month) {
askAjaxChunk(hookId, 'GET', objectUrl, fieldName+':pxView', params);
}
function openEventPopup(action, fieldName, day, spansDays,
function openEventPopup(action, fieldName, day, timeslot, spansDays,
applicableEventTypes, message) {
/* Opens the popup for creating (or deleting, depending on p_action) a
calendar event at some p_day. When action is "del", we need to know
(from p_spansDays) if the event spans more days, in order to propose a
checkbox allowing to delete events for those successive days. When action
is "new", a possibly restricted list of applicable event types for this
day is given in p_applicableEventTypes; p_message contains an optional
message explaining why not applicable types are not applicable. */
calendar event at some p_day. When action is "del", we need to know the
p_timeslot where the event is assigned and if the event spans more days
(from p_spansDays), in order to propose a checkbox allowing to delete
events for those successive days. When action is "new", a possibly
restricted list of applicable event types for this day is given in
p_applicableEventTypes; p_message contains an optional message explaining
why not applicable types are not applicable. */
var prefix = fieldName + '_' + action + 'Event';
var f = document.getElementById(prefix + 'Form');
f.day.value = day;
if (action == 'del') {
// Show or hide the checkbox for deleting the event for successive days.
f.timeslot.value = timeslot;
// Show or hide the checkbox for deleting the event for successive days
var elem = document.getElementById(prefix + 'DelNextEvent');
var cb = elem.getElementsByTagName('input');
cb[0].checked = false;
cb[1].value = 'False';
if (spansDays == 'True') { elem.style.display = 'block' }
else { elem.style.display = 'none' }
if (spansDays == 'True') elem.style.display = 'block';
else elem.style.display = 'none';
}
else if (action == 'new') {
// First: reinitialise input fields
@ -42,8 +44,8 @@ function openEventPopup(action, fieldName, day, spansDays,
for (var i=0; i < allOptions.length; i++) {
allOptions[i].selected = false;
}
f.eventSpan.style.background = '';
// Among all event types, show applicable ones and hide the others.
if (f.eventSpan) f.eventSpan.style.background = '';
// Among all event types, show applicable ones and hide the others
var applicable = applicableEventTypes.split(',');
var applicableDict = {};
for (var i=0; i < applicable.length; i++) {
@ -76,13 +78,15 @@ function triggerCalendarEvent(action, hookId, fieldName, objectUrl,
f.eventType.style.background = wrongTextInput;
return;
}
// Check that eventSpan is empty or contains a valid number
var spanNumber = f.eventSpan.value.replace(' ', '');
if (spanNumber) {
spanNumber = parseInt(spanNumber);
if (isNaN(spanNumber) || (spanNumber > maxEventLength)) {
f.eventSpan.style.background = wrongTextInput;
return;
if (f.eventSpan) {
// Check that eventSpan is empty or contains a valid number
var spanNumber = f.eventSpan.value.replace(' ', '');
if (spanNumber) {
spanNumber = parseInt(spanNumber);
if (isNaN(spanNumber) || (spanNumber > maxEventLength)) {
f.eventSpan.style.background = wrongTextInput;
return;
}
}
}
}