hide parent manipulation controlls if user lacks permission

pull/2077/head
Jens Ulferts 10 years ago
parent 98a69a21a7
commit 86db27cb90
  1. 4
      app/assets/javascripts/angular/work_packages/view_models/relations-handler.js
  2. 6
      doc/apiv3-documentation.apib
  3. 8
      lib/api/v3/work_packages/work_package_representer.rb
  4. 7
      spec/lib/api/v3/work_packages/work_package_representer_spec.rb

@ -183,8 +183,8 @@ angular.module('openproject.viewModels')
handler.isSingletonRelation = true; handler.isSingletonRelation = true;
handler.relationsId = relationsId; handler.relationsId = relationsId;
handler.canAddRelation = function() { return !!this.workPackage.links.update; }; handler.canAddRelation = function() { return !!this.workPackage.links.changeParent; };
handler.canDeleteRelation = function() { return !!this.workPackage.links.update; }; handler.canDeleteRelation = function() { return !!this.workPackage.links.changeParent; };
handler.getRelatedWorkPackage = function(workPackage, relation) { return relation.fetch() }; handler.getRelatedWorkPackage = function(workPackage, relation) { return relation.fetch() };
handler.addRelation = function(scope) { handler.addRelation = function(scope) {
WorkPackageService.updateWorkPackage(this.workPackage, {parentId: scope.relationToAddId}).then(function(workPackage) { WorkPackageService.updateWorkPackage(this.workPackage, {parentId: scope.relationToAddId}).then(function(workPackage) {

@ -878,6 +878,7 @@ Updates an activity's comment and, on success, returns the updated activity.
|:------:|-------------| ---- | ----------- | -------------------- | |:------:|-------------| ---- | ----------- | -------------------- |
| self | This work package | WorkPackage | not null | READ | | self | This work package | WorkPackage | not null | READ |
| author | The person that created the work package | User | not null | READ | | author | The person that created the work package | User | not null | READ |
| changeParent | Endpoint to change the parent (only if the user has the manage_subtasks permission) | | | READ |
## Properties: ## Properties:
| Property | Description | Type | Constraints | Example | Supported operations | | Property | Description | Type | Constraints | Example | Supported operations |
@ -973,6 +974,11 @@ Updates an activity's comment and, on success, returns the updated activity.
"method": "post", "method": "post",
"title": "Add relation" "title": "Add relation"
}, },
"changeParent": {
"href": "/api/v3/work_packages/694",
"method": "patch",
"title": "Change parent of Bug in OpenProject"
},
"addComment": { "addComment": {
"href": "/api/v3/work_packages/1528/activities", "href": "/api/v3/work_packages/1528/activities",
"method": "post", "method": "post",

@ -176,6 +176,14 @@ module API
} if current_user_allowed_to(:add_work_packages, represented.model) } if current_user_allowed_to(:add_work_packages, represented.model)
end end
link :changeParent do
{
href: "#{root_path}api/v3/work_packages/#{represented.model.id}",
method: :patch,
title: "Change parent of #{represented.subject}"
} if current_user_allowed_to(:manage_subtasks, represented.model)
end
link :addComment do link :addComment do
{ {
href: "#{root_path}api/v3/work_packages/#{represented.model.id}/activities", href: "#{root_path}api/v3/work_packages/#{represented.model.id}/activities",

@ -312,6 +312,13 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
let(:permission) { :move_work_packages } let(:permission) { :move_work_packages }
end end
end end
describe 'changeParent' do
it_behaves_like 'action link' do
let(:action) { 'changeParent' }
let(:permission) { :manage_subtasks }
end
end
end end
describe '_embedded' do describe '_embedded' do

Loading…
Cancel
Save