Переглянути джерело

User editable dashboards... implementation in progress

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2002 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 13 роки тому
батько
коміт
334606b98e
1 змінених файлів з 42 додано та 0 видалено
  1. 42 0
      pages/ajax.render.php

+ 42 - 0
pages/ajax.render.php

@@ -631,6 +631,48 @@ try
 		$oMenu = ApplicationMenu::GetMenuNode($idx);
 		$oMenu = ApplicationMenu::GetMenuNode($idx);
 		$oMenu->RenderEditor($oPage);
 		$oMenu->RenderEditor($oPage);
 		break;
 		break;
+		
+		case 'update_dashlet_property':
+		require_once(APPROOT.'application/forms.class.inc.php');
+		require_once(APPROOT.'application/dashlet.class.inc.php');
+		$aParams = utils::ReadParam('params', '', false, 'raw_data');
+		$sDashletClass = $aParams['attr_dashlet_class'];
+		$sDashletId = $aParams['attr_dashlet_id'];
+		$aUpdatedProperties = $aParams['updated'];
+		$aPreviousValues = $aParams['previous_values'];
+		if (is_subclass_of($sDashletClass, 'Dashlet'))
+		{
+			$oDashlet = new $sDashletClass($sDashletId);
+			$oForm = $oDashlet->GetForm();
+			$aValues = $oForm->ReadParams();
+			
+			$aCurrentValues = $aValues;
+			foreach($aUpdatedProperties as $sProp)
+			{
+				$aCurrentValues[$sProp] = $aPreviousValues[$sProp];
+			}
+			
+			$oDashlet->FromParams($aCurrentValues);
+			$oDashlet->Update($aValues, $aUpdatedProperties);
+			if ($oDashlet->IsRedrawNeeded())
+			{
+				$offset = $oPage->start_capture();
+				$oDashlet->Render($oPage, true);
+				$sHtml = addslashes($oPage->end_capture($offset));
+				
+				$oPage->add_script("$('#dashlet_$sDashletId').html('$sHtml')"); // in ajax web page add_script has the same effect as add_ready_script
+																				// but is executed BEFORE all 'ready_scripts'
+			}
+			if ($oDashlet->IsFormRedrawNeeded())
+			{
+				$oForm = $oDashlet->GetForm($oPage, $oDashlet);
+				$oForm->SetSubmitParams(utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php', array('operation' => 'update_dashlet_property'));
+				$sHtml = addslashes($oForm->RenderAsPropertySheet($oPage, true /* bReturnHtml */));
+				$oPage->add_script("$('#dashlet_properties_$sDashletId').html('$sHtml')"); // in ajax web page add_script has the same effect as add_ready_script																	   // but is executed BEFORE all 'ready_scripts'
+																						   // but is executed BEFORE all 'ready_scripts'
+			}
+		}
+		break;
 			
 			
 		default:
 		default:
 		$oPage->p("Invalid query.");
 		$oPage->p("Invalid query.");