parent
1b00a67988
commit
eb3d5f50eb
@ -1,5 +1,4 @@ |
|||||||
<div class="work-packages--filters-optional-container" ng-show="wpFilters.visible"> |
<div class="work-packages--filters-optional-container" ng-show="wpFilters.visible"> |
||||||
<div id="query_form_content" class="hide-when-print"> |
<div id="query_form_content" class="hide-when-print"> |
||||||
<query-filters></query-filters> |
|
||||||
</div> |
</div> |
||||||
</div> |
</div> |
||||||
|
@ -1,9 +1,9 @@ |
|||||||
<button id="{{ ::vm.buttonId }}" |
<button class="button {{ buttonClass }}" |
||||||
class="button {{ ::vm.buttonClass }}" |
[ngClass]="{ '-active': isActive() }" |
||||||
title="{{ vm.label }}" |
[disabled]="disabled || (!isToggle() && isActive())" |
||||||
ng-click="vm.performAction()" |
[attr.id]="buttonId" |
||||||
ng-attr-accesskey="{{ ::vm.accessKey }}" |
[attr.title]="label" |
||||||
ng-disabled="vm.disabled || (!vm.isToggle() && vm.isActive())" |
[attr.accesskey]="accessKey" |
||||||
ng-class="{ '-active': vm.isActive() }"> |
(click)="performAction()"> |
||||||
<op-icon icon-classes="{{ ::vm.iconClass }} button--icon"></op-icon> |
<op-icon icon-classes="{{ iconClass }} button--icon"></op-icon> |
||||||
</button> |
</button> |
||||||
|
@ -1,171 +0,0 @@ |
|||||||
// -- 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.
|
|
||||||
// ++
|
|
||||||
|
|
||||||
import {WorkPackageNavigationButtonController} from './wp-buttons.module'; |
|
||||||
import {StateService} from '@uirouter/angularjs'; |
|
||||||
|
|
||||||
var expect = chai.expect; |
|
||||||
|
|
||||||
class GenericWpButtonController extends WorkPackageNavigationButtonController { |
|
||||||
|
|
||||||
public accessKey:number = 1; |
|
||||||
public activeState:string = 'some-state.show'; |
|
||||||
public buttonId:string = 'some-button-id'; |
|
||||||
public iconClass:string = 'some-icon-class'; |
|
||||||
|
|
||||||
constructor(public $state:StateService, public I18n:op.I18n) { |
|
||||||
super($state, I18n); |
|
||||||
} |
|
||||||
|
|
||||||
public performAction() { |
|
||||||
} |
|
||||||
|
|
||||||
public get labelKey():string { |
|
||||||
return 'js.some-label'; |
|
||||||
} |
|
||||||
|
|
||||||
public get textKey():string { |
|
||||||
return 'js.some-text'; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
describe('WP button directives', () => { |
|
||||||
var $state:any, I18n:any, scope:any, label:any, button:any; |
|
||||||
var controller:GenericWpButtonController; |
|
||||||
|
|
||||||
before(() => { |
|
||||||
angular.module('openproject.wpButtons').directive('genericWpButton', function ():any { |
|
||||||
return { |
|
||||||
templateUrl: '/components/wp-buttons/wp-button.template.html', |
|
||||||
|
|
||||||
scope: { |
|
||||||
disabled: '=?' |
|
||||||
}, |
|
||||||
|
|
||||||
controller: GenericWpButtonController, |
|
||||||
controllerAs: 'vm', |
|
||||||
bindToController: true |
|
||||||
} |
|
||||||
}); |
|
||||||
}); |
|
||||||
|
|
||||||
beforeEach(angular.mock.module('openproject.wpButtons', 'openproject.templates')); |
|
||||||
|
|
||||||
beforeEach(angular.mock.inject(($compile:ng.ICompileService, $rootScope:ng.IRootScopeService, |
|
||||||
_$state_:StateService, _I18n_:any) => { |
|
||||||
|
|
||||||
var html = '<generic-wp-button disabled="disabled"></generic-wp-button>'; |
|
||||||
|
|
||||||
$state = _$state_; |
|
||||||
I18n = _I18n_; |
|
||||||
|
|
||||||
scope = $rootScope.$new(); |
|
||||||
var element = angular.element(html); |
|
||||||
|
|
||||||
var stub = sinon.stub(I18n, 't'); |
|
||||||
stub.withArgs('js.some-label').returns('a wonderful title'); |
|
||||||
stub.withArgs('js.some-text').returns('text'); |
|
||||||
|
|
||||||
$compile(element)(scope); |
|
||||||
scope.$digest(); |
|
||||||
|
|
||||||
controller = element.controller('genericWpButton'); |
|
||||||
label = element.find('span'); |
|
||||||
button = element.find('button'); |
|
||||||
})); |
|
||||||
|
|
||||||
afterEach(() => { |
|
||||||
I18n.t.restore(); |
|
||||||
}); |
|
||||||
|
|
||||||
describe('when initial', () => { |
|
||||||
it('should have the performAction method', () => { |
|
||||||
expect(controller.performAction).not.to.throw(Error); |
|
||||||
}); |
|
||||||
|
|
||||||
it('should be enabled by default', () => { |
|
||||||
expect(controller.disabled).not.to.be.ok; |
|
||||||
}); |
|
||||||
|
|
||||||
it('should be disabled if disabled attribute is set', () => { |
|
||||||
scope.disabled = true; |
|
||||||
scope.$digest(); |
|
||||||
expect(controller.disabled).to.be.true; |
|
||||||
}); |
|
||||||
}); |
|
||||||
|
|
||||||
describe('when activeState is set', () => { |
|
||||||
var includes:any; |
|
||||||
|
|
||||||
beforeEach(() => { |
|
||||||
includes = sinon.stub($state, 'includes'); |
|
||||||
}); |
|
||||||
|
|
||||||
it('should be active if the current state includes the given activeState name', () => { |
|
||||||
includes.withArgs(controller.activeState).returns(true); |
|
||||||
|
|
||||||
expect(controller.isActive()).to.be.true; |
|
||||||
}); |
|
||||||
|
|
||||||
it('should not be active if the current state does not include the activeState name', () => { |
|
||||||
includes.returns(false); |
|
||||||
|
|
||||||
expect(controller.isActive()).to.be.false; |
|
||||||
}); |
|
||||||
}); |
|
||||||
|
|
||||||
describe('when active', () => { |
|
||||||
beforeEach(() => { |
|
||||||
sinon.stub(controller, 'isActive').returns(true); |
|
||||||
scope.$digest(); |
|
||||||
}); |
|
||||||
|
|
||||||
it('should not have a label with an access key', () => { |
|
||||||
expect(button.attr('accesskey')).not.to.eq(controller.activeAccessKey); |
|
||||||
}); |
|
||||||
|
|
||||||
it("should have the button class set to '-active' ", () => { |
|
||||||
expect(button.attr('class')).to.contain('-active') |
|
||||||
}); |
|
||||||
|
|
||||||
it('should have equal text values', () => { |
|
||||||
expect(button.attr('title').trim()).to.eq(controller.label); |
|
||||||
}); |
|
||||||
}); |
|
||||||
|
|
||||||
describe('when not active', () => { |
|
||||||
it('should have a label with an access key attribute', () => { |
|
||||||
expect(parseInt(button.attr('accesskey'))).to.eq(controller.activeAccessKey); |
|
||||||
}); |
|
||||||
|
|
||||||
it("should have the 'activate' prefix in the text values", () => { |
|
||||||
expect(button.attr('title').trim()).to.contain(controller.label); |
|
||||||
}); |
|
||||||
}); |
|
||||||
}); |
|
@ -1,28 +0,0 @@ |
|||||||
<div class="wp-create-button"> |
|
||||||
<button class="button -alt-highlight add-work-package" |
|
||||||
ng-if="$ctrl.projectIdentifier" |
|
||||||
has-dropdown-menu |
|
||||||
target="TypesContextMenu" |
|
||||||
ng-init="projectIdentifier = $ctrl.projectIdentifier; stateName = $ctrl.stateName" |
|
||||||
locals="projectIdentifier, stateName" |
|
||||||
ng-disabled="$ctrl.isDisabled()" |
|
||||||
aria-label="{{ ::$ctrl.text.explanation }}"> |
|
||||||
|
|
||||||
<op-icon icon-classes="button--icon icon-add"></op-icon> |
|
||||||
<span class="button--text" |
|
||||||
ng-bind="::$ctrl.text.createWithDropdown" |
|
||||||
aria-hidden="true"></span> |
|
||||||
<op-icon icon-classes="button--icon icon-small icon-pulldown"></op-icon> |
|
||||||
</button> |
|
||||||
<button class="button -alt-highlight add-work-package" |
|
||||||
ng-if="!$ctrl.projectIdentifier" |
|
||||||
ng-click="$ctrl.createWorkPackage()" |
|
||||||
ng-disabled="$ctrl.isDisabled()" |
|
||||||
aria-label="{{ ::$ctrl.text.explanation }}"> |
|
||||||
|
|
||||||
<op-icon icon-classes="button--icon icon-add"></op-icon> |
|
||||||
<span class="button--text" |
|
||||||
ng-bind="::$ctrl.text.createButton" |
|
||||||
aria-hidden="true"></span> |
|
||||||
</button> |
|
||||||
</div> |
|
@ -1,48 +0,0 @@ |
|||||||
// -- 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.
|
|
||||||
// ++
|
|
||||||
|
|
||||||
import {wpButtonsModule} from '../../../angular-modules'; |
|
||||||
|
|
||||||
function wpCreateButton() { |
|
||||||
return { |
|
||||||
restrict: 'E', |
|
||||||
templateUrl: '/components/wp-buttons/wp-create-button/wp-create-button.directive.html', |
|
||||||
|
|
||||||
scope: { |
|
||||||
projectIdentifier: '=', |
|
||||||
allowed: '=', |
|
||||||
stateName: '@' |
|
||||||
}, |
|
||||||
|
|
||||||
bindToController: true, |
|
||||||
controllerAs: '$ctrl', |
|
||||||
controller: 'WorkPackageCreateButtonController' |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
wpButtonsModule.directive('wpCreateButton', wpCreateButton); |
|
@ -0,0 +1,26 @@ |
|||||||
|
<div class="wp-create-button"> |
||||||
|
<button class="button -alt-highlight add-work-package" |
||||||
|
*ngIf="projectIdentifier" |
||||||
|
[disabled]="isDisabled()" |
||||||
|
[attr.aria-label]="text.explanation" |
||||||
|
hasDropdownMenu |
||||||
|
[hasDropdownMenu-locals]="{'projectIdentifier': projectIdentifier, 'stateName': stateName}" |
||||||
|
[hasDropdownMenu-target]="'TypesContextMenu'"> |
||||||
|
<op-icon icon-classes="button--icon icon-add"></op-icon> |
||||||
|
<span class="button--text" |
||||||
|
[textContent]="text.createWithDropdown" |
||||||
|
aria-hidden="true"></span> |
||||||
|
<op-icon icon-classes="button--icon icon-small icon-pulldown"></op-icon> |
||||||
|
</button> |
||||||
|
<button class="button -alt-highlight add-work-package" |
||||||
|
*ngIf="!projectIdentifier" |
||||||
|
(click)="createWorkPackage()" |
||||||
|
[disabled]="isDisabled()" |
||||||
|
[attr.aria-label]="text.explanation"> |
||||||
|
|
||||||
|
<op-icon icon-classes="button--icon icon-add"></op-icon> |
||||||
|
<span class="button--text" |
||||||
|
[textContent]="text.createButton" |
||||||
|
aria-hidden="true"></span> |
||||||
|
</button> |
||||||
|
</div> |
@ -1,70 +0,0 @@ |
|||||||
// -- 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.
|
|
||||||
// ++
|
|
||||||
|
|
||||||
import {WorkPackageDetailsViewButtonController} from './wp-details-view-button.directive'; |
|
||||||
import {KeepTabService} from '../../wp-panels/keep-tab/keep-tab.service'; |
|
||||||
|
|
||||||
var expect = chai.expect; |
|
||||||
|
|
||||||
describe('wpListViewButton directive', () => { |
|
||||||
var $state:any, scope:any; |
|
||||||
var keepTab:KeepTabService; |
|
||||||
var controller:WorkPackageDetailsViewButtonController; |
|
||||||
|
|
||||||
beforeEach(angular.mock.module('openproject.wpButtons', 'openproject.templates', |
|
||||||
'openproject.config')); |
|
||||||
|
|
||||||
beforeEach(angular.mock.inject(($compile:any, $rootScope:any, _$state_:any, _keepTab_:any) => { |
|
||||||
var html = '<wp-details-view-button></wp-details-view-button>'; |
|
||||||
|
|
||||||
var element = angular.element(html); |
|
||||||
|
|
||||||
$state = _$state_; |
|
||||||
keepTab = _keepTab_; |
|
||||||
|
|
||||||
scope = $rootScope.$new(); |
|
||||||
|
|
||||||
$compile(element)(scope); |
|
||||||
scope.$digest(); |
|
||||||
|
|
||||||
controller = element.controller('wpDetailsViewButton'); |
|
||||||
})); |
|
||||||
|
|
||||||
describe('when using openDetailsView()', () => { |
|
||||||
var go:any; |
|
||||||
|
|
||||||
beforeEach(() => { |
|
||||||
go = sinon.stub($state, 'go'); |
|
||||||
controller.openDetailsView(); |
|
||||||
}); |
|
||||||
|
|
||||||
it("should redirect user to 'work-packages.list'", () => { |
|
||||||
expect(go.withArgs(keepTab.currentDetailsState).calledOnce).to.be.true; |
|
||||||
}); |
|
||||||
}); |
|
||||||
}); |
|
@ -1,12 +0,0 @@ |
|||||||
<button id="{{ ::vm.buttonId }}" |
|
||||||
class="button" |
|
||||||
title="{{ vm.label }}" |
|
||||||
ng-click="vm.performAction()" |
|
||||||
ng-attr-accesskey="{{ ::vm.accessKey }}" |
|
||||||
ng-disabled="vm.disabled" |
|
||||||
ng-class="{ '-active': vm.isActive() }" |
|
||||||
aria-label="{{ vm.label }}"> |
|
||||||
<op-icon icon-classes="{{ ::vm.iconClass }} button--icon"></op-icon> |
|
||||||
<span class="button--text" ng-bind="::vm.buttonText"></span> |
|
||||||
<span class="badge -secondary" ng-if="vm.initialized">{{ vm.filterCount }}</span> |
|
||||||
</button> |
|
@ -1,116 +0,0 @@ |
|||||||
// -- 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.
|
|
||||||
// ++
|
|
||||||
|
|
||||||
import {WorkPackageFilterButtonController} from './wp-filter-button.directive'; |
|
||||||
|
|
||||||
var expect = chai.expect; |
|
||||||
|
|
||||||
describe('wpFilterButton directive', () => { |
|
||||||
var scope:ng.IScope; |
|
||||||
var element:ng.IAugmentedJQuery; |
|
||||||
var controller:WorkPackageFilterButtonController; |
|
||||||
var state:any; |
|
||||||
var subscribe:Function; |
|
||||||
var compile:any; |
|
||||||
|
|
||||||
beforeEach(angular.mock.module( |
|
||||||
'openproject.wpButtons', |
|
||||||
'openproject.templates' |
|
||||||
)); |
|
||||||
|
|
||||||
let doCompile = () => { |
|
||||||
compile(element)(scope); |
|
||||||
scope.$apply(); |
|
||||||
|
|
||||||
controller = element.controller('wpFilterButton'); |
|
||||||
} |
|
||||||
|
|
||||||
beforeEach(angular.mock.module('openproject.services', function($provide:any) { |
|
||||||
var wpTableFilters = { |
|
||||||
observeOnScope: function(scope:ng.IScope) { |
|
||||||
return { |
|
||||||
subscribe: subscribe |
|
||||||
} |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
$provide.constant('wpTableFilters', wpTableFilters); |
|
||||||
})); |
|
||||||
|
|
||||||
|
|
||||||
beforeEach(angular.mock.inject(($compile:any, $rootScope:ng.IScope) => { |
|
||||||
var html = '<wp-filter-button></wp-filter-button>'; |
|
||||||
element = angular.element(html); |
|
||||||
scope = $rootScope.$new(); |
|
||||||
compile = $compile; |
|
||||||
|
|
||||||
state = { |
|
||||||
current: ['mock', 'mock', 'mock'] |
|
||||||
} |
|
||||||
|
|
||||||
subscribe = function(callback:Function) { |
|
||||||
callback(state); |
|
||||||
} |
|
||||||
})); |
|
||||||
|
|
||||||
describe('when getting the filterCount', () => { |
|
||||||
it('returns the length of the current array', () => { |
|
||||||
doCompile(); |
|
||||||
|
|
||||||
expect(controller.filterCount).to.eq(state.current.length); |
|
||||||
}); |
|
||||||
}); |
|
||||||
|
|
||||||
describe('initialized', () => { |
|
||||||
it('is true', () => { |
|
||||||
doCompile(); |
|
||||||
|
|
||||||
expect(controller.initialized).to.eq(true); |
|
||||||
}); |
|
||||||
|
|
||||||
describe('when not having received a message yet', () => { |
|
||||||
it('is false', () => { |
|
||||||
subscribe = function(callback:Function) { |
|
||||||
//do nothing
|
|
||||||
} |
|
||||||
|
|
||||||
doCompile(); |
|
||||||
|
|
||||||
expect(controller.initialized).to.eq(false); |
|
||||||
}); |
|
||||||
}); |
|
||||||
}); |
|
||||||
|
|
||||||
describe('badge element', () => { |
|
||||||
it ('is the length of the current array', () => { |
|
||||||
doCompile(); |
|
||||||
|
|
||||||
expect(element.find('.badge').text()).to.eq(state.current.length.toString()); |
|
||||||
}); |
|
||||||
}); |
|
||||||
}); |
|
@ -0,0 +1,12 @@ |
|||||||
|
<button class="button" |
||||||
|
[attr.id]="buttonId" |
||||||
|
[attr.accesskey]="accessKey" |
||||||
|
[attr.title]="label" |
||||||
|
[attr.aria-label]="label" |
||||||
|
[disabled]="disabled" |
||||||
|
(click)="performAction()" |
||||||
|
[ngClass]="{ '-active': isActive() }"> |
||||||
|
<op-icon icon-classes="{{ iconClass }} button--icon"></op-icon> |
||||||
|
<span class="button--text" [textContent]="buttonText"></span> |
||||||
|
<span class="badge -secondary" *ngIf="initialized" [textContent]="filterCount"></span> |
||||||
|
</button> |
@ -1,84 +0,0 @@ |
|||||||
// -- 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.
|
|
||||||
// ++
|
|
||||||
|
|
||||||
import {WorkPackageViewButtonController} from './wp-view-button.directive'; |
|
||||||
import {StateService} from '@uirouter/angularjs'; |
|
||||||
|
|
||||||
var expect = chai.expect; |
|
||||||
|
|
||||||
describe('wpViewButton directive', () => { |
|
||||||
var $state:any, scope:any; |
|
||||||
var controller:WorkPackageViewButtonController; |
|
||||||
|
|
||||||
beforeEach(angular.mock.module( |
|
||||||
'openproject.wpButtons', 'openproject.templates', 'openproject.config')); |
|
||||||
|
|
||||||
beforeEach(angular.mock.inject(($compile:ng.ICompileService, $rootScope:ng.IRootScopeService, |
|
||||||
_$state_:StateService) => { |
|
||||||
|
|
||||||
var html = '<wp-view-button next-wp-func-="nextWp"' + |
|
||||||
' work-package-id="workPackageId"></wp-view-button>'; |
|
||||||
|
|
||||||
var element = angular.element(html); |
|
||||||
|
|
||||||
$state = _$state_; |
|
||||||
|
|
||||||
scope = $rootScope.$new(); |
|
||||||
|
|
||||||
$compile(element)(scope); |
|
||||||
scope.$digest(); |
|
||||||
|
|
||||||
controller = element.controller('wpViewButton'); |
|
||||||
})); |
|
||||||
|
|
||||||
describe('openWorkPackageShowView()', () => { |
|
||||||
var sGo:any, sIs:any; |
|
||||||
beforeEach(() => { |
|
||||||
sGo = sinon.stub($state, 'go'); |
|
||||||
sIs = sinon.stub($state, 'is'); |
|
||||||
}); |
|
||||||
|
|
||||||
it('should redirect to work-packages.show by default', () => { |
|
||||||
scope.workPackageId = 123; |
|
||||||
scope.$digest(); |
|
||||||
|
|
||||||
controller.openWorkPackageShowView(); |
|
||||||
|
|
||||||
expect(sGo.calledWith('work-packages.show.activity')).to.be.true; |
|
||||||
}); |
|
||||||
|
|
||||||
it('should redirect to show create when in list create', () => { |
|
||||||
sIs.withArgs('work-packages.list.new').returns(true); |
|
||||||
$state.params.type = 'something'; |
|
||||||
|
|
||||||
controller.openWorkPackageShowView(); |
|
||||||
|
|
||||||
expect(sGo.calledWith('work-packages.new', $state.params)).to.be.true; |
|
||||||
}); |
|
||||||
}); |
|
||||||
}); |
|
@ -1,90 +0,0 @@ |
|||||||
// -- 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.
|
|
||||||
// ++
|
|
||||||
|
|
||||||
import {wpButtonsModule} from '../../../angular-modules'; |
|
||||||
import {WorkPackageNavigationButtonController, wpButtonDirective} from '../wp-buttons.module'; |
|
||||||
import {KeepTabService} from '../../wp-panels/keep-tab/keep-tab.service'; |
|
||||||
import {States} from '../../states.service'; |
|
||||||
import {WorkPackageTableFocusService} from 'core-components/wp-fast-table/state/wp-table-focus.service'; |
|
||||||
import {StateService} from '@uirouter/angularjs'; |
|
||||||
|
|
||||||
export class WorkPackageViewButtonController extends WorkPackageNavigationButtonController { |
|
||||||
public workPackageId:number; |
|
||||||
|
|
||||||
public accessKey:number = 9; |
|
||||||
public activeState:string = 'work-packages.show'; |
|
||||||
public buttonId:string = 'work-packages-show-view-button'; |
|
||||||
public iconClass:string = 'icon-view-fullscreen'; |
|
||||||
|
|
||||||
constructor( |
|
||||||
public $state:StateService, |
|
||||||
public states:States, |
|
||||||
public I18n:op.I18n, |
|
||||||
public wpTableFocus:WorkPackageTableFocusService, |
|
||||||
public keepTab:KeepTabService) { |
|
||||||
'ngInject'; |
|
||||||
|
|
||||||
super($state, I18n); |
|
||||||
} |
|
||||||
|
|
||||||
public get labelKey():string { |
|
||||||
return 'js.button_show_view'; |
|
||||||
} |
|
||||||
|
|
||||||
public performAction() { |
|
||||||
this.openWorkPackageShowView(); |
|
||||||
} |
|
||||||
|
|
||||||
public openWorkPackageShowView() { |
|
||||||
let args:any = ['work-packages.new', this.$state.params]; |
|
||||||
let id = this.$state.params['workPackageId'] || this.workPackageId || this.wpTableFocus.focusedWorkPackage; |
|
||||||
|
|
||||||
if (!this.$state.is('work-packages.list.new')) { |
|
||||||
let params = { |
|
||||||
workPackageId: id |
|
||||||
}; |
|
||||||
args = [this.keepTab.currentShowState, params]; |
|
||||||
|
|
||||||
angular.extend(params, this.$state.params); |
|
||||||
} |
|
||||||
|
|
||||||
this.$state.go.apply(this.$state, args); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
function wpViewButton():ng.IDirective { |
|
||||||
return wpButtonDirective({ |
|
||||||
scope: { |
|
||||||
workPackageId: '=?', |
|
||||||
}, |
|
||||||
|
|
||||||
controller: WorkPackageViewButtonController, |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
wpButtonsModule.directive('wpViewButton', wpViewButton); |
|
@ -1,17 +0,0 @@ |
|||||||
<div class="title-container"> |
|
||||||
<div class="text"> |
|
||||||
<h2> |
|
||||||
<span has-dropdown-menu |
|
||||||
target="wpQuerySelectService" |
|
||||||
collision-container="#content" |
|
||||||
locals="selectedTitle"> |
|
||||||
<accessible-by-keyboard |
|
||||||
link-class="wp-table--query-menu-link" |
|
||||||
link-title="{{ I18n.t('js.toolbar.search_query_title') }}" > |
|
||||||
<op-icon icon-classes="icon-pulldown icon-button icon-small hide-when-print"></op-icon> |
|
||||||
{{ selectedTitle | characters:50 }} |
|
||||||
</accessible-by-keyboard> |
|
||||||
</span> |
|
||||||
</h2> |
|
||||||
</div> |
|
||||||
</div> |
|
Loading…
Reference in new issue