瀏覽代碼

Customer portal : Small update of the BrowseBrick in order to set a default filter value

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4197 a333f486-631f-4898-b8df-5754b55c2be0
glajarige 9 年之前
父節點
當前提交
d404517944

+ 5 - 4
datamodels/2.x/itop-portal-base/portal/src/controllers/browsebrickcontroller.class.inc.php

@@ -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),

+ 10 - 14
datamodels/2.x/itop-portal-base/portal/src/views/bricks/browse/mode_list.html.twig

@@ -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;

+ 6 - 1
datamodels/2.x/itop-portal-base/portal/src/views/bricks/browse/mode_tree.html.twig

@@ -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 %}