mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-01 14:38:47 +02:00
N°1320: Add option to show/hide linkedsets out of user's scopes in portal
This commit is contained in:
@@ -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