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