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

add loading component to baseline component

bsatarnejad8e7bd1acad6c
diff --git a/frontend/src/app/shared/components/baseline/baseline.component.html b/frontend/src/app/shared/components/baseline/baseline.component.html
index c172e2bb78a..561ee6847a0 100644
--- a/frontend/src/app/shared/components/baseline/baseline.component.html
+++ b/frontend/src/app/shared/components/baseline/baseline.component.html
@@ -1,4 +1,5 @@
<form
+ *ngIf="(nonWorkingDays$ | async); else loadingTemplate"
(submit)="onSubmit($event)"
class="spot-container op-baseline--body"
>
@@ -30,7 +31,7 @@
(change)="timeChange($event.target.value)"
type="time"
class="op-baseline--time-input"/>
-
+
<spot-tooltip
slot="input"
class="op-baseline--time-tooltip op-baseline--time-help spot-body-small"
@@ -67,3 +68,6 @@
</div>
</form>
+<ng-template #loadingTemplate>
+ <op-baseline-loading></op-baseline-loading>
+</ng-template>
diff --git a/frontend/src/app/shared/components/baseline/baseline.component.ts b/frontend/src/app/shared/components/baseline/baseline.component.ts
index bc49ea3da8a..393534f2003 100644
--- a/frontend/src/app/shared/components/baseline/baseline.component.ts
+++ b/frontend/src/app/shared/components/baseline/baseline.component.ts
@@ -27,7 +27,6 @@
//++
import {
- AfterViewInit,
ChangeDetectionStrategy,
Component,
HostBinding,
@@ -41,9 +40,9 @@ import SpotDropAlignmentOption from 'core-app/spot/drop-alignment-options';
import { WeekdayService } from 'core-app/core/days/weekday.service';
import { DayResourceService } from 'core-app/core/state/days/day.service';
import { IDay } from 'core-app/core/state/days/day.model';
-import { take } from 'rxjs/operators';
import { TimezoneService } from 'core-app/core/datetime/timezone.service';
import { ConfigurationService } from 'core-app/core/config/configuration.service';
+import { Observable } from 'rxjs';
@Component({
selector: 'op-baseline',
@@ -51,7 +50,7 @@ import { ConfigurationService } from 'core-app/core/config/configuration.service
templateUrl: './baseline.component.html',
styleUrls: ['./baseline.component.sass'],
})
-export class OpBaselineComponent extends UntilDestroyedMixin implements AfterViewInit {
+export class OpBaselineComponent extends UntilDestroyedMixin {
@HostBinding('class.op-baseline') className = true;
public opened = false;
@@ -60,6 +59,8 @@ export class OpBaselineComponent extends UntilDestroyedMixin implements AfterVie
public nonWorkingDays:IDay[] = [];
+ public nonWorkingDays$:Observable<IDay[]> = this.requireNonWorkingDaysOfTwoYears();
+
public selectedDate = '';
public selectedTimezoneFormattedTime = '';
@@ -127,10 +128,6 @@ export class OpBaselineComponent extends UntilDestroyedMixin implements AfterVie
super();
}
- async ngAfterViewInit():Promise<void> {
- await this.requireNonWorkingDaysOfTwoYears();
- }
-
public toggleOpen():void {
this.opened = !this.opened;
}
@@ -175,15 +172,13 @@ export class OpBaselineComponent extends UntilDestroyedMixin implements AfterVie
return this.selectedDate;
}
- async requireNonWorkingDaysOfTwoYears() {
+ requireNonWorkingDaysOfTwoYears() {
const today = new Date();
const lastYear = new Date(today);
lastYear.setFullYear(today.getFullYear() - 1);
- this.nonWorkingDays = await this
+ return this
.daysService
- .requireNonWorkingYears$(lastYear, today)
- .pipe(take(1))
- .toPromise()?? [];
+ .requireNonWorkingYears$(lastYear, today);
}
isNonWorkingDay(date:Date|string):boolean {