From 72abb4524949bbe296a04614d34b545423810cbe Mon Sep 17 00:00:00 2001 From: ulferts Date: Wed, 7 Apr 2021 13:24:09 +0200 Subject: [PATCH] Fix/project status flaws (#9138) * fix documentation on project statusExplanation * correctly denote the type of the project status * don`t reloy on faulty backend type --- docs/api/apiv3/endpoints/projects.apib | 33 +++++++++++-------- .../display/display-field.initializer.ts | 2 +- .../fields/edit/edit-field.initializer.ts | 2 +- .../schemas/project_schema_representer.rb | 2 +- .../project_schema_representer_spec.rb | 2 +- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/docs/api/apiv3/endpoints/projects.apib b/docs/api/apiv3/endpoints/projects.apib index 7bcf0cbbdd..9bea240376 100644 --- a/docs/api/apiv3/endpoints/projects.apib +++ b/docs/api/apiv3/endpoints/projects.apib @@ -30,18 +30,18 @@ Depending on custom fields defined for projects, additional links might exist. ## Local Properties -| Property | Description | Type | Constraints | Supported operations | -| :---------------------:| ------------- | ---- | ----------- | -------------------- | -| id | Projects's id | Integer | x > 0 | READ/WRITE | -| identifier | | String | | READ/WRITE | -| name | | String | | READ/WRITE | -| active | Indicates whether the project is currently active or already archived | Boolean | | READ/WRITE | -| status | Denotes the status of the project, so whether the project is on track, at risk is having trouble. | String | "on track", "at risk" or "off track" | READ/WRITE | -| statusExplanation | A text detailing and explaining why the project has the reported status | Formattable | | READ/WRITE | -| public | Indicates whether the project is accessible for everybody | Boolean | | READ/WRITE | -| description | | Formattable | | READ/WRITE | -| createdAt | Time of creation | DateTime | | READ | -| updatedAt | Time of the most recent change to the project | DateTime | | READ | +| Property | Description | Type | Constraints | Supported operations | +| :---------------------:| ------------- | ---- | ----------- | -------------------- | +| id | Projects' id | Integer | x > 0 | READ/WRITE | +| identifier | | String | | READ/WRITE | +| name | | String | | READ/WRITE | +| active | Indicates whether the project is currently active or already archived | Boolean | | READ/WRITE | +| status | Denotes the status of the project, so whether the project is on track, at risk or is having trouble. | String | "on track", "at risk" or "off track" | READ/WRITE | +| statusExplanation | A text detailing and explaining why the project has the reported status | Formattable | | READ/WRITE | +| public | Indicates whether the project is accessible for everybody | Boolean | | READ/WRITE | +| description | | Formattable | | READ/WRITE | +| createdAt | Time of creation | DateTime | | READ | +| updatedAt | Time of the most recent change to the project | DateTime | | READ | Depending on custom fields defined for projects, additional properties might exist. @@ -377,7 +377,7 @@ the project scheduled for deletion, it is archived at once. "name": "Another project", "active": false, "status": "off track", - "statusSxplanation": { + "statusExplanation": { "format": "markdown", "raw": "Uh **oh**", "html": "

Uh oh

" @@ -779,6 +779,13 @@ For more details and all possible responses see the general specification of [Fo "hasDefault": true, "writable": true }, + "statusExplanation": { + "type": "Formattable", + "name": "Status explanation", + "required": false, + "hasDefault": false, + "writable": true + }, "parent": { "type": "Project", "name": "Subproject of", diff --git a/frontend/src/app/modules/fields/display/display-field.initializer.ts b/frontend/src/app/modules/fields/display/display-field.initializer.ts index ff775582a7..cbbebafdab 100644 --- a/frontend/src/app/modules/fields/display/display-field.initializer.ts +++ b/frontend/src/app/modules/fields/display/display-field.initializer.ts @@ -79,7 +79,6 @@ export function initializeCoreDisplayFields(displayFieldService:DisplayFieldServ .addFieldType(ProgressDisplayField, 'progress', ['percentageDone']) .addFieldType(LinkedWorkPackageDisplayField, 'work_package', ['WorkPackage']) .addFieldType(IdDisplayField, 'id', ['id']) - .addFieldType(ProjectStatusDisplayField, 'project_status', ['ProjectStatus']) .addFieldType(UserDisplayField, 'user', ['User']); displayFieldService @@ -87,6 +86,7 @@ export function initializeCoreDisplayFields(displayFieldService:DisplayFieldServ .addSpecificFieldType('WorkPackage', WorkPackageSpentTimeDisplayField, 'spentTime', ['spentTime']) .addSpecificFieldType('WorkPackage', CombinedDateDisplayField, 'combinedDate', ['combinedDate']) .addSpecificFieldType('TimeEntry', PlainFormattableDisplayField, 'comment', ['comment']) + .addSpecificFieldType('Project', ProjectStatusDisplayField, 'status', ['status']) .addSpecificFieldType('TimeEntry', WorkPackageDisplayField, 'work_package', ['workPackage']); }; } diff --git a/frontend/src/app/modules/fields/edit/edit-field.initializer.ts b/frontend/src/app/modules/fields/edit/edit-field.initializer.ts index 1b11070699..072d3835d1 100644 --- a/frontend/src/app/modules/fields/edit/edit-field.initializer.ts +++ b/frontend/src/app/modules/fields/edit/edit-field.initializer.ts @@ -72,13 +72,13 @@ export function initializeCoreEditFields(editFieldService:EditFieldService, sele .addFieldType(BooleanEditFieldComponent, 'boolean', ['Boolean']) .addFieldType(DateEditFieldComponent, 'date', ['Date']) .addFieldType(FormattableEditFieldComponent, 'wiki-textarea', ['Formattable']) - .addFieldType(ProjectStatusEditFieldComponent, 'project_status', ['ProjectStatus']) .addFieldType(WorkPackageCommentFieldComponent, '_comment', ['comment']); editFieldService .addSpecificFieldType('WorkPackage', CombinedDateEditFieldComponent, 'date', ['combinedDate', 'startDate', 'dueDate', 'date']) + .addSpecificFieldType('Project', ProjectStatusEditFieldComponent, 'status', ['status']) .addSpecificFieldType('TimeEntry', PlainFormattableEditFieldComponent, 'comment', ['comment']) .addSpecificFieldType('TimeEntry', TimeEntryWorkPackageEditFieldComponent, 'workPackage', ['WorkPackage']); diff --git a/lib/api/v3/projects/schemas/project_schema_representer.rb b/lib/api/v3/projects/schemas/project_schema_representer.rb index f82098f5eb..6e91df44f9 100644 --- a/lib/api/v3/projects/schemas/project_schema_representer.rb +++ b/lib/api/v3/projects/schemas/project_schema_representer.rb @@ -60,7 +60,7 @@ module API type: 'Boolean' schema :status, - type: 'ProjectStatus', + type: 'String', name_source: ->(*) { I18n.t('activerecord.attributes.projects/status.code') }, required: false, writable: ->(*) { represented.writable?(:status) } diff --git a/spec/lib/api/v3/projects/schemas/project_schema_representer_spec.rb b/spec/lib/api/v3/projects/schemas/project_schema_representer_spec.rb index a6fd962f4c..46e195f3bd 100644 --- a/spec/lib/api/v3/projects/schemas/project_schema_representer_spec.rb +++ b/spec/lib/api/v3/projects/schemas/project_schema_representer_spec.rb @@ -182,7 +182,7 @@ describe ::API::V3::Projects::Schemas::ProjectSchemaRepresenter do let(:path) { 'status' } it_behaves_like 'has basic schema properties' do - let(:type) { 'ProjectStatus' } + let(:type) { 'String' } let(:name) { I18n.t('activerecord.attributes.projects/status.code') } let(:required) { false } let(:writable) { true }