[gen] appy.js: closing the confirm popup via button 'no' cleans field 'comment'.
This commit is contained in:
		
							parent
							
								
									988626e3f2
								
							
						
					
					
						commit
						f44bb4e06b
					
				
					 3 changed files with 17 additions and 11 deletions
				
			
		|  | @ -1285,7 +1285,7 @@ class ToolMixin(BaseMixin): | ||||||
|            request, a server action can be executed before rendering the XHTML |            request, a server action can be executed before rendering the XHTML | ||||||
|            chunk. This method executes this action.''' |            chunk. This method executes this action.''' | ||||||
|         if action.startswith(':'): |         if action.startswith(':'): | ||||||
|             # The action corresponds to a method on Appy p_obj. |             # The action corresponds to a method on Appy p_obj | ||||||
|             msg = getattr(obj, action[1:])() |             msg = getattr(obj, action[1:])() | ||||||
|         else: |         else: | ||||||
|             # The action must be executed on p_field if present, on obj.o else. |             # The action must be executed on p_field if present, on obj.o else. | ||||||
|  |  | ||||||
|  | @ -242,10 +242,9 @@ function AjaxData(hook, px, params, parentHook, url, mode, beforeSend, onGet) { | ||||||
|   this.parentHook = parentHook; |   this.parentHook = parentHook; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | function askAjax(hook, form, params) { | ||||||
| function askAjax(hook, form) { |   /* Call askAjaxChunk by getting an AjaxData instance from p_hook, a | ||||||
|   /* Call askAjaxChunk by getting an AjaxData instance from p_hook and a |       potential action from p_form and additional parameters from p_param. */ | ||||||
|       potential action from p_form). */ |  | ||||||
|   var d = document.getElementById(hook)['ajax']; |   var d = document.getElementById(hook)['ajax']; | ||||||
|   // Complete data with a parent data if present
 |   // Complete data with a parent data if present
 | ||||||
|   if (d['parentHook']) { |   if (d['parentHook']) { | ||||||
|  | @ -277,6 +276,8 @@ function askAjax(hook, form) { | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   else var mode = d.mode; |   else var mode = d.mode; | ||||||
|  |   // Get p_params if given. Note that they override anything else.
 | ||||||
|  |   if (params) { for (var key in params) d.params[key] = params[key]; } | ||||||
|   askAjaxChunk(d.hook,mode,d.url,d.px,d.params,d.beforeSend,d.onGet) } |   askAjaxChunk(d.hook,mode,d.url,d.px,d.params,d.beforeSend,d.onGet) } | ||||||
| 
 | 
 | ||||||
| /* The functions below wrap askAjaxChunk for getting specific content through | /* The functions below wrap askAjaxChunk for getting specific content through | ||||||
|  | @ -859,7 +860,7 @@ function openPopup(popupId, msg, width, height) { | ||||||
|   popup.style.display = 'block'; |   popup.style.display = 'block'; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function closePopup(popupId) { | function closePopup(popupId, clean) { | ||||||
|   // Get the popup
 |   // Get the popup
 | ||||||
|   var container = null; |   var container = null; | ||||||
|   if (popupId == 'iframePopup') container = window.parent.document; |   if (popupId == 'iframePopup') container = window.parent.document; | ||||||
|  | @ -868,8 +869,13 @@ function closePopup(popupId) { | ||||||
|   // Close the popup
 |   // Close the popup
 | ||||||
|   popup.style.display = 'none'; |   popup.style.display = 'none'; | ||||||
|   popup.style.width = null; |   popup.style.width = null; | ||||||
|  |   // Clean field "clean" if specified
 | ||||||
|  |   if (clean) { | ||||||
|  |     var f = popup.getElementsByTagName('form')[0]; | ||||||
|  |     f.elements[clean].value = ''; | ||||||
|  |   } | ||||||
|   if (popupId == 'iframePopup') { |   if (popupId == 'iframePopup') { | ||||||
|     // Reinitialise the enclosing iframe.
 |     // Reinitialise the enclosing iframe
 | ||||||
|     var iframe = container.getElementById('appyIFrame'); |     var iframe = container.getElementById('appyIFrame'); | ||||||
|     iframe.style.width = null; |     iframe.style.width = null; | ||||||
|     iframe.innerHTML = ''; |     iframe.innerHTML = ''; | ||||||
|  | @ -920,14 +926,14 @@ function transferComment(confirmForm, targetForm) { | ||||||
| 
 | 
 | ||||||
| // Function triggered when an action confirmed by the user must be performed
 | // Function triggered when an action confirmed by the user must be performed
 | ||||||
| function doConfirm() { | function doConfirm() { | ||||||
|   // The user confirmed: perform the required action.
 |   // The user confirmed: perform the required action
 | ||||||
|   closePopup('confirmActionPopup'); |   closePopup('confirmActionPopup'); | ||||||
|   var confirmForm = document.getElementById('confirmActionForm'); |   var confirmForm = document.getElementById('confirmActionForm'); | ||||||
|   var actionType = confirmForm.actionType.value; |   var actionType = confirmForm.actionType.value; | ||||||
|   var action = confirmForm.action.value; |   var action = confirmForm.action.value; | ||||||
|   if (actionType == 'form') { |   if (actionType == 'form') { | ||||||
|     /* Submit the form whose id is in "action", and transmit him the comment |     /* Submit the form whose id is in "action", and transmit him the comment | ||||||
|        from the popup when relevant */ |        from the popup when relevant. */ | ||||||
|     var f = document.getElementById(action); |     var f = document.getElementById(action); | ||||||
|     transferComment(confirmForm, f); |     transferComment(confirmForm, f); | ||||||
|     f.submit(); |     f.submit(); | ||||||
|  |  | ||||||
|  | @ -109,8 +109,8 @@ class AbstractWrapper(object): | ||||||
|           <br/> |           <br/> | ||||||
|          </div><br/> |          </div><br/> | ||||||
|          <input type="button" onclick="doConfirm()" value=":_('yes')"/> |          <input type="button" onclick="doConfirm()" value=":_('yes')"/> | ||||||
|          <input type="button" onclick="closePopup('confirmActionPopup')" |          <input type="button" value=":_('no')" | ||||||
|                value=":_('no')"/> |                 onclick="closePopup('confirmActionPopup', 'comment')"/> | ||||||
|         </div> |         </div> | ||||||
|        </form> |        </form> | ||||||
|       </div> |       </div> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Gaetan Delannay
						Gaetan Delannay