Remove type dropdown

pull/4401/head
Oliver Günther 9 years ago
parent fcc1f866d5
commit c612a862ff
  1. 27
      frontend/app/components/api/api-v3/hal-resources/work-package-resource.service.ts
  2. 41
      frontend/app/components/context-menus/types-drop-down-menu/types-drop-down-menu.service.js
  3. 13
      frontend/app/components/context-menus/types-drop-down-menu/types-drop-down-menu.template.html
  4. 3
      frontend/app/components/routing/wp-list/wp-list.controller.ts
  5. 3
      frontend/app/components/routing/wp-list/wp.list.html
  6. 23
      frontend/app/components/wp-buttons/wp-create-button/wp-create-button.controller.ts
  7. 7
      frontend/app/components/wp-buttons/wp-create-button/wp-create-button.directive.html
  8. 2
      frontend/app/components/wp-buttons/wp-create-button/wp-create-button.directive.ts
  9. 41
      frontend/app/components/wp-buttons/wp-inline-create-button/wp-inline-create-button.controller.ts
  10. 2
      frontend/app/components/wp-buttons/wp-inline-create-button/wp-inline-create-button.directive.html
  11. 2
      frontend/app/components/wp-buttons/wp-inline-create-button/wp-inline-create-button.directive.ts
  12. 2
      frontend/app/components/wp-table/wp-table.directive.html
  13. 1
      frontend/app/components/wp-table/wp-table.directive.ts
  14. 5
      frontend/app/typings/open-project.typings.ts

@ -41,26 +41,17 @@ export class WorkPackageResource extends HalResource {
public id;
public $pristine: { [attribute: string]: any } = {};
public static fromCreateForm(projectIdentifier?:string):ng.IPromise<WorkPackageResource> {
var deferred = $q.defer();
apiWorkPackages.emptyCreateForm(projectIdentifier)
.then(resource => {
var wp = new WorkPackageResource(resource.payload.$source, true);
public static fromCreateForm(form: op.WorkPackageForm) {
var wp = new WorkPackageResource(form.payload.$plain(), true);
// Copy resources from form response
wp.schema = resource.schema;
wp.form = $q.when(resource);
wp.id = 'new-' + Date.now();
// Copy resources from form response
wp.schema = form.schema;
wp.form = $q.when(form);
wp.id = 'new-' + Date.now();
// Set update link to form
wp.$links.update = resource.$links.self;
deferred.resolve(wp);
})
.catch(deferred.reject);
return deferred.promise;
// Set update link to form
wp.$links.update = resource.$links.self;
return wp;
}
public get isNew():boolean {

@ -1,41 +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.
// ++
angular
.module('openproject.workPackages')
.factory('typesDropDownMenu', typesDropDownMenu);
function typesDropDownMenu(ngContextMenu) {
return ngContextMenu({
templateUrl: '/components/context-menus/types-drop-down-menu/' +
'types-drop-down-menu.template.html',
container: '.wp-create-button'
});
}

@ -1,13 +0,0 @@
<div class="dropdown action-menu dropdown-relative dropdown-anchor-right dropdownToolbar"
id="tasksDropdown">
<ul class="dropdown-menu">
<li ng-repeat="type in vm.types">
<a ui-sref="{{ vm.stateName }}({ projectPath: vm.projectIdentifier, type: type.id })"
class="menu-item">
{{ type.name }}
</a>
</li>
</ul>
</div>

@ -153,9 +153,6 @@ function WorkPackagesListController($scope,
$scope.groupableColumns = WorkPackagesTableService.getGroupableColumns();
$scope.totalEntries = QueryService.getTotalEntries();
$scope.resource = json.resource;
$scope.allowedTo = {
createWorkPackage: !!json._links.create
};
// Authorisation
AuthorisationService.initModelAuth("work_package", meta._links);

@ -10,7 +10,7 @@
<ul class="toolbar-items">
<li class="toolbar-item">
<wp-create-button
allowed="allowedTo.createWorkPackage"
resource="resource"
project-identifier="projectIdentifier"
state-name="work-packages.list.new">
</wp-create-button>
@ -70,7 +70,6 @@
<div class="work-packages--list-table-area">
<wp-table ng-if="rows && columns"
project-identifier="projectIdentifier"
allowed-to="allowedTo"
columns="columns"
rows="rows"
query="query"

@ -29,31 +29,32 @@
import {wpButtonsModule} from '../../../angular-modules';
export default class WorkPackageCreateButtonController {
public projectIdentifier:string;
public text:any;
public types:any;
public projectIdentifier: string;
public text: any;
public types: any;
protected allowed:boolean = false;
protected resource;
public get inProjectContext() {
return !!this.projectIdentifier;
}
constructor(protected $state, protected I18n, protected ProjectService) {
constructor(
protected $state,
protected I18n
) {
this.text = {
button: I18n.t('js.label_work_package'),
create: I18n.t('js.label_create_work_package')
};
}
if (this.inProjectContext) {
this.ProjectService.getProject(this.projectIdentifier).then(project => {
this.types = project.embedded.types;
});
}
public get allowed() {
return this.resource && !!this.resource.$links.createWorkPackage;
}
public isDisabled() {
return !this.inProjectContext || !this.allowed || this.$state.includes('**.new') || !this.types;
return !this.allowed || this.$state.includes('**.new');
}
}

@ -1,10 +1,9 @@
<div class="wp-create-button">
<button class="button -alt-highlight add-work-package" has-dropdown-menu
target="typesDropDownMenu" locals="vm" ng-disabled="vm.isDisabled()"
aria-label="{{ ::vm.text.create }}" aria-haspopup="true">
<button class="button -alt-highlight add-work-package"
ng-disabled="vm.isDisabled()"
aria-label="{{ ::vm.text.create }}">
<i class="button--icon icon-add"></i>
<span class="button--text" ng-bind="::vm.text.button" aria-hidden="true"></span>
<i class="button--dropdown-indicator"></i>
</button>
</div>

@ -35,7 +35,7 @@ function wpCreateButton() {
scope: {
projectIdentifier: '=',
allowed: '=',
resource: '=',
stateName: '@'
},

@ -34,8 +34,10 @@ class WorkPackageInlineCreateButtonController extends WorkPackageCreateButtonCon
public rows:any[];
public hidden:boolean = false;
// Template create form
protected form: op.HalResource;
private _wp;
private availableProjects = [];
constructor(
protected $state,
@ -44,11 +46,10 @@ class WorkPackageInlineCreateButtonController extends WorkPackageCreateButtonCon
protected $element,
protected FocusHelper,
protected I18n,
protected ProjectService,
protected WorkPackageResource,
protected apiWorkPackages
) {
super($state, I18n, ProjectService);
super($state, I18n);
$rootScope.$on('workPackageSaved', (event, savedWp) => {
if (savedWp === this._wp) {
@ -61,10 +62,6 @@ class WorkPackageInlineCreateButtonController extends WorkPackageCreateButtonCon
this.show();
});
this.apiWorkPackages.availableProjects().then(resource => {
this.availableProjects = resource.elements;
});
$rootScope.$on('inlineWorkPackageCreateCancelled', (event, index, row) => {
if (row.object === this._wp) {
this.rows.splice(index, 1);
@ -74,26 +71,13 @@ class WorkPackageInlineCreateButtonController extends WorkPackageCreateButtonCon
});
}
public isDisabled() {
return !this.allowed || this.$state.includes('**.new');
}
public get projectIdentifierForCreate() {
if (this.inProjectContext) {
return this.projectIdentifier;
} else {
return this.availableProjects[0].identifier;
}
}
public addWorkPackageRow() {
this.WorkPackageResource.fromCreateForm(this.projectIdentifierForCreate).then(wp => {
this._wp = wp;
wp.inlineCreated = true;
this.getForm().then(form => {
this._wp = this.WorkPackageResource.fromCreateForm(form);
this._wp.inlineCreated = true;
this.query.applyDefaultsFromFilters(this._wp);
this.rows.push({level: 0, ancestors: [], object: wp, parent: void 0});
this.rows.push({ level: 0, ancestors: [], object: this._wp, parent: void 0 });
this.hide();
});
}
@ -105,6 +89,15 @@ class WorkPackageInlineCreateButtonController extends WorkPackageCreateButtonCon
public show() {
return this.hidden = false;
}
private getForm() {
if (this.form) {
return this.form;
}
return this.apiWorkPackages.emptyCreateForm();
}
}
wpButtonsModule.controller(

@ -1,6 +1,6 @@
<div
class="wp-inline-create-button"
ng-hide="$ctrl.hidden || $ctrl.isDisabled() || !$ctrl.canCreate">
ng-hide="$ctrl.hidden || $ctrl.isDisabled()">
<a class="wp-inline-create--add-link"
ng-click="$ctrl.addWorkPackageRow()"
ng-disabled="$ctrl.isDisabled()"

@ -34,7 +34,7 @@ function wpInlineCreateButton() {
scope: {
projectIdentifier: '=',
allowed: '=',
resource: '=',
rows: '=',
query: '='
},

@ -194,7 +194,7 @@
<td colspan="{{ numTableColumns }}">
<wp-inline-create-button
project-identifier="projectIdentifier"
allowed="allowedTo.createWorkPackage"
resource="resource"
query="query"
rows="rows"
></wp-inline-create-button>

@ -46,7 +46,6 @@ function wpTable(
templateUrl: '/components/wp-table/wp-table.directive.html',
scope: {
projectIdentifier: '=',
allowedTo: '=',
columns: '=',
rows: '=',
query: '=',

@ -208,6 +208,11 @@ declare namespace op {
schema:FieldSchema;
}
interface WorkPackageForm {
payload: op.HalResource;
schema: op.HalResource;
}
interface WorkPackage extends api.v3.WorkPackage, WorkPackageLinks {
getForm();
getSchema();

Loading…
Cancel
Save