|
|
|
@ -36,7 +36,7 @@ module API |
|
|
|
|
class WorkPackageRepresenter < Roar::Decorator |
|
|
|
|
include Roar::JSON::HAL |
|
|
|
|
include Roar::Hypermedia |
|
|
|
|
include API::Utilities::UrlHelper |
|
|
|
|
include API::V3::Utilities::PathHelper |
|
|
|
|
include OpenProject::TextFormatting |
|
|
|
|
|
|
|
|
|
self.as_strategy = ::API::Utilities::CamelCasingStrategy.new |
|
|
|
@ -52,14 +52,14 @@ module API |
|
|
|
|
|
|
|
|
|
link :self do |
|
|
|
|
{ |
|
|
|
|
href: "#{root_path}api/v3/work_packages/#{represented.id}", |
|
|
|
|
href: api_v3_paths.work_package(represented.id), |
|
|
|
|
title: "#{represented.subject}" |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
link :update do |
|
|
|
|
{ |
|
|
|
|
href: "#{root_path}api/v3/work_packages/#{represented.id}/form", |
|
|
|
|
href: api_v3_paths.work_package_form(represented.id), |
|
|
|
|
method: :post, |
|
|
|
|
title: "Update #{represented.subject}" |
|
|
|
|
} if current_user_allowed_to(:edit_work_packages) |
|
|
|
@ -67,7 +67,7 @@ module API |
|
|
|
|
|
|
|
|
|
link :updateImmediately do |
|
|
|
|
{ |
|
|
|
|
href: "#{root_path}api/v3/work_packages/#{represented.id}", |
|
|
|
|
href: api_v3_paths.work_package(represented.id), |
|
|
|
|
method: :patch, |
|
|
|
|
title: "Update #{represented.subject}" |
|
|
|
|
} if current_user_allowed_to(:edit_work_packages) |
|
|
|
@ -107,21 +107,21 @@ module API |
|
|
|
|
|
|
|
|
|
link :author do |
|
|
|
|
{ |
|
|
|
|
href: "#{root_path}api/v3/users/#{represented.author.id}", |
|
|
|
|
href: api_v3_paths.user(represented.author.id), |
|
|
|
|
title: "#{represented.author.name} - #{represented.author.login}" |
|
|
|
|
} unless represented.author.nil? |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
link :responsible do |
|
|
|
|
{ |
|
|
|
|
href: "#{root_path}api/v3/users/#{represented.responsible.id}", |
|
|
|
|
href: api_v3_paths.user(represented.responsible.id), |
|
|
|
|
title: "#{represented.responsible.name} - #{represented.responsible.login}" |
|
|
|
|
} unless represented.responsible.nil? |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
link :assignee do |
|
|
|
|
{ |
|
|
|
|
href: "#{root_path}api/v3/users/#{represented.assigned_to.id}", |
|
|
|
|
href: api_v3_paths.user(represented.assigned_to.id), |
|
|
|
|
title: "#{represented.assigned_to.name} - #{represented.assigned_to.login}" |
|
|
|
|
} unless represented.assigned_to.nil? |
|
|
|
|
end |
|
|
|
@ -136,14 +136,14 @@ module API |
|
|
|
|
|
|
|
|
|
link :availableWatchers do |
|
|
|
|
{ |
|
|
|
|
href: "#{root_path}api/v3/work_packages/#{represented.id}/available_watchers", |
|
|
|
|
href: api_v3_paths.available_watchers(represented.id), |
|
|
|
|
title: 'Available Watchers' |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
link :watchChanges do |
|
|
|
|
{ |
|
|
|
|
href: "#{root_path}api/v3/work_packages/#{represented.id}/watchers", |
|
|
|
|
href: api_v3_paths.work_package_watchers(represented.id), |
|
|
|
|
method: :post, |
|
|
|
|
data: { user_id: @current_user.id }, |
|
|
|
|
title: 'Watch work package' |
|
|
|
@ -154,7 +154,7 @@ module API |
|
|
|
|
|
|
|
|
|
link :unwatchChanges do |
|
|
|
|
{ |
|
|
|
|
href: "#{root_path}api/v3/work_packages/#{represented.id}/watchers/#{@current_user.id}", |
|
|
|
|
href: "#{api_v3_paths.work_package_watchers(represented.id)}/#{@current_user.id}", |
|
|
|
|
method: :delete, |
|
|
|
|
title: 'Unwatch work package' |
|
|
|
|
} if current_user_allowed_to(:view_work_packages) && |
|
|
|
@ -163,7 +163,7 @@ module API |
|
|
|
|
|
|
|
|
|
link :addWatcher do |
|
|
|
|
{ |
|
|
|
|
href: "#{root_path}api/v3/work_packages/#{represented.id}/watchers{?user_id}", |
|
|
|
|
href: "#{api_v3_paths.work_package_watchers(represented.id)}{?user_id}", |
|
|
|
|
method: :post, |
|
|
|
|
title: 'Add watcher', |
|
|
|
|
templated: true |
|
|
|
@ -172,7 +172,7 @@ module API |
|
|
|
|
|
|
|
|
|
link :addRelation do |
|
|
|
|
{ |
|
|
|
|
href: "#{root_path}api/v3/work_packages/#{represented.id}/relations", |
|
|
|
|
href: api_v3_paths.work_package_relations(represented.id), |
|
|
|
|
method: :post, |
|
|
|
|
title: 'Add relation' |
|
|
|
|
} if current_user_allowed_to(:manage_work_package_relations) |
|
|
|
@ -188,7 +188,7 @@ module API |
|
|
|
|
|
|
|
|
|
link :changeParent do |
|
|
|
|
{ |
|
|
|
|
href: "#{root_path}api/v3/work_packages/#{represented.id}", |
|
|
|
|
href: api_v3_paths.work_package(represented.id), |
|
|
|
|
method: :patch, |
|
|
|
|
title: "Change parent of #{represented.subject}" |
|
|
|
|
} if current_user_allowed_to(:manage_subtasks) |
|
|
|
@ -196,7 +196,7 @@ module API |
|
|
|
|
|
|
|
|
|
link :addComment do |
|
|
|
|
{ |
|
|
|
|
href: "#{root_path}api/v3/work_packages/#{represented.id}/activities", |
|
|
|
|
href: api_v3_paths.work_package_activities(represented.id), |
|
|
|
|
method: :post, |
|
|
|
|
title: 'Add comment' |
|
|
|
|
} if current_user_allowed_to(:add_work_package_notes) |
|
|
|
@ -204,7 +204,7 @@ module API |
|
|
|
|
|
|
|
|
|
link :parent do |
|
|
|
|
{ |
|
|
|
|
href: "#{root_path}api/v3/work_packages/#{represented.parent.id}", |
|
|
|
|
href: api_v3_paths.work_package(represented.parent.id), |
|
|
|
|
title: represented.parent.subject |
|
|
|
|
} unless represented.parent.nil? || !represented.parent.visible? |
|
|
|
|
end |
|
|
|
@ -219,7 +219,7 @@ module API |
|
|
|
|
|
|
|
|
|
link :version do |
|
|
|
|
{ |
|
|
|
|
href: version_path(represented.fixed_version), |
|
|
|
|
href: api_v3_paths.versions(represented.fixed_version), |
|
|
|
|
type: 'text/html', |
|
|
|
|
title: "#{represented.fixed_version.to_s_for_project(represented.project)}" |
|
|
|
|
} if represented.fixed_version && @current_user.allowed_to?({ controller: 'versions', action: 'show' }, represented.fixed_version.project, global: false) |
|
|
|
|