Skip to content

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

Table works

Benjamin Bädorf1228a1de56db
diff --git a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html
index c1bce8ccd41..8ea68f858e6 100644
--- a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html
+++ b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html
@@ -106,7 +106,8 @@
<button
type="button"
class="op-link"
- >Restore defaults</button>
+ (click)="removeProjectSettings(item.value[0]._links.project.href)"
+ >Remove Project Settings</button>
</td>
</ng-container>
</tr>
diff --git a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts
index 788ba5aa376..cc178186802 100644
--- a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts
+++ b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts
@@ -7,7 +7,7 @@ import {
} from '@angular/core';
import { map } from 'rxjs/operators';
import { KeyValue } from '@angular/common';
-import { arrayAdd, arrayUpdate } from '@datorama/akita';
+import { arrayAdd, arrayUpdate, arrayRemove } from '@datorama/akita';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { UserPreferencesService } from 'core-app/features/user-preferences/state/user-preferences.service';
import { UserPreferencesStore } from 'core-app/features/user-preferences/state/user-preferences.store';
@@ -52,7 +52,6 @@ export class NotificationSettingsTableComponent {
constructor(
private I18n:I18nService,
- private stateService:UserPreferencesService,
private store:UserPreferencesStore,
private query:UserPreferencesQuery,
) {
@@ -76,16 +75,22 @@ export class NotificationSettingsTableComponent {
this.store.update(
({ notifications }) => ({
notifications: arrayUpdate(
- notifications, this.getStoreMatcherFn(delta, projectHref), delta,
+ notifications,
+ (notification:NotificationSetting) => {
+ return notification._links.project.href === projectHref
+ && notification.channel === 'in_app';
+ },
+ delta,
),
}),
);
}
- private getStoreMatcherFn(delta:Partial<NotificationSetting>, projectHref: string) {
- return (notification:NotificationSetting) => {
- return notification._links.project.href === projectHref
- && notification.channel === delta.channel;
- };
+ removeProjectSettings(projectHref: string) {
+ this.store.update(
+ ({ notifications }) => ({
+ notifications: arrayRemove(notifications, (notification:NotificationSetting) => notification._links.project.href === projectHref),
+ }),
+ );
}
}
diff --git a/frontend/src/app/features/user-preferences/state/user-preferences.query.ts b/frontend/src/app/features/user-preferences/state/user-preferences.query.ts
index e17b1bba315..6778a184121 100644
--- a/frontend/src/app/features/user-preferences/state/user-preferences.query.ts
+++ b/frontend/src/app/features/user-preferences/state/user-preferences.query.ts
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { Query } from '@datorama/akita';
-import { map, tap } from 'rxjs/operators';
+import { map } from 'rxjs/operators';
import { Observable } from 'rxjs';
import { UserPreferencesStore } from 'core-app/features/user-preferences/state/user-preferences.store';
import { UserPreferencesModel } from 'core-app/features/user-preferences/state/user-preferences.model';
@@ -18,7 +18,6 @@ export class UserPreferencesQuery extends Query<UserPreferencesModel> {
.pipe(
map((notifications) => notifications.filter((setting) => setting.channel === 'in_app' && setting._links.project.title)),
map((notifications) => _.groupBy(notifications, (setting) => setting._links.project.title)),
- tap(console.log),
);
projectNotifications$ = this