Skip to content

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

Adopt project status widget to new style using ngSelect.

Wieland Lindenthal196c6f21f65f
diff --git a/app/assets/stylesheets/content/_autocomplete.sass b/app/assets/stylesheets/content/_autocomplete.sass
index 69f6d7b02bd..9461738f55b 100644
--- a/app/assets/stylesheets/content/_autocomplete.sass
+++ b/app/assets/stylesheets/content/_autocomplete.sass
@@ -184,3 +184,22 @@ mark.ui-autocomplete-match
line-height: 22px
.work-package-table--container .ng-dropdown-panel
z-index: auto !important
+
+// Project status widget
+.ng-select
+ &.traffic-lights
+ max-width: 300px
+ &.ng-select-disabled
+ > .ng-select-container
+ background: none
+ border: none
+ box-shadow: none
+ .ng-select-container
+ min-height: 56px !important
+ height: 56px !important
+ .ng-value-container
+ padding-left: 0
+ .ng-arrow-wrapper
+ display: none
+ .ng-select.ng-select-single .ng-select-container
+
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.html
index b3164670e9e..bb842181192 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,21 +9,16 @@
</widget-header>
<div class="grid--widget-content">
- <div class="content-grid">
- <div class="left-column">
- <div class="traffic-lights">
- <div class="light" [ngClass]="{'-active':currentStatusCode === 'off track'}">
- <div class="bulb -red" [attr.title]="availableStatuses['off_track']"></div>
- </div>
- <div class="light" [ngClass]="{'-active':currentStatusCode === 'at risk'}" >
- <div class="bulb -yellow" [attr.title]="availableStatuses['at_risk']"></div>
- </div>
- <div class="light" [ngClass]="{'-active':currentStatusCode === 'on track'}">
- <div class="bulb -green -active" [attr.title]="availableStatuses['on_track']"></div>
- </div>
- </div>
- <div class="current-status" [innerHtml]="availableStatuses[currentStatusCode]"></div>
- </div>
- <div class="right-column" [innerHtml]="explanation"></div>
- </div>
+ <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.sass b/frontend/src/app/modules/grids/widgets/project-status/project-status.component.sass
index fc00d2d2330..9cc7ca20ca7 100644
--- a/frontend/src/app/modules/grids/widgets/project-status/project-status.component.sass
+++ b/frontend/src/app/modules/grids/widgets/project-status/project-status.component.sass
@@ -1,83 +1,42 @@
-.traffic-lights
- width: 40px
- height: 100px
- padding: 5px
- border: 1px solid gray
- border-radius: 2px
-
-.light
- width: 30px
- height: 30px
- padding: 5px
- &:hover,
- &.-active
- padding: 0px
- animation-name: shrink-padding
- animation-duration: 200ms
- &.-active
- .-green
- background-color: green
- .-yellow
- background-color: orange
- .-red
- background-color: red
+$gray: #CCCCCC
+$red: #E73E3D
+$orange: #FFB030
+$green: #00D12D
.bulb
- width: 20px
- height: 20px
+ display: inline-block
+ width: 40px
+ height: 40px
border-radius: 50%
- border-width: 1px
+ border-width: 10px
border-style: solid
+ margin-right: 7px
+ vertical-align: middle
+ &.-gray
+ border-color: $gray
+ background-color: adjust-color($gray, $alpha: -0.7)
+ &.-red
+ border-color: $red
+ background-color: adjust-color($red, $alpha: -0.7)
+ &.-orange
+ border-color: $orange
+ background-color: adjust-color($orange, $alpha: -0.7)
&.-green
- border-color: green
- &.-yellow
- border-color: orange
+ border-color: $green
+ background-color: adjust-color($green, $alpha: -0.7)
+
+.status-name
+ text-transform: uppercase
+ font-weight: bold
+ &.-gray
+ color: $gray
&.-red
- border-color: red
-
-.light
- &:hover,
- &.-active
- .bulb
- width: 30px
- height: 30px
- border-width: 4px
- animation-name: increase-size
- animation-duration: 200ms
-
-.current-status
- margin-top: 10px
-
-.content-grid
- display: flex
- flex-direction: row
- width: 100%
-
-.left-column
- flex: 1
- flex-direction: column
- flex-basis: content
- max-width: 100px
- padding-right: 20px
-
-.right-column
- flex: 2
- flex-direction: column
+ color: $red
+ &.-orange
+ color: $orange
+ &.-green
+ color: $green
-@keyframes shrink-padding
- from
- padding: 5px
- to
- padding: 0px
+.explanation
+ margin-top: 9px
-@keyframes increase-size
- from
- width: 20px
- height: 20px
- border-width: 1px
- background-color: transparent
- to
- width: 30px
- height: 30px
- border-width: 4px
- background-color: transparent
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.ts
index 5b502f02443..04c07fdc49a 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
@@ -54,14 +54,30 @@ export const emptyPlaceholder = '-';
export class WidgetProjectStatusComponent extends AbstractWidgetComponent implements OnInit {
@ViewChild('contentContainer', { static: true }) readonly contentContainer:ElementRef;
- public currentStatusCode:string = 'not_set';
+ public currentStatusCode:string = 'not set';
public explanation:String = '';
- public availableStatuses:any = {
- on_track: this.i18n.t('js.grid.widgets.project_status.on_track'),
- off_track: this.i18n.t('js.grid.widgets.project_status.off_track'),
- at_risk: this.i18n.t('js.grid.widgets.project_status.at_risk'),
- not_set: this.i18n.t('js.grid.widgets.project_status.not_set')
- };
+ 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,
@@ -86,13 +102,18 @@ export class WidgetProjectStatusComponent extends AbstractWidgetComponent implem
this.loadProjectSchema()]
)
.then(([project, schema]) => {
- if (project.status) {
+ 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.currentStatusCode = 'not_set';
this.explanation = '';
}
+
this.redraw();
});
}
diff --git a/modules/dashboards/spec/features/project_status_spec.rb b/modules/dashboards/spec/features/project_status_spec.rb
index 9cadc292844..168c4b53acc 100644
--- a/modules/dashboards/spec/features/project_status_spec.rb
+++ b/modules/dashboards/spec/features/project_status_spec.rb
@@ -65,7 +65,7 @@ describe 'Project status widget on dashboard', type: :feature, js: true do
.to have_content project_status.explanation
expect(page)
- .to have_selector(".bulb.-green.-active")
+ .to have_content 'ON TRACK'
end
end
end