OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
WIP
Wieland Lindenthalaee739eed67a
diff --git a/frontend/src/app/modules/grids/widgets/project-status/project-status.component.html b/frontend/src/app/modules/grids/widgets/project-status/project-status.component.htmlindex bb842181192..e339d32ef3e 100644--- a/frontend/src/app/modules/grids/widgets/project-status/project-status.component.html+++ b/frontend/src/app/modules/grids/widgets/project-status/project-status.component.html@@ -9,16 +9,27 @@</widget-header><div class="grid--widget-content">- <ng-select [disabled]="true"- [items]="availableStatuses"- [(ngModel)]="currentStatusCode"- bindLabel="name"- bindValue="code"- class="traffic-lights">- <ng-template ng-label-tmp let-item="item">- <span class="bulb" [ngClass]="item.colorClass"></span>- <span class="status-name" [ngClass]="item.colorClass">{{item.name}}</span>- </ng-template>- </ng-select>- <div class="explanation" [innerHtml]="explanation"></div>+ <edit-form *ngIf="(project$ | async) as project" [resource]="project">+ <editable-attribute-field [resource]="project"+ fieldName="statusCode">+ </editable-attribute-field>+ <editable-attribute-field [resource]="project"+ fieldName="statusExplanation">+ </editable-attribute-field>+ </edit-form>++<!-- <ng-select [disabled]="true"-->+<!-- [items]="availableStatuses"-->+<!-- [(ngModel)]="currentStatusCode"-->+<!-- bindLabel="name"-->+<!-- bindValue="code"-->+<!-- class="traffic-lights">-->+<!-- <ng-template ng-label-tmp let-item="item">-->+<!-- <span class="bulb" [ngClass]="item.colorClass"></span>-->+<!-- <span class="status-name" [ngClass]="item.colorClass">{{item.name}}</span>-->+<!-- </ng-template>-->+<!-- </ng-select>-->+<!-- <div class="explanation" [innerHtml]="explanation"></div>-->+</div>+diff --git a/frontend/src/app/modules/grids/widgets/project-status/project-status.component.ts b/frontend/src/app/modules/grids/widgets/project-status/project-status.component.tsindex 04c07fdc49a..fa51232e7d7 100644--- a/frontend/src/app/modules/grids/widgets/project-status/project-status.component.ts+++ b/frontend/src/app/modules/grids/widgets/project-status/project-status.component.ts@@ -37,6 +37,8 @@ import {PortalCleanupService} from 'core-app/modules/fields/display/display-portimport {WorkPackageViewHighlightingService} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-highlighting.service";import {IsolatedQuerySpace} from "core-app/modules/work_packages/query-space/isolated-query-space";import {ProjectCacheService} from "core-components/projects/project-cache.service";+import {from, Observable} from "rxjs";+import {HalResourceEditingService} from "core-app/modules/fields/edit/services/hal-resource-editing.service";export const emptyPlaceholder = '-';@@ -48,89 +50,94 @@ export const emptyPlaceholder = '-';// required by the displayField service to render the fieldsPortalCleanupService,WorkPackageViewHighlightingService,- IsolatedQuerySpace+ IsolatedQuerySpace,+ HalResourceEditingService]})export class WidgetProjectStatusComponent extends AbstractWidgetComponent implements OnInit {+@ViewChild('contentContainer', { static: true }) readonly contentContainer:ElementRef;public currentStatusCode:string = 'not set';public explanation:String = '';- public availableStatuses:any[] = [- {- code: 'not set',- name: this.i18n.t('js.grid.widgets.project_status.not_set'),- colorClass: '-gray',- },- {- code: 'off track',- name: this.i18n.t('js.grid.widgets.project_status.off_track'),- colorClass: '-red',- },- {- code: 'on track',- name: this.i18n.t('js.grid.widgets.project_status.on_track'),- colorClass: '-green',- },- {- code: 'at risk',- name: this.i18n.t('js.grid.widgets.project_status.at_risk'),- colorClass: '-orange',- },- ];+ public project$:Observable<ProjectResource>;+ // public availableStatuses:any[] = [+ // {+ // code: 'not set',+ // name: this.i18n.t('js.grid.widgets.project_status.not_set'),+ // colorClass: '-gray',+ // },+ // {+ // code: 'off track',+ // name: this.i18n.t('js.grid.widgets.project_status.off_track'),+ // colorClass: '-red',+ // },+ // {+ // code: 'on track',+ // name: this.i18n.t('js.grid.widgets.project_status.on_track'),+ // colorClass: '-green',+ // },+ // {+ // code: 'at risk',+ // name: this.i18n.t('js.grid.widgets.project_status.at_risk'),+ // colorClass: '-orange',+ // },+ // ];constructor(protected readonly i18n:I18nService,protected readonly injector:Injector,protected readonly projectDm:ProjectDmService,protected readonly projectCache:ProjectCacheService,protected readonly currentProject:CurrentProjectService,- protected readonly cdr:ChangeDetectorRef) {+ protected readonly cdRef:ChangeDetectorRef) {super(i18n, injector);}ngOnInit() {- this.loadAndRender();+ // this.loadAndRender();+ this.project$ = this.projectCache.requireAndStream(this.currentProject.id!);+ this.cdRef.detectChanges();}public get isEditable() {return false;}- private loadAndRender() {- Promise.all(- [this.loadCurrentProject(),- this.loadProjectSchema()]- )- .then(([project, schema]) => {- if (project.status && project.status.code) {- this.currentStatusCode = project.status.code;- } else {- this.currentStatusCode = 'not set';- }-- if (project.status && project.status.explanation) {- this.explanation = project.status.explanation.html;- } else {- this.explanation = '';- }-- this.redraw();- });- }-- private loadCurrentProject() {- return this.projectCache.require(this.currentProject.id as string);- }+ // private loadAndRender() {+ // Promise.all(+ // [this.loadCurrentProject(),+ // this.loadProjectSchema()]+ // )+ // .then(([project, schema]) => {+ // if (project.status && project.status.code) {+ // this.currentStatusCode = project.status.code;+ // } else {+ // this.currentStatusCode = 'not set';+ // }+ //+ // if (project.status && project.status.explanation) {+ // this.explanation = project.status.explanation.html;+ // } else {+ // this.explanation = '';+ // }+ //+ // this.redraw();+ // });+ // }- public get isLoaded() {- return this.projectCache.state(this.currentProject.id as string).value;- }-- private loadProjectSchema() {- return this.projectDm.schema();- }-- private redraw() {- this.cdr.detectChanges();- }+ // private loadCurrentProject() {+ // return this.projectCache.require(this.currentProject.id as string);+ // }+ //+ // public get isLoaded() {+ // return this.projectCache.state(this.currentProject.id as string).value;+ // }+ //+ // private loadProjectSchema() {+ // return this.projectDm.schema();+ // }+ //+ // private redraw() {+ // this.cdRef.detectChanges();+ // }}diff --git a/lib/api/v3/projects/project_representer.rb b/lib/api/v3/projects/project_representer.rbindex dceb391c5d6..2ed4ce9ee12 100644--- a/lib/api/v3/projects/project_representer.rb+++ b/lib/api/v3/projects/project_representer.rb@@ -66,11 +66,11 @@ module APIcache_if: -> {current_user_allowed_to(:view_work_packages, context: represented)} do- { href: api_v3_paths.work_packages_by_project(represented.id) }+ {href: api_v3_paths.work_packages_by_project(represented.id)}endlink :categories do- { href: api_v3_paths.categories_by_project(represented.id) }+ {href: api_v3_paths.categories_by_project(represented.id)}endlink :versions,@@ -78,7 +78,7 @@ module APIcurrent_user_allowed_to(:view_work_packages, context: represented) ||current_user_allowed_to(:manage_versions, context: represented)} do- { href: api_v3_paths.versions_by_project(represented.id) }+ {href: api_v3_paths.versions_by_project(represented.id)}endlink :memberships,@@ -86,7 +86,7 @@ module APIcurrent_user_allowed_to(:view_members, context: represented)} do{- href: api_v3_paths.path_for(:memberships, filters: [{ project: { operator: "=", values: [represented.id.to_s] } }]),+ href: api_v3_paths.path_for(:memberships, filters: [{project: {operator: "=", values: [represented.id.to_s]}}]),}end@@ -95,7 +95,7 @@ module APIcurrent_user_allowed_to(:view_work_packages, context: represented) ||current_user_allowed_to(:manage_types, context: represented)} do- { href: api_v3_paths.types_by_project(represented.id) }+ {href: api_v3_paths.types_by_project(represented.id)}endlink :update,@@ -162,25 +162,32 @@ module APIdate_time_property :updated_at- property :status,+ formattable_property :status_explanation,+ getter: ->(*) {+ status = represented.status || Project::Status.new+ ::API::Decorators::Formattable.new(status.explanation,+ object: represented,+ plain: false)+ },+ setter: ->(fragment:, **) {+ represented.status ||= {}+ represented.status[:explanation] = fragment["raw"]+ }++ property :status_code,render_nil: true,- exec_context: :decorator,- getter: ->(*) {- ::API::V3::Projects::Status::ProjectStatusRepresenter.create(represented.status || Project::Status.new,- current_user: current_user)+ getter: ->(represented:, **) {+ next unless represented.status&.code++ represented.status.code.to_s.tr('_', ' ')},setter: ->(fragment:, **) {- status = fragment.with_indifferent_access.slice(:explanation)-- if fragment.key?('code')- status[:code] = if fragment['code'].nil?- nil- else- fragment['code'].strip.tr(' ', '_').underscore.to_sym- end- end-- represented.status = status+ represented.status ||= {}+ represented.status[:code] = if fragment.nil?+ nil+ else+ fragment.strip.tr(' ', '_').underscore.to_sym+ end}def _typediff --git a/lib/api/v3/projects/schemas/project_schema_representer.rb b/lib/api/v3/projects/schemas/project_schema_representer.rbindex cd94aa7df2a..dbd27ad77ca 100644--- a/lib/api/v3/projects/schemas/project_schema_representer.rb+++ b/lib/api/v3/projects/schemas/project_schema_representer.rb@@ -65,9 +65,17 @@ module APItype: 'Boolean',visibility: false- schema :status,+ schema :status_code,type: 'ProjectStatus',- visibility: false+ visibility: false,+ required: false,+ writable: ->(*) { represented.writable?(:status) }++ schema :status_explanation,+ type: 'Formattable',+ visibility: false,+ required: false,+ writable: ->(*) { represented.writable?(:status) }schema_with_allowed_link :parent,type: 'Project',diff --git a/lib/api/v3/projects/status/project_status_representer.rb b/lib/api/v3/projects/status/project_status_representer.rbdeleted file mode 100644index c34191b9c88..00000000000--- a/lib/api/v3/projects/status/project_status_representer.rb+++ /dev/null@@ -1,51 +0,0 @@-#-- encoding: UTF-8--#-- copyright-# OpenProject is a project management system.-# Copyright (C) 2012-2018 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-2017 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 docs/COPYRIGHT.rdoc for more details.-#++--require 'roar/decorator'-require 'roar/json/hal'--module API- module V3- module Projects- module Status- class ProjectStatusRepresenter < ::API::Decorators::Single- include API::Decorators::FormattableProperty-- formattable_property :explanation- property :code,- render_nil: true,- getter: ->(represented:, **) {- represented.code.to_s.tr('_', ' ') if represented.code- }- end- end- end- end-end