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:
parent
a74b8fa744
commit
ef514fb3c0
@ -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) {
|
||||
// hide the excess panels
|
||||
$(panels).each(function( index ) {
|
||||
if(index+1 > scope.maxPanels) {
|
||||
$(this).addClass('Panel-hidden');
|
||||
}
|
||||
else {
|
||||
$(this).removeClass('Panel-hidden');
|
||||
}
|
||||
});
|
||||
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 > maxPanels) {
|
||||
$(this).addClass('Panel-hidden');
|
||||
}
|
||||
else {
|
||||
$(this).removeClass('Panel-hidden');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// show all the panels
|
||||
$(panels).removeClass('Panel-hidden');
|
||||
}
|
||||
}
|
||||
else {
|
||||
// show all the panels
|
||||
$(panels).removeClass('Panel-hidden');
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
};
|
||||
}];
|
||||
|
Loading…
Reference in New Issue
Block a user