From 3b188524caa904954b3afbdeb6cb4d744ce8bb02 Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Mon, 9 Dec 2013 15:55:11 +0000 Subject: [PATCH] #770 Complete the fix implemented in [2990], the configuration is kept even if not saved for the list SVN:trunk[3029] --- application/datatable.class.inc.php | 2 +- application/shortcut.class.inc.php | 21 +++++++++++---------- application/utils.inc.php | 6 +++--- js/utils.js | 11 +++++++++-- pages/ajax.render.php | 6 +++--- 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/application/datatable.class.inc.php b/application/datatable.class.inc.php index a86b5b77f..ade96ecca 100644 --- a/application/datatable.class.inc.php +++ b/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; diff --git a/application/shortcut.class.inc.php b/application/shortcut.class.inc.php index 0231a7b04..abca8f5d3 100644 --- a/application/shortcut.class.inc.php +++ b/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('
'); - $oForm = self::GetCreationForm($sOQL, $sSourceTableId); + $oForm = self::GetCreationForm($sOQL, $sTableSettings); $oForm->Render($oPage); $oPage->add('
'); diff --git a/application/utils.inc.php b/application/utils.inc.php index 8adb88f35..fd27b4b1c 100644 --- a/application/utils.inc.php +++ b/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; diff --git a/js/utils.js b/js/utils.js index 8296f4d9d..6c0dc9af5 100644 --- a/js/utils.js +++ b/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; diff --git a/pages/ajax.render.php b/pages/ajax.render.php index 45c66e052..b1f87df02 100644 --- a/pages/ajax.render.php +++ b/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 //