Force updating activities

pull/6263/head
Oliver Günther 7 years ago
parent f6773333f2
commit 2418998d9b
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 3
      frontend/app/components/wp-custom-actions/wp-custom-actions/wp-custom-action.component.ts
  2. 3
      frontend/app/components/wp-edit-form/work-package-changeset.ts
  3. 3
      frontend/app/components/wp-single-view-tabs/activity-panel/activity-entry-info.ts
  4. 2
      frontend/app/components/wp-single-view-tabs/watchers-tab/watchers-tab.component.ts
  5. 2
      frontend/app/components/wp-single-view-tabs/watchers-tab/wp-watchers.service.ts
  6. 6
      frontend/app/components/wp-single-view-tabs/wp-linked-resource-cache.service.ts
  7. 13
      frontend/app/modules/hal/resources/work-package-resource.ts

@ -35,6 +35,7 @@ import {WorkPackageNotificationService} from 'core-components/wp-edit/wp-notific
import {downgradeComponent} from '@angular/upgrade/static';
import {HalResourceService} from 'core-app/modules/hal/services/hal-resource.service';
import {CustomActionResource} from 'core-app/modules/hal/resources/custom-action-resource';
import {WorkPackagesActivityService} from 'core-components/wp-single-view-tabs/activity-panel/wp-activity.service';
@Component({
selector: 'wp-custom-action',
@ -47,6 +48,7 @@ export class WpCustomActionComponent {
constructor(private halResourceService:HalResourceService,
private wpCacheService:WorkPackageCacheService,
private wpActivity:WorkPackagesActivityService,
private wpNotificationsService:WorkPackageNotificationService) { }
private fetchAction() {
@ -72,6 +74,7 @@ export class WpCustomActionComponent {
.then((savedWp:WorkPackageResource) => {
this.wpNotificationsService.showSave(savedWp, false);
this.workPackage = savedWp;
this.wpActivity.clear(this.workPackage.id);
this.wpCacheService.updateWorkPackage(savedWp);
}).catch((errorResource:any) => {
this.wpNotificationsService.handleErrorResponse(errorResource, this.workPackage);

@ -37,6 +37,7 @@ import {Injector} from '@angular/core';
import {WorkPackageResource} from 'core-app/modules/hal/resources/work-package-resource';
import {FormResource} from 'core-app/modules/hal/resources/form-resource';
import {HalResourceService} from 'core-app/modules/hal/services/hal-resource.service';
import {WorkPackagesActivityService} from 'core-components/wp-single-view-tabs/activity-panel/wp-activity.service';
export class WorkPackageChangeset {
// Injections
@ -45,6 +46,7 @@ export class WorkPackageChangeset {
public wpCacheService:WorkPackageCacheService = this.injector.get(WorkPackageCacheService);
public wpCreate:WorkPackageCreateService = this.injector.get(WorkPackageCreateService);
public wpEditing:WorkPackageEditingService = this.injector.get(WorkPackageEditingService);
public wpActivity:WorkPackagesActivityService = this.injector.get(WorkPackagesActivityService);
public halResourceService:HalResourceService = this.injector.get(HalResourceService);
// The changeset to be applied to the work package
@ -187,6 +189,7 @@ export class WorkPackageChangeset {
this.wpCreate.newWorkPackageCreated(this.workPackage);
}
this.wpActivity.clear(this.workPackage.id);
this.wpCacheService.updateWorkPackage(this.workPackage);
this.resource = null;
this.clear();

@ -78,7 +78,8 @@ export class ActivityEntryInfo {
}
protected activityDate(activity:any) {
return this.timezoneService.formattedDatetime(activity.createdAt);
// Force long date regardless of current date settings for headers
return moment(activity.createdAt).format('LL');
}
protected orderedIndex(activityNo:number, forceReverse:boolean = false) {

@ -209,6 +209,7 @@ export class WorkPackageWatchersTabComponent implements OnInit, OnDestroy {
.then(() => {
// Forcefully reload the resource to update the watch/unwatch links
// should the current user have been added
this.wpWatchersService.require(this.workPackage, true);
this.wpCacheService.loadWorkPackage(this.workPackage.id, true);
this.autocompleteInput = '';
})
@ -224,6 +225,7 @@ export class WorkPackageWatchersTabComponent implements OnInit, OnDestroy {
// Forcefully reload the resource to update the watch/unwatch links
// should the current user have been removed
this.wpWatchersService.require(this.workPackage, true);
this.wpCacheService.loadWorkPackage(this.workPackage.id, true);
})
.catch((error:any) => this.wpNotificationsService.showError(error, this.workPackage));

@ -36,7 +36,7 @@ import {WorkPackageLinkedResourceCache} from 'core-components/wp-single-view-tab
export class WorkPackageWatchersService extends WorkPackageLinkedResourceCache<HalResource[]> {
protected async load(workPackage:WorkPackageResource) {
return workPackage.watchers.$load()
return workPackage.watchers.$update()
.then((collection:CollectionResource<HalResource>) => {
return collection.elements;
});

@ -74,6 +74,12 @@ export abstract class WorkPackageLinkedResourceCache<T> {
.toPromise();
}
public clear(workPackageId:string|number) {
if (this.cache.id === workPackageId.toString()) {
this.cache.state.clear();
}
}
/**
* Return whether the given work package is cached.
* @param {string} workPackageId

@ -292,19 +292,6 @@ export class WorkPackageResource extends HalResource {
return promise;
}
/**
* Get updated activities from the server and inform the cache service about the work
* package update.
*
* Return a promise that returns the activities. Reject, if the work package has
* no activities.
*/
public async updateActivities():Promise<HalResource> {
return this
.updateLinkedResources('activities')
.then((resources:any) => resources.activities);
}
/**
* Get updated attachments and activities from the server and inform the cache service
* about the update.

Loading…
Cancel
Save