File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
projects/saas-ui/src/app/main/components/add-plan Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -189,25 +189,40 @@ <h3>Plan Configuration</h3>
189
189
>
190
190
< div class ="feature-details ">
191
191
< span class ="feature-name "> {{ feature.name }}</ span >
192
+ <!-- for boolean -->
192
193
< div class ="feature-input ">
193
194
< nb-toggle
194
195
*ngIf ="feature.type === 'boolean' "
195
196
[formControlName] ="feature.key "
196
197
> </ nb-toggle >
198
+ <!-- for number -->
197
199
< input
198
200
*ngIf ="feature.type === 'number' "
199
201
nbInput
200
202
type ="number "
201
203
[formControlName] ="feature.key "
202
204
placeholder ="{{ feature.name }} "
203
205
/>
206
+ <!-- for conditional metadata handling -->
207
+ < select
208
+ *ngIf ="feature.metadata "
209
+ [formControlName] ="feature.key "
210
+ >
211
+ < option
212
+ *ngFor ="let option of feature.metadata "
213
+ [value] ="option "
214
+ >
215
+ {{ option }}
216
+ </ option >
217
+ </ select >
204
218
< input
205
- *ngIf ="feature.type === 'string' "
219
+ *ngIf ="!feature.metadata && feature.type === 'string' "
206
220
nbInput
207
221
type ="text "
208
222
[formControlName] ="feature.key "
209
223
placeholder ="{{ feature.name }} "
210
224
/>
225
+ <!-- for object -->
211
226
< textarea
212
227
*ngIf ="feature.value_type === 'object' "
213
228
nbInput
@@ -232,7 +247,7 @@ <h3>Plan Configuration</h3>
232
247
>
233
248
Cancel
234
249
</ button >
235
-
250
+
236
251
< button
237
252
nbButton
238
253
size ="medium "
Original file line number Diff line number Diff line change @@ -183,7 +183,7 @@ export class AddPlanComponent implements OnInit {
183
183
) ;
184
184
break ;
185
185
case 'string' :
186
- control = new FormControl ( ) ;
186
+ control = new FormControl ( feature . defaultValue || '' ) ;
187
187
break ;
188
188
case 'object' :
189
189
control = new FormControl ( ) ;
@@ -374,6 +374,12 @@ export class AddPlanComponent implements OnInit {
374
374
getFeatures ( ) {
375
375
this . featureListService . getFeatures ( ) . subscribe ( res => {
376
376
this . featureOption = res ;
377
+ // error handling
378
+ this . featureOption . forEach ( feature => {
379
+ if ( feature . metadata ) {
380
+ feature . metadata = feature . metadata . split ( ',' ) ;
381
+ }
382
+ } ) ;
377
383
this . createFeatureControls ( ) ;
378
384
} ) ;
379
385
}
You can’t perform that action at this time.
0 commit comments