mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
N°5905 - Harmonize how linksets are displayed part I
* Always display a table and its actions to ease link creation * Display linkset description in an alert block
This commit is contained in:
@@ -1304,17 +1304,12 @@ JS
|
||||
}
|
||||
}
|
||||
if (count($aAuthorizedClasses) > 0) {
|
||||
if ($this->m_oSet->CountWithLimit(1) > 0) {
|
||||
if (empty($aExtraParams['currentId'])) {
|
||||
$iListId = utils::GetUniqueId(); // Works only if not in an Ajax page !!
|
||||
} else {
|
||||
$iListId = $aExtraParams['currentId'];
|
||||
}
|
||||
$oBlock->AddSubBlock(DataTableUIBlockFactory::MakeForObject($oPage, $iListId, $this->m_oSet, $aExtraParams));
|
||||
if (empty($aExtraParams['currentId'])) {
|
||||
$iListId = utils::GetUniqueId(); // Works only if not in an Ajax page !!
|
||||
} else {
|
||||
// Empty set
|
||||
$oBlock->bEmptySet = true;
|
||||
$iListId = $aExtraParams['currentId'];
|
||||
}
|
||||
$oBlock->AddSubBlock(DataTableUIBlockFactory::MakeForObject($oPage, $iListId, $this->m_oSet, $aExtraParams));
|
||||
} else {
|
||||
// Not authorized
|
||||
$oBlock->bNotAuthorized = true;
|
||||
@@ -1337,43 +1332,13 @@ JS
|
||||
}
|
||||
|
||||
// The list is made of only 1 class of objects, actions on the list are possible
|
||||
if (($this->m_oSet->CountWithLimit(1) > 0) && (UserRights::IsActionAllowed($this->m_oSet->GetClass(), UR_ACTION_READ, $this->m_oSet) == UR_ALLOWED_YES)) {
|
||||
if (UserRights::IsActionAllowed($this->m_oSet->GetClass(), UR_ACTION_READ, $this->m_oSet) == UR_ALLOWED_YES) {
|
||||
$oBlock->AddSubBlock(cmdbAbstractObject::GetDisplaySetBlock($oPage, $this->m_oSet, $aExtraParams));
|
||||
} else {
|
||||
$oBlock->bEmptySet = true;
|
||||
$oBlock->sClass = $this->m_oFilter->GetClass();
|
||||
$oBlock->sClassLabel = MetaModel::GetName($oBlock->sClass);
|
||||
$bDisplayMenu = isset($aExtraParams['menu']) ? ($aExtraParams['menu'] == true) : true;
|
||||
if ($bDisplayMenu) {
|
||||
if ((UserRights::IsActionAllowed($oBlock->sClass, UR_ACTION_MODIFY) == UR_ALLOWED_YES)) {
|
||||
$oBlock->sLinkTarget = '';
|
||||
$oAppContext = new ApplicationContext();
|
||||
$oBlock->sParams = $oAppContext->GetForLink();
|
||||
// 1:n links, populate the target object as a default value when creating a new linked object
|
||||
if (isset($aExtraParams['target_attr'])) {
|
||||
$oBlock->sLinkTarget = ' target="_blank" ';
|
||||
$aExtraParams['default'][$aExtraParams['target_attr']] = $aExtraParams['object_id'];
|
||||
}
|
||||
if (!empty($aExtraParams['default'])) {
|
||||
foreach ($aExtraParams['default'] as $sKey => $sValue) {
|
||||
$oBlock->sDefault .= "&default[$sKey]=$sValue";
|
||||
}
|
||||
}
|
||||
$oBlock->bCreateNew = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($aExtraParams["surround_with_panel"]) && $aExtraParams["surround_with_panel"]) {
|
||||
$oPanel = PanelUIBlockFactory::MakeForClass($aExtraParams["panel_class"], $aExtraParams["panel_title"]);
|
||||
if(isset($aExtraParams["panel_icon"]) && strlen($aExtraParams["panel_icon"]) > 0){
|
||||
$oPanel->SetIcon($aExtraParams["panel_icon"]);
|
||||
}
|
||||
$oPanel->AddSubBlock($oBlock);
|
||||
|
||||
return $oPanel;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $oBlock;
|
||||
|
||||
@@ -144,13 +144,12 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
||||
}
|
||||
}
|
||||
|
||||
// Default behavor, surrond table with a panel for better display
|
||||
if (!isset($aExtraParams['surround_with_panel']) || $aExtraParams['surround_with_panel']) {
|
||||
if(!empty($oDataTable->GetInitDisplayData()) && isset($oDataTable->GetInitDisplayData()['recordsTotal'])){
|
||||
$iCount = $oDataTable->GetInitDisplayData()['recordsTotal'];
|
||||
} else {
|
||||
$iCount = $oSet->Count();
|
||||
}
|
||||
$oContainer = PanelUIBlockFactory::MakeForClass($oSet->GetClass(), '')->AddCSSClass('ibo-datatable-panel');
|
||||
$oContainer = PanelUIBlockFactory::MakeForClass($oSet->GetClass(), '')
|
||||
->AddCSSClass('ibo-datatable-panel');
|
||||
|
||||
// Panel title
|
||||
if (isset($aExtraParams['panel_title'])) {
|
||||
if (isset($aExtraParams['panel_title_is_html']) && $aExtraParams['panel_title_is_html'] === true) {
|
||||
$oContainer->AddTitleBlock(HtmlFactory::MakeRaw($aExtraParams['panel_title']));
|
||||
@@ -159,6 +158,12 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
||||
}
|
||||
}
|
||||
|
||||
// Panel subtitle
|
||||
if(!empty($oDataTable->GetInitDisplayData()) && isset($oDataTable->GetInitDisplayData()['recordsTotal'])){
|
||||
$iCount = $oDataTable->GetInitDisplayData()['recordsTotal'];
|
||||
} else {
|
||||
$iCount = $oSet->Count();
|
||||
}
|
||||
$sCountHtml = '<span class="ibo-datatable--result-count">'.$iCount.'</span>';
|
||||
if ($oDataTable->GetOption('select_mode') === 'multiple') {
|
||||
$sSubTitle = Dict::Format('UI:Pagination:HeaderSelection', $sCountHtml, '<span class="ibo-datatable--selected-count">0</span>');
|
||||
@@ -169,11 +174,13 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
||||
if (utils::IsNotNullOrEmptyString($sFilterListUrl)) {
|
||||
$sSubTitle = '<a href="'.$sFilterListUrl.'" title="'.Dict::S('UI:Menu:FilterList').'">'.$sSubTitle.'</a>';
|
||||
}
|
||||
|
||||
$oContainer->AddSubTitleBlock(new Html($sSubTitle));
|
||||
if (isset($aExtraParams["panel_icon"]) && strlen($aExtraParams["panel_icon"]) > 0) {
|
||||
$oContainer->SetIcon($aExtraParams["panel_icon"]);
|
||||
|
||||
// Panel icon
|
||||
if (isset($aExtraParams['panel_icon']) && strlen($aExtraParams['panel_icon']) > 0) {
|
||||
$oContainer->SetIcon($aExtraParams['panel_icon']);
|
||||
}
|
||||
|
||||
$oContainer->AddToolbarBlock($oBlockMenu);
|
||||
$oContainer->AddMainBlock($oDataTable);
|
||||
} else {
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Combodo\iTop\Application\UI\Links;
|
||||
use ApplicationException;
|
||||
use ArchivedObjectException;
|
||||
use AttributeLinkedSet;
|
||||
use Combodo\iTop\Application\UI\Base\Component\MedallionIcon\MedallionIcon;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Alert\AlertUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
|
||||
use CoreException;
|
||||
use CoreWarning;
|
||||
@@ -121,10 +121,11 @@ abstract class AbstractBlockLinksViewTable extends UIContentBlock
|
||||
*/
|
||||
private function InitHeader()
|
||||
{
|
||||
// MedallionIcon
|
||||
$oClassIcon = new MedallionIcon(MetaModel::GetClassIcon($this->sTargetClass, false));
|
||||
$oClassIcon->SetDescription($this->oAttDef->GetDescription())->AddCSSClass('ibo-block-list--medallion');
|
||||
$this->AddSubBlock($oClassIcon);
|
||||
$sDescription = $this->oAttDef->GetDescription();
|
||||
if (utils::IsNotNullOrEmptyString($sDescription)) {
|
||||
$oAlert = AlertUIBlockFactory::MakeForInformation('', $sDescription);
|
||||
$this->AddSubBlock($oAlert);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,9 +38,11 @@ class BlockDirectLinksViewTable extends AbstractBlockLinksViewTable
|
||||
'table_id' => $this->GetTableId(),
|
||||
'row_actions' => $this->GetRowActions(),
|
||||
'currentId' => $this->GetTableId(),
|
||||
'panel_title' => 'TODO: Replace with current tab label?', // TODO 3.1: What to put there: Tab label? Unlikely. Lnk class name? Unlikely. Maybe there should be a dedicated "label" property so we can define the label.
|
||||
'panel_icon' => MetaModel::GetClassIcon($this->GetTargetClass(), false),
|
||||
);
|
||||
|
||||
// - Add creation in modal if the linkset is not readonly
|
||||
// Add creation in modal if the linkset is not readonly
|
||||
if (!$this->oAttDef->GetReadOnly()) {
|
||||
$aExtraParams['creation_in_modal_is_allowed'] = true;
|
||||
$aExtraParams['creation_in_modal_js_handler'] = 'LinkSetWorker.CreateLinkedObject("'.$this->GetTableId().'");';
|
||||
|
||||
@@ -50,10 +50,11 @@ class BlockIndirectLinksViewTable extends AbstractBlockLinksViewTable
|
||||
'extra_fields' => $this->GetAttCodesToDisplay(),
|
||||
'row_actions' => $this->GetRowActions(),
|
||||
'currentId' => $this->GetTableId(),
|
||||
'panel_title' => 'TODO: Replace with current tab label?', // TODO 3.1: What to put there: Tab label? Unlikely. Lnk class name? Unlikely. Maybe there should be a dedicated "label" property so we can define the label.
|
||||
'panel_icon' => MetaModel::GetClassIcon($this->GetTargetClass(), false),
|
||||
);
|
||||
|
||||
// - Add creation in modal if the linkset is not readonly
|
||||
|
||||
// Add creation in modal if the linkset is not readonly
|
||||
if (!$this->oAttDef->GetReadOnly()) {
|
||||
$aExtraParams['creation_in_modal_is_allowed'] = true;
|
||||
$aExtraParams['creation_in_modal_js_handler'] = 'LinkSetWorker.CreateLinkedObject("'.$this->GetTableId().'");';
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<div class="ibo-block-list--empty-text">{{ 'UI:NoObjectToDisplay'|dict_s }}</div>
|
||||
{% endif %}
|
||||
|
||||
{# TODO 3.1: This section should be removed if BlockList is no longer used as is, but always with a table #}
|
||||
{% if oUIBlock.bCreateNew %}
|
||||
<div class="ibo-block-list--create-action">
|
||||
<a{{ oUIBlock.sLinkTarget }} href="{{ oUIBlock.sAbsoluteUrlAppRoot }}pages/UI.php?operation=new&class={{ oUIBlock.sClass }}&{{ oUIBlock.sParams }}{{ oUIBlock.sDefault }}">
|
||||
|
||||
Reference in New Issue
Block a user