[gen] Calendar field: added a validation mechanism.
This commit is contained in:
		
							parent
							
								
									d1aec8d5e6
								
							
						
					
					
						commit
						09bf03f9bf
					
				
					 13 changed files with 251 additions and 65 deletions
				
			
		|  | @ -727,6 +727,18 @@ msgstr "" | |||
| msgid "timeslot_misfit" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "Validate events" | ||||
| msgid "validate_events" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "All the checked events will be confirmed, while the unchecked ones will be discarded. The concerned user(s) will be warned. Are you sure?" | ||||
| msgid "validate_events_confirm" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "${validated} event(s) was (were) validated and ${discarded} was (were) discarded." | ||||
| msgid "validate_events_done" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "Inserted by ${userName}" | ||||
| msgid "history_insert" | ||||
| msgstr "" | ||||
|  |  | |||
							
								
								
									
										12
									
								
								gen/tr/ar.po
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								gen/tr/ar.po
									
										
									
									
									
								
							|  | @ -727,6 +727,18 @@ msgstr "" | |||
| msgid "timeslot_misfit" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "Validate events" | ||||
| msgid "validate_events" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "All the checked events will be confirmed, while the unchecked ones will be discarded. The concerned user(s) will be warned. Are you sure?" | ||||
| msgid "validate_events_confirm" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "${validated} event(s) was (were) validated and ${discarded} was (were) discarded." | ||||
| msgid "validate_events_done" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "Inserted by ${userName}" | ||||
| msgid "history_insert" | ||||
| msgstr "" | ||||
|  |  | |||
							
								
								
									
										12
									
								
								gen/tr/de.po
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								gen/tr/de.po
									
										
									
									
									
								
							|  | @ -727,6 +727,18 @@ msgstr "" | |||
| msgid "timeslot_misfit" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "Validate events" | ||||
| msgid "validate_events" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "All the checked events will be confirmed, while the unchecked ones will be discarded. The concerned user(s) will be warned. Are you sure?" | ||||
| msgid "validate_events_confirm" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "${validated} event(s) was (were) validated and ${discarded} was (were) discarded." | ||||
| msgid "validate_events_done" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "Inserted by ${userName}" | ||||
| msgid "history_insert" | ||||
| msgstr "" | ||||
|  |  | |||
							
								
								
									
										12
									
								
								gen/tr/en.po
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								gen/tr/en.po
									
										
									
									
									
								
							|  | @ -728,6 +728,18 @@ msgstr "All day" | |||
| msgid "timeslot_misfit" | ||||
| msgstr "Cannot create such an event in the ${slot} slot." | ||||
| 
 | ||||
| #. Default: "Validate events" | ||||
| msgid "validate_events" | ||||
| msgstr "Validate events" | ||||
| 
 | ||||
| #. Default: "All the checked events will be confirmed, while the unchecked ones will be discarded. The concerned user(s) will be warned. Are you sure?" | ||||
| msgid "validate_events_confirm" | ||||
| msgstr "All the checked events will be confirmed, while the unchecked ones will be discarded. The concerned user(s) will be warned. Are you sure?" | ||||
| 
 | ||||
| #. Default: "${validated} event(s) was (were) validated and ${discarded} was (were) discarded." | ||||
| msgid "validate_events_done" | ||||
| msgstr "${validated} event(s) was (were) validated and ${discarded} was (were) discarded." | ||||
| 
 | ||||
| #. Default: "Inserted by ${userName}" | ||||
| msgid "history_insert" | ||||
| msgstr "Inserted by ${userName}" | ||||
|  |  | |||
							
								
								
									
										12
									
								
								gen/tr/es.po
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								gen/tr/es.po
									
										
									
									
									
								
							|  | @ -727,6 +727,18 @@ msgstr "" | |||
| msgid "timeslot_misfit" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "Validate events" | ||||
| msgid "validate_events" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "All the checked events will be confirmed, while the unchecked ones will be discarded. The concerned user(s) will be warned. Are you sure?" | ||||
| msgid "validate_events_confirm" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "${validated} event(s) was (were) validated and ${discarded} was (were) discarded." | ||||
| msgid "validate_events_done" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "Inserted by ${userName}" | ||||
| msgid "history_insert" | ||||
| msgstr "" | ||||
|  |  | |||
							
								
								
									
										12
									
								
								gen/tr/fr.po
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								gen/tr/fr.po
									
										
									
									
									
								
							|  | @ -728,6 +728,18 @@ msgstr "Toute la journée" | |||
| msgid "timeslot_misfit" | ||||
| msgstr "Impossible de créer ce type d'événement dans la plage horaire ${slot}." | ||||
| 
 | ||||
| #. Default: "Validate events" | ||||
| msgid "validate_events" | ||||
| msgstr "Valider les événements" | ||||
| 
 | ||||
| #. Default: "All the checked events will be confirmed, while the unchecked ones will be discarded. The concerned user(s) will be warned. Are you sure?" | ||||
| msgid "validate_events_confirm" | ||||
| msgstr "Tous les événements sélectionnés seront confirmés, tandis que ceux qui sont désélectionnés seront rejetés. Le ou les utilisateurs concernés seront prévenus. Êtes-vous sûr?" | ||||
| 
 | ||||
| #. Default: "${validated} event(s) was (were) validated and ${discarded} was (were) discarded." | ||||
| msgid "validate_events_done" | ||||
| msgstr "${validated} événement(s) a (ont) été validé(s) et ${discarded} a (ont) été rejeté(s)." | ||||
| 
 | ||||
| #. Default: "Inserted by ${userName}" | ||||
| msgid "history_insert" | ||||
| msgstr "Inséré par ${userName}" | ||||
|  |  | |||
							
								
								
									
										12
									
								
								gen/tr/it.po
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								gen/tr/it.po
									
										
									
									
									
								
							|  | @ -727,6 +727,18 @@ msgstr "" | |||
| msgid "timeslot_misfit" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "Validate events" | ||||
| msgid "validate_events" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "All the checked events will be confirmed, while the unchecked ones will be discarded. The concerned user(s) will be warned. Are you sure?" | ||||
| msgid "validate_events_confirm" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "${validated} event(s) was (were) validated and ${discarded} was (were) discarded." | ||||
| msgid "validate_events_done" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "Inserted by ${userName}" | ||||
| msgid "history_insert" | ||||
| msgstr "" | ||||
|  |  | |||
							
								
								
									
										12
									
								
								gen/tr/nl.po
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								gen/tr/nl.po
									
										
									
									
									
								
							|  | @ -727,6 +727,18 @@ msgstr "" | |||
| msgid "timeslot_misfit" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "Validate events" | ||||
| msgid "validate_events" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "All the checked events will be confirmed, while the unchecked ones will be discarded. The concerned user(s) will be warned. Are you sure?" | ||||
| msgid "validate_events_confirm" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "${validated} event(s) was (were) validated and ${discarded} was (were) discarded." | ||||
| msgid "validate_events_done" | ||||
| msgstr "" | ||||
| 
 | ||||
| #. Default: "Inserted by ${userName}" | ||||
| msgid "history_insert" | ||||
| msgstr "Ingevuld door ${userName}" | ||||
|  |  | |||
|  | @ -198,3 +198,4 @@ td.search { padding-top: 8px } | |||
| .highlight { background-color: yellow } | ||||
| .globalActions { margin-bottom: 4px } | ||||
| .objectActions { margin: 2px 0 } | ||||
| .smallbox { margin: 0 } | ||||
|  |  | |||
|  | @ -295,9 +295,10 @@ function askAjax(hook, form, params) { | |||
|   } | ||||
|   else var mode = d.mode; | ||||
|   // Get p_params if given. Note that they override anything else.
 | ||||
|   if (params && ('mode' in params)) { | ||||
|     mode = params['mode']; delete params['mode'] } | ||||
|   if (params) { for (var key in params) d.params[key] = params[key]; } | ||||
|   askAjaxChunk(hook, mode, d.url, d.px, d.params, d.beforeSend, | ||||
|                evalInnerScripts); | ||||
|   askAjaxChunk(hook,mode,d.url,d.px,d.params,d.beforeSend,evalInnerScripts); | ||||
| } | ||||
| 
 | ||||
| function askBunch(hookId, startNumber) { | ||||
|  |  | |||
|  | @ -8,11 +8,8 @@ function toggleVisibility(node, nodeType){ | |||
|   } | ||||
| } | ||||
| 
 | ||||
| function askCalendar(hookId, objectUrl, render, fieldName, month) { | ||||
|   // Sends an Ajax request for getting the calendar, at p_month
 | ||||
|   var params = {'month': month, 'render': render}; | ||||
|   askAjaxChunk(hookId, 'GET', objectUrl, fieldName+':pxView', params); | ||||
| } | ||||
| // Sends an Ajax request for getting the calendar, at p_month
 | ||||
| function askMonth(hookId, month) {askAjax(hookId, null, {'month': month})} | ||||
| 
 | ||||
| function enableOptions(select, enabled, selectFirst, message){ | ||||
|   /* This function disables, in p_select, all options that are not in p_enabled. | ||||
|  | @ -46,7 +43,7 @@ function enableOptions(select, enabled, selectFirst, message){ | |||
|   } | ||||
| } | ||||
| 
 | ||||
| function openEventPopup(action, fieldName, day, timeslot, spansDays, | ||||
| function openEventPopup(hookId, action, day, timeslot, spansDays, | ||||
|                         applicableEventTypes, message, freeSlots) { | ||||
|   /* 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 the | ||||
|  | @ -57,13 +54,13 @@ function openEventPopup(action, fieldName, day, timeslot, spansDays, | |||
|      p_applicableEventTypes; p_message contains an optional message explaining | ||||
|      why not applicable types are not applicable. When "new", p_freeSlots may | ||||
|      list the available timeslots at p_day. */ | ||||
|   var prefix = fieldName + '_' + action + 'Event'; | ||||
|   var f = document.getElementById(prefix + 'Form'); | ||||
|   var popupId = hookId + '_' + action; | ||||
|   var f = document.getElementById(popupId + 'Form'); | ||||
|   f.day.value = day; | ||||
|   if (action == 'del') { | ||||
|     if (f.timeslot) f.timeslot.value = timeslot; | ||||
|     // Show or hide the checkbox for deleting the event for successive days
 | ||||
|     var elem = document.getElementById(prefix + 'DelNextEvent'); | ||||
|     var elem = document.getElementById(hookId + '_DelNextEvent'); | ||||
|     var cb = elem.getElementsByTagName('input'); | ||||
|     cb[0].checked = false; | ||||
|     cb[1].value = 'False'; | ||||
|  | @ -78,15 +75,15 @@ function openEventPopup(action, fieldName, day, timeslot, spansDays, | |||
|     enableOptions(f.eventType, applicableEventTypes, false, message); | ||||
|     if (f.timeslot) enableOptions(f.timeslot, freeSlots, true, 'Not free'); | ||||
|   } | ||||
|   openPopup(prefix + 'Popup'); | ||||
|   openPopup(popupId); | ||||
| } | ||||
| 
 | ||||
| function triggerCalendarEvent(action, hookId, fieldName, objectUrl, | ||||
|                               maxEventLength) { | ||||
| function triggerCalendarEvent(hookId, action, maxEventLength) { | ||||
|   /* Sends an Ajax request for triggering a calendar event (create or delete an | ||||
|      event) and refreshing the view month. */ | ||||
|   var prefix = fieldName + '_' + action + 'Event'; | ||||
|   var f = document.getElementById(prefix + 'Form'); | ||||
|   var popupId = hookId + '_' + action; | ||||
|   var formId = popupId + 'Form'; | ||||
|   var f = document.getElementById(formId); | ||||
|   if (action == 'new') { | ||||
|     // Check that an event span has been specified
 | ||||
|     if (f.eventType.selectedIndex == 0) { | ||||
|  | @ -105,12 +102,25 @@ function triggerCalendarEvent(action, hookId, fieldName, objectUrl, | |||
|       } | ||||
|     } | ||||
|   } | ||||
|   var elems = f.elements; | ||||
|   var params = {}; | ||||
|   // Put form elements into "params"
 | ||||
|   for (var i=0; i < elems.length; i++) { | ||||
|     params[elems[i].name] = elems[i].value; | ||||
|   } | ||||
|   closePopup(prefix + 'Popup'); | ||||
|   askAjaxChunk(hookId, 'POST', objectUrl, fieldName+':pxView', params); | ||||
|   closePopup(popupId); | ||||
|   askAjax(hookId, formId); | ||||
| } | ||||
| 
 | ||||
| // Function for validating and discarding calendar events
 | ||||
| function validateEvents(hookId) { | ||||
|   // Collect checkboxes from hookId and identify checked and unchecked ones
 | ||||
|   var validated = []; | ||||
|   var discarded = []; | ||||
|   var node = document.getElementById(hookId + '_cal'); | ||||
|   var cbs = node.getElementsByTagName('input'); | ||||
|   for (var i=0; i<cbs.length; i++) { | ||||
|     if (cbs[i].type != 'checkbox') continue; | ||||
|     if (cbs[i].checked) validated.push(cbs[i].id); | ||||
|     else discarded.push(cbs[i].id); | ||||
|   } | ||||
|   validated = validated.join() | ||||
|   discarded = discarded.join() | ||||
|   var params = {'action': 'validateEvents', 'validated': validated, | ||||
|                 'discarded': discarded, 'mode': 'POST'}; | ||||
|   askAjax(hookId, null, params); | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Gaetan Delannay
						Gaetan Delannay