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) .save(change)
.then(() => { .then(() => {
this.workPackageNotificationService.showSave(this.workPackage); 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 {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 {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 {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 { export interface DisabledButtonPlaceholder {
text:string; text:string;
@ -136,6 +137,7 @@ export class BoardListComponent extends AbstractWidgetComponent implements OnIni
readonly notifications:NotificationsService, readonly notifications:NotificationsService,
readonly querySpace:IsolatedQuerySpace, readonly querySpace:IsolatedQuerySpace,
readonly halNotification:HalResourceNotificationService, readonly halNotification:HalResourceNotificationService,
readonly halEvents:HalEventsService,
readonly wpStatesInitialization:WorkPackageStatesInitializationService, readonly wpStatesInitialization:WorkPackageStatesInitializationService,
readonly wpViewFocusService:WorkPackageViewFocusService, readonly wpViewFocusService:WorkPackageViewFocusService,
readonly wpViewSelectionService:WorkPackageViewSelectionService, readonly wpViewSelectionService:WorkPackageViewSelectionService,
@ -211,6 +213,9 @@ export class BoardListComponent extends AbstractWidgetComponent implements OnIni
) )
.subscribe(() => this.updateQuery(true)); .subscribe(() => this.updateQuery(true));
// Listen to changes to action attribute
this.listenToActionAttributeChanges();
this.querySpace.query this.querySpace.query
.values$() .values$()
.pipe( .pipe(
@ -426,4 +431,24 @@ export class BoardListComponent extends AbstractWidgetComponent implements OnIni
this.columnsQueryProps = newColumnsQueryProps; 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 {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 {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 {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({ @Component({
selector: 'edit-form,[edit-form]', selector: 'edit-form,[edit-form]',
@ -129,9 +130,8 @@ export class EditFormComponent extends EditForm<HalResource> implements OnInit,
ctrl.deactivate(focus); ctrl.deactivate(focus);
} }
public onSaved(isInitial:boolean, saved:HalResource) { public onSaved(commit:ResourceChangesetCommit) {
super.onSaved(isInitial, saved); this.stopEditingAndLeave(commit.resource, commit.wasNew);
this.stopEditingAndLeave(saved, isInitial);
} }
public requireVisible(fieldName:string):Promise<void> { public requireVisible(fieldName:string):Promise<void> {

@ -32,7 +32,10 @@ import {Subscription} from 'rxjs';
import {States} from 'core-components/states.service'; import {States} from 'core-components/states.service';
import {IFieldSchema} from "core-app/modules/fields/field.base"; 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 {HalEventsService} from "core-app/modules/hal/services/hal-events.service";
import {EditFieldHandler} from "core-app/modules/fields/edit/editing-portal/edit-field-handler"; import {EditFieldHandler} from "core-app/modules/fields/edit/editing-portal/edit-field-handler";
import {HalResource} from "core-app/modules/hal/resources/hal-resource"; 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 * Optional callback when the form is being saved
*/ */
protected onSaved(isInitial:boolean, saved:HalResource):void { protected onSaved(commit:ResourceChangesetCommit):void {
const eventType = isInitial ? 'created' : 'updated'; // Does nothing by default
this.halEvents.push(saved, { eventType });
} }
protected abstract focusOnFirstError():void; protected abstract focusOnFirstError():void;
@ -190,7 +192,7 @@ export abstract class EditForm<T extends HalResource = HalResource> {
this.halNotification.showSave(result.resource, result.wasNew); this.halNotification.showSave(result.resource, result.wasNew);
this.editMode = false; this.editMode = false;
this.onSaved(result.wasNew, result.resource); this.onSaved(result);
this.change.inFlight = false; this.change.inFlight = false;
}) })
.catch((error:ErrorResource|Object) => { .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 {HalResource} from "core-app/modules/hal/resources/hal-resource";
import {StateCacheService} from "core-components/states/state-cache.service"; import {StateCacheService} from "core-components/states/state-cache.service";
import {HookService} from "core-app/modules/plugins/hook-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 { class ChangesetStates extends StatesGroup {
name = 'Changesets'; name = 'Changesets';
@ -98,6 +99,7 @@ export class HalResourceEditingService extends StateCacheService<ResourceChanges
private stateGroup = new ChangesetStates(); private stateGroup = new ChangesetStates();
constructor(protected readonly injector:Injector, constructor(protected readonly injector:Injector,
protected readonly halEvents:HalEventsService,
protected readonly hook:HookService) { protected readonly hook:HookService) {
super(); super();
} }
@ -125,6 +127,9 @@ export class HalResourceEditingService extends StateCacheService<ResourceChanges
this.comittedChanges.next(commit); this.comittedChanges.next(commit);
this.reset(change); this.reset(change);
const eventType = commit.wasNew ? 'created' : 'updated';
this.halEvents.push(commit.resource, { eventType, commit });
return commit; return commit;
} }

@ -2,11 +2,13 @@ import {Injectable} from "@angular/core";
import {Observable, Subject} from "rxjs"; import {Observable, Subject} from "rxjs";
import {buffer, debounceTime, filter, scan} from "rxjs/operators"; import {buffer, debounceTime, filter, scan} from "rxjs/operators";
import {HalResource} from "core-app/modules/hal/resources/hal-resource"; 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 { export interface HalEvent {
id:string; id:string;
eventType:string; eventType:string;
resourceType:string; resourceType:string;
commit?:ResourceChangesetCommit;
} }
export interface HalCreatedEvent extends HalEvent { export interface HalCreatedEvent extends HalEvent {

Loading…
Cancel
Save