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

SVN:trunk[3029]
This commit is contained in:
Romain Quetiez
2013-12-09 15:55:11 +00:00
parent bd1096b0fc
commit 3b188524ca
5 changed files with 27 additions and 19 deletions

View File

@@ -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;

View File

@@ -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>');

View File

@@ -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;

View File

@@ -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;

View File

@@ -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
//