Skip to content

Commit 9d49045

Browse files
committed
[DURACOM-235] improvement of redirects logic
1 parent be45231 commit 9d49045

2 files changed

Lines changed: 8 additions & 19 deletions

File tree

src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ export class ComColFormComponent<T extends Collection | Community> implements On
9191
@Output() submitForm: EventEmitter<{
9292
dso: T,
9393
operations: Operation[],
94-
uploader?: FileUploader,
95-
deleteLogo?: boolean,
94+
uploader?: FileUploader
9695
}> = new EventEmitter();
9796

9897
/**
@@ -210,17 +209,15 @@ export class ComColFormComponent<T extends Collection | Community> implements On
210209
}
211210
});
212211

213-
if (!this.isCreation) {
212+
if (this.isCreation) {
214213
this.submitForm.emit({
215214
dso: updatedDSO,
215+
uploader: hasValue(this.uploaderComponent) ? this.uploaderComponent.uploader : undefined,
216216
operations: operations,
217217
});
218-
this.finish.emit();
219218
} else {
220219
this.submitForm.emit({
221220
dso: updatedDSO,
222-
deleteLogo: false,
223-
uploader: hasValue(this.uploaderComponent) ? this.uploaderComponent.uploader : undefined,
224221
operations: operations,
225222
});
226223
}
@@ -262,6 +259,7 @@ export class ComColFormComponent<T extends Collection | Community> implements On
262259
modalRef.componentInstance.cancelLabel = 'form.cancel';
263260
modalRef.componentInstance.confirmLabel = 'community-collection.edit.logo.delete.title';
264261
modalRef.componentInstance.confirmIcon = 'fas fa-trash';
262+
modalRef.componentInstance.brandColor = 'danger';
265263
return modalRef;
266264
}
267265

src/app/shared/comcol/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { RemoteData } from '../../../../../core/data/remote-data';
55
import { ActivatedRoute, Router } from '@angular/router';
66
import { map, take } from 'rxjs/operators';
77
import { getFirstCompletedRemoteData, getFirstSucceededRemoteData } from '../../../../../core/shared/operators';
8-
import { hasValue, isEmpty } from '../../../../empty.util';
8+
import { isEmpty } from '../../../../empty.util';
99
import { ResourceType } from '../../../../../core/shared/resource-type';
1010
import { ComColDataService } from '../../../../../core/data/comcol-data.service';
1111
import { NotificationsService } from '../../../../notifications/notifications.service';
@@ -50,29 +50,20 @@ export class ComcolMetadataComponent<TDomain extends Community | Collection> imp
5050
* @param event The event returned by the community/collection form. Contains the new dso and logo uploader
5151
*/
5252
onSubmit(event) {
53-
54-
const uploader = event.uploader;
55-
const deleteLogo = event.deleteLogo;
56-
57-
const newLogo = hasValue(uploader) && uploader.queue.length > 0;
58-
if (newLogo) {
59-
this.dsoDataService.getLogoEndpoint(event.dso.uuid).pipe(take(1)).subscribe((href: string) => {
60-
uploader.options.url = href;
61-
uploader.uploadAll();
62-
});
63-
}
64-
6553
if (!isEmpty(event.operations)) {
6654
this.dsoDataService.patch(event.dso, event.operations).pipe(getFirstCompletedRemoteData())
6755
.subscribe(async (response: RemoteData<DSpaceObject>) => {
6856
if (response.hasSucceeded) {
57+
await this.router.navigate([this.frontendURL + event.dso.uuid]);
6958
this.notificationsService.success(null, this.translate.get(`${this.type.value}.edit.notifications.success`));
7059
} else if (response.statusCode === 403) {
7160
this.notificationsService.error(null, this.translate.get(`${this.type.value}.edit.notifications.unauthorized`));
7261
} else {
7362
this.notificationsService.error(null, this.translate.get(`${this.type.value}.edit.notifications.error`));
7463
}
7564
});
65+
} else {
66+
this.router.navigate([this.frontendURL + event.dso.uuid]);
7667
}
7768
}
7869

0 commit comments

Comments
 (0)