Commit 6557b8f5 authored by Alexander Philipp Nowosad's avatar Alexander Philipp Nowosad
Browse files

Add merge navigation if coming from select expert knowledge

parent 23287a48
......@@ -66,11 +66,14 @@ export class CompanyModelSelectExpertKnowledgeComponent
}
async mergeExpertModel(expertModelId: string): Promise<void> {
await this.router.navigate([
'/merge',
this.companyModel._id,
expertModelId,
]);
await this.router.navigate(
['/merge', this.companyModel._id, expertModelId],
{
queryParams: {
bmProcessId: this.bmProcess._id,
},
}
);
}
async selectExpertModel(): Promise<void> {
......
......@@ -196,7 +196,31 @@
</ng-template>
<div class="nav-scroller bg-white shadow-sm">
<nav class="nav nav-underline">
<nav class="nav nav-underline" *ngIf="bmProcessGiven && bmProcess != null">
<a
class="nav-link"
[routerLink]="['/', 'bmprocess', 'bmprocessview', bmProcess._id]"
>
{{ bmProcess.name }}
</a>
<a
*ngIf="companyModel"
class="nav-link"
[routerLink]="['/', 'companyModels', companyModel._id, 'select']"
[queryParams]="{ bmProcessId: this.bmProcess._id }"
>
{{ companyModel.name }}
</a>
<a
*ngIf="companyModel && expertModel"
class="nav-link active"
[routerLink]="[]"
[queryParams]="{ bmProcessId: this.bmProcess._id }"
>
Merge {{ expertModel.name }}
</a>
</nav>
<nav *ngIf="!bmProcessGiven" class="nav nav-underline">
<a class="nav-link" [routerLink]="['/', 'companyModels']">
Composed Models
</a>
......@@ -211,8 +235,9 @@
*ngIf="companyModel && expertModel"
class="nav-link active"
[routerLink]="[]"
>Merge {{ expertModel.name }}</a
>
Merge {{ expertModel.name }}
</a>
</nav>
</div>
......
......@@ -11,6 +11,8 @@ import { CompanyModelService } from '../../../canvas-meta-model/company-model.se
import { ExpertModelService } from '../../../canvas-meta-model/expert-model.service';
import { RelationshipType } from '../../../canvas-meta-model/relationships';
import { MergeService } from '../merge.service';
import { BmProcessService } from '../../../development-process-registry/bm-process/bm-process.service';
import { BmProcess } from '../../../development-process-registry/bm-process/bm-process';
@Component({
selector: 'app-merge-model-view',
......@@ -18,23 +20,27 @@ import { MergeService } from '../merge.service';
styleUrls: ['./merge-model-view.component.css'],
})
export class MergeModelViewComponent implements OnInit, OnDestroy {
@ViewChild('dependencyModal', { static: true }) dependencyModal: any;
@ViewChild('mergeModal', { static: true }) mergeModal: any;
@ViewChild('addAllModal', { static: true }) addAllModal: any;
@ViewChild('updateModal', { static: true }) updateModal: any;
@ViewChild('traceModal', { static: true }) traceModal: any;
@ViewChild('selectModal', { static: true }) selectModal: any;
@ViewChild('deleteModal', { static: true }) deleteModal: any;
@ViewChild('dependencyModal', { static: true }) dependencyModal: unknown;
@ViewChild('mergeModal', { static: true }) mergeModal: unknown;
@ViewChild('addAllModal', { static: true }) addAllModal: unknown;
@ViewChild('updateModal', { static: true }) updateModal: unknown;
@ViewChild('traceModal', { static: true }) traceModal: unknown;
@ViewChild('selectModal', { static: true }) selectModal: unknown;
@ViewChild('deleteModal', { static: true }) deleteModal: unknown;
expertModel: ExpertModel;
companyModel: CompanyModel;
bmProcessGiven = false;
bmProcess?: BmProcess;
companyFeatureList: { id: string; levelname: string }[] = [];
companyModelId: string;
expertModelId: string;
paramSubscription: Subscription;
private querySubscription: Subscription;
private paramSubscription: Subscription;
modalFeatureModel: FeatureModel;
modalFeature: Feature;
......@@ -48,6 +54,7 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
isFullyMerged = false;
constructor(
private bmProcessService: BmProcessService,
private fb: FormBuilder,
private mergeService: MergeService,
private modalService: NgbModal,
......@@ -56,7 +63,16 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
private route: ActivatedRoute
) {}
ngOnInit() {
ngOnInit(): void {
this.querySubscription = this.route.queryParamMap.subscribe((paramMap) => {
if (paramMap.has('bmProcessId')) {
this.bmProcessGiven = true;
void this.loadBmProcess(paramMap.get('bmProcessId'));
} else {
this.bmProcess = undefined;
this.bmProcessGiven = false;
}
});
this.paramSubscription = this.route.paramMap.subscribe((params) => {
this.companyModelId = params.get('companyModelId');
this.expertModelId = params.get('expertModelId');
......@@ -64,13 +80,20 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
});
}
ngOnDestroy() {
ngOnDestroy(): void {
if (this.querySubscription !== null) {
this.querySubscription.unsubscribe();
}
if (this.paramSubscription !== null) {
this.paramSubscription.unsubscribe();
}
}
async loadModels() {
async loadBmProcess(bmProcessId: string): Promise<void> {
this.bmProcess = await this.bmProcessService.get(bmProcessId);
}
async loadModels(): Promise<void> {
await Promise.all([this.loadExpertModel(), this.loadCompanyModel()]);
this.isFullyMerged = this.checkIsFullyMerged();
}
......@@ -79,7 +102,7 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
this.expertModel = await this.expertModelService.get(this.expertModelId);
}
async loadCompanyModel(): Promise<any> {
async loadCompanyModel(): Promise<void> {
const companyModel = await this.companyModelService.get(
this.companyModelId
);
......@@ -102,15 +125,15 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
this.companyFeatureList = companyModel.getFeatureList();
}
openDependenciesModalExpertModel(featureId: string) {
openDependenciesModalExpertModel(featureId: string): void {
this.openDependenciesModal(this.expertModel, featureId);
}
openDependenciesModalCompanyModel(featureId: string) {
openDependenciesModalCompanyModel(featureId: string): void {
this.openDependenciesModal(this.companyModel, featureId);
}
openDependenciesModal(featureModel: FeatureModel, featureId: string) {
openDependenciesModal(featureModel: FeatureModel, featureId: string): void {
const feature = featureModel.getFeature(featureId);
this.modalFeatureModel = featureModel;
this.modalFeature = feature;
......@@ -119,7 +142,7 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
});
}
openTraceModal(featureId) {
openTraceModal(featureId): void {
this.modalFeatureModel = this.companyModel;
this.modalFeature = this.companyModel.getFeature(featureId);
this.modalTracedFeature = this.expertModel.getFeature(
......@@ -130,7 +153,7 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
});
}
openExpertTraceModal(featureId) {
openExpertTraceModal(featureId): void {
this.modalFeatureModel = this.expertModel;
this.modalFeature = this.expertModel.getFeature(featureId);
this.modalTracedFeature = this.companyModel.getFeature(
......@@ -142,7 +165,7 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
});
}
openMergeModal(featureId: string) {
openMergeModal(featureId: string): void {
const expertFeature = this.expertModel.getFeature(featureId);
const parentId =
this.companyModel.expertModelTraces[this.expertModelId]
......@@ -165,7 +188,7 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
});
}
openAddAllModal(featureId: string) {
openAddAllModal(featureId: string): void {
this.modalFeature = featureId
? this.expertModel.getFeature(featureId)
: null;
......@@ -174,7 +197,7 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
});
}
openSelectModal(featureId: string) {
openSelectModal(featureId: string): void {
this.modalFeature = this.expertModel.getFeature(featureId);
this.modalSubfeatureIds = this.companyModel
.getFeature(
......@@ -197,14 +220,14 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
});
}
openDeleteFeatureModal(featureId: string) {
openDeleteFeatureModal(featureId: string): void {
this.modalFeature = this.companyModel.getFeature(featureId);
this.modalReference = this.modalService.open(this.deleteModal, {
size: 'lg',
});
}
openUpdateFeatureModal(featureId: string) {
openUpdateFeatureModal(featureId: string): void {
const feature = this.companyModel.getFeature(featureId);
this.modalFeature = feature;
this.modalSubfeatureIds = feature.getAllSubfeatures().map((f) => f.id);
......@@ -217,13 +240,13 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
/**
* Closes the current modal.
*/
async closeModal() {
async closeModal(): Promise<void> {
this.modalReference.close();
this.modalFeature = null;
await this.loadModels();
}
async mergeFeature(featureForm: FormGroup) {
async mergeFeature(featureForm: FormGroup): Promise<void> {
await this.mergeService.addFeatureMerge(
this.companyModelId,
featureForm.value,
......@@ -234,7 +257,7 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
await this.closeModal();
}
async addAll(featureId: string) {
async addAll(featureId: string): Promise<void> {
await this.mergeService.addAllSubfeaturesMerge(
this.companyModelId,
this.expertModelId,
......@@ -243,7 +266,7 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
await this.closeModal();
}
async mergeIntoSelected() {
async mergeIntoSelected(): Promise<void> {
await this.mergeService.addTrace(
this.companyModelId,
this.modalSelectFeatureForm.value.feature,
......@@ -253,7 +276,7 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
await this.closeModal();
}
async deleteTrace() {
async deleteTrace(): Promise<void> {
if (this.modalFeatureModel === this.companyModel) {
await this.deleteCompanyTrace();
} else {
......@@ -261,7 +284,7 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
}
}
async deleteCompanyTrace() {
async deleteCompanyTrace(): Promise<void> {
await this.mergeService.deleteTrace(
this.companyModelId,
this.modalFeature.id,
......@@ -270,7 +293,7 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
await this.closeModal();
}
async deleteExpertTrace() {
async deleteExpertTrace(): Promise<void> {
await this.mergeService.deleteTrace(
this.companyModelId,
this.modalTracedFeature.id,
......@@ -279,7 +302,7 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
await this.closeModal();
}
async deleteFeature(featureId) {
async deleteFeature(featureId): Promise<void> {
await this.mergeService.deleteFeature(this.companyModelId, featureId);
await this.closeModal();
}
......@@ -288,7 +311,7 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
relationshipType: RelationshipType,
fromFeatureId: string,
toFeatureId: string
) {
): Promise<void> {
await this.mergeService.addRelationship(
this.companyModelId,
relationshipType,
......@@ -302,7 +325,7 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
relationshipType: RelationshipType,
fromId: string,
toId: string
) {
): Promise<void> {
await this.mergeService.removeRelationship(
this.companyModelId,
relationshipType,
......@@ -313,7 +336,7 @@ export class MergeModelViewComponent implements OnInit, OnDestroy {
this.modalFeature = this.companyModel.getFeature(this.modalFeature.id);
}
async updateFeature(featureForm: FormGroup) {
async updateFeature(featureForm: FormGroup): Promise<void> {
await this.mergeService.updateFeature(
this.companyModelId,
this.modalFeature.id,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment