Skip to content
Snippets Groups Projects
Commit ac323f48 authored by Giuseppe Digilio's avatar Giuseppe Digilio
Browse files

Added item authorizations component

parent e396fe05
Branches
Tags
No related merge requests found
......@@ -745,6 +745,9 @@
"item.edit.authorizations.title": "Edit item's Policies",
"item.edit.delete.cancel": "Cancel",
"item.edit.delete.confirm": "Delete",
......
......@@ -23,6 +23,7 @@ import { EditRelationshipListComponent } from './item-relationships/edit-relatio
import { ItemMoveComponent } from './item-move/item-move.component';
import { VirtualMetadataComponent } from './virtual-metadata/virtual-metadata.component';
import { ItemVersionHistoryComponent } from './item-version-history/item-version-history.component';
import { ItemAuthorizationsComponent } from './item-authorizations/item-authorizations.component';
/**
* Module that contains all components related to the Edit Item page administrator functionality
......@@ -55,6 +56,7 @@ import { ItemVersionHistoryComponent } from './item-version-history/item-version
ItemCollectionMapperComponent,
ItemMoveComponent,
VirtualMetadataComponent,
ItemAuthorizationsComponent
]
})
export class EditItemPageModule {
......
......@@ -14,6 +14,7 @@ import { ItemMoveComponent } from './item-move/item-move.component';
import { ItemRelationshipsComponent } from './item-relationships/item-relationships.component';
import { I18nBreadcrumbResolver } from '../../core/breadcrumbs/i18n-breadcrumb.resolver';
import { ItemVersionHistoryComponent } from './item-version-history/item-version-history.component';
import { ItemAuthorizationsComponent } from './item-authorizations/item-authorizations.component';
export const ITEM_EDIT_WITHDRAW_PATH = 'withdraw';
export const ITEM_EDIT_REINSTATE_PATH = 'reinstate';
......@@ -21,6 +22,7 @@ export const ITEM_EDIT_PRIVATE_PATH = 'private';
export const ITEM_EDIT_PUBLIC_PATH = 'public';
export const ITEM_EDIT_DELETE_PATH = 'delete';
export const ITEM_EDIT_MOVE_PATH = 'move';
export const ITEM_EDIT_AUTHORIZATIONS_PATH = 'authorizations';
/**
* Routing module that handles the routing for the Edit Item page administrator functionality
......@@ -111,6 +113,11 @@ export const ITEM_EDIT_MOVE_PATH = 'move';
path: ITEM_EDIT_MOVE_PATH,
component: ItemMoveComponent,
data: { title: 'item.edit.move.title' },
},
{
path: ITEM_EDIT_AUTHORIZATIONS_PATH,
component: ItemAuthorizationsComponent,
data: { title: 'item.edit.authorizations.title' },
}
]
}
......
<div class="container">
</div>
import { ComponentFixture } from '@angular/core/testing';
import { ItemAuthorizationsComponent } from './item-authorizations.component';
describe('ItemAuthorizationsComponent', () => {
let comp: ItemAuthorizationsComponent;
let fixture: ComponentFixture<ItemAuthorizationsComponent>;
});
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs';
import { flatMap, map } from 'rxjs/operators';
import { ResourcePolicyService } from '../../../core/resource-policy/resource-policy.service';
import { PaginatedList } from '../../../core/data/paginated-list';
import { getFirstSucceededRemoteDataPayload } from '../../../core/shared/operators';
import { RemoteData } from '../../../core/data/remote-data';
import { Item } from '../../../core/shared/item.model';
import { followLink } from '../../../shared/utils/follow-link-config.model';
import { LinkService } from '../../../core/cache/builders/link.service';
import { Bundle } from '../../../core/shared/bundle.model';
@Component({
selector: 'ds-item-authorizations',
templateUrl: './item-authorizations.component.html'
})
/**
* Component that handles the item Authorizations
*/
export class ItemAuthorizationsComponent implements OnInit {
private bundles$: Observable<RemoteData<PaginatedList<Bundle>>>;
private item$: Observable<Item>;
constructor(
private linkService: LinkService,
private resourcePolicyService: ResourcePolicyService,
private route: ActivatedRoute
) {
}
ngOnInit(): void {
this.item$ = this.route.data.pipe(
map((data) => data.item),
getFirstSucceededRemoteDataPayload(),
map((item: Item) => this.linkService.resolveLink(item, followLink('bundles')))
) as Observable<Item>;
this.bundles$ = this.item$.pipe(flatMap((item: Item) => item.bundles));
}
}
......@@ -68,6 +68,7 @@ export class ItemStatusComponent implements OnInit {
The value is supposed to be a href for the button
*/
this.operations = [];
this.operations.push(new ItemOperation('authorizations', this.getCurrentUrl(item) + '/authorizations'));
this.operations.push(new ItemOperation('mappedCollections', this.getCurrentUrl(item) + '/mapper'));
if (item.isWithdrawn) {
this.operations.push(new ItemOperation('reinstate', this.getCurrentUrl(item) + '/reinstate'));
......
......@@ -106,7 +106,7 @@ export class ResourcePolicyService {
* @param resourceUUID Limit the returned policies to the specified DSO
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
*/
searchByEPerson(UUID: string, resourceUUID?: string, ...linksToFollow: Array<FollowLinkConfig<ResourcePolicy>>) {
searchByEPerson(UUID: string, resourceUUID?: string, ...linksToFollow: Array<FollowLinkConfig<ResourcePolicy>>): Observable<RemoteData<PaginatedList<ResourcePolicy>>> {
const options = new FindListOptions();
options.searchParams = [new SearchParam('uuid', UUID)];
if (isNotEmpty(resourceUUID)) {
......@@ -122,7 +122,7 @@ export class ResourcePolicyService {
* @param resourceUUID Limit the returned policies to the specified DSO
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
*/
searchByGroup(UUID: string, resourceUUID?: string, ...linksToFollow: Array<FollowLinkConfig<ResourcePolicy>>) {
searchByGroup(UUID: string, resourceUUID?: string, ...linksToFollow: Array<FollowLinkConfig<ResourcePolicy>>): Observable<RemoteData<PaginatedList<ResourcePolicy>>> {
const options = new FindListOptions();
options.searchParams = [new SearchParam('uuid', UUID)];
if (isNotEmpty(resourceUUID)) {
......@@ -138,7 +138,7 @@ export class ResourcePolicyService {
* @param action Limit the returned policies to the specified {@link ActionType}
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
*/
searchByResource(UUID: string, action?: ActionType, ...linksToFollow: Array<FollowLinkConfig<ResourcePolicy>>) {
searchByResource(UUID: string, action?: ActionType, ...linksToFollow: Array<FollowLinkConfig<ResourcePolicy>>): Observable<RemoteData<PaginatedList<ResourcePolicy>>> {
const options = new FindListOptions();
options.searchParams = [new SearchParam('uuid', UUID)];
if (isNotEmpty(action)) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment