瀏覽代碼

#770 Complete the fix implemented in [2990], the configuration is kept even if not saved for the list

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3029 a333f486-631f-4898-b8df-5754b55c2be0
romainq 11 年之前
父節點
當前提交
77683afb6e
共有 5 個文件被更改,包括 27 次插入19 次删除
  1. 1 1
      application/datatable.class.inc.php
  2. 11 10
      application/shortcut.class.inc.php
  3. 3 3
      application/utils.inc.php
  4. 9 2
      js/utils.js
  5. 3 3
      pages/ajax.render.php

+ 1 - 1
application/datatable.class.inc.php

@@ -298,7 +298,7 @@ EOF;
 			$oMenuItem1->GetUID() => $oMenuItem1->GetMenuItem(),
 		);
 		$this->oSet->Rewind();
-		utils::GetPopupMenuItems($oPage, iPopupMenuExtension::MENU_OBJLIST_TOOLKIT, $this->oSet, $aActions, $this->sTableId);
+		utils::GetPopupMenuItems($oPage, iPopupMenuExtension::MENU_OBJLIST_TOOLKIT, $this->oSet, $aActions, $this->sTableId, $this->iListId);
 		$this->oSet->Rewind();
 		$sHtml .= $oPage->RenderPopupMenuItems($aActions);
 		return $sHtml;

+ 11 - 10
application/shortcut.class.inc.php

@@ -209,17 +209,18 @@ class ShortcutOQL extends Shortcut
 			
 	}
 
-	public function CloneTableSettings($sSourceTableId)
+	public function CloneTableSettings($sTableSettings)
 	{
+		$aTableSettings = json_decode($sTableSettings, true);
+
 		$oFilter = DBObjectSearch::FromOQL($this->Get('oql'));
-		$oCustomSettings = DataTableSettings::GetTableSettings($oFilter->GetSelectedClasses(), $sSourceTableId, true /*dedicated settings only*/);
-		if (!is_null($oCustomSettings))
-		{
-			$oCustomSettings->Save('shortcut_'.$this->GetKey());
-		}
+		$oCustomSettings = new DataTableSettings($oFilter->GetSelectedClasses());
+		$oCustomSettings->iDefaultPageSize = $aTableSettings['iPageSize'];
+		$oCustomSettings->aColumns = $aTableSettings['oColumns'];
+		$oCustomSettings->Save('shortcut_'.$this->GetKey());
 	}
 
-	public static function GetCreationForm($sOQL = null, $sSourceTableId = null)
+	public static function GetCreationForm($sOQL = null, $sTableSettings = null)
 	{
 		$oForm = new DesignerForm();
 
@@ -261,17 +262,17 @@ class ShortcutOQL extends Shortcut
 		$oField = new DesignerHiddenField('oql', '', $sOQL);
 		$oForm->AddField($oField);
 
-		$oField = new DesignerHiddenField('source_table_id', '', $sSourceTableId);
+		$oField = new DesignerHiddenField('table_settings', '', $sTableSettings);
 		$oForm->AddField($oField);
 
 		return $oForm;
 	}
 
-	public static function GetCreationDlgFromOQL($oPage, $sOQL, $sSourceTableId)
+	public static function GetCreationDlgFromOQL($oPage, $sOQL, $sTableSettings)
 	{
 		$oPage->add('<div id="shortcut_creation_dlg">');
 
-		$oForm = self::GetCreationForm($sOQL, $sSourceTableId);
+		$oForm = self::GetCreationForm($sOQL, $sTableSettings);
 
 		$oForm->Render($oPage);
 		$oPage->add('</div>');

+ 3 - 3
application/utils.inc.php

@@ -768,7 +768,7 @@ class utils
 	/**
 	 * Merge standard menu items with plugin provided menus items
 	 */
-	public static function GetPopupMenuItems($oPage, $iMenuId, $param, &$aActions, $sTableId = null)
+	public static function GetPopupMenuItems($oPage, $iMenuId, $param, &$aActions, $sTableId = null, $sDataTableId = null)
 	{
 		// 1st - add standard built-in menu items
 		// 
@@ -778,7 +778,7 @@ class utils
 			// $param is a DBObjectSet
 			$oAppContext = new ApplicationContext();
 			$sContext = $oAppContext->GetForLink();
-			$sSourceTableId = is_null($sTableId) ? '' : $sTableId;
+			$sDataTableId = is_null($sDataTableId) ? '' : $sDataTableId;
 			$sUIPage = cmdbAbstractObject::ComputeStandardUIPage($param->GetFilter()->GetClass());
 			$sOQL = addslashes($param->GetFilter()->ToOQL(true));
 			$sFilter = urlencode($param->GetFilter()->serialize());
@@ -789,7 +789,7 @@ class utils
 				new URLPopupMenuItem('UI:Menu:EMail', Dict::S('UI:Menu:EMail'), "mailto:?body=".urlencode($sUrl).' '), // Add an extra space to make it work in Outlook
 				new URLPopupMenuItem('UI:Menu:CSVExport', Dict::S('UI:Menu:CSVExport'), $sUrl."&format=csv"),
 				new JSPopupMenuItem('UI:Menu:AddToDashboard', Dict::S('UI:Menu:AddToDashboard'), "DashletCreationDlg('$sOQL')"),
-				new JSPopupMenuItem('UI:Menu:ShortcutList', Dict::S('UI:Menu:ShortcutList'), "ShortcutListDlg('$sOQL', '$sSourceTableId', '$sContext')"),
+				new JSPopupMenuItem('UI:Menu:ShortcutList', Dict::S('UI:Menu:ShortcutList'), "ShortcutListDlg('$sOQL', '$sDataTableId', '$sContext')"),
 			);
 			break;
 

+ 9 - 2
js/utils.js

@@ -361,9 +361,16 @@ function DashletCreationDlg(sOQL)
 	return false;
 }
 
-function ShortcutListDlg(sOQL, sSourceTableId, sContext)
+function ShortcutListDlg(sOQL, sDataTableId, sContext)
 {
-	$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?'+sContext, {operation: 'shortcut_list_dlg', oql: sOQL, source_table_id: sSourceTableId}, function(data){
+	var sDataTableName = 'datatable_'+sDataTableId;
+	var oTableSettings = {
+		oColumns: $('#'+sDataTableName).datatable('option', 'oColumns'),
+		iPageSize: $('#'+sDataTableName).datatable('option', 'iPageSize')
+	};
+	var sTableSettings = JSON.stringify(oTableSettings);
+
+	$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?'+sContext, {operation: 'shortcut_list_dlg', oql: sOQL, table_settings: sTableSettings}, function(data){
 		$('body').append(data);
 	});
 	return false;

+ 3 - 3
pages/ajax.render.php

@@ -981,8 +981,8 @@ EOF
 		
 		case 'shortcut_list_dlg':
 		$sOQL = utils::ReadParam('oql', '', false, 'raw_data');
-		$sSourceTableId = utils::ReadParam('source_table_id', '', false, 'raw_data');
-		ShortcutOQL::GetCreationDlgFromOQL($oPage, $sOQL, $sSourceTableId);
+		$sTableSettings = utils::ReadParam('table_settings', '', false, 'raw_data');
+		ShortcutOQL::GetCreationDlgFromOQL($oPage, $sOQL, $sTableSettings);
 		break;
 		
 		case 'shortcut_list_create':
@@ -1006,7 +1006,7 @@ EOF
 		}
 		$iId = $oShortcut->DBInsertNoReload();
 
-		$oShortcut->CloneTableSettings($aValues['source_table_id']);
+		$oShortcut->CloneTableSettings($aValues['table_settings']);
 
 		// Add the menu node in the right place
 		//