Move column-context-menu directive to components

pull/3982/head
Alex Dik 9 years ago
parent 718025d960
commit 64c8461b9c
  1. 2
      frontend/app/components/wp-table/directives/wp-table/wp-table.directive.html
  2. 0
      frontend/app/components/wp-table/services/column-context-menu.service.html
  3. 40
      frontend/app/components/wp-table/services/column-context-menu.service.js
  4. 15
      frontend/app/components/wp-table/services/column-context-menu.service.test.js
  5. 4
      frontend/app/work_packages/controllers/menus/column-context-menu-controller.js
  6. 13
      frontend/app/work_packages/controllers/menus/index.js

@ -24,7 +24,7 @@
<th sort-header ng-repeat="column in columns"
has-dropdown-menu
position-relative-to=".generic-table--sort-header-outer"
target="ColumnContextMenu"
target="columnContextMenu"
locals="columns, column"
locale="column.custom_field && columns.custom_field.name_locale || I18n.locale"
header-name="column.name"

@ -0,0 +1,40 @@
// -- copyright
// OpenProject is a project management system.
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See doc/COPYRIGHT.rdoc for more details.
// ++
angular
.module('openproject.workPackages')
.factory('columnContextMenu', columnContextMenu);
function columnContextMenu(ngContextMenu) {
return ngContextMenu({
controller: 'ColumnContextMenuController',
controllerAs: 'contextMenu',
templateUrl: '/components/wp-table/services/column-context-menu.service.html',
container: '.work-packages--list-table-area'
});
}

@ -1,4 +1,4 @@
//-- copyright
// -- copyright
// OpenProject is a project management system.
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
//
@ -24,15 +24,13 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See doc/COPYRIGHT.rdoc for more details.
//++
/*jshint expr: true*/
// ++
describe('columnContextMenu', function() {
var container, contextMenu, $rootScope, scope, stateParams, ngContextMenu;
stateParams = {};
beforeEach(module('ng-context-menu',
beforeEach(angular.mock.module('ng-context-menu',
'openproject.workPackages',
'openproject.workPackages.controllers',
'openproject.models',
@ -41,7 +39,7 @@ describe('columnContextMenu', function() {
'openproject.services',
'openproject.templates'));
beforeEach(module('openproject.templates', function($provide) {
beforeEach(angular.mock.module('openproject.templates', function($provide) {
var configurationService = {};
configurationService.isTimezoneSet = sinon.stub().returns(false);
@ -60,7 +58,7 @@ describe('columnContextMenu', function() {
$rootScope = _$rootScope_;
ngContextMenu = _ngContextMenu_;
var template = $templateCache.get('/templates/work_packages/menus/column_context_menu.html');
var template = $templateCache.get('/components/wp-table/services/column-context-menu.service.html');
$templateCache.put('column_context_menu.html', [200, template, {}]);
contextMenu = ngContextMenu({
@ -74,12 +72,11 @@ describe('columnContextMenu', function() {
}));
describe('when the context menu handler of a column is clicked', function() {
var I18n, QueryService;
var QueryService;
var column = { name: 'status', title: 'Status' },
anotherColumn = { name: 'subject', title: 'Subject' },
columns = [column, anotherColumn],
query = Factory.build('Query', { columns: columns });
var directiveScope;
beforeEach(inject(function(_QueryService_) {
QueryService = _QueryService_;

@ -26,7 +26,7 @@
// See doc/COPYRIGHT.rdoc for more details.
//++
module.exports = function($scope, ColumnContextMenu, I18n, QueryService, WorkPackagesTableHelper, WorkPackagesTableService, columnsModal) {
module.exports = function($scope, columnContextMenu, I18n, QueryService, WorkPackagesTableHelper, WorkPackagesTableService, columnsModal) {
$scope.I18n = I18n;
@ -64,7 +64,7 @@ module.exports = function($scope, ColumnContextMenu, I18n, QueryService, WorkPac
};
$scope.hideColumn = function(columnName) {
ColumnContextMenu.close();
columnContextMenu.close();
QueryService.hideColumns(new Array(columnName));
QueryService.getQuery().dirty = true;
};

@ -28,20 +28,9 @@
angular.module('openproject.workPackages')
.factory('ColumnContextMenu', [
'ngContextMenu',
function(ngContextMenu) {
return ngContextMenu({
controller: 'ColumnContextMenuController',
controllerAs: 'contextMenu',
templateUrl: '/templates/work_packages/menus/column_context_menu.html',
container: '.work-packages--list-table-area'
});
}
])
.controller('ColumnContextMenuController', [
'$scope',
'ColumnContextMenu',
'columnContextMenu',
'I18n',
'QueryService',
'WorkPackagesTableHelper',

Loading…
Cancel
Save