1
1
< div class ="card mx-8 ">
2
- < p-progressSpinner
3
- class ="flex align-items-center justify-content-center h-screen "
4
- *ngIf ="loading "
5
- styleClass ="w-4rem h-4rem "
6
- strokeWidth ="8 "
7
- animationDuration =".5s " />
8
- < p-toast />
9
- < ng-container *ngIf ="!loading ">
10
- < p-toolbar *ngIf ="isAdmin " styleClass ="mt-4 mb-2 gap-2 ">
11
- < div class ="p-justify-end ">
12
- < p-button
13
- icon ="pi pi-plus "
14
- severity ="primary "
15
- [outlined] ="true "
16
- label ="New "
17
- class ="mr-2 "
18
- (onClick) ="openNewQuestion() " />
19
- < p-button
20
- icon ="pi pi-trash "
21
- severity ="danger "
22
- label ="Delete "
23
- (onClick) ="deleteSelectedQuestions() "
24
- [disabled] ="!selectedQuestions || !selectedQuestions.length " />
25
- </ div >
26
- </ p-toolbar >
27
- < div class ="table-container " style ="max-width: 1000px; margin: 0 auto ">
28
- < p-table
29
- sortField ="id "
30
- [sortOrder] ="1 "
31
- [columns] ="cols "
32
- [value] ="questions "
33
- [(selection)] ="selectedQuestions "
34
- datakey ="id "
35
- [tableStyle] ="{ 'table-layout': 'fixed', width: '100%', 'text-align': 'center' } "
36
- [paginator] ="true "
37
- [rows] ="10 "
38
- [rowsPerPageOptions] ="[10, 25, 50] "
39
- styleClass ="p-datatable-gridlines-striped ">
40
- < ng-template pTemplate ="caption ">
41
- < div class ="flex ">
42
- < h3 class ="m-0 "> Questions</ h3 >
43
- </ div >
44
- </ ng-template >
45
- < ng-template pTemplate ="header " let-columns >
46
- < tr >
47
- < th *ngIf ="isAdmin " style ="width: 5% "> < p-tableHeaderCheckbox /> </ th >
48
- < th pSortableColumn ="id " style ="width: 5% "> Id < p-sortIcon field ="id " /> </ th >
49
- < th style ="width: 20% "> Title</ th >
50
- < th style ="width: 20% "> Topics</ th >
51
- < th style ="width: 7% "> Difficulty</ th >
52
- < th *ngIf ="isAdmin " style ="width: 6% "> </ th >
53
- </ tr >
54
- </ ng-template >
55
- < ng-template pTemplate ="body " let-question >
56
- < tr (click) ="onRowSelect(question) ">
57
- < td *ngIf ="isAdmin ">
58
- < p-tableCheckbox [value] ="question " />
59
- </ td >
60
- < td > {{ question.id }}</ td >
61
- < td > {{ question.title }}</ td >
62
- < td > {{ question.topics.join(', ') }}</ td >
63
- < td > {{ question.difficulty }}</ td >
64
- < td *ngIf ="isAdmin ">
2
+ @if (loading) {
3
+ < p-progressSpinner
4
+ class ="flex align-items-center justify-content-center h-screen "
5
+ styleClass ="w-4rem h-4rem "
6
+ strokeWidth ="8 "
7
+ animationDuration =".5s " />
8
+ < p-toast />
9
+ } @else {
10
+ < ng-container >
11
+ < div [ngStyle] ="isAdmin ? {'max-width': '1150px', 'margin': '0 auto'} : {'max-width': '900px', 'margin': '0 auto'} ">
12
+ @if (isAdmin) {
13
+ < p-toolbar styleClass ="mt-4 mb-2 gap-2 ">
14
+ < div class ="p-justify-end ">
65
15
< p-button
66
- label =" Edit "
16
+ icon =" pi pi-plus "
67
17
severity ="primary "
68
- icon ="pi pi-file-edit "
18
+ [outlined] ="true "
19
+ label ="New "
69
20
class ="mr-2 "
70
- [text] ="true "
71
- (onClick) ="editQuestion(question) " />
72
- </ td >
73
- </ tr >
74
- </ ng-template >
75
- </ p-table >
76
- </ div >
77
- </ ng-container >
21
+ (onClick) ="openNewQuestion() "/>
22
+ < p-button
23
+ icon ="pi pi-trash "
24
+ severity ="danger "
25
+ label ="Delete "
26
+ (onClick) ="deleteSelectedQuestions() "
27
+ [disabled] ="!selectedQuestions || !selectedQuestions.length " />
28
+ </ div >
29
+ </ p-toolbar >
30
+ } @else {
31
+ < div style ="height: 50px; "> </ div >
32
+ }
33
+ < div class ="table-container ">
34
+ < p-table
35
+ sortField ="id "
36
+ [sortOrder] ="1 "
37
+ [columns] ="cols "
38
+ [value] ="questions "
39
+ [(selection)] ="selectedQuestions "
40
+ datakey ="id "
41
+ [tableStyle] ="{ 'table-layout': 'fixed', width: '100%', 'text-align': 'center' } "
42
+ [paginator] ="true "
43
+ [rows] ="10 "
44
+ [rowsPerPageOptions] ="[10, 25, 50] "
45
+ styleClass ="p-datatable-gridlines-striped ">
46
+ < ng-template pTemplate ="caption ">
47
+ < div class ="flex ">
48
+ < h3 class ="m-0 "> Questions</ h3 >
49
+ </ div >
50
+ </ ng-template >
51
+ < ng-template pTemplate ="header " let-columns >
52
+ < tr >
53
+ @if (isAdmin) {
54
+ < th style ="width: 10% "> < p-tableHeaderCheckbox /> </ th >
55
+ < th pSortableColumn ="id " style ="width: 13% "> Id< p-sortIcon field ="id " /> </ th >
56
+ < th style ="width: 27% "> Title</ th >
57
+ < th style ="width: 30% "> Topics</ th >
58
+ < th style ="width: 10% "> Difficulty</ th >
59
+ < th style ="width: 10% "> </ th >
60
+ } @else {
61
+ < th style ="width: 15% "> Id</ th >
62
+ < th style ="width: 35% "> Title</ th >
63
+ < th style ="width: 37% "> Topics</ th >
64
+ < th style ="width: 13% "> Difficulty</ th >
65
+ }
66
+ </ tr >
67
+ </ ng-template >
68
+ < ng-template pTemplate ="body " let-question >
69
+ < tr (click) ="onRowSelect(question) ">
70
+ @ if (isAdmin) {
71
+ < td > < p-tableCheckbox [value] ="question " /> </ td >
72
+ < td > {{ question.id }}</ td >
73
+ < td > {{ question.title }}</ td >
74
+ < td > {{ question.topics.join(', ') }}</ td >
75
+ < td > {{ question.difficulty }}</ td >
76
+ < td > < p-button
77
+ label ="Edit "
78
+ severity ="primary "
79
+ icon ="pi pi-file-edit "
80
+ class ="mr-2 "
81
+ [text] ="true "
82
+ (onClick) ="editQuestion(question) " />
83
+ </ td >
84
+ } @else {
85
+ < td > {{ question.id }}</ td >
86
+ < td > {{ question.title }}</ td >
87
+ < td > {{ question.topics.join(', ') }}</ td >
88
+ < td > {{ question.difficulty }}</ td >
89
+ }
90
+ </ tr >
91
+ </ ng-template >
92
+ </ p-table >
93
+ </ div >
94
+ </ div >
95
+ </ ng-container >
96
+ }
78
97
< app-question-dialog
79
98
[isDialogVisible] ="isDialogVisible "
80
99
[question] ="question "
@@ -99,4 +118,4 @@ <h4>{{ clickedOnQuestion?.title }}</h4>
99
118
< p style ="white-space: pre-wrap "> {{ clickedOnQuestion?.description }}</ p >
100
119
</ div >
101
120
</ div >
102
- </ div >
121
+ </ div >
0 commit comments