Update target list when matching halEvent arrives

pull/8230/head
Oliver Günther 5 years ago
parent 1732938a4d
commit c123092633
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 1
      frontend/src/app/components/op-context-menu/handlers/wp-status-dropdown-menu.directive.ts
  2. 27
      frontend/src/app/modules/boards/board/board-list/board-list.component.ts
  3. 6
      frontend/src/app/modules/fields/edit/edit-form/edit-form.component.ts
  4. 12
      frontend/src/app/modules/fields/edit/edit-form/edit-form.ts
  5. 5
      frontend/src/app/modules/fields/edit/services/hal-resource-editing.service.ts
  6. 2
      frontend/src/app/modules/hal/services/hal-events.service.ts

@ -91,7 +91,6 @@ export class WorkPackageStatusDropdownDirective extends OpContextMenuTrigger {
.save(change)
.then(() => {
this.workPackageNotificationService.showSave(this.workPackage);
this.halEvents.push(this.workPackage, { eventType: 'updated' });
});
}
}

@ -53,7 +53,8 @@ import {StateService, TransitionService} from "@uirouter/core";
import {WorkPackageViewFocusService} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-focus.service";
import {WorkPackageViewSelectionService} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-selection.service";
import {BoardListCrossSelectionService} from "core-app/modules/boards/board/board-list/board-list-cross-selection.service";
import {debounceTime} from "rxjs/operators";
import {debounceTime, filter, map} from "rxjs/operators";
import {HalEvent, HalEventsService} from "core-app/modules/hal/services/hal-events.service";
export interface DisabledButtonPlaceholder {
text:string;
@ -136,6 +137,7 @@ export class BoardListComponent extends AbstractWidgetComponent implements OnIni
readonly notifications:NotificationsService,
readonly querySpace:IsolatedQuerySpace,
readonly halNotification:HalResourceNotificationService,
readonly halEvents:HalEventsService,
readonly wpStatesInitialization:WorkPackageStatesInitializationService,
readonly wpViewFocusService:WorkPackageViewFocusService,
readonly wpViewSelectionService:WorkPackageViewSelectionService,
@ -211,6 +213,9 @@ export class BoardListComponent extends AbstractWidgetComponent implements OnIni
)
.subscribe(() => this.updateQuery(true));
// Listen to changes to action attribute
this.listenToActionAttributeChanges();
this.querySpace.query
.values$()
.pipe(
@ -426,4 +431,24 @@ export class BoardListComponent extends AbstractWidgetComponent implements OnIni
this.columnsQueryProps = newColumnsQueryProps;
}
private listenToActionAttributeChanges() {
// If we don't have an action attribute
// nothing to do
if (!this.board.actionAttribute) {
return;
}
// Listen to hal events to detect changes to an action attribute
this.halEvents
.events$
.pipe(
filter(event => event.resourceType === 'WorkPackage'),
map((event:HalEvent) => event.commit?.changes[this.board.actionAttribute!]),
filter((value:HalResource|undefined) => this.actionResource?.href === value?.href)
).subscribe((event) => {
this.updateQuery(true);
});
}
}

@ -43,6 +43,7 @@ import {IFieldSchema} from "core-app/modules/fields/field.base";
import {EditFieldHandler} from "core-app/modules/fields/edit/editing-portal/edit-field-handler";
import {EditingPortalService} from "core-app/modules/fields/edit/editing-portal/editing-portal-service";
import {EditFormRoutingService} from "core-app/modules/fields/edit/edit-form/edit-form-routing.service";
import {ResourceChangesetCommit} from "core-app/modules/fields/edit/services/hal-resource-editing.service";
@Component({
selector: 'edit-form,[edit-form]',
@ -129,9 +130,8 @@ export class EditFormComponent extends EditForm<HalResource> implements OnInit,
ctrl.deactivate(focus);
}
public onSaved(isInitial:boolean, saved:HalResource) {
super.onSaved(isInitial, saved);
this.stopEditingAndLeave(saved, isInitial);
public onSaved(commit:ResourceChangesetCommit) {
this.stopEditingAndLeave(commit.resource, commit.wasNew);
}
public requireVisible(fieldName:string):Promise<void> {

@ -32,7 +32,10 @@ import {Subscription} from 'rxjs';
import {States} from 'core-components/states.service';
import {IFieldSchema} from "core-app/modules/fields/field.base";
import {HalResourceEditingService} from "core-app/modules/fields/edit/services/hal-resource-editing.service";
import {
HalResourceEditingService,
ResourceChangesetCommit
} from "core-app/modules/fields/edit/services/hal-resource-editing.service";
import {HalEventsService} from "core-app/modules/hal/services/hal-events.service";
import {EditFieldHandler} from "core-app/modules/fields/edit/editing-portal/edit-field-handler";
import {HalResource} from "core-app/modules/hal/resources/hal-resource";
@ -87,9 +90,8 @@ export abstract class EditForm<T extends HalResource = HalResource> {
/**
* Optional callback when the form is being saved
*/
protected onSaved(isInitial:boolean, saved:HalResource):void {
const eventType = isInitial ? 'created' : 'updated';
this.halEvents.push(saved, { eventType });
protected onSaved(commit:ResourceChangesetCommit):void {
// Does nothing by default
}
protected abstract focusOnFirstError():void;
@ -190,7 +192,7 @@ export abstract class EditForm<T extends HalResource = HalResource> {
this.halNotification.showSave(result.resource, result.wasNew);
this.editMode = false;
this.onSaved(result.wasNew, result.resource);
this.onSaved(result);
this.change.inFlight = false;
})
.catch((error:ErrorResource|Object) => {

@ -36,6 +36,7 @@ import {ResourceChangeset} from "core-app/modules/fields/changeset/resource-chan
import {HalResource} from "core-app/modules/hal/resources/hal-resource";
import {StateCacheService} from "core-components/states/state-cache.service";
import {HookService} from "core-app/modules/plugins/hook-service";
import {HalEventsService} from "core-app/modules/hal/services/hal-events.service";
class ChangesetStates extends StatesGroup {
name = 'Changesets';
@ -98,6 +99,7 @@ export class HalResourceEditingService extends StateCacheService<ResourceChanges
private stateGroup = new ChangesetStates();
constructor(protected readonly injector:Injector,
protected readonly halEvents:HalEventsService,
protected readonly hook:HookService) {
super();
}
@ -125,6 +127,9 @@ export class HalResourceEditingService extends StateCacheService<ResourceChanges
this.comittedChanges.next(commit);
this.reset(change);
const eventType = commit.wasNew ? 'created' : 'updated';
this.halEvents.push(commit.resource, { eventType, commit });
return commit;
}

@ -2,11 +2,13 @@ import {Injectable} from "@angular/core";
import {Observable, Subject} from "rxjs";
import {buffer, debounceTime, filter, scan} from "rxjs/operators";
import {HalResource} from "core-app/modules/hal/resources/hal-resource";
import {ResourceChangesetCommit} from "core-app/modules/fields/edit/services/hal-resource-editing.service";
export interface HalEvent {
id:string;
eventType:string;
resourceType:string;
commit?:ResourceChangesetCommit;
}
export interface HalCreatedEvent extends HalEvent {

Loading…
Cancel
Save