mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°1320: Add option to show/hide linkedsets out of user's scopes in portal
This commit is contained in:
@@ -490,6 +490,11 @@ class ObjectFormManager extends FormManager
|
||||
{
|
||||
$aFieldsExtraData[$sFieldId]['opened'] = true;
|
||||
}
|
||||
// Checking if field allows to ignore scope (For linked set)
|
||||
if ($oFieldNode->hasAttribute('data-field-ignore-scopes') && ($oFieldNode->getAttribute('data-field-ignore-scopes') === 'true'))
|
||||
{
|
||||
$aFieldsExtraData[$sFieldId]['ignore_scopes'] = true;
|
||||
}
|
||||
// Checking field display mode
|
||||
if ($oFieldNode->hasAttribute('data-field-display-mode') && $oFieldNode->getAttribute('data-field-display-mode') !== '')
|
||||
{
|
||||
@@ -889,6 +894,11 @@ class ObjectFormManager extends FormManager
|
||||
{
|
||||
$oField->SetDisplayOpened(true);
|
||||
}
|
||||
// - Displaying out of scopes items
|
||||
if (array_key_exists($sAttCode, $aFieldsExtraData) && array_key_exists('ignore_scopes', $aFieldsExtraData[$sAttCode]))
|
||||
{
|
||||
$oField->SetDisplayLimitedAccessItems(true);
|
||||
}
|
||||
}
|
||||
// - BlobField
|
||||
if (in_array(get_class($oField), array('Combodo\\iTop\\Form\\Field\\BlobField', 'Combodo\\iTop\\Form\\Field\\ImageField')))
|
||||
|
||||
@@ -34,7 +34,9 @@ class LinkedSetField extends Field
|
||||
const DEFAULT_INDIRECT = false;
|
||||
/** @var bool DEFAULT_DISPLAY_OPENED */
|
||||
const DEFAULT_DISPLAY_OPENED = false;
|
||||
|
||||
/** @var bool DEFAULT_DISPLAY_LIMITED_ACCESS_ITEMS */
|
||||
const DEFAULT_DISPLAY_LIMITED_ACCESS_ITEMS = false;
|
||||
|
||||
/** @var string $sTargetClass */
|
||||
protected $sTargetClass;
|
||||
/** @var string $sExtKeyToRemote */
|
||||
@@ -43,6 +45,8 @@ class LinkedSetField extends Field
|
||||
protected $bIndirect;
|
||||
/** @var bool $bDisplayOpened */
|
||||
protected $bDisplayOpened;
|
||||
/** @var bool $bDisplayLimitedAccessItems */
|
||||
protected $bDisplayLimitedAccessItems;
|
||||
/** @var array $aLimitedAccessItemIDs IDs of the items that are not visible or cannot be edited */
|
||||
protected $aLimitedAccessItemIDs;
|
||||
/** @var array $aAttributesToDisplay */
|
||||
@@ -61,6 +65,7 @@ class LinkedSetField extends Field
|
||||
$this->sExtKeyToRemote = null;
|
||||
$this->bIndirect = static::DEFAULT_INDIRECT;
|
||||
$this->bDisplayOpened = static::DEFAULT_DISPLAY_OPENED;
|
||||
$this->bDisplayLimitedAccessItems = static::DEFAULT_DISPLAY_LIMITED_ACCESS_ITEMS;
|
||||
$this->aLimitedAccessItemIDs = array();
|
||||
$this->aAttributesToDisplay = array();
|
||||
$this->sSearchEndpoint = null;
|
||||
@@ -159,6 +164,30 @@ class LinkedSetField extends Field
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the field should display limited access items
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function GetDisplayLimitedAccessItems()
|
||||
{
|
||||
return $this->bDisplayLimitedAccessItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if the field should display limited access items
|
||||
*
|
||||
* @param boolean $bDisplayLimitedAccessItems
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetDisplayLimitedAccessItems($bDisplayLimitedAccessItems)
|
||||
{
|
||||
$this->bDisplayLimitedAccessItems = $bDisplayLimitedAccessItems;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns IDs of the linked items with a limited access (not visible or not editable)
|
||||
*
|
||||
|
||||
@@ -171,7 +171,14 @@ EOF
|
||||
"render": function(data, type, row)
|
||||
{
|
||||
var oCheckboxElem = $('{$sSelectionInputHtml}');
|
||||
oCheckboxElem.find(':input').attr('data-object-id', row.id).attr('data-target-object-id', row.target_id);
|
||||
if(row.limited_access)
|
||||
{
|
||||
oCheckboxElem.html('-');
|
||||
}
|
||||
else
|
||||
{
|
||||
oCheckboxElem.find(':input').attr('data-object-id', row.id).attr('data-target-object-id', row.target_id);
|
||||
}
|
||||
return oCheckboxElem.prop('outerHTML');
|
||||
}
|
||||
});
|
||||
@@ -218,7 +225,7 @@ EOF
|
||||
{
|
||||
var iDefaultOrderColumnIndex = ({$sIsEditable}) ? 1 : 0;
|
||||
|
||||
// Instanciates datatables
|
||||
// Instantiates datatables
|
||||
oTable_{$this->oField->GetGlobalId()} = $('#{$sTableId}').DataTable({
|
||||
"language": {
|
||||
"emptyTable": "{$sEmptyTableLabel}"
|
||||
@@ -234,6 +241,10 @@ EOF
|
||||
"rowId": "id",
|
||||
"data": oRawDatas_{$this->oField->GetGlobalId()},
|
||||
"rowCallback": function(oRow, oData){
|
||||
if(oData.limited_access)
|
||||
{
|
||||
$(oRow).addClass('limited_access');
|
||||
}
|
||||
// Opening in a new modal on click
|
||||
$(oRow).find('a').off('click').on('click', function(oEvent){
|
||||
// Prevents link opening.
|
||||
@@ -252,7 +263,14 @@ EOF
|
||||
});
|
||||
|
||||
// Handles items selection/deselection
|
||||
// - Directly on the table
|
||||
// - Preventing limited access rows to be selected on click
|
||||
oTable_{$this->oField->GetGlobalId()}.off('user-select').on('user-select', function(oEvent, dt, type, cell, originalEvent){
|
||||
if($(originalEvent.target).closest('tr[role="row"]').hasClass('limited_access'))
|
||||
{
|
||||
oEvent.preventDefault();
|
||||
}
|
||||
});
|
||||
// - Selecting when clicking on the rows (instead of the global checkbox)
|
||||
oTable_{$this->oField->GetGlobalId()}.off('select').on('select', function(oEvent, dt, type, indexes){
|
||||
var aData = oTable_{$this->oField->GetGlobalId()}.rows(indexes).data().toArray();
|
||||
|
||||
@@ -270,6 +288,7 @@ EOF
|
||||
// Updating remove button
|
||||
updateRemoveButtonState_{$this->oField->GetGlobalId()}();
|
||||
});
|
||||
// - Deselecting when clicking on the rows (instead of the global checkbox)
|
||||
oTable_{$this->oField->GetGlobalId()}.off('deselect').on('deselect', function(oEvent, dt, type, indexes){
|
||||
var aData = oTable_{$this->oField->GetGlobalId()}.rows(indexes).data().toArray();
|
||||
|
||||
@@ -293,11 +312,11 @@ EOF
|
||||
$('#{$this->oField->GetGlobalId()}_check_all').off('click').on('click', function(oEvent){
|
||||
if($(this).prop('checked'))
|
||||
{
|
||||
oTable_{$this->oField->GetGlobalId()}.rows().select();
|
||||
oTable_{$this->oField->GetGlobalId()}.rows(':not(.limited_access)').select();
|
||||
}
|
||||
else
|
||||
{
|
||||
oTable_{$this->oField->GetGlobalId()}.rows().deselect();
|
||||
oTable_{$this->oField->GetGlobalId()}.rows(':not(.limited_access)').deselect();
|
||||
}
|
||||
updateRemoveButtonState_{$this->oField->GetGlobalId()}();
|
||||
});
|
||||
@@ -449,7 +468,7 @@ EOF
|
||||
// Checking removed objects
|
||||
for(var i in oValues.current)
|
||||
{
|
||||
if($('#{$sTableId} tr[role="row"] input[data-object-id="'+i+'"]').length === 0)
|
||||
if($('#{$sTableId} tr[role="row"][id="'+i+'"]').length === 0)
|
||||
{
|
||||
oValues.remove[i] = {};
|
||||
}
|
||||
@@ -564,9 +583,10 @@ JS
|
||||
{
|
||||
$oRemoteItem = $oItem;
|
||||
}
|
||||
|
||||
|
||||
// Skip item if not supposed to be displayed
|
||||
if ($this->oField->IsLimitedAccessItem($oRemoteItem->GetKey()))
|
||||
$bLimitedAccessItem = $this->oField->IsLimitedAccessItem($oRemoteItem->GetKey());
|
||||
if ($bLimitedAccessItem && !$this->oField->GetDisplayLimitedAccessItems())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -575,8 +595,13 @@ JS
|
||||
'id' => ($this->oField->IsIndirect() && $oItem->IsNew()) ? -1*$oRemoteItem->GetKey() : $oItem->GetKey(),
|
||||
'target_id' => $oRemoteItem->GetKey(),
|
||||
'name' => $oItem->GetName(),
|
||||
'attributes' => array()
|
||||
);
|
||||
'attributes' => array(),
|
||||
'limited_access' => $bLimitedAccessItem,
|
||||
'disabled' => true,
|
||||
'active' => false,
|
||||
'inactive' => true,
|
||||
'not-selectable' => true,
|
||||
);
|
||||
|
||||
// Target object others attributes
|
||||
// TODO: Support for AttributeImage, AttributeBlob
|
||||
|
||||
Reference in New Issue
Block a user