Merge pull request #2556 from opf/feature/cleanup_work_package_representation

17753 Cleanup work package representation
pull/2614/head
Alex Coles 10 years ago
commit bacc4d6343
  1. 2
      frontend/app/services/overview-tab-inplace-editor-config.js
  2. 3
      frontend/app/work_packages/controllers/details-tab-overview-controller.js
  3. 2
      frontend/app/work_packages/services/index.js
  4. 31
      frontend/tests/integration/mocks/work-package.json
  5. 58
      frontend/tests/integration/mocks/work-packages/819.json
  6. 2
      frontend/tests/integration/mocks/work-packages/819_form.json
  7. 31
      frontend/tests/integration/mocks/work-packages/819_patch.json
  8. 31
      frontend/tests/integration/mocks/work-packages/820.json
  9. 2
      frontend/tests/integration/mocks/work-packages/820_form.json
  10. 31
      frontend/tests/integration/mocks/work-packages/821.json
  11. 2
      frontend/tests/integration/mocks/work-packages/821_form.json
  12. 31
      frontend/tests/integration/mocks/work-packages/822.json
  13. 2
      frontend/tests/integration/work-package-details-spec.js
  14. 2
      frontend/tests/unit/tests/work_packages/controllers/details-tab-overview-controller-test.js
  15. 17
      lib/api/v3/work_packages/work_package_representer.rb
  16. 24
      spec/lib/api/v3/work_packages/work_package_representer_spec.rb

@ -91,7 +91,7 @@ module.exports = function() {
placeholder: '-',
attributeTitle: I18n.t('js.work_packages.properties.status')
},
versionName: {
version: {
type: 'select2',
attribute: 'version.name',
embedded: true,

@ -60,6 +60,7 @@ module.exports = function($scope,
function getPropertyValue(property, format) {
switch(format) {
case STATUS_TYPE:
case VERSION_TYPE:
case USER_TYPE:
case CATEGORY_TYPE:
case PRIORITY_TYPE:
@ -198,6 +199,8 @@ module.exports = function($scope,
switch(property) {
case 'status':
return STATUS_TYPE;
case 'version':
return VERSION_TYPE;
case 'category':
return CATEGORY_TYPE;
case 'priority':

@ -36,7 +36,7 @@ angular.module('openproject.workPackages.services')
.constant('WORK_PACKAGE_ATTRIBUTES', [
{
groupName: 'details',
attributes: ['status', 'percentageDone', 'date', 'priority', 'versionName', 'category']
attributes: ['status', 'percentageDone', 'date', 'priority', 'version', 'category']
},
{
groupName: 'people',

@ -71,6 +71,10 @@
"href": "/api/v3/work_packages/819/activities",
"method": "post",
"title": "Add comment"
},
"project": {
"href": "/api/v3/projects/2",
"title": "Seeded Project"
}
},
"id": 819,
@ -89,10 +93,6 @@
"value": null
},
"percentageDone": 0,
"versionId": null,
"versionName": null,
"projectId": 2,
"projectName": "Seeded Project",
"createdAt": "2014-03-10T16:20:23Z",
"updatedAt": "2014-03-10T16:20:23Z",
"customProperties": [
@ -195,6 +195,29 @@
"createdAt": "2014-03-10T16:20:23Z"
}
],
"project": {
"_type": "Project",
"_links": {
"self": {
"href": "/api/v3/projects/2",
"title": "Seeded Project"
},
"categories": {
"href": "/api/v3/projects/2/categories"
},
"versions": {
"href": "/api/v3/projects/2/versions"
}
},
"id": 1,
"identifier": "seeded-project",
"name": "Seeded Project",
"description": "",
"homepage": "",
"createdAt": "2013-04-30T15:02:51+00:00",
"updatedAt": "2013-04-30T16:28:51+00:00",
"type": null
},
"watchers": [
{
"_type": "User",

@ -89,6 +89,10 @@
"version": {
"href": "/api/v3/versions/1",
"title": "alpha"
},
"project": {
"href": "/api/v3/projects/1",
"title": "Seeded Project"
}
},
"id": 819,
@ -106,10 +110,6 @@
"estimatedTime": "PT0S",
"spentTime": "PT0S",
"percentageDone": 0,
"versionId": 1,
"versionName": "alpha",
"projectId": 1,
"projectName": "Seeded Project",
"parentId": 54,
"createdAt": "2014-11-05T15:56:53Z",
"updatedAt": "2014-11-21T08:48:57Z",
@ -131,6 +131,33 @@
}
],
"_embedded": {
"version":{
"_type":"Version",
"_links":{
"self":{
"href":"/api/v3/versions/2",
"title":"v2"
},
"definingProject":{
"href":"/api/v3/projects/1",
"title":"Seeded Project"
},
"availableInProjects":{
"href":"/api/v3/versions/2/projects"
}
},
"id":2,
"name":"v2",
"description":{
"format":"plain",
"raw":""
},
"startDate":"2015-02-02",
"endDate":null,
"status":"open",
"createdAt":"2015-02-18T14:53:28+00:00",
"updatedAt":"2015-02-18T14:53:28+00:00"
},
"status": {
"name": "specified",
"isClosed": false
@ -2188,6 +2215,29 @@
"createdAt": "01/21/2015/ 09:30 AM",
"updatedAt": "01/21/2015/ 09:30 AM"
},
"project": {
"_type": "Project",
"_links": {
"self": {
"href": "/api/v3/projects/1",
"title": "No Plugins Project"
},
"categories": {
"href": "/api/v3/projects/1/categories"
},
"versions": {
"href": "/api/v3/projects/1/versions"
}
},
"id": 1,
"identifier": "seeded-project",
"name": "Seeded Project",
"description": "",
"homepage": "",
"createdAt": "2014-04-30T13:28:51+00:00",
"updatedAt": "2014-04-30T13:28:51+00:00",
"type": null
},
"watchers": [],
"attachments": [],
"relations": []

@ -39,10 +39,8 @@
"raw": "#820\n2"
},
"parentId": 54,
"projectId": 1,
"startDate": "2014-10-23T00:00:00+00:00",
"dueDate": "2014-12-27T00:00:00+00:00",
"versionId": null,
"createdAt": "2014-11-05T15:56:53Z",
"updatedAt": "2014-11-21T08:48:57Z"
},

@ -89,6 +89,10 @@
"href": "/work_packages/819/time_entries",
"type": "text/html",
"title": "Time entries"
},
"project": {
"href": "/api/v3/projects/1",
"title": "Seeded Project"
}
},
"id": 819,
@ -108,10 +112,6 @@
"estimatedTime": "PT0S",
"spentTime": "PT0S",
"percentageDone": 0,
"versionId": null,
"versionName": null,
"projectId": 1,
"projectName": "Seeded Project",
"parentId": 54,
"createdAt": "2014-11-05T15:56:53Z",
"updatedAt": "2014-11-21T08:48:57Z",
@ -2153,6 +2153,29 @@
"createdAt": "2014-11-21T08:48:57Z"
}
],
"project": {
"_type": "Project",
"_links": {
"self": {
"href": "/api/v3/projects/1",
"title": "No Plugins Project"
},
"categories": {
"href": "/api/v3/projects/1/categories"
},
"versions": {
"href": "/api/v3/projects/1/versions"
}
},
"id": 1,
"identifier": "seeded-project",
"name": "Seeded Project",
"description": "",
"homepage": "",
"createdAt": "2014-04-30T13:28:51+00:00",
"updatedAt": "2014-04-30T13:28:51+00:00",
"type": null
},
"watchers": [],
"attachments": [],
"relations": []

@ -80,6 +80,10 @@
"href": "/work_packages/820/time_entries",
"type": "text/html",
"title": "Time entries"
},
"project": {
"href": "/api/v3/projects/1",
"title": "Seeded Project"
}
},
"id": 820,
@ -97,10 +101,6 @@
"estimatedTime": "PT0S",
"spentTime": "PT0S",
"percentageDone": 0,
"versionId": null,
"versionName": null,
"projectId": 1,
"projectName": "Seeded Project",
"parentId": 54,
"createdAt": "2014-11-05T15:56:53Z",
"updatedAt": "2014-11-21T08:48:57Z",
@ -2176,6 +2176,29 @@
"createdAt": "01/21/2015/ 09:30 AM",
"updatedAt": "01/21/2015/ 09:30 AM"
},
"project": {
"_type": "Project",
"_links": {
"self": {
"href": "/api/v3/projects/1",
"title": "No Plugins Project"
},
"categories": {
"href": "/api/v3/projects/1/categories"
},
"versions": {
"href": "/api/v3/projects/1/versions"
}
},
"id": 1,
"identifier": "seeded-project",
"name": "Seeded Project",
"description": "",
"homepage": "",
"createdAt": "2014-04-30T13:28:51+00:00",
"updatedAt": "2014-04-30T13:28:51+00:00",
"type": null
},
"watchers": [],
"attachments": [],
"relations": []

@ -39,10 +39,8 @@
"raw": "#54\n2"
},
"parentId": 54,
"projectId": 1,
"startDate": "2014-10-23T00:00:00+00:00",
"dueDate": "2014-12-27T00:00:00+00:00",
"versionId": null,
"createdAt": "2014-11-05T15:56:53Z",
"updatedAt": "2014-11-21T08:48:57Z"
},

@ -85,6 +85,10 @@
"href": "/work_packages/821/time_entries",
"type": "text/html",
"title": "Time entries"
},
"project": {
"href": "/api/v3/projects/1",
"title": "Seeded Project"
}
},
"id": 821,
@ -101,10 +105,6 @@
"estimatedTime": "PT0S",
"spentTime": "PT0S",
"percentageDone": 0,
"versionId": null,
"versionName": null,
"projectId": 1,
"projectName": "Seeded Project",
"parentId": 54,
"createdAt": "2014-11-05T15:56:53Z",
"updatedAt": "2014-11-21T08:48:57Z",
@ -2180,6 +2180,29 @@
"createdAt": "01/21/2015/ 09:30 AM",
"updatedAt": "01/21/2015/ 09:30 AM"
},
"project": {
"_type": "Project",
"_links": {
"self": {
"href": "/api/v3/projects/1",
"title": "No Plugins Project"
},
"categories": {
"href": "/api/v3/projects/1/categories"
},
"versions": {
"href": "/api/v3/projects/1/versions"
}
},
"id": 1,
"identifier": "seeded-project",
"name": "Seeded Project",
"description": "",
"homepage": "",
"createdAt": "2014-04-30T13:28:51+00:00",
"updatedAt": "2014-04-30T13:28:51+00:00",
"type": null
},
"watchers": [],
"attachments": [],
"relations": []

@ -39,10 +39,8 @@
"raw": "#54\n2"
},
"parentId": 54,
"projectId": 1,
"startDate": "2014-10-23T00:00:00+00:00",
"dueDate": "2014-12-27T00:00:00+00:00",
"versionId": null,
"createdAt": "2014-11-05T15:56:53Z",
"updatedAt": "2014-11-21T08:48:57Z"
},

@ -93,6 +93,10 @@
"href": "/work_packages/822/time_entries",
"type": "text/html",
"title": "Time entries"
},
"project": {
"href": "/api/v3/projects/1",
"title": "Seeded Project"
}
},
"id": 822,
@ -107,10 +111,6 @@
"estimatedTime": "PT0S",
"spentTime": "PT12H",
"percentageDone": 0,
"versionId": 1,
"versionName": "alpha",
"projectId": 1,
"projectName": "Seeded Project",
"parentId": 54,
"createdAt": "2014-11-05T15:56:53Z",
"updatedAt": "2014-12-04T09:48:50Z",
@ -2671,6 +2671,29 @@
"createdAt": "01/21/2015/ 09:30 AM",
"updatedAt": "01/21/2015/ 09:30 AM"
},
"project": {
"_type": "Project",
"_links": {
"self": {
"href": "/api/v3/projects/1",
"title": "No Plugins Project"
},
"categories": {
"href": "/api/v3/projects/1/categories"
},
"versions": {
"href": "/api/v3/projects/1/versions"
}
},
"id": 1,
"identifier": "seeded-project",
"name": "Seeded Project",
"description": "",
"homepage": "",
"createdAt": "2014-04-30T13:28:51+00:00",
"updatedAt": "2014-04-30T13:28:51+00:00",
"type": null
},
"watchers": [],
"attachments": [],
"relations": []

@ -142,7 +142,7 @@ describe('OpenProject', function() {
});
describe('description', function() {
var descriptionEditor = $('.single-attribute .inplace-editor');
var descriptionEditor = $('.inplace-editor.attribute-description');
beforeEach(function() {
loadPane(819);

@ -31,7 +31,7 @@
describe('DetailsTabOverviewController', function() {
var DEFAULT_WORK_PACKAGE_PROPERTIES = ['status', 'assignee', 'responsible',
'date', 'percentageDone', 'priority',
'estimatedTime', 'versionName', 'spentTime'];
'estimatedTime', 'version', 'spentTime'];
var scope, ctrl;
var buildController;

@ -34,7 +34,6 @@ module API
module V3
module WorkPackages
class WorkPackageRepresenter < ::API::Decorators::Single
self_link title_getter: -> (*) { represented.subject }
link :update do
@ -181,6 +180,8 @@ module API
represented.fixed_version.to_s_for_project(represented.project)
}
linked_property :project
linked_property :priority
links :children do
@ -233,13 +234,6 @@ module API
exec_context: :decorator,
setter: -> (value, *) { self.done_ratio = value },
writeable: false
property :version_id,
getter: -> (*) { fixed_version.try(:id) },
setter: -> (value, *) { self.fixed_version_id = value },
render_nil: true
property :version_name, getter: -> (*) { fixed_version.try(:name) }, render_nil: true
property :project_id, getter: -> (*) { project.id }
property :project_name, getter: -> (*) { project.try(:name) }
property :parent_id, writeable: true
property :created_at,
exec_context: :decorator,
@ -286,6 +280,10 @@ module API
embedded: true,
exec_context: :decorator,
if: ->(*) { represented.fixed_version.present? }
property :project,
embedded: true,
class: ::Project,
decorator: ::API::V3::Projects::ProjectRepresenter
property :watchers,
embedded: true,
exec_context: :decorator,
@ -308,7 +306,8 @@ module API
end
def watchers
watchers = represented.watcher_users.order(User::USER_FORMATS_STRUCTURE[Setting.user_format])
watchers =
represented.watcher_users.order(User::USER_FORMATS_STRUCTURE[Setting.user_format])
watchers.map do |watcher|
::API::V3::Users::UserRepresenter.new(watcher,
work_package: represented,

@ -80,9 +80,6 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
it { is_expected.to have_json_path('percentageDone') }
it { is_expected.to have_json_path('projectId') }
it { is_expected.to have_json_path('projectName') }
describe 'startDate' do
it_behaves_like 'has ISO 8601 date only' do
let(:date) { work_package.start_date }
@ -130,11 +127,6 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
it { is_expected.to have_json_path('subject') }
it { is_expected.to have_json_path('type') }
describe 'version' do
it { is_expected.to have_json_path('versionId') }
it { is_expected.to have_json_path('versionName') }
end
describe 'lock version' do
it { is_expected.to have_json_path('lockVersion') }
@ -350,6 +342,22 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
end
end
describe 'project' do
let(:embedded_path) { '_embedded/project' }
let(:href_path) { '_links/project/href' }
it_behaves_like 'has a titled link' do
let(:link) { 'project' }
let(:href) { api_v3_paths.project(project.id) }
let(:title) { project.name }
end
it 'has the project embedded' do
is_expected.to be_json_eql('Project'.to_json).at_path("#{embedded_path}/_type")
is_expected.to be_json_eql(project.name.to_json).at_path("#{embedded_path}/name")
end
end
describe 'category' do
let(:embedded_path) { '_embedded/category' }
let(:href_path) { '_links/category/href' }

Loading…
Cancel
Save