Skip to content

Commit

Permalink
support inverseTypeName of AlgoRelationTypes (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
salmma authored Jun 22, 2021
1 parent d962176 commit 527f355
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 21 deletions.
2 changes: 1 addition & 1 deletion generated/api-atlas/models/algorithm-relation-dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export type AlgorithmRelationDto = {
sourceAlgorithmId: string;
targetAlgorithmId: string;
description?: string;
algoRelationType: AlgorithmRelationTypeDto;
algorithmRelationType: AlgorithmRelationTypeDto;
};
6 changes: 5 additions & 1 deletion generated/api-atlas/models/algorithm-relation-type-dto.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
/* tslint:disable */
export type AlgorithmRelationTypeDto = { id: string; name: string };
export type AlgorithmRelationTypeDto = {
id: string;
name: string;
inverseTypeName?: string;
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import { AddOrEditAlgorithmRelationTypeDialogComponent } from '../dialogs/add-or
})
export class AlgorithmRelationTypesListComponent implements OnInit {
algorithmRelationTypes: any[] = [];
tableColumns = ['Name'];
variableNames = ['name'];
tableColumns = ['Name', 'Inverse Type Name'];
variableNames = ['name', 'inverseTypeName'];
pagingInfo: any = {};
paginatorConfig: any = {
amountChoices: [10, 25, 50],
Expand Down Expand Up @@ -68,6 +68,7 @@ export class AlgorithmRelationTypesListComponent implements OnInit {
const algorithmRelationType: AlgorithmRelationTypeDto = {
id: undefined,
name: dialogResult.name,
inverseTypeName: dialogResult.inverseTypeName,
};

params.body = algorithmRelationType;
Expand Down Expand Up @@ -167,6 +168,7 @@ export class AlgorithmRelationTypesListComponent implements OnInit {
title: 'Edit algorithm relation type',
id: event.id,
name: event.name,
inverseTypeName: event.inverseTypeName,
}
);

Expand All @@ -175,6 +177,7 @@ export class AlgorithmRelationTypesListComponent implements OnInit {
const updatedAlgorithmRelationType: AlgorithmRelationTypeDto = {
id: dialogResult.id,
name: dialogResult.name,
inverseTypeName: dialogResult.inverseTypeName,
};

const params: any = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ <h1 mat-dialog-title>{{data.title}}</h1>
<input formControlName="algorithmRelationTypeName" matInput required/>
</label>
</mat-form-field>
<mat-form-field class="input-field">
<mat-label>Inverse Type Name</mat-label>
<label>
<input formControlName="inverseAlgorithmRelationTypeName" matInput/>
</label>
</mat-form-field>
</form>
</div>
<div mat-dialog-actions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ export class AddOrEditAlgorithmRelationTypeDialogComponent implements OnInit {
return this.algorithmRelationTypeFormGroup.get('algorithmRelationTypeName');
}

get inverseAlgorithmRelationTypeName(): AbstractControl | null {
return this.algorithmRelationTypeFormGroup.get(
'inverseAlgorithmRelationTypeName'
);
}

onNoClick(): void {
this.dialogRef.close();
}
Expand All @@ -37,10 +43,18 @@ export class AddOrEditAlgorithmRelationTypeDialogComponent implements OnInit {
Validators.required,
Validators.maxLength(255),
]),
inverseAlgorithmRelationTypeName: new FormControl(
this.data.inverseTypeName,
[
// eslint-disable-next-line @typescript-eslint/unbound-method
Validators.maxLength(255),
]
),
});

this.dialogRef.beforeClosed().subscribe(() => {
this.data.name = this.algorithmRelationTypeName.value;
this.data.inverseTypeName = this.inverseAlgorithmRelationTypeName.value;
});
}

Expand All @@ -53,4 +67,5 @@ export interface DialogData {
title: string;
id: string;
name: string;
inverseTypeName: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,13 @@ export class AlgorithmRelatedAlgosListComponent implements OnInit {
) {
event.queryParams.page--;
}
this.getAlgorithmRelations(event.queryParams);
this.getAlgorithmRelations({
algorithmId: this.algorithm.id,
search: event.queryParams.search,
page: event.queryParams.page,
size: event.queryParams.size,
sort: event.queryParams.sort,
});
snackbarMessages.push(
this.utilService.generateFinishingSnackbarMessage(
successfulUnlinks,
Expand Down Expand Up @@ -325,8 +331,8 @@ export class AlgorithmRelatedAlgosListComponent implements OnInit {
description: relation.description,
targetAlgName: algorithm.name,
targetAlgObject: algorithm,
relationTypeName: relation.algoRelationType.name,
relationTypeObject: relation.algoRelationType,
relationTypeName: relation.algorithmRelationType.name,
relationTypeObject: relation.algorithmRelationType,
});
});
}
Expand All @@ -341,14 +347,14 @@ export class AlgorithmRelatedAlgosListComponent implements OnInit {
id: string,
sourceAlgorithm: AlgorithmDto,
targetAlgorithm: AlgorithmDto,
algoRelationType: AlgorithmRelationTypeDto,
algorithmRelationType: AlgorithmRelationTypeDto,
description: string
): AlgorithmRelationDto {
return {
id,
sourceAlgorithmId: sourceAlgorithm.id,
targetAlgorithmId: targetAlgorithm.id,
algoRelationType,
algorithmRelationType,
description,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h1 mat-dialog-title>{{data.title}}</h1>
<mat-autocomplete #relationType="matAutocomplete" (optionSelected)="setRelationType($event.option.value)" [displayWith]="displayRelation">
<mat-optgroup *ngFor="let stateGroup of stateGroups" [label]="stateGroup.optionName">
<mat-option
*ngFor="let type of stateGroup.algoRelationTypes"
*ngFor="let type of stateGroup.algorithmRelationTypes"
[value]="type"
(click)="setRelationType(type)">
{{type.name}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import { AlgorithmRelationTypeDto } from 'api-atlas/models';
export class AddAlgorithmRelationDialogComponent implements OnInit {
algorithmRelationForm: FormGroup;
stateGroups: StateGroup[] = [];
algoRelationTypes: AlgorithmRelationTypeDto[] = [];
algorithmRelationTypes: AlgorithmRelationTypeDto[] = [];
linkableAlgorithms: AlgorithmDto[] = [];
selectedAlgorithm: AlgorithmDto;
isUpdateDialog = false;

constructor(
private algorithmService: AlgorithmService,
private algoRelationTypeService: AlgorithmRelationTypeService,
private algorithmRelationTypeService: AlgorithmRelationTypeService,
public dialogRef: MatDialogRef<AddAlgorithmRelationDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: DialogData
) {}
Expand Down Expand Up @@ -60,15 +60,15 @@ export class AddAlgorithmRelationDialogComponent implements OnInit {
}

// Init list of available relation types
this.algoRelationTypeService
this.algorithmRelationTypeService
.getAlgorithmRelationTypes()
.subscribe((relationTypes) => {
this.algoRelationTypes = relationTypes.content
this.algorithmRelationTypes = relationTypes.content
? relationTypes.content
: [];
this.stateGroups.push({
optionName: 'Existing Algorithm-Relations',
algoRelationTypes: this.algoRelationTypes,
algorithmRelationTypes: this.algorithmRelationTypes,
});
// Set filtered Types if update-dialog
if (this.isUpdateDialog) {
Expand All @@ -89,7 +89,7 @@ export class AddAlgorithmRelationDialogComponent implements OnInit {
filterTypes(type: string): void {
this.stateGroups[
this.stateGroups.length - 1
].algoRelationTypes = this.algoRelationTypes.filter(
].algorithmRelationTypes = this.algorithmRelationTypes.filter(
(filterType) =>
filterType.name.toLowerCase().indexOf(type.toLowerCase()) === 0
);
Expand All @@ -106,7 +106,7 @@ export class AddAlgorithmRelationDialogComponent implements OnInit {
}

findObjectByName(name): AlgorithmRelationTypeDto {
const foundType = this.algoRelationTypes.find((x) => x.name === name);
const foundType = this.algorithmRelationTypes.find((x) => x.name === name);
return foundType ? foundType : { id: null, name };
}

Expand Down Expand Up @@ -200,7 +200,7 @@ export class AddAlgorithmRelationDialogComponent implements OnInit {
// Filter existing types
this.filterTypes(searchType.name);
// Return Type from Input if it exists
const existingRelationType = this.algoRelationTypes.find(
const existingRelationType = this.algorithmRelationTypes.find(
(x) => x.name === searchType.name
);

Expand All @@ -210,7 +210,7 @@ export class AddAlgorithmRelationDialogComponent implements OnInit {
if (this.algoTypesNotEmpty() || this.isFirstTypeNew()) {
this.pushNewRelationType(searchType);
} else if (!this.isFirstTypeNew()) {
this.stateGroups[0].algoRelationTypes[0] = searchType;
this.stateGroups[0].algorithmRelationTypes[0] = searchType;
}
} else {
if (!this.isFirstTypeNew()) {
Expand All @@ -222,7 +222,7 @@ export class AddAlgorithmRelationDialogComponent implements OnInit {
pushNewRelationType(type): void {
this.stateGroups.unshift({
optionName: 'New Algorithm-Relation',
algoRelationTypes: [type],
algorithmRelationTypes: [type],
});
}

Expand All @@ -249,5 +249,5 @@ export interface DialogData {

export interface StateGroup {
optionName: string;
algoRelationTypes: AlgorithmRelationTypeDto[];
algorithmRelationTypes: AlgorithmRelationTypeDto[];
}

0 comments on commit 527f355

Please sign in to comment.