7
7
animationDuration =".5s " />
8
8
< p-toast />
9
9
< ng-container *ngIf ="!loading ">
10
- < p-toolbar styleClass ="mb-2 gap-2 ">
10
+ < p-toolbar *ngIf =" isAdmin " styleClass ="mb-2 gap-2 ">
11
11
< div class ="p-justify-end ">
12
12
< p-button
13
13
icon ="pi pi-plus "
24
24
[disabled] ="!selectedQuestions || !selectedQuestions.length " />
25
25
</ div >
26
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] =" { 'table-layout': 'fixed' } "
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 >
42
- </ 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 >
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 " >
65
+ < p-button
66
+ label =" Edit "
67
+ severity =" primary "
68
+ icon =" pi pi-file-edit "
69
+ class =" mr-2 "
70
+ [text] =" true "
71
+ (onClick) =" editQuestion(question) " />
72
+ </ td >
73
+ </ tr >
74
+ </ ng-template >
75
+ </ p-table >
76
+ </ div >
77
77
</ ng-container >
78
78
< app-question-dialog
79
79
[isDialogVisible] ="isDialogVisible "
@@ -85,4 +85,18 @@ <h3 class="m-0">Manage Questions</h3>
85
85
(successfulRequest) ="onSuccessfulRequest($event) ">
86
86
</ app-question-dialog >
87
87
< p-confirmDialog [style] ="{ width: '450px' } " />
88
+ < div class ="sliding-panel " [class.open] ="isPanelVisible ">
89
+ < div class ="panel-header ">
90
+ < h4 > {{ clickedOnQuestion?.title }}</ h4 >
91
+ < p-button
92
+ icon ="pi pi-times "
93
+ severity ="secondary "
94
+ label ="Close "
95
+ (onClick) ="closePanel() "
96
+ class ="p-button-text " />
97
+ </ div >
98
+ < div class ="panel-content ">
99
+ < p style ="white-space: pre-wrap "> {{ clickedOnQuestion?.description }}</ p >
100
+ </ div >
101
+ </ div >
88
102
</ div >
0 commit comments