mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
62589: Exclude owning collection + redirect to first tab after mapping + page reload fix
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
<p [innerHTML]="'collection.item-mapper.collection' | translate:{ name: (collectionRD$ | async)?.payload?.name }" id="collection-name"></p>
|
||||
<p>{{'collection.item-mapper.description' | translate}}</p>
|
||||
|
||||
<ngb-tabset (tabChange)="tabChange($event)" [destroyOnHide]="true">
|
||||
<ngb-tab title="{{'collection.item-mapper.tabs.browse' | translate}}">
|
||||
<ngb-tabset (tabChange)="tabChange($event)" [destroyOnHide]="true" #tabs="ngbTabset">
|
||||
<ngb-tab title="{{'collection.item-mapper.tabs.browse' | translate}}" id="browseTab">
|
||||
<ng-template ngbTabContent>
|
||||
<div class="mt-2">
|
||||
<ds-item-select class="mt-2"
|
||||
@@ -19,7 +19,7 @@
|
||||
</div>
|
||||
</ng-template>
|
||||
</ngb-tab>
|
||||
<ngb-tab title="{{'collection.item-mapper.tabs.map' | translate}}">
|
||||
<ngb-tab title="{{'collection.item-mapper.tabs.map' | translate}}" id="mapTab">
|
||||
<ng-template ngbTabContent>
|
||||
<div class="row mt-2">
|
||||
<div class="col-12 col-lg-6">
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
|
||||
|
||||
import { ChangeDetectionStrategy, Component, Inject, OnInit } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, Inject, OnInit, ViewChild } from '@angular/core';
|
||||
import { fadeIn, fadeInOut } from '../../shared/animations/fade';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { RemoteData } from '../../core/data/remote-data';
|
||||
@@ -44,6 +44,12 @@ import { SEARCH_CONFIG_SERVICE } from '../../+my-dspace-page/my-dspace-page.comp
|
||||
*/
|
||||
export class CollectionItemMapperComponent implements OnInit {
|
||||
|
||||
/**
|
||||
* A view on the tabset element
|
||||
* Used to switch tabs programmatically
|
||||
*/
|
||||
@ViewChild('tabs') tabs;
|
||||
|
||||
/**
|
||||
* The collection to map items to
|
||||
*/
|
||||
@@ -180,8 +186,9 @@ export class CollectionItemMapperComponent implements OnInit {
|
||||
this.notificationsService.error(head, content);
|
||||
});
|
||||
}
|
||||
// Force an update on all lists
|
||||
// Force an update on all lists and switch back to the first tab
|
||||
this.shouldUpdate$.next(true);
|
||||
this.switchToFirstTab();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -228,4 +235,11 @@ export class CollectionItemMapperComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch the view to focus on the first tab
|
||||
*/
|
||||
switchToFirstTab() {
|
||||
this.tabs.select('browseTab');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -5,8 +5,8 @@
|
||||
<p [innerHTML]="'item.edit.item-mapper.item' | translate:{ name: (itemRD$ | async)?.payload?.name }" id="item-name"></p>
|
||||
<p>{{'item.edit.item-mapper.description' | translate}}</p>
|
||||
|
||||
<ngb-tabset (tabChange)="tabChange($event)" [destroyOnHide]="true">
|
||||
<ngb-tab title="{{'item.edit.item-mapper.tabs.browse' | translate}}">
|
||||
<ngb-tabset (tabChange)="tabChange($event)" [destroyOnHide]="true" #tabs="ngbTabset">
|
||||
<ngb-tab title="{{'item.edit.item-mapper.tabs.browse' | translate}}" id="browseTab">
|
||||
<ng-template ngbTabContent>
|
||||
<div class="mt-2">
|
||||
<ds-collection-select class="mt-2"
|
||||
@@ -18,7 +18,7 @@
|
||||
</div>
|
||||
</ng-template>
|
||||
</ngb-tab>
|
||||
<ngb-tab title="{{'item.edit.item-mapper.tabs.map' | translate}}">
|
||||
<ngb-tab title="{{'item.edit.item-mapper.tabs.map' | translate}}" id="mapTab">
|
||||
<ng-template ngbTabContent>
|
||||
<div class="row mt-2">
|
||||
<div class="col-12 col-lg-6">
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
|
||||
|
||||
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { fadeIn, fadeInOut } from '../../../shared/animations/fade';
|
||||
import { PaginatedSearchOptions } from '../../../+search-page/paginated-search-options.model';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
@@ -34,6 +34,13 @@ import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
|
||||
* Component for mapping collections to an item
|
||||
*/
|
||||
export class ItemCollectionMapperComponent implements OnInit {
|
||||
|
||||
/**
|
||||
* A view on the tabset element
|
||||
* Used to switch tabs programmatically
|
||||
*/
|
||||
@ViewChild('tabs') tabs;
|
||||
|
||||
/**
|
||||
* The item to map to collections
|
||||
*/
|
||||
@@ -92,14 +99,18 @@ export class ItemCollectionMapperComponent implements OnInit {
|
||||
switchMap((item: Item) => this.itemDataService.getMappedCollections(item.id))
|
||||
);
|
||||
|
||||
const owningCollectionRD$ = this.itemRD$.pipe(
|
||||
switchMap((itemRD: RemoteData<Item>) => itemRD.payload.owningCollection)
|
||||
);
|
||||
const itemCollectionsAndOptions$ = observableCombineLatest(
|
||||
this.itemCollectionsRD$,
|
||||
owningCollectionRD$,
|
||||
this.searchOptions$
|
||||
);
|
||||
this.mappedCollectionsRD$ = itemCollectionsAndOptions$.pipe(
|
||||
switchMap(([itemCollectionsRD, searchOptions]) => {
|
||||
switchMap(([itemCollectionsRD, owningCollectionRD, searchOptions]) => {
|
||||
return this.searchService.search(Object.assign(new PaginatedSearchOptions(searchOptions), {
|
||||
query: this.buildQuery(itemCollectionsRD.payload.page, searchOptions.query),
|
||||
query: this.buildQuery([...itemCollectionsRD.payload.page, owningCollectionRD.payload], searchOptions.query),
|
||||
dsoType: DSpaceObjectType.COLLECTION
|
||||
}));
|
||||
}),
|
||||
@@ -190,8 +201,9 @@ export class ItemCollectionMapperComponent implements OnInit {
|
||||
this.notificationsService.error(head, content);
|
||||
});
|
||||
}
|
||||
// Force an update on all lists
|
||||
// Force an update on all lists and switch back to the first tab
|
||||
this.shouldUpdate$.next(true);
|
||||
this.switchToFirstTab();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -251,4 +263,11 @@ export class ItemCollectionMapperComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch the view to focus on the first tab
|
||||
*/
|
||||
switchToFirstTab() {
|
||||
this.tabs.select('browseTab');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<ng-container *ngVar="(dsoRD$ | async) as collectionsRD">
|
||||
<ds-pagination
|
||||
*ngIf="collectionsRD?.payload?.totalElements > 0"
|
||||
*ngIf="collectionsRD?.payload?.totalElements > 0 || collectionsRD?.payload?.page?.length > 0"
|
||||
[paginationOptions]="paginationOptions"
|
||||
[sortOptions]="sortOptions"
|
||||
[pageInfoState]="collectionsRD?.payload"
|
||||
|
Reference in New Issue
Block a user