mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-09 02:54:13 +00:00
55693: Authentication Guard and TSDocs
This commit is contained in:
@@ -28,13 +28,37 @@ import { TranslateService } from '@ngx-translate/core';
|
|||||||
fadeInOut
|
fadeInOut
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
/**
|
||||||
|
* Collection used to map items to a collection
|
||||||
|
*/
|
||||||
export class CollectionItemMapperComponent implements OnInit {
|
export class CollectionItemMapperComponent implements OnInit {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The collection to map items to
|
||||||
|
*/
|
||||||
collectionRD$: Observable<RemoteData<Collection>>;
|
collectionRD$: Observable<RemoteData<Collection>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search options
|
||||||
|
*/
|
||||||
searchOptions$: Observable<PaginatedSearchOptions>;
|
searchOptions$: Observable<PaginatedSearchOptions>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of items to show under the "Browse" tab
|
||||||
|
* Items inside the collection
|
||||||
|
*/
|
||||||
collectionItemsRD$: Observable<RemoteData<PaginatedList<DSpaceObject>>>;
|
collectionItemsRD$: Observable<RemoteData<PaginatedList<DSpaceObject>>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of items to show under the "Map" tab
|
||||||
|
* Items outside the collection
|
||||||
|
*/
|
||||||
mappingItemsRD$: Observable<RemoteData<PaginatedList<DSpaceObject>>>;
|
mappingItemsRD$: Observable<RemoteData<PaginatedList<DSpaceObject>>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort on title ASC by default
|
||||||
|
* @type {SortOptions}
|
||||||
|
*/
|
||||||
defaultSortOptions: SortOptions = new SortOptions('dc.title', SortDirection.ASC);
|
defaultSortOptions: SortOptions = new SortOptions('dc.title', SortDirection.ASC);
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute,
|
constructor(private route: ActivatedRoute,
|
||||||
@@ -52,6 +76,11 @@ export class CollectionItemMapperComponent implements OnInit {
|
|||||||
this.loadItemLists();
|
this.loadItemLists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load collectionItemsRD$ with a fixed scope to only obtain the items this collection owns
|
||||||
|
* Load mappingItemsRD$ to only obtain items this collection doesn't own
|
||||||
|
* TODO: When the API support it, fetch items excluding the collection's scope (currently fetches all items)
|
||||||
|
*/
|
||||||
loadItemLists() {
|
loadItemLists() {
|
||||||
const collectionAndOptions$ = Observable.combineLatest(
|
const collectionAndOptions$ = Observable.combineLatest(
|
||||||
this.collectionRD$,
|
this.collectionRD$,
|
||||||
@@ -79,6 +108,10 @@ export class CollectionItemMapperComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map the selected items to the collection and display notifications
|
||||||
|
* @param {string[]} ids The list of item UUID's to map to the collection
|
||||||
|
*/
|
||||||
mapItems(ids: string[]) {
|
mapItems(ids: string[]) {
|
||||||
const responses$ = this.collectionRD$.pipe(
|
const responses$ = this.collectionRD$.pipe(
|
||||||
getSucceededRemoteData(),
|
getSucceededRemoteData(),
|
||||||
@@ -112,12 +145,20 @@ export class CollectionItemMapperComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear url parameters on tab change (temporary fix until pagination is improved)
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
tabChange(event) {
|
tabChange(event) {
|
||||||
// TODO: Fix tabs to maintain their own pagination options (once the current pagination system is improved)
|
// TODO: Fix tabs to maintain their own pagination options (once the current pagination system is improved)
|
||||||
// Temporary solution: Clear url params when changing tabs
|
// Temporary solution: Clear url params when changing tabs
|
||||||
this.router.navigateByUrl(this.getCurrentUrl());
|
this.router.navigateByUrl(this.getCurrentUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current url without parameters
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
getCurrentUrl(): string {
|
getCurrentUrl(): string {
|
||||||
if (this.router.url.indexOf('?') > -1) {
|
if (this.router.url.indexOf('?') > -1) {
|
||||||
return this.router.url.substring(0, this.router.url.indexOf('?'));
|
return this.router.url.substring(0, this.router.url.indexOf('?'));
|
||||||
|
@@ -4,6 +4,7 @@ import { RouterModule } from '@angular/router';
|
|||||||
import { CollectionPageComponent } from './collection-page.component';
|
import { CollectionPageComponent } from './collection-page.component';
|
||||||
import { CollectionPageResolver } from './collection-page.resolver';
|
import { CollectionPageResolver } from './collection-page.resolver';
|
||||||
import { CollectionItemMapperComponent } from './collection-item-mapper/collection-item-mapper.component';
|
import { CollectionItemMapperComponent } from './collection-item-mapper/collection-item-mapper.component';
|
||||||
|
import { AuthenticatedGuard } from '../core/auth/authenticated.guard';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -22,7 +23,8 @@ import { CollectionItemMapperComponent } from './collection-item-mapper/collecti
|
|||||||
pathMatch: 'full',
|
pathMatch: 'full',
|
||||||
resolve: {
|
resolve: {
|
||||||
collection: CollectionPageResolver
|
collection: CollectionPageResolver
|
||||||
}
|
},
|
||||||
|
canActivate: [AuthenticatedGuard]
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
],
|
],
|
||||||
|
@@ -14,20 +14,40 @@ import { take } from 'rxjs/operators';
|
|||||||
templateUrl: './item-select.component.html'
|
templateUrl: './item-select.component.html'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A component used to select items from a specific list and returning the UUIDs of the selected items
|
||||||
|
*/
|
||||||
export class ItemSelectComponent implements OnInit {
|
export class ItemSelectComponent implements OnInit {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of items to display
|
||||||
|
*/
|
||||||
@Input()
|
@Input()
|
||||||
itemsRD$: Observable<RemoteData<PaginatedList<Item>>>;
|
itemsRD$: Observable<RemoteData<PaginatedList<Item>>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The pagination options used to display the items
|
||||||
|
*/
|
||||||
@Input()
|
@Input()
|
||||||
paginationOptions: PaginationComponentOptions;
|
paginationOptions: PaginationComponentOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message key used for the confirm button
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
@Input()
|
@Input()
|
||||||
confirmButton = 'item.select.confirm';
|
confirmButton = 'item.select.confirm';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EventEmitter to return the selected UUIDs when the confirm button is pressed
|
||||||
|
* @type {EventEmitter<string[]>}
|
||||||
|
*/
|
||||||
@Output()
|
@Output()
|
||||||
confirm: EventEmitter<string[]> = new EventEmitter<string[]>();
|
confirm: EventEmitter<string[]> = new EventEmitter<string[]>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of selected UUIDs
|
||||||
|
*/
|
||||||
selectedIds$: Observable<string[]>;
|
selectedIds$: Observable<string[]>;
|
||||||
|
|
||||||
constructor(private itemSelectService: ItemSelectService) {
|
constructor(private itemSelectService: ItemSelectService) {
|
||||||
@@ -37,14 +57,27 @@ export class ItemSelectComponent implements OnInit {
|
|||||||
this.selectedIds$ = this.itemSelectService.getAllSelected();
|
this.selectedIds$ = this.itemSelectService.getAllSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switch the state of a checkbox
|
||||||
|
* @param {string} id
|
||||||
|
*/
|
||||||
switch(id: string) {
|
switch(id: string) {
|
||||||
this.itemSelectService.switch(id);
|
this.itemSelectService.switch(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current state of a checkbox
|
||||||
|
* @param {string} id The item's UUID
|
||||||
|
* @returns {Observable<boolean>}
|
||||||
|
*/
|
||||||
getSelected(id: string): Observable<boolean> {
|
getSelected(id: string): Observable<boolean> {
|
||||||
return this.itemSelectService.getSelected(id);
|
return this.itemSelectService.getSelected(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the confirm button is pressed
|
||||||
|
* Sends the selected UUIDs to the parent component
|
||||||
|
*/
|
||||||
confirmSelected() {
|
confirmSelected() {
|
||||||
this.selectedIds$.pipe(
|
this.selectedIds$.pipe(
|
||||||
take(1)
|
take(1)
|
||||||
|
Reference in New Issue
Block a user