Skip to content

Commit a2f8105

Browse files
authored
Merge pull request #84 from sourcefuse/GH-83
feat(arc-saas): adding new feature named identity feature
2 parents af46d61 + 5990297 commit a2f8105

File tree

3 files changed

+38
-10
lines changed

3 files changed

+38
-10
lines changed

projects/saas-ui/src/app/main/components/add-plan/add-plan.component.html

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,25 +189,49 @@ <h3>Plan Configuration</h3>
189189
>
190190
<div class="feature-details">
191191
<span class="feature-name">{{ feature.name }}</span>
192+
<!-- for boolean -->
192193
<div class="feature-input">
193194
<nb-toggle
194195
*ngIf="feature.type === 'boolean'"
195196
[formControlName]="feature.key"
196197
></nb-toggle>
198+
<!-- for number -->
197199
<input
198200
*ngIf="feature.type === 'number'"
199201
nbInput
200202
type="number"
201203
[formControlName]="feature.key"
202204
placeholder="{{ feature.name }}"
203205
/>
206+
<!-- for conditional metadata handling -->
207+
<div class="select">
208+
<nb-select
209+
*ngIf="
210+
feature.metadata && feature.metadata.length > 0
211+
"
212+
class="dropdown-wrapper"
213+
placeholder="Select your Choice"
214+
status="basic"
215+
[formControlName]="feature.key"
216+
>
217+
<nb-option
218+
*ngFor="let option of feature.metadata"
219+
[value]="option"
220+
>
221+
{{ option }}
222+
</nb-option>
223+
</nb-select>
224+
</div>
225+
226+
<!-- For string input when metadata is empty -->
204227
<input
205-
*ngIf="feature.type === 'string'"
228+
*ngIf="!feature.metadata && feature.type === 'string'"
206229
nbInput
207230
type="text"
208231
[formControlName]="feature.key"
209232
placeholder="{{ feature.name }}"
210233
/>
234+
<!-- for object -->
211235
<textarea
212236
*ngIf="feature.value_type === 'object'"
213237
nbInput
@@ -232,7 +256,7 @@ <h3>Plan Configuration</h3>
232256
>
233257
Cancel
234258
</button>
235-
259+
236260
<button
237261
nbButton
238262
size="medium"

projects/saas-ui/src/app/main/components/add-plan/add-plan.component.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export class AddPlanComponent implements OnInit {
183183
);
184184
break;
185185
case 'string':
186-
control = new FormControl();
186+
control = new FormControl(feature.defaultValue || '');
187187
break;
188188
case 'object':
189189
control = new FormControl();
@@ -273,7 +273,6 @@ export class AddPlanComponent implements OnInit {
273273
{} as {[key: string]: any},
274274
)
275275
: {};
276-
console.log(this.addPlanForm.value);
277276
const generalDetailsData = {
278277
name: domainData.name,
279278
billingCycleId: domainData.billingCycleId,
@@ -297,7 +296,6 @@ export class AddPlanComponent implements OnInit {
297296
)
298297
.map(key => {
299298
const feature = this.featureValue.features.find(f => f.id === key);
300-
console.log(feature);
301299
return {
302300
id: selectedFeatures[key].id,
303301
featureKey: feature.id,
@@ -308,15 +306,12 @@ export class AddPlanComponent implements OnInit {
308306
};
309307
})
310308
.filter(item => item.id !== null);
311-
console.log(updateFeatureDetails);
312309
this.featureListService
313310
.editFeatures(
314311
updateFeatureDetails,
315312
this.activateRoute.snapshot.params.id,
316313
)
317-
.subscribe(respFeature => {
318-
console.log(respFeature);
319-
});
314+
.subscribe(respFeature => {});
320315
} else {
321316
// Handle form validation errors if necessary
322317
console.error('Form is invalid');
@@ -374,6 +369,11 @@ export class AddPlanComponent implements OnInit {
374369
getFeatures() {
375370
this.featureListService.getFeatures().subscribe(res => {
376371
this.featureOption = res;
372+
this.featureOption.forEach(feature => {
373+
if (typeof feature.metadata === 'string') {
374+
feature.metadata = feature.metadata.split(',');
375+
}
376+
});
377377
this.createFeatureControls();
378378
});
379379
}

projects/saas-ui/src/app/shared/models/feature.model.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
import {AnyObject} from '@project-lib/core/api';
12
import {FeatureValues} from './feature-values.model';
23

34
export class Features {
5+
[x: string]: any;
46
id?: string;
57
name: string;
68
description: string;
79
key: string;
810
type: 'boolean' | 'number' | 'string' | 'object';
9-
defaultValue: any;
11+
defaultValue: 'boolean' | 'number' | 'string' | 'object';
12+
metadata?: any;
1013
value?: FeatureValues;
1114
constructor(data?: Partial<Features>) {
1215
this.id = data?.id;
@@ -16,5 +19,6 @@ export class Features {
1619
this.type = data.type;
1720
this.defaultValue = data.defaultValue;
1821
this.value = data.value;
22+
this.metadata = data?.metadata;
1923
}
2024
}

0 commit comments

Comments
 (0)