mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-16 22:43:03 +00:00
[DURACOM-235] Refactored creation in order to navigate to created object page
This commit is contained in:
@@ -6,6 +6,5 @@
|
|||||||
</div>
|
</div>
|
||||||
<ds-collection-form (submitForm)="onSubmit($event)"
|
<ds-collection-form (submitForm)="onSubmit($event)"
|
||||||
[isCreation]="true"
|
[isCreation]="true"
|
||||||
(back)="navigateToHome()"
|
(back)="navigateToHome()"></ds-collection-form>
|
||||||
(finish)="navigateToNewPage()"></ds-collection-form>
|
|
||||||
</div>
|
</div>
|
||||||
|
@@ -9,6 +9,5 @@
|
|||||||
</div>
|
</div>
|
||||||
<ds-community-form (submitForm)="onSubmit($event)"
|
<ds-community-form (submitForm)="onSubmit($event)"
|
||||||
[isCreation]="true"
|
[isCreation]="true"
|
||||||
(back)="navigateToHome()"
|
(back)="navigateToHome()"></ds-community-form>
|
||||||
(finish)="navigateToNewPage()"></ds-community-form>
|
|
||||||
</div>
|
</div>
|
||||||
|
@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
|
|||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { mergeMap, take } from 'rxjs/operators';
|
import { map, mergeMap, take, tap } from 'rxjs/operators';
|
||||||
import { ComColDataService } from '../../../../core/data/comcol-data.service';
|
import { ComColDataService } from '../../../../core/data/comcol-data.service';
|
||||||
import { CommunityDataService } from '../../../../core/data/community-data.service';
|
import { CommunityDataService } from '../../../../core/data/community-data.service';
|
||||||
import { RemoteData } from '../../../../core/data/remote-data';
|
import { RemoteData } from '../../../../core/data/remote-data';
|
||||||
@@ -16,6 +16,8 @@ import { RequestParam } from '../../../../core/cache/models/request-param.model'
|
|||||||
import { RequestService } from '../../../../core/data/request.service';
|
import { RequestService } from '../../../../core/data/request.service';
|
||||||
import { Collection } from '../../../../core/shared/collection.model';
|
import { Collection } from '../../../../core/shared/collection.model';
|
||||||
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
|
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
|
||||||
|
import { of } from 'rxjs/internal/observable/of';
|
||||||
|
import { getHomePageRoute } from '../../../../app-routing-paths';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component representing the create page for communities and collections
|
* Component representing the create page for communities and collections
|
||||||
@@ -83,33 +85,46 @@ export class CreateComColPageComponent<TDomain extends Collection | Community> i
|
|||||||
this.parentUUID$.pipe(
|
this.parentUUID$.pipe(
|
||||||
take(1),
|
take(1),
|
||||||
mergeMap((uuid: string) => {
|
mergeMap((uuid: string) => {
|
||||||
const params = uuid ? [new RequestParam('parent', uuid)] : [];
|
const params = uuid ? [new RequestParam('parent', uuid)] : [];
|
||||||
return this.dsoDataService.create(dso, ...params)
|
return this.dsoDataService.create(dso, ...params)
|
||||||
.pipe(getFirstSucceededRemoteDataPayload()
|
.pipe(getFirstSucceededRemoteDataPayload()
|
||||||
);
|
);
|
||||||
}))
|
}),
|
||||||
.subscribe((dsoRD: TDomain) => {
|
mergeMap((dsoRD: TDomain) => {
|
||||||
if (isNotUndefined(dsoRD)) {
|
if (isNotUndefined(dsoRD)) {
|
||||||
this.newUUID = dsoRD.uuid;
|
this.newUUID = dsoRD.uuid;
|
||||||
if (uploader.queue.length > 0) {
|
if (uploader.queue.length > 0) {
|
||||||
this.dsoDataService.getLogoEndpoint(this.newUUID).pipe(take(1)).subscribe((href: string) => {
|
return this.dsoDataService.getLogoEndpoint(this.newUUID).pipe(
|
||||||
uploader.options.url = href;
|
take(1),
|
||||||
uploader.uploadAll();
|
tap((href: string) => {
|
||||||
});
|
uploader.options.url = href;
|
||||||
|
uploader.onCompleteAll = () => {
|
||||||
|
this.navigateToNewPage();
|
||||||
|
this.notificationsService.success(null, this.translate.get(this.type.value + '.create.notifications.success'));
|
||||||
|
};
|
||||||
|
uploader.uploadAll();
|
||||||
|
}),
|
||||||
|
map(() => false)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
this.navigateToNewPage();
|
this.dsoDataService.refreshCache(dsoRD);
|
||||||
|
return of(true);
|
||||||
}
|
}
|
||||||
this.dsoDataService.refreshCache(dsoRD);
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
).subscribe((notify: boolean) => {
|
||||||
|
if (notify) {
|
||||||
|
this.navigateToNewPage();
|
||||||
this.notificationsService.success(null, this.translate.get(this.type.value + '.create.notifications.success'));
|
this.notificationsService.success(null, this.translate.get(this.type.value + '.create.notifications.success'));
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Navigate to home page
|
* Navigate to home page
|
||||||
*/
|
*/
|
||||||
navigateToHome() {
|
navigateToHome() {
|
||||||
this.router.navigate(['/home']);
|
this.router.navigate([getHomePageRoute()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user