@@ -86,15 +86,15 @@ <h3 class="m-0">Manage Questions</h3>
86
86
< div class ="field grid col-12 ">
87
87
< label for ="title "> Title</ label >
88
88
< input
89
- formControlName ="textTitle "
89
+ formControlName ="title "
90
90
type ="text "
91
91
pInputText
92
92
id ="title "
93
93
required
94
94
class ="text-base text-color surface-overlay p-2 border-1 border-solid surface-border border-round appearance-none outline-none focus:border-primary w-full " />
95
- < small class =" p-error " *ngIf =" submitted && (question.title === undefined || !question.title) " >
96
- Title is required.
97
- </ small >
95
+ @if (isTitleInvalid) {
96
+ < small class =" text-red-300 " > Title is required.</ small >
97
+ }
98
98
</ div >
99
99
< div class ="formgrid grid field ">
100
100
< div class ="field col-12 md:col-6 ">
@@ -107,11 +107,9 @@ <h3 class="m-0">Manage Questions</h3>
107
107
optionLabel ="label "
108
108
optionValue ="value "
109
109
placeholder ="Select Topics " />
110
- < small
111
- class ="p-error "
112
- *ngIf ="submitted && (question.topics === undefined || question.topics.length === 0) ">
113
- Topic is required.
114
- </ small >
110
+ @if (isTopicsInvalid) {
111
+ < small class ="text-red-300 "> Topic(s) is required.</ small >
112
+ }
115
113
</ div >
116
114
< div class ="field col-12 md:col-6 ">
117
115
< label for ="questionTopics "> Difficulty</ label >
@@ -123,34 +121,34 @@ <h3 class="m-0">Manage Questions</h3>
123
121
optionLabel ="label "
124
122
optionValue ="value "
125
123
placeholder ="Select Difficulty " />
126
- < small
127
- class ="p-error "
128
- *ngIf ="submitted && (question.difficulty === undefined || !question.difficulty) ">
129
- Difficulty is required.
130
- </ small >
124
+ @if (isDifficultyInvalid) {
125
+ < small class ="text-red-300 "> Difficulty is required.</ small >
126
+ }
131
127
</ div >
132
128
</ div >
133
129
< div class ="field grid col-12 " field >
134
130
< label for ="questionDescription "> Description</ label >
135
131
< textarea
136
- formControlName ="textDescription "
132
+ formControlName ="description "
137
133
[required] ="true "
138
134
id ="questionDescription "
139
135
type ="text "
140
136
rows ="6 "
141
137
class ="text-base text-color surface-overlay p-2 border-1 border-solid surface-border border-round appearance-none outline-none focus:border-primary w-full ">
142
138
</ textarea >
143
- < small
144
- class ="p-error "
145
- *ngIf ="submitted && (question.description === undefined || !question.description) ">
146
- Description is required.
147
- </ small >
139
+ @if (isDescriptionInvalid) {
140
+ < small class ="text-red-300 "> Description is required.</ small >
141
+ }
148
142
</ div >
149
143
</ form >
150
144
151
145
< ng-template pTemplate ="footer ">
152
146
< p-button label ="Cancel " [text] ="true " severity ="secondary " (onClick) ="isDialogVisible = false " />
153
- < p-button label ="Save " class ="p-button-success " (onClick) ="saveQuestion() " />
147
+ < p-button
148
+ label ="Save "
149
+ class ="p-button-success "
150
+ (onClick) ="saveQuestion() "
151
+ [disabled] ="!questionFormGroup.valid " />
154
152
</ ng-template >
155
153
</ p-dialog >
156
154
0 commit comments