Bläddra i källkod

User editable dashboards... implementation in progress

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2018 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 13 år sedan
förälder
incheckning
acf45b2a0d
1 ändrade filer med 25 tillägg och 0 borttagningar
  1. 25 0
      pages/ajax.render.php

+ 25 - 0
pages/ajax.render.php

@@ -632,6 +632,31 @@ try
 		$oMenu->RenderEditor($oPage);
 		break;
 		
+		case 'new_dashlet':
+		require_once(APPROOT.'application/forms.class.inc.php');
+		require_once(APPROOT.'application/dashlet.class.inc.php');
+		$sDashletClass = utils::ReadParam('dashlet_class', '');
+		$sDashletId =  utils::ReadParam('dashlet_id', '', false, 'raw_data');
+		if (is_subclass_of($sDashletClass, 'Dashlet'))
+		{
+			$oDashlet = new $sDashletClass($sDashletId);
+			$offset = $oPage->start_capture();
+			$oDashlet->Render($oPage, true);
+			$sHtml = addslashes($oPage->end_capture($offset));
+			$sHtml = str_replace("\n", '', $sHtml);
+			$sHtml = str_replace("\r", '', $sHtml);
+			
+			$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'
+			$oForm = $oDashlet->GetForm(); // Rebuild the form since the values/content changed
+			$oForm->SetSubmitParams(utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php', array('operation' => 'update_dashlet_property'));
+			$sHtml = addslashes($oForm->RenderAsPropertySheet($oPage, true /* bReturnHtml */));
+			$sHtml = str_replace("\n", '', $sHtml);
+			$sHtml = str_replace("\r", '', $sHtml);
+			$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'
+		}
+		break;
+			
 		case 'update_dashlet_property':
 		require_once(APPROOT.'application/forms.class.inc.php');
 		require_once(APPROOT.'application/dashlet.class.inc.php');