mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
55693: emit only once and reset selected items + notification
This commit is contained in:
@@ -15,6 +15,7 @@ import { SearchService } from '../../+search-page/search-service/search.service'
|
|||||||
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||||
import { DSpaceObjectType } from '../../core/shared/dspace-object-type.model';
|
import { DSpaceObjectType } from '../../core/shared/dspace-object-type.model';
|
||||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
||||||
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-collection-item-mapper',
|
selector: 'ds-collection-item-mapper',
|
||||||
@@ -35,11 +36,11 @@ export class CollectionItemMapperComponent implements OnInit {
|
|||||||
|
|
||||||
defaultSortOptions: SortOptions = new SortOptions('dc.title', SortDirection.ASC);
|
defaultSortOptions: SortOptions = new SortOptions('dc.title', SortDirection.ASC);
|
||||||
|
|
||||||
constructor(private collectionDataService: CollectionDataService,
|
constructor(private route: ActivatedRoute,
|
||||||
private route: ActivatedRoute,
|
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private searchConfigService: SearchConfigurationService,
|
private searchConfigService: SearchConfigurationService,
|
||||||
private searchService: SearchService) {
|
private searchService: SearchService,
|
||||||
|
private notificationsService: NotificationsService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@@ -71,7 +72,9 @@ export class CollectionItemMapperComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mapItems(ids: string[]) {
|
mapItems(ids: string[]) {
|
||||||
console.log(ids);
|
this.collectionRD$.subscribe((collectionRD: RemoteData<Collection>) => {
|
||||||
|
this.notificationsService.success('Mapping completed', `Successfully mapped ${ids.length} items to collection "${collectionRD.payload.name}".`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getCurrentUrl(): string {
|
getCurrentUrl(): string {
|
||||||
|
@@ -6,6 +6,7 @@ import { Observable } from 'rxjs/Observable';
|
|||||||
import { Item } from '../../core/shared/item.model';
|
import { Item } from '../../core/shared/item.model';
|
||||||
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
|
||||||
import { ItemSelectService } from './item-select.service';
|
import { ItemSelectService } from './item-select.service';
|
||||||
|
import { take } from 'rxjs/operators';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-item-select',
|
selector: 'ds-item-select',
|
||||||
@@ -42,8 +43,11 @@ export class ItemSelectComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
confirmSelected() {
|
confirmSelected() {
|
||||||
this.selectedIds$.subscribe((ids: string[]) => {
|
this.selectedIds$.pipe(
|
||||||
|
take(1)
|
||||||
|
).subscribe((ids: string[]) => {
|
||||||
this.confirm.emit(ids);
|
this.confirm.emit(ids);
|
||||||
|
this.itemSelectService.reset();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user