parent
457e1ce9d9
commit
17582a831a
@ -1,116 +0,0 @@ |
||||
<td |
||||
*ngIf="first" |
||||
[attr.rowspan]="count" |
||||
> |
||||
<span |
||||
*ngIf="setting._links.project.href; else defaultTitle" |
||||
[textContent]="setting._links.project.title" |
||||
></span> |
||||
<ng-template #defaultTitle> |
||||
<em [textContent]="text.default_all_projects"></em> |
||||
</ng-template> |
||||
</td> |
||||
<td [textContent]="text.channel(setting.channel)"> |
||||
</td> |
||||
<td> |
||||
<input |
||||
type="checkbox" |
||||
[checked]="setting.involved || setting.all" |
||||
[disabled]="setting.all" |
||||
(change)="update({ involved: $event.target.checked })" |
||||
data-qa-notification-type="involved" |
||||
[attr.aria-label]="text.involved_header" |
||||
/> |
||||
</td> |
||||
<td> |
||||
<input |
||||
type="checkbox" |
||||
[checked]="setting.mentioned || setting.all" |
||||
[disabled]="setting.all" |
||||
(change)="update({ mentioned: $event.target.checked })" |
||||
data-qa-notification-type="mentioned" |
||||
[attr.aria-label]="text.mentioned_header" |
||||
/> |
||||
</td> |
||||
<td> |
||||
<input |
||||
type="checkbox" |
||||
[checked]="setting.watched || setting.all" |
||||
[disabled]="setting.all" |
||||
(change)="update({ watched: $event.target.checked })" |
||||
data-qa-notification-type="watched" |
||||
[attr.aria-label]="text.watched_header" |
||||
/> |
||||
</td> |
||||
<td> |
||||
<input |
||||
type="checkbox" |
||||
[checked]="setting.workPackageCreated || setting.all" |
||||
[disabled]="setting.all" |
||||
(change)="update({ workPackageCreated: $event.target.checked })" |
||||
data-qa-notification-type="work_package_created" |
||||
[attr.aria-label]="text.work_package_created_header" |
||||
/> |
||||
</td> |
||||
<td> |
||||
<input |
||||
type="checkbox" |
||||
[checked]="setting.workPackageCommented || setting.all" |
||||
[disabled]="setting.all" |
||||
(change)="update({ workPackageCommented: $event.target.checked })" |
||||
data-qa-notification-type="work_package_commented" |
||||
[attr.aria-label]="text.work_package_commented_header" |
||||
/> |
||||
</td> |
||||
<td> |
||||
<input |
||||
type="checkbox" |
||||
[checked]="setting.workPackageProcessed || setting.all" |
||||
[disabled]="setting.all" |
||||
(change)="update({ workPackageProcessed: $event.target.checked })" |
||||
data-qa-notification-type="work_package_processed" |
||||
[attr.aria-label]="text.work_package_processed_header" |
||||
/> |
||||
</td> |
||||
<td> |
||||
<input |
||||
type="checkbox" |
||||
[checked]="setting.workPackagePrioritized || setting.all" |
||||
[disabled]="setting.all" |
||||
(change)="update({ workPackagePrioritized: $event.target.checked })" |
||||
data-qa-notification-type="work_package_prioritized" |
||||
[attr.aria-label]="text.work_package_prioritized_header" |
||||
/> |
||||
</td> |
||||
<td> |
||||
<input |
||||
type="checkbox" |
||||
[checked]="setting.workPackageScheduled || setting.all" |
||||
[disabled]="setting.all" |
||||
(change)="update({ workPackageScheduled: $event.target.checked })" |
||||
data-qa-notification-type="work_package_scheduled" |
||||
[attr.aria-label]="text.work_package_scheduled_header" |
||||
/> |
||||
</td> |
||||
<td> |
||||
<input |
||||
type="checkbox" |
||||
[checked]="setting.all" |
||||
(change)="update({ all: $event.target.checked })" |
||||
data-qa-notification-type="all" |
||||
[attr.aria-label]="text.any_event_header" |
||||
/> |
||||
</td> |
||||
<td |
||||
*ngIf="first" |
||||
[attr.rowspan]="count" |
||||
class="buttons" |
||||
> |
||||
<button |
||||
*ngIf="!global" |
||||
class="op-link" |
||||
(click)="remove()" |
||||
> |
||||
<op-icon icon-classes="icon-remove icon-no-color"></op-icon> |
||||
</button> |
||||
</td> |
@ -1,77 +0,0 @@ |
||||
import { |
||||
ChangeDetectionStrategy, Component, Input, OnInit, |
||||
} from '@angular/core'; |
||||
import { I18nService } from 'core-app/core/i18n/i18n.service'; |
||||
import { arrayUpdate } from '@datorama/akita'; |
||||
import { NotificationSetting } from 'core-app/features/user-preferences/state/notification-setting.model'; |
||||
import { UserPreferencesStore } from 'core-app/features/user-preferences/state/user-preferences.store'; |
||||
|
||||
@Component({ |
||||
// eslint-disable-next-line @angular-eslint/component-selector
|
||||
selector: '[op-notification-setting-row]', |
||||
templateUrl: './notification-setting-row.component.html', |
||||
changeDetection: ChangeDetectionStrategy.OnPush, |
||||
}) |
||||
export class NotificationSettingRowComponent implements OnInit { |
||||
@Input() first = false; |
||||
|
||||
@Input() count:number; |
||||
|
||||
@Input() setting:NotificationSetting; |
||||
|
||||
/** Whether this setting is global */ |
||||
global = false; |
||||
|
||||
text = { |
||||
title: this.I18n.t('js.notifications.settings.title'), |
||||
save: this.I18n.t('js.button_save'), |
||||
email: this.I18n.t('js.notifications.email'), |
||||
inApp: this.I18n.t('js.notifications.in_app'), |
||||
remove_all: this.I18n.t('js.notifications.settings.remove_all'), |
||||
involved_header: this.I18n.t('js.notifications.settings.involved'), |
||||
mentioned_header: this.I18n.t('js.notifications.settings.mentioned'), |
||||
watched_header: this.I18n.t('js.notifications.settings.watched'), |
||||
work_package_commented_header: this.I18n.t('js.notifications.settings.work_package_commented'), |
||||
work_package_created_header: this.I18n.t('js.notifications.settings.work_package_created'), |
||||
work_package_processed_header: this.I18n.t('js.notifications.settings.work_package_processed'), |
||||
work_package_prioritized_header: this.I18n.t('js.notifications.settings.work_package_prioritized'), |
||||
work_package_scheduled_header: this.I18n.t('js.notifications.settings.work_package_scheduled'), |
||||
any_event_header: this.I18n.t('js.notifications.settings.all'), |
||||
default_all_projects: this.I18n.t('js.notifications.settings.default_all_projects'), |
||||
add_setting: this.I18n.t('js.notifications.settings.add'), |
||||
channel: (channel:string):string => this.I18n.t(`js.notifications.channels.${channel}`), |
||||
}; |
||||
|
||||
constructor( |
||||
private I18n:I18nService, |
||||
private store:UserPreferencesStore, |
||||
) { |
||||
} |
||||
|
||||
ngOnInit() { |
||||
this.global = this.setting._links.project.href === null; |
||||
} |
||||
|
||||
remove():void { |
||||
this.store.update( |
||||
({ notifications }) => ({ |
||||
notifications: notifications.filter((notification) => notification._links.project.href !== this.setting._links.project.href), |
||||
}), |
||||
); |
||||
} |
||||
|
||||
update(delta:Partial<NotificationSetting>) { |
||||
this.store.update( |
||||
({ notifications }) => ({ |
||||
notifications: arrayUpdate( |
||||
notifications, this.matcherFn.bind(this), delta, |
||||
), |
||||
}), |
||||
); |
||||
} |
||||
|
||||
private matcherFn(notification:NotificationSetting) { |
||||
return notification._links.project.href === this.setting._links.project.href |
||||
&& notification.channel === this.setting.channel; |
||||
} |
||||
} |
Loading…
Reference in new issue