1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00

Mitigated race condition issues with limit-panel directive by removing dependency on the state transition event

This commit is contained in:
mabashian 2018-05-14 14:28:52 -04:00
parent a74b8fa744
commit ef514fb3c0

View File

@ -1,4 +1,4 @@
export default ['$rootScope', '$transitions', function($rootScope, $transitions) {
export default [function() {
return {
restrict: 'E',
scope: {
@ -7,27 +7,28 @@ export default ['$rootScope', '$transitions', function($rootScope, $transitions)
},
link: function(scope) {
scope.maxPanels = parseInt(scope.maxPanels);
const maxPanels = parseInt(scope.maxPanels);
$transitions.onSuccess({}, function() {
let panels = angular.element('#' + scope.panelContainer).find('.Panel');
if(panels.length > scope.maxPanels) {
scope.$watch(
() => angular.element('#' + scope.panelContainer).find('.Panel').length,
() => {
const panels = angular.element('#' + scope.panelContainer).find('.Panel');
if(panels.length > maxPanels) {
// hide the excess panels
$(panels).each(function( index ) {
if(index+1 > scope.maxPanels) {
if(index+1 > maxPanels) {
$(this).addClass('Panel-hidden');
}
else {
$(this).removeClass('Panel-hidden');
}
});
}
else {
} else {
// show all the panels
$(panels).removeClass('Panel-hidden');
}
});
}
);
}
};
}];