kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
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.
48 lines
1.3 KiB
48 lines
1.3 KiB
11 years ago
|
angular.module('openproject.layout')
|
||
|
|
||
11 years ago
|
.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();
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
}])
|
||
11 years ago
|
|
||
11 years ago
|
.directive('queryMenuItem', [
|
||
11 years ago
|
'queryMenuItemFactory',
|
||
|
function(queryMenuItemFactory) {
|
||
11 years ago
|
return {
|
||
|
restrict: 'A',
|
||
11 years ago
|
scope: true,
|
||
|
link: queryMenuItemFactory.link
|
||
11 years ago
|
};
|
||
|
}]);
|