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