Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #10271: When we filter directive by tags, and update a directive, the tree is refreshed without taking into account the filter #1537

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ class RestCompletion(
toJsonError(None, e.messageChain)("quicksearch", false)

case Full(results) =>
logger.info(results)
toJsonResponse(None, results.map(("value",_)))("completeTags", false)
}

Expand All @@ -98,7 +97,6 @@ class RestCompletion(
toJsonError(None, e.messageChain)("quicksearch", false)

case Full(results) =>
logger.info(results)
toJsonResponse(None, results.map(("value",_)))("completeTags", false)
}

Expand All @@ -116,7 +114,6 @@ class RestCompletion(
toJsonError(None, e.messageChain)("quicksearch", false)

case Full(results) =>
logger.warn(results)
toJsonResponse(None, results.map(("value",_)))("completeTags", false)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ class DirectiveManagement extends DispatchSnippet with Loggable {
case Left(dir) => // ok, we've received a directive, show it
updateDirectiveLibrary(workflowEnabled) &
updateDirectiveForm(workflowEnabled)(Left(dir),None) &
After(0,JsRaw("""searchTree('#treeSearch', '#activeTechniquesTree');"""))
After(0,JsRaw("""applyFilter('directiveFilter');"""))

case Right(changeRequestId) => // oh, we have a change request, go to it
JsInitContextLinkUtil.redirectToChangeRequestLink(changeRequestId)
Expand Down
27 changes: 17 additions & 10 deletions rudder-web/src/main/webapp/javascript/rudder/angular/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ app.controller('filterTagCtrl', function ($scope, $http, $location, $timeout, $r
// Should be changed using ng-init
var directiveFilter = true;

function search() {
$scope.search = function () {
if (directiveFilter) {
$scope.searchTree(directiveTreeId);
$timeout(function() {
Expand All @@ -76,7 +76,7 @@ app.controller('filterTagCtrl', function ($scope, $http, $location, $timeout, $r
$scope.searchStr = "";
if (directiveFilter) {
clearSearchFieldTree('#activeTechniquesTree');
search();
$scope.search();
} else {
$scope.filterGlobal('');
}
Expand Down Expand Up @@ -123,7 +123,7 @@ app.controller('filterTagCtrl', function ($scope, $http, $location, $timeout, $r
if(isNewTag){
$scope.tags.push(newTag);
$scope.$broadcast('angucomplete-alt:clearInput');
search();
$scope.search();
$scope.resetNewTag();
}
}
Expand All @@ -135,12 +135,13 @@ app.controller('filterTagCtrl', function ($scope, $http, $location, $timeout, $r
$scope.removeTag = function(index){
var tag = $scope.tags[index];
$scope.tags.splice(index, 1);
search();
$scope.search();
}

$scope.registerScope = function(scope){
$scope.tagScopes.push(scope)
scope.$emit("registerScope", $rootScope)
scope.$emit("updateFilter",{ "tags" : $scope.tags, "mode" : $scope.only})
}

$scope.updateFilter = function(){
Expand All @@ -151,7 +152,7 @@ app.controller('filterTagCtrl', function ($scope, $http, $location, $timeout, $r

$scope.clearAllTags = function(){
$scope.tags = [];
search();
$scope.search();
}

$scope.toggleFilter = function(chevron, forceOpen){
Expand All @@ -175,23 +176,23 @@ app.controller('filterTagCtrl', function ($scope, $http, $location, $timeout, $r
button.toggleClass('active');
$scope.only.key = !$scope.only.key;
$scope.only.value = false;
search();
$scope.search();
}

$scope.onlyValue = function(elem){
var button = $(elem.currentTarget);
button.toggleClass('active');
$scope.only.value = !$scope.only.value;
$scope.only.key = false;
search();
$scope.search();
}

$scope.onlyAll = function(elem){
var button = $(elem.currentTarget);
button.addClass('active');
$scope.only.key = false;
$scope.only.value = false;
search();
$scope.search();
}

//Avoid compilation error using ngClass directive with '&&' condition
Expand All @@ -205,7 +206,7 @@ app.controller('filterTagCtrl', function ($scope, $http, $location, $timeout, $r

$scope.clearSearchFieldTree = function(treeId) {
$scope.searchStr = "";
$(treeId).jstree('searchtag', '', $scope.tags, $scope.only);
$scope.searchTree(treeId);
}

$scope.refuseEnter = function(event){
Expand Down Expand Up @@ -286,4 +287,10 @@ app.config(function($locationProvider) {
enabled: true,
requireBase: false
});
});
});


function applyFilter (filterId, treeId) {
var scope = angular.element($("#"+filterId)).scope();
scope.search()
}
1 change: 1 addition & 0 deletions rudder-web/src/main/webapp/javascript/rudder/rudder.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ function toggleTree(treeId, toggleButton) {
}
$(toggleButton).children().toggleClass('fa-folder-open');
}

var searchTree = function(inputId, treeId) {

if($(inputId).val() && $(inputId).val().length >= 3) {
Expand Down