mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-19 16:48:42 +02:00
Customer portal : Small update of the BrowseBrick in order to set a default filter value
SVN:trunk[4197]
This commit is contained in:
@@ -24,7 +24,6 @@ use \Symfony\Component\HttpFoundation\Request;
|
||||
use \Exception;
|
||||
use \UserRights;
|
||||
use \Dict;
|
||||
use \IssueLog;
|
||||
use \MetaModel;
|
||||
use \DBSearch;
|
||||
use \DBObjectSearch;
|
||||
@@ -56,6 +55,10 @@ class BrowseBrickController extends BrickController
|
||||
$sDataLoading = ($sDataLoading !== null) ? $sDataLoading : ( ($oRequest->query->get('sDataLoading') !== null) ? $oRequest->query->get('sDataLoading') : $oBrick->GetDataLoading() );
|
||||
// Getting search value
|
||||
$sSearchValue = $oRequest->get('sSearchValue', null);
|
||||
if ($sSearchValue !== null)
|
||||
{
|
||||
$sDataLoading = AbstractBrick::ENUM_DATA_LOADING_LAZY;
|
||||
}
|
||||
|
||||
$aData = array();
|
||||
$aLevelsProperties = array();
|
||||
@@ -65,12 +68,10 @@ class BrowseBrickController extends BrickController
|
||||
// Concistency checks
|
||||
if (!in_array($sBrowseMode, array_keys($aBrowseModes)))
|
||||
{
|
||||
IssueLog::Error(__METHOD__ . ' at line ' . __LINE__ . ' : Unknown browse mode "' . $sBrowseMode . '" for brick #' . $sBrickId . ', availables are ' . implode(' / ', array_keys($aBrowseModes)));
|
||||
$oApp->abort(500, 'Browse brick "' . $sBrickId . '" : Unknown browse mode "' . $sBrowseMode . '", availables are ' . implode(' / ', array_keys($aBrowseModes)));
|
||||
}
|
||||
if (empty($aLevelsProperties))
|
||||
{
|
||||
IssueLog::Info(__METHOD__ . ' at line ' . __LINE__ . ' : No levels to display for brick #' . $sBrickId . '.');
|
||||
$oApp->abort(500, 'Browse brick "' . $sBrickId . '" : No levels to display.');
|
||||
}
|
||||
|
||||
@@ -238,7 +239,6 @@ class BrowseBrickController extends BrickController
|
||||
|
||||
if (!$bFoundLevel)
|
||||
{
|
||||
IssueLog::Error(__METHOD__ . ' at line ' . __LINE__ . ' : Level alias "' . $sLevelAlias . '" is not defined for brick #' . $sBrickId . '.');
|
||||
$oApp->abort(500, 'Browse brick "' . $sBrickId . '" : Level alias "' . $sLevelAlias . '" is not defined for that brick.');
|
||||
}
|
||||
}
|
||||
@@ -293,6 +293,7 @@ class BrowseBrickController extends BrickController
|
||||
'sBrickId' => $sBrickId,
|
||||
'sBrowseMode' => $sBrowseMode,
|
||||
'aBrowseButtons' => $aBrowseButtons,
|
||||
'sSearchValue' => $sSearchValue,
|
||||
'sDataLoading' => $sDataLoading,
|
||||
'aItems' => json_encode($aItems),
|
||||
'iItemsCount' => count($aItems),
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
var getColumnsDefinition = function()
|
||||
{
|
||||
var aColumnsDefinition = [];
|
||||
var iPriorityCounter = 100; // This number is arbiratrory
|
||||
|
||||
for(sKey in oLevelsProperties)
|
||||
{
|
||||
@@ -41,7 +40,6 @@
|
||||
"width": "auto",
|
||||
"searchable": true,
|
||||
"sortable": (sDataLoading === '{{ constant('Combodo\\iTop\\Portal\\Brick\\AbstractBrick::ENUM_DATA_LOADING_FULL') }}'),
|
||||
"responsivePriority": iPriorityCounter,
|
||||
"title": oLevelsProperties[sKey].title,
|
||||
"defaultContent": "",
|
||||
"type": "html",
|
||||
@@ -54,14 +52,7 @@
|
||||
var drilldownActionIndex;
|
||||
var levelPrimaryAction;
|
||||
var url = '';
|
||||
var rowGlobalId = '';
|
||||
|
||||
// Preparing global row id
|
||||
for(sLevelId in row)
|
||||
{
|
||||
rowGlobalId += ((rowGlobalId !== '') ? '-' : '') + row[sLevelId].id;
|
||||
}
|
||||
rowGlobalId = levelAltId + '_' + rowGlobalId;
|
||||
// Preparing actions on the cell
|
||||
levelActions = oLevelsProperties[data.level_alias].actions;
|
||||
// - Removing explicit (not default) drilldown action as it has no prupose on that browse mode
|
||||
@@ -132,8 +123,8 @@
|
||||
// Preparing secondary actions for small screens
|
||||
if(bHasSeveralSecondaryActions)
|
||||
{
|
||||
var actionsSSTogglerElem = $('<a class="glyphicon glyphicon-menu-hamburger" data-toggle="collapse" data-target="#item-actions-menu-'+rowGlobalId+'"></a>');
|
||||
var actionsSSMenuElem = $('<div id="item-actions-menu-'+rowGlobalId+'" class="item-action-wrapper panel panel-default"></div>');
|
||||
var actionsSSTogglerElem = $('<a class="glyphicon glyphicon-menu-hamburger" data-toggle="collapse" data-target="#item-actions-menu-'+levelAltId+'"></a>');
|
||||
var actionsSSMenuElem = $('<div id="item-actions-menu-'+levelAltId+'" class="item-action-wrapper panel panel-default"></div>');
|
||||
var actionsSSMenuContainerElem = $('<div class="panel-body"></div>');
|
||||
actionsSSMenuElem.append(actionsSSMenuContainerElem);
|
||||
actionsElem.append(actionsSSTogglerElem);
|
||||
@@ -204,7 +195,6 @@
|
||||
"width": "auto",
|
||||
"searchable": true,
|
||||
"sortable": false,
|
||||
// Responsive priority is not applyed on those columns as we preserve the levels main column
|
||||
"title": oLevelsProperties[sKey].fields[i].label,
|
||||
"defaultContent": "",
|
||||
"type": "html",
|
||||
@@ -212,8 +202,6 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
iPriorityCounter--;
|
||||
}
|
||||
|
||||
return aColumnsDefinition;
|
||||
@@ -275,6 +263,14 @@
|
||||
d.iCountPerPage = d.length;
|
||||
d.columns = null;
|
||||
d.orders = null;
|
||||
{% if sSearchValue is not null %}
|
||||
// Sets default filter value
|
||||
if(d.draw === 1)
|
||||
{
|
||||
$('#brick-content-table_filter input').val('{{ sSearchValue }}');
|
||||
d.search.value = $('#brick-content-table_filter input').val();
|
||||
}
|
||||
{% endif %}
|
||||
if(d.search.value)
|
||||
{
|
||||
d.sSearchValue = d.search.value;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-8 col-sm-10 col-lg-11 text-right">
|
||||
<label>Filtrer :<input type="search" class="form-control input-sm" id="brick_search_field" placeholder="" aria-controls="brick_main_table"></label>
|
||||
<label>Filtrer :<input type="search" class="form-control input-sm" id="brick_search_field" placeholder="" aria-controls="brick_main_table" value="{{ sSearchValue }}"></label>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="list-group" id="brick_content_tree" data-level-id="L">
|
||||
@@ -459,6 +459,11 @@
|
||||
hideTreeLoader();
|
||||
registerFilterListeners();
|
||||
collapseAll();
|
||||
|
||||
{% if sSearchValue is not null %}
|
||||
// Filters from default value
|
||||
$('#brick_search_field').trigger('change');
|
||||
{% endif %}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user