OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/app/assets/javascripts/angular/layout/query-menu-items.js

48 lines
1.3 KiB

angular.module('openproject.layout')
.constant('QUERY_MENU_ITEM_TYPE', 'query-menu-item')
.factory('queryMenuItemFactory', [
'menuItemFactory',
'$stateParams',
'$animate',
'$timeout',
'QUERY_MENU_ITEM_TYPE',
function(menuItemFactory, $stateParams, $animate, $timeout, QUERY_MENU_ITEM_TYPE) {
return menuItemFactory({
itemType: QUERY_MENU_ITEM_TYPE,
container: '#main-menu-work-packages-wrapper ~ .menu-children',
linkFn: function(scope, element, attrs) {
scope.queryId = scope.objectId || attrs.objectId;
function setActiveState() {
element.toggleClass('selected', (scope.queryId || null) === $stateParams.query_id);
}
$timeout(setActiveState);
scope.$on('$stateChangeSuccess', setActiveState);
function removeItem() {
$animate.leave(element.parent(), function () {
scope.$destroy();
});
}
scope.$on('openproject.layout.removeMenuItem', function(event, itemData) {
if (itemData.itemType === QUERY_MENU_ITEM_TYPE && itemData.objectId === scope.queryId) {
removeItem();
}
});
}
});
}])
.directive('queryMenuItem', [
'queryMenuItemFactory',
function(queryMenuItemFactory) {
return {
restrict: 'A',
scope: true,
link: queryMenuItemFactory.link
};
}]);