-
Notifications
You must be signed in to change notification settings - Fork 0
/
common-wrapper.component.ts
51 lines (49 loc) · 1.69 KB
/
common-wrapper.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
import { MessageInterface } from '@angular-monorepo/shared/util-common';
import { CardComponent } from '../card/card.component';
import { MessagesComponent } from '../messages/messages.component';
import { ProgressSpinnerComponent } from '../progress-spinner/progress-spinner.component';
@Component({
selector: 'common-common-wrapper',
standalone: true,
imports: [
CardComponent,
MessagesComponent,
ProgressSpinnerComponent,
],
template: `
<common-card [header]="header()">
@if(messages().length > 0) {
<div data-testid="messages">
<common-messages [messages]="messages()">
</common-messages>
</div>
}
@if(showContent() && !isLoading()) {
<!-- THE CONTENT OF THE COMPONENT THAT IS WRAPPED -->
<ng-content></ng-content>
}
@if(showContent() && !isLoading() && noData()) {
<div data-testid="no-data" class="flex justify-content-center">
<span class="p-3">No data</span>
</div>
}
@if(isLoading()) {
<div class="flex justify-content-center" data-testid="loading">
<common-progress-spinner [loadingMessage]="loadingMessage()">
</common-progress-spinner>
</div>
}
</common-card>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CommonWrapperComponent {
messages = input<MessageInterface[]>([]);
showContent = input<boolean>(true);
isLoading = input<boolean>(false);
loadingMessage = input<string>('');
lastMessagesAmount = input<number>(5);
header = input<string | undefined>(undefined);
noData = input<boolean>(false);
}