mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°3648 - Fix "Configure this list..."
This commit is contained in:
@@ -74,22 +74,20 @@ $(function()
|
||||
$.post(this.options.sRenderUrl, oParams, function(data) {
|
||||
// Nasty workaround to clear the pager's state for paginated lists !!!
|
||||
// See jquery.tablesorter.pager.js / saveParams / restoreParams
|
||||
if (window.pager_params)
|
||||
{
|
||||
if (window.pager_params) {
|
||||
window.pager_params['pager'+me.options.sListId] = undefined;
|
||||
}
|
||||
|
||||
// try {
|
||||
var parentElt = $('#'+me.options.sListId).parent().parent();
|
||||
var parentElt = $('#'+me.options.sListId).closest('.dataTables_wrapper').parent();
|
||||
$('#'+me.options.sListId).DataTable().destroy(true);
|
||||
var sThead="";
|
||||
if(me.options.sSelectMode !=""){
|
||||
var sThead = "";
|
||||
if (me.options.sSelectMode != "") {
|
||||
sThead += "<th></th>";
|
||||
}
|
||||
var aOptions = JSON.parse(data);
|
||||
$.each(aOptions['allColumns'], function(i, item) {
|
||||
$.each(item, function(j, champs) {
|
||||
if(champs.checked == 'true') {
|
||||
$.each(aOptions['allColumns'], function (i, item) {
|
||||
$.each(item, function (j, champs) {
|
||||
if (champs.checked == 'true') {
|
||||
sThead += "<th>"+champs.label+"</th>";
|
||||
}
|
||||
});
|
||||
|
||||
@@ -167,6 +167,12 @@ class AjaxRenderController
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($aExtraParams['list_id'])) {
|
||||
$sListId = utils::ReadParam('list_id', null);
|
||||
if (!is_null($sListId)) {
|
||||
$aExtraParams['list_id'] = $sListId;
|
||||
}
|
||||
}
|
||||
$iLength = utils::ReadParam('end', 10);
|
||||
$aColumns = utils::ReadParam('columns', array(), false, 'raw_data');
|
||||
$sSelectMode = utils::ReadParam('select_mode', '');
|
||||
@@ -318,7 +324,9 @@ class AjaxRenderController
|
||||
if ($sIdName != "") {
|
||||
$aObj["id"] = $aObj[$sIdName];
|
||||
}
|
||||
array_push($aResult["data"], $aObj);
|
||||
if (isset($aObj)) {
|
||||
array_push($aResult["data"], $aObj);
|
||||
}
|
||||
}
|
||||
|
||||
return $aResult;
|
||||
@@ -350,7 +358,7 @@ class AjaxRenderController
|
||||
|
||||
if ($bSaveAsDefaults) {
|
||||
if ($sTableId != null) {
|
||||
$oCurrSettings = unserialize(DataTableSettings::GetTableSettings($aClassAliases, $sTableId, true /* bOnlyTable */));
|
||||
$oCurrSettings = DataTableSettings::GetTableSettings($aClassAliases, $sTableId, true /* bOnlyTable */);
|
||||
if ($oCurrSettings) {
|
||||
$oCurrSettings->ResetToDefault(false); // Reset this table to the defaults
|
||||
}
|
||||
|
||||
@@ -51,7 +51,8 @@ class DataTable extends UIContentBlock
|
||||
public function __construct(?string $sId = null)
|
||||
{
|
||||
parent::__construct($sId);
|
||||
$this->AddDeferredBlock(new DataTableConfig($this));
|
||||
//$this->AddDeferredBlock(new DataTableConfig($this));
|
||||
$this->AddSubBlock(new DataTableConfig($this));
|
||||
$this->aDisplayColumns = [];
|
||||
$this->aOptions = [];
|
||||
$this->aResultColumns = [];
|
||||
|
||||
@@ -196,26 +196,27 @@ class DataTableSettings implements Serializable
|
||||
*/
|
||||
static public function GetTableSettings($aClassAliases, $sTableId = null, $bOnlyOnTable = false)
|
||||
{
|
||||
$pref = null;
|
||||
$oSettings = new DataTableSettings($aClassAliases, $sTableId);
|
||||
$pref = null;
|
||||
$oSettings = new DataTableSettings($aClassAliases, $sTableId);
|
||||
|
||||
if ($sTableId != null) {
|
||||
// An identified table, let's fetch its own settings (if any)
|
||||
$pref = appUserPreferences::GetPref($oSettings->GetPrefsKey($sTableId), null);
|
||||
}
|
||||
if ($sTableId != null) {
|
||||
// An identified table, let's fetch its own settings (if any)
|
||||
$pref = appUserPreferences::GetPref($oSettings->GetPrefsKey($sTableId), null);
|
||||
}
|
||||
|
||||
if ($pref == null) {
|
||||
if (!$bOnlyOnTable) {
|
||||
// Try the global preferred values for this class / set of classes
|
||||
$pref = appUserPreferences::GetPref($oSettings->GetPrefsKey(null), null);
|
||||
}
|
||||
if ($pref == null) {
|
||||
// no such settings, use the default values provided by the data model
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if ($pref == null) {
|
||||
if (!$bOnlyOnTable) {
|
||||
// Try the global preferred values for this class / set of classes
|
||||
$pref = appUserPreferences::GetPref($oSettings->GetPrefsKey(null), null);
|
||||
}
|
||||
if ($pref == null) {
|
||||
// no such settings, use the default values provided by the data model
|
||||
return null;
|
||||
}
|
||||
}
|
||||
$oSettings->unserialize($pref);
|
||||
|
||||
return $oSettings;
|
||||
return $oSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -165,7 +165,7 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
||||
$oDataTable = new DataTable('datatable_'.$sListId);
|
||||
|
||||
$oAppRoot = utils::GetAbsoluteUrlAppRoot();
|
||||
|
||||
|
||||
// Initialize and check the parameters
|
||||
$bViewLink = isset($aExtraParams['view_link']) ? $aExtraParams['view_link'] : true;
|
||||
$sLinkageAttribute = isset($aExtraParams['link_attr']) ? $aExtraParams['link_attr'] : '';
|
||||
@@ -433,7 +433,7 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
||||
$oDataTable = new DataTable('datatable_'.$sListId);
|
||||
$aList = array();
|
||||
$oAppRoot = utils::GetAbsoluteUrlAppRoot();
|
||||
|
||||
|
||||
// Initialize and check the parameters
|
||||
$bViewLink = isset($aExtraParams['view_link']) ? $aExtraParams['view_link'] : true;
|
||||
// Check if there is a list of aliases to limit the display to...
|
||||
@@ -551,40 +551,47 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
||||
}
|
||||
$aSortDatable = [];
|
||||
foreach ($aAuthorizedClasses as $sClassAlias => $sClassName) {
|
||||
foreach ($oCustomSettings->aColumns[$sClassAlias] as $sAttCode => $aData) {
|
||||
if ($aData['sort'] != 'none') {
|
||||
$sCode = ($aData['code'] == '_key_') ? 'friendlyname' : $aData['code'];
|
||||
$aSortOrder[$sAlias.$sCode] = ($aData['sort'] == 'asc'); // true for ascending, false for descending
|
||||
$aSortDatable = [$iIndexColumn, $aData['sort']];
|
||||
}
|
||||
if ($aData['checked']) {
|
||||
if ($sAttCode == '_key_') {
|
||||
if ($bViewLink) {
|
||||
if (isset($oCustomSettings->aColumns[$sClassAlias])) {
|
||||
foreach ($oCustomSettings->aColumns[$sClassAlias] as $sAttCode => $aData) {
|
||||
if ($aData['sort'] != 'none') {
|
||||
$sCode = ($aData['code'] == '_key_') ? 'friendlyname' : $aData['code'];
|
||||
$aSortOrder[$sAlias.$sCode] = ($aData['sort'] == 'asc'); // true for ascending, false for descending
|
||||
$aSortDatable = [$iIndexColumn, $aData['sort']];
|
||||
}
|
||||
if ($aData['checked']) {
|
||||
if ($sAttCode == '_key_') {
|
||||
if ($bViewLink) {
|
||||
if (MetaModel::IsValidAttCode($sClassName, 'obsolescence_flag')) {
|
||||
$sRender = "let displayField = '<span class=\"object-ref\" title=\"".$sClassAlias."::'+data+'\"><a class=\'object-ref-link\' href=\'".$oAppRoot."/pages/UI.php?operation=details&class=".$sClassName."&id='+data+'\'>'+row['".$sClassAlias."/friendlyname']+'</a></span>'; if (row['".$sClassAlias."/obsolescence_flag'].indexOf('no') == -1){displayField = '<span class=\"object-ref obsolete\" title=\"obsolete\"><span class=\"object-ref-icon text_decoration\"><span class=\"fas fa-eye-slash object-obsolete fa-1x fa-fw\"></span></span><a class=\'object-ref-link\' href=\'UI.php?operation=details&class=".$sClassName."&id='+data+'\'>'+row['".$sClassAlias."/friendlyname']+'</a></span>';} return displayField;";
|
||||
} else {
|
||||
$sRender = "let displayField = '<span class=\"object-ref\" title=\"".$sClassAlias."::'+data+'\"><a class=\'object-ref-link\' href=\'".$oAppRoot."/pages/UI.php?operation=details&class=".$sClassName."&id='+data+'\'>'+row['".$sClassAlias."/friendlyname']+'</a></span>'; return displayField;";
|
||||
}
|
||||
$aColumnDefinition[] = [
|
||||
'description' => $aData['label'],
|
||||
'object_class' => $sClassName,
|
||||
'class_alias' => $sClassAlias,
|
||||
'attribute_code' => $sAttCode,
|
||||
'attribute_type' => '_key_',
|
||||
'attribute_label' => $aData['alias'],
|
||||
"render" => $sRender,
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$oAttDef = MetaModel::GetAttributeDef($sClassName, $sAttCode);
|
||||
$sAttDefClass = get_class($oAttDef);
|
||||
$sAttLabel = MetaModel::GetLabel($sClassName, $sAttCode);
|
||||
$aColumnDefinition[] = [
|
||||
'description' => $aData['label'],
|
||||
'description' => $oAttDef->GetOrderByHint(),
|
||||
'object_class' => $sClassName,
|
||||
'class_alias' => $sClassAlias,
|
||||
'attribute_code' => $sAttCode,
|
||||
'attribute_type' => '_key_',
|
||||
'attribute_label' => $aData['alias'],
|
||||
"render" => "let displayField = '<span class=\"object-ref\" title=\"".$sClassAlias."::'+data+'\"><a class=\'object-ref-link\' href=\'".$oAppRoot."/pages/UI.php?operation=details&class=".$sClassName."&id='+data+'\'>'+row['".$sClassAlias."/friendlyname']+'</a></span>'; if (row['".$sClassAlias."/obsolescence_flag'].indexOf('no') == -1){displayField = '<span class=\"object-ref obsolete\" title=\"obsolete\"><span class=\"object-ref-icon text_decoration\"><span class=\"fas fa-eye-slash object-obsolete fa-1x fa-fw\"></span></span><a class=\'object-ref-link\' href=\'UI.php?operation=details&class=".$sClassName."&id='+data+'\'>'+row['".$sClassAlias."/friendlyname']+'</a></span>';} return displayField;",
|
||||
'attribute_type' => $sAttDefClass,
|
||||
'attribute_label' => $sAttLabel,
|
||||
"render" => $oAttDef->GetRenderForDataTable($sClassAlias),
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$oAttDef = MetaModel::GetAttributeDef($sClassName, $sAttCode);
|
||||
$sAttDefClass = get_class($oAttDef);
|
||||
$sAttLabel = MetaModel::GetLabel($sClassName, $sAttCode);
|
||||
$aColumnDefinition[] = [
|
||||
'description' => $oAttDef->GetOrderByHint(),
|
||||
'object_class' => $sClassName,
|
||||
'class_alias' => $sClassAlias,
|
||||
'attribute_code' => $sAttCode,
|
||||
'attribute_type' => $sAttDefClass,
|
||||
'attribute_label' => $sAttLabel,
|
||||
"render" => $oAttDef->GetRenderForDataTable($sClassAlias),
|
||||
];
|
||||
$iIndexColumn++;
|
||||
}
|
||||
$iIndexColumn++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -645,7 +652,7 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
||||
public static function GetOptionsForRendering(array $aColumns, string $sSelectMode, string $sFilter, int $iLength, array $aClassAliases, array $aExtraParams)
|
||||
{
|
||||
$oAppRoot = utils::GetAbsoluteUrlAppRoot();
|
||||
|
||||
|
||||
$aOptions = [];
|
||||
$sTableId = $aExtraParams["table_id"];
|
||||
$sListId = $aExtraParams["list_id"];
|
||||
@@ -695,8 +702,13 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
||||
'attribute_label' => $aData['alias'],
|
||||
];
|
||||
$aColumnDefinition["data"] = $sClassAlias."/".$sAttCode;
|
||||
if (MetaModel::IsValidAttCode($sClassName, 'obsolescence_flag')) {
|
||||
$sDisplay = "let displayField = '<span class=\"object-ref\" title=\"".$sClassAlias."::'+data+'\"><a class=\'object-ref-link\' href=\'".$oAppRoot."/pages/UI.php?operation=details&class=".$sClassName."&id='+data+'\'>'+row['".$sClassAlias."/friendlyname']+'</a></span>'; if (row['".$sClassAlias."/obsolescence_flag'].indexOf('no') == -1){displayField = '<span class=\"object-ref obsolete\" title=\"obsolete\"><a class=\'object-ref-link\' href=\'UI.php?operation=details&class=".$sClassName."&id='+data+'\'><span class=\"object-ref-icon text_decoration\"><span class=\"fas fa-eye-slash object-obsolete fa-1x fa-fw\"></span></span>'+row['".$sClassAlias."/friendlyname']+'</a></span>';} return displayField;";
|
||||
} else {
|
||||
$sDisplay = "let displayField = '<span class=\"object-ref\" title=\"".$sClassAlias."::'+data+'\"><a class=\'object-ref-link\' href=\'".$oAppRoot."/pages/UI.php?operation=details&class=".$sClassName."&id='+data+'\'>'+row['".$sClassAlias."/friendlyname']+'</a></span>'; return displayField;";
|
||||
}
|
||||
$aColumnDefinition["render"] = [
|
||||
"display" => "let displayField = '<span class=\"object-ref\" title=\"".$sClassAlias."::'+data+'\"><a class=\'object-ref-link\' href=\'".$oAppRoot."/pages/UI.php?operation=details&class=".$sClassName."&id='+data+'\'>'+row['".$sClassAlias."/friendlyname']+'</a></span>'; if (row['".$sClassAlias."/obsolescence_flag'].indexOf('no') == -1){displayField = '<span class=\"object-ref obsolete\" title=\"obsolete\"><span class=\"object-ref-icon text_decoration\"><span class=\"fas fa-eye-slash object-obsolete fa-1x fa-fw\"></span></span><a class=\'object-ref-link\' href=\'UI.php?operation=details&class=".$sClassName."&id='+data+'\'>'+row['".$sClassAlias."/friendlyname']+'</a></span>';} return displayField;",
|
||||
"display" => $sDisplay,
|
||||
"_" => $sClassAlias."/".$sAttCode,
|
||||
];
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user