소스 검색

N.546: Portal: Edit value in case log was kept after UserRequest update.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4500 a333f486-631f-4898-b8df-5754b55c2be0
glajarige 8 년 전
부모
커밋
6aa3e85c3b

+ 10 - 0
datamodels/2.x/itop-portal-base/portal/web/js/portal_form_handler.js

@@ -135,6 +135,16 @@ $(function()
 							// If everything is okay, we close the form and reload it.
 							if(oValidation.valid)
 							{
+								// Resetting textarea fields (delay is necessary has we have to wait for the form to be built.
+								setTimeout(function(){
+									me.options.field_set.find('.portal_form_field_html').each(function(iIndex, oElem){
+										if($(oElem).find('.cke').length > 0)
+										{
+											$(oElem).triggerHandler('set_current_value', '');
+										}
+									});
+								}, 200);
+								
 								if(me.options.is_modal)
 								{
 									me.element.closest('.modal').modal('hide');

+ 6 - 1
sources/renderer/bootstrap/fieldrenderer/bssimplefieldrenderer.class.inc.php

@@ -387,9 +387,14 @@ EOF
 				break;
 			case 'Combodo\\iTop\\Form\\Field\\TextAreaField':
 			case 'Combodo\\iTop\\Form\\Field\\CaseLogField':
+				// Overloading $sFormFieldOptions to include the set_current_value_callback. It would have been nicer to refactor the variable for all field types, but as this is a fix for a maintenance release, we rather be safe.
+				$sValidators = json_encode($aValidators);
 				$oOutput->AddJs(
 					<<<EOF
-					$("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}']").portal_form_field_html($sFormFieldOptions);
+					$("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}']").portal_form_field_html({
+						validators: $sValidators,
+						set_current_value_callback: function(me, oEvent, oData){ $(me.element).find('textarea').val(oData); }
+					});
 EOF
 				);
 				// MagnificPopup on images