[26152] Add loading indicator for initial relations loading

https://community.openproject.com/wp/26152
pull/5873/head
Oliver Günther 7 years ago
parent 3b7032e03d
commit 5bb83c0c22
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 12
      frontend/app/components/common/loading-indicator/loading-indicator.service.ts
  2. 4
      frontend/app/components/wp-relations/wp-relations.directive.ts
  3. 3
      frontend/app/components/wp-relations/wp-relations.template.html
  4. 2
      spec/features/work_packages/details/details_relations_spec.rb

@ -34,12 +34,16 @@ export class LoadingIndicator {
constructor(public indicator:JQuery, public element:JQuery) {} constructor(public indicator:JQuery, public element:JQuery) {}
public set promise(promise:ng.IPromise<any>) { public set promise(promise:Promise<any>) {
this.start(); this.start();
promise.finally(() => {
// Delay hiding the indicator a little bit. const stop = () => {
setTimeout(() => this.stop(), 25); setTimeout(() => this.stop(), 25);
}); };
promise
.then(stop)
.catch(stop);
} }
public start() { public start() {

@ -34,6 +34,7 @@ import {WorkPackageResourceInterface} from '../api/api-v3/hal-resources/work-pac
import {WorkPackageCacheService} from '../work-packages/work-package-cache.service'; import {WorkPackageCacheService} from '../work-packages/work-package-cache.service';
import {RelatedWorkPackagesGroup} from './wp-relations.interfaces'; import {RelatedWorkPackagesGroup} from './wp-relations.interfaces';
import {RelationsStateValue, WorkPackageRelationsService} from './wp-relations.service'; import {RelationsStateValue, WorkPackageRelationsService} from './wp-relations.service';
import {LoadingIndicatorService} from '../common/loading-indicator/loading-indicator.service';
export class WorkPackageRelationsController { export class WorkPackageRelationsController {
public relationGroups:RelatedWorkPackagesGroup; public relationGroups:RelatedWorkPackagesGroup;
@ -48,10 +49,11 @@ export class WorkPackageRelationsController {
protected $q:ng.IQService, protected $q:ng.IQService,
protected $state:ng.ui.IState, protected $state:ng.ui.IState,
protected I18n:op.I18n, protected I18n:op.I18n,
protected loadingIndicator:LoadingIndicatorService,
protected wpRelations:WorkPackageRelationsService, protected wpRelations:WorkPackageRelationsService,
protected wpCacheService:WorkPackageCacheService) { protected wpCacheService:WorkPackageCacheService) {
this.wpRelations.require(this.workPackage.id, true); loadingIndicator.indicator('relation-groups').promise = this.wpRelations.require(this.workPackage.id, true);
scopedObservable(this.$scope, scopedObservable(this.$scope,
this.wpRelations.state(this.workPackage.id).values$()) this.wpRelations.state(this.workPackage.id).values$())
.subscribe((relations:RelationsStateValue) => { .subscribe((relations:RelationsStateValue) => {

@ -1,4 +1,5 @@
<div> <div class="loading-indicator--location"
data-indicator-name="relation-groups">
<div ng-repeat="(type, relatedWorkPackages) in $ctrl.relationGroups"> <div ng-repeat="(type, relatedWorkPackages) in $ctrl.relationGroups">
<wp-relations-group header="type" <wp-relations-group header="type"
group-by-work-package-type="$ctrl.groupByWorkPackageType" group-by-work-package-type="$ctrl.groupByWorkPackageType"

@ -250,6 +250,8 @@ describe 'Work package relations tab', js: true, selenium: true do
# Save description # Save description
created_row.find('.inplace-edit--control--save a').click created_row.find('.inplace-edit--control--save a').click
loading_indicator_saveguard
## Toggle description again ## Toggle description again
relations.hover_action(relatable, :info) relations.hover_action(relatable, :info)
created_row = relations.find_row(relatable) created_row = relations.find_row(relatable)

Loading…
Cancel
Save