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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add previous changes in order to listen to them
Oliver Günther8d69993defa1
diff --git a/frontend/src/app/modules/boards/board/board-list/board-list.component.ts b/frontend/src/app/modules/boards/board/board-list/board-list.component.tsindex e12aa7da7be..7d767c6acb8 100644--- a/frontend/src/app/modules/boards/board/board-list/board-list.component.ts+++ b/frontend/src/app/modules/boards/board/board-list/board-list.component.ts@@ -55,6 +55,7 @@ import {WorkPackageViewSelectionService} from "core-app/modules/work_packages/roimport {BoardListCrossSelectionService} from "core-app/modules/boards/board/board-list/board-list-cross-selection.service";import {debounceTime, filter, map} from "rxjs/operators";import {HalEvent, HalEventsService} from "core-app/modules/hal/services/hal-events.service";+import {ChangeItem} from "core-app/modules/fields/changeset/changeset";export interface DisabledButtonPlaceholder {text:string;@@ -446,7 +447,17 @@ export class BoardListComponent extends AbstractWidgetComponent implements OnIni.pipe(filter(event => event.resourceType === 'WorkPackage'),map((event:HalEvent) => event.commit?.changes[this.board.actionAttribute!]),- filter((value:HalResource|undefined) => this.actionResource?.href === value?.href)+ filter(value => !!value),+ filter((value:ChangeItem) => {++ // Compare the from and to values from the committed changes+ // with the current actionResource+ const current = this.actionResource?.href;+ const to = (value.to as HalResource|undefined)?.href;+ const from = (value.from as HalResource|undefined)?.href;++ return !!current && (current === to || current === from);+ })).subscribe((event) => {this.updateQuery(true);});diff --git a/frontend/src/app/modules/fields/changeset/changeset.ts b/frontend/src/app/modules/fields/changeset/changeset.tsindex e2798ed63f6..df54dfbf8cd 100644--- a/frontend/src/app/modules/fields/changeset/changeset.ts+++ b/frontend/src/app/modules/fields/changeset/changeset.ts@@ -1,4 +1,8 @@-export type ChangeMap = { [attribute:string]:unknown };+export type ChangeItem = {+ from:unknown;+ to:unknown;+};+export type ChangeMap = { [attribute:string]:ChangeItem };export class Changeset {private changes:ChangeMap = {};@@ -32,7 +36,9 @@ export class Changeset {* @param key*/public reset(...keys:string[]) {- keys.forEach((k) => delete this.changes[k]);+ keys.forEach((k) => {+ delete this.changes[k];+ });}/**@@ -42,15 +48,34 @@ export class Changeset {this.changes = {};}- public set(key:string, value:unknown):void {- this.changes[key] = value;+ public set(key:string, value:unknown, pristineValue:unknown):void {+ this.changes[key] = {+ from: pristineValue,+ to: value+ };}/**- * Get a single value from the changeset+ * Get a change item for the given key, if any* @param key*/- public get(key:string):unknown|undefined {+ public getItem(key:string):ChangeItem|undefined {return this.changes[key];}++ /**+ * Get a single value from the changeset+ * @param key+ */+ public getValue(key:string):unknown|undefined {+ return this.getItem(key)?.to;+ }++ /**+ * Get a single pristine value from the changeset+ * @param key+ */+ public getPristine(key:string):unknown|undefined {+ return this.changes[key]?.from;+ }}diff --git a/frontend/src/app/modules/fields/changeset/resource-changeset.ts b/frontend/src/app/modules/fields/changeset/resource-changeset.tsindex 1b8bc47cf4f..8da53b744a3 100644--- a/frontend/src/app/modules/fields/changeset/resource-changeset.ts+++ b/frontend/src/app/modules/fields/changeset/resource-changeset.ts@@ -1,12 +1,11 @@import {SchemaResource} from "core-app/modules/hal/resources/schema-resource";import {FormResource} from "core-app/modules/hal/resources/form-resource";import {HalResource} from "core-app/modules/hal/resources/hal-resource";-import {ChangeMap, Changeset} from "core-app/modules/fields/changeset/changeset";+import {ChangeItem, ChangeMap, Changeset} from "core-app/modules/fields/changeset/changeset";import {input, InputState} from "reactivestates";import {IFieldSchema} from "core-app/modules/fields/field.base";import {debugLog} from "core-app/helpers/debug_output";import {take} from "rxjs/operators";-import {Form} from "@angular/forms";/*** Temporary class living while a resource is being edited@@ -69,8 +68,6 @@ export class ResourceChangeset<T extends HalResource|{ [key:string]:unknown; } =}--public getSchemaName(attribute:string):string {if (this.projectedResource.getSchemaName) {return this.projectedResource.getSchemaName(attribute);@@ -138,9 +135,22 @@ export class ResourceChangeset<T extends HalResource|{ [key:string]:unknown; } =}/**- * Return a shallow copy of the changes+ * Returns the changed `to` values of the ChangeMap+ */+ public get changes():{ [key:string]:unknown } {+ let changes:{ [key:string]:unknown } = {};++ _.each(this.changeset.all, (item, key) => {+ changes[key] = item.to;+ });++ return changes;+ }++ /**+ * Returns the change map with from and to values*/- public get changes():ChangeMap {+ public get changeMap():ChangeMap {return { ...this.changeset.all };}@@ -199,7 +209,7 @@ export class ResourceChangeset<T extends HalResource|{ [key:string]:unknown; } =public value(key:string) {// Overridden value by user?if (this.changeset.contains(key)) {- return this.changeset.get(key);+ return this.changeset.getValue(key);}// Return whatever is on the base.@@ -217,7 +227,7 @@ export class ResourceChangeset<T extends HalResource|{ [key:string]:unknown; } =}public setValue(key:string, val:any) {- this.changeset.set(key, val);+ this.changeset.set(key, val, this.pristineResource[key]);}public clear() {@@ -269,7 +279,7 @@ export class ResourceChangeset<T extends HalResource|{ [key:string]:unknown; } =reference = this.form$.value.payload.$source;}- _.each(this.changeset.all, (val:unknown, key:string) => {+ _.each(this.changeset.all, (val:ChangeItem, key:string) => {const fieldSchema:IFieldSchema|undefined = this.schema[key];if (!(typeof (fieldSchema) === 'object' && fieldSchema.writable)) {debugLog(`Trying to write ${key} but is not writable in schema`);@@ -278,9 +288,9 @@ export class ResourceChangeset<T extends HalResource|{ [key:string]:unknown; } =// Override in _links if it is a linked propertyif (reference._links[key]) {- plainPayload._links[key] = this.getLinkedValue(val, fieldSchema);+ plainPayload._links[key] = this.getLinkedValue(val.to, fieldSchema);} else {- plainPayload[key] = val;+ plainPayload[key] = val.to;}});diff --git a/frontend/src/app/modules/fields/edit/services/hal-resource-editing.service.ts b/frontend/src/app/modules/fields/edit/services/hal-resource-editing.service.tsindex 1b842434ed2..dd733c0bfb9 100644--- a/frontend/src/app/modules/fields/edit/services/hal-resource-editing.service.ts+++ b/frontend/src/app/modules/fields/edit/services/hal-resource-editing.service.ts@@ -81,7 +81,7 @@ export class ResourceChangesetCommit<T extends HalResource = HalResource> {this.id = saved.id!.toString();this.wasNew = change.pristineResource.isNew;this.resource = saved;- this.changes = change.changes;+ this.changes = change.changeMap;}}