Skip to content

Commit 7d7bb41

Browse files
committed
feat(GenericGroupConfig): enhance integration configuration handling and visibility logic
1 parent 23c7370 commit 7d7bb41

2 files changed

Lines changed: 32 additions & 9 deletions

File tree

frontend/src/app/app-module/conf/int-generic-group-config/int-generic-group-config.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101

102102
<ng-select *ngIf="integrationConfig.confDataType === 'select'"
103103
#options="ngModel"
104+
(change)="onChange($event, integrationConfig)"
104105
[items]="integrationConfig.confOptions"
105106
bindLabel="label"
106107
bindValue="value"

frontend/src/app/app-module/conf/int-generic-group-config/int-generic-group-config.component.ts

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export class IntGenericGroupConfigComponent implements OnInit, OnChanges, OnDest
221221

222222
tenantIsConfigValid(group: UtmModuleGroupType): boolean {
223223

224-
const required = group.moduleGroupConfigurations.filter(value => value.confRequired === true);
224+
const required = group.moduleGroupConfigurations.filter(value => value.confRequired === true && this.isVisible(value));
225225
const valid = required.filter(value => value.confValue !== null && value.confValue);
226226

227227
if (this.groupType === GroupTypeEnum.COLLECTOR) {
@@ -253,10 +253,18 @@ export class IntGenericGroupConfigComponent implements OnInit, OnChanges, OnDest
253253
const index = this.changes.keys
254254
.findIndex(value =>
255255
value.confName === integrationConfig.confName && value.groupId === integrationConfig.groupId);
256+
257+
const config = {
258+
...integrationConfig,
259+
confOptions: integrationConfig.confOptions ? JSON.stringify(integrationConfig.confOptions) : integrationConfig.confOptions,
260+
confVisibility: integrationConfig.confVisibility ? JSON.stringify(integrationConfig.confVisibility) :
261+
integrationConfig.confVisibility,
262+
};
263+
256264
if (index === -1) {
257-
this.changes.keys.push(integrationConfig);
265+
this.changes.keys.push(config);
258266
} else {
259-
this.changes.keys[index].confValue = integrationConfig.confValue;
267+
this.changes.keys[index].confValue = config.confValue;
260268
}
261269
// this.configValidChange.emit(this.tenantGroupConfigValid());
262270
}
@@ -392,12 +400,6 @@ export class IntGenericGroupConfigComponent implements OnInit, OnChanges, OnDest
392400
return this.changes.keys.some(change => change.groupId === id);
393401
}
394402

395-
396-
ngOnDestroy() {
397-
this.destroy$.next();
398-
this.destroy$.complete();
399-
}
400-
401403
isVisible(integrationConfig: UtmModuleGroupConfType): boolean {
402404

403405
if (!integrationConfig.confVisibility) {
@@ -409,4 +411,24 @@ export class IntGenericGroupConfigComponent implements OnInit, OnChanges, OnDest
409411
return group.moduleGroupConfigurations.some(c => c.confKey === integrationConfig.confVisibility.dependsOn
410412
&& integrationConfig.confVisibility.values.includes(c.confValue));
411413
}
414+
415+
onChange($event: { value: string; }, integrationConfig: UtmModuleGroupConfType) {
416+
417+
const group = this.groups.find(g => g.id === integrationConfig.groupId);
418+
419+
group.moduleGroupConfigurations.map(g => {
420+
if (g.confVisibility && g.confVisibility.dependsOn === integrationConfig.confKey
421+
&& $event.value !== g.confValue) {
422+
g.confValue = null;
423+
}
424+
});
425+
426+
console.log(this.groups);
427+
this.addChange(integrationConfig);
428+
}
429+
430+
ngOnDestroy() {
431+
this.destroy$.next();
432+
this.destroy$.complete();
433+
}
412434
}

0 commit comments

Comments
 (0)