fix: update notifications design (#3000)

This commit is contained in:
Alex Inkin
2025-07-30 11:17:59 +07:00
committed by GitHub
parent 377b7b12ce
commit 55eb999305
5 changed files with 48 additions and 24 deletions

View File

@@ -49,12 +49,12 @@ import { i18nPipe } from '@start9labs/shared'
(overflownChange)="overflow = $event" (overflownChange)="overflow = $event"
/> />
@if (overflow) { @if (overflow) {
<button tuiLink (click)="service.viewModal(notificationItem, true)"> <button tuiLink (click.stop)="onClick()">
{{ 'View full' | i18n }} {{ 'View full' | i18n }}
</button> </button>
} }
@if (notificationItem.code === 1 || notificationItem.code === 2) { @if ([1, 2].includes(notificationItem.code)) {
<button tuiLink (click)="service.viewModal(notificationItem)"> <button tuiLink (click.stop)="onClick()">
{{ {{
notificationItem.code === 1 notificationItem.code === 1
? ('View report' | i18n) ? ('View report' | i18n)
@@ -66,7 +66,8 @@ import { i18nPipe } from '@start9labs/shared'
`, `,
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
host: { host: {
'[class._new]': '!notificationItem.read', '[class._new]': '!notificationItem.seen',
'(click)': 'onClick()',
}, },
styles: ` styles: `
@use '@taiga-ui/core/styles/taiga-ui-local' as taiga; @use '@taiga-ui/core/styles/taiga-ui-local' as taiga;
@@ -74,11 +75,20 @@ import { i18nPipe } from '@start9labs/shared'
:host { :host {
grid-template-columns: 1fr; grid-template-columns: 1fr;
&._new { &._new td {
background: var(--tui-background-neutral-1) !important; font-weight: bold;
color: var(--tui-text-primary);
&.checkbox {
box-shadow: inset 0.25rem 0 var(--tui-text-action);
}
} }
} }
tui-icon {
vertical-align: text-top;
}
button { button {
position: relative; position: relative;
} }
@@ -86,6 +96,7 @@ import { i18nPipe } from '@start9labs/shared'
td { td {
padding: 0.25rem; padding: 0.25rem;
vertical-align: top; vertical-align: top;
color: var(--tui-text-secondary);
} }
.checkbox { .checkbox {
@@ -98,11 +109,6 @@ import { i18nPipe } from '@start9labs/shared'
.checkbox { .checkbox {
@include taiga.fullsize(); @include taiga.fullsize();
@include taiga.transition(box-shadow);
&:has(:checked) {
box-shadow: inset 0.25rem 0 var(--tui-background-accent-1);
}
} }
.date { .date {
@@ -114,6 +120,7 @@ import { i18nPipe } from '@start9labs/shared'
font-weight: bold; font-weight: bold;
font-size: 1.2em; font-size: 1.2em;
display: flex; display: flex;
align-items: center;
gap: 0.5rem; gap: 0.5rem;
} }
@@ -121,6 +128,10 @@ import { i18nPipe } from '@start9labs/shared'
display: none; display: none;
} }
} }
:host-context(tui-root._mobile table:has(:checked)) tui-icon {
opacity: 0;
}
`, `,
imports: [CommonModule, RouterLink, TuiLineClamp, TuiLink, TuiIcon, i18nPipe], imports: [CommonModule, RouterLink, TuiLineClamp, TuiLink, TuiIcon, i18nPipe],
}) })
@@ -155,4 +166,14 @@ export class NotificationItemComponent {
getLink(id: string) { getLink(id: string) {
return toRouterLink(id) return toRouterLink(id)
} }
onClick() {
if (this.overflow) {
this.service.viewModal(this.notificationItem, true)
this.notificationItem.seen = true
} else if ([1, 2].includes(this.notificationItem.code)) {
this.service.viewModal(this.notificationItem)
this.notificationItem.seen = true
}
}
} }

View File

@@ -38,10 +38,10 @@ import { NotificationsTableComponent } from './table.component'
tuiDropdownAlign="right" tuiDropdownAlign="right"
[tuiDropdown]="dropdown" [tuiDropdown]="dropdown"
[tuiDropdownEnabled]="!!table.selected().length" [tuiDropdownEnabled]="!!table.selected().length"
[style.margin-inline-start]="'auto'" [style.margin-inline-start.rem]="0.5"
[disabled]="!table.selected().length" [disabled]="!table.selected().length"
> >
{{ 'Batch action' | i18n }} {{ 'Actions' | i18n }}
<ng-template #dropdown let-close> <ng-template #dropdown let-close>
<tui-data-list (click)="close()"> <tui-data-list (click)="close()">
<button <button
@@ -130,7 +130,7 @@ export default class NotificationsComponent implements OnInit {
this.notifications.set( this.notifications.set(
current.map(c => ({ current.map(c => ({
...c, ...c,
read: toUpdate.some(n => n.id === c.id) || c.seen, seen: toUpdate.some(n => n.id === c.id) || c.seen,
})), })),
) )
@@ -144,7 +144,7 @@ export default class NotificationsComponent implements OnInit {
this.notifications.set( this.notifications.set(
current.map(c => ({ current.map(c => ({
...c, ...c,
read: c.seen && !toUpdate.some(n => n.id === c.id), seen: c.seen && !toUpdate.some(n => n.id === c.id),
})), })),
) )

View File

@@ -41,7 +41,7 @@ import { i18nPipe } from '@start9labs/shared'
@for (notification of notifications; track $index) { @for (notification of notifications; track $index) {
<tr <tr
[notificationItem]="notification" [notificationItem]="notification"
[style.font-weight]="notification.seen ? 'normal' : 'bold'" (longtap)="handleToggle(notification)"
> >
<input <input
tuiCheckbox tuiCheckbox
@@ -50,6 +50,7 @@ import { i18nPipe } from '@start9labs/shared'
[style.display]="'block'" [style.display]="'block'"
[ngModel]="selected().includes(notification)" [ngModel]="selected().includes(notification)"
(ngModelChange)="handleToggle(notification)" (ngModelChange)="handleToggle(notification)"
(click.stop)="(0)"
/> />
</tr> </tr>
} @empty { } @empty {
@@ -69,13 +70,17 @@ import { i18nPipe } from '@start9labs/shared'
</tbody> </tbody>
`, `,
styles: ` styles: `
@use '@taiga-ui/core/styles/taiga-ui-local' as taiga;
:host-context(tui-root._mobile) { :host-context(tui-root._mobile) {
margin: 0 -1rem; margin: 0 -1rem;
input { input {
@include taiga.fullsize(); position: absolute;
top: 0.875rem;
left: 1rem;
z-index: 1;
}
:host:not(:has(:checked)) input {
opacity: 0; opacity: 0;
} }
} }

View File

@@ -75,7 +75,6 @@ import { i18nPipe } from '@start9labs/shared'
:host { :host {
position: relative; position: relative;
font-size: 1rem; font-size: 1rem;
overflow: hidden;
} }
:host-context(tui-root._mobile) { :host-context(tui-root._mobile) {

View File

@@ -93,14 +93,13 @@ export class NotificationService {
} }
} }
viewModal( viewModal(notification: ServerNotification<number>, full = false) {
{ data, createdAt, code, title, message }: ServerNotification<number>, const { data, createdAt, code, title, message } = notification
full = false,
) {
const label = code === 1 ? 'Backup Report' : (title as i18nKey) const label = code === 1 ? 'Backup Report' : (title as i18nKey)
const component = code === 1 ? REPORT : MARKDOWN const component = code === 1 ? REPORT : MARKDOWN
const content = code === 1 ? data : of(data) const content = code === 1 ? data : of(data)
this.markSeen([notification])
this.dialogs this.dialogs
.openComponent(full ? message : component, { .openComponent(full ? message : component, {
label, label,