in frontend/src/app/modules/migrations/components/create-migration/create-migration.component.ts [153:186]
onSubmit() {
this.formHasErrors = this.getFormValidationErrors();
if (this.formHasErrors) return;
delete this.migrationForm.value.id;
if (this.isEditing) {
if (!this.currentId) return;
this.migrationService.updateMigrationProject(this.currentId , this.migrationForm.value)
.subscribe(
(resp:Migration) => {
this.migrationForm.setValue(resp);
this.openSnackBar(this.notificationService.GENERAL_SUCCESS_MESSAGE);
this.migrationService.getAndStoreMigrationsProjects();
this.router.navigateByUrl(`/mymigrationprojects/view/${this.currentId}`);
},
(error) => {
this.openSnackBar(error);
}
)
} else {
this.migrationService.createMigrationProject(this.migrationForm.value)
.subscribe(
(resp: Migration) => {
this.openSnackBar(this.notificationService.GENERAL_SUCCESS_MESSAGE);
localStorage.setItem('currentProjectId' , String(resp.id));
window.dispatchEvent( new Event('storage'));
this.migrationService.getAndStoreMigrationsProjects();
this.router.navigateByUrl(`/softwarelibrary`);
},
(error) => {
this.openSnackBar(error);
}
)
}
}