mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Added create and edit resource policy link
This commit is contained in:
@@ -2,10 +2,10 @@
|
|||||||
<table class="table table-striped table-bordered table-hover">
|
<table class="table table-striped table-bordered table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="6">
|
<th colspan="7">
|
||||||
<p class="d-flex justify-content-between align-items-center m-0">
|
<p class="d-flex justify-content-between align-items-center m-0">
|
||||||
{{ 'resource-policies.table.headers.title.for.' + resourceKey | translate }} {{resourceUUID}}
|
{{ 'resource-policies.table.headers.title.for.' + resourceKey | translate }} {{resourceUUID}}
|
||||||
<button class="btn btn-outline-primary float-right">
|
<button class="btn btn-outline-primary float-right" (click)="createResourcePolicy()">
|
||||||
{{'resource-policies.add.for.' + resourceKey | translate}}
|
{{'resource-policies.add.for.' + resourceKey | translate}}
|
||||||
</button>
|
</button>
|
||||||
</p>
|
</p>
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
<th>{{'resource-policies.table.headers.id' | translate}}</th>
|
<th>{{'resource-policies.table.headers.id' | translate}}</th>
|
||||||
<th>{{'resource-policies.table.headers.name' | translate}}</th>
|
<th>{{'resource-policies.table.headers.name' | translate}}</th>
|
||||||
<th>{{'resource-policies.table.headers.action' | translate}}</th>
|
<th>{{'resource-policies.table.headers.action' | translate}}</th>
|
||||||
|
<th>{{'resource-policies.table.headers.eperson' | translate}}</th>
|
||||||
<th>{{'resource-policies.table.headers.group' | translate}}</th>
|
<th>{{'resource-policies.table.headers.group' | translate}}</th>
|
||||||
<th>{{'resource-policies.table.headers.date.start' | translate}}</th>
|
<th>{{'resource-policies.table.headers.date.start' | translate}}</th>
|
||||||
<th>{{'resource-policies.table.headers.date.end' | translate}}</th>
|
<th>{{'resource-policies.table.headers.date.end' | translate}}</th>
|
||||||
@@ -22,13 +23,22 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr *ngFor="let policy of (getResourcePolicies() | async)?.payload?.page; trackById">
|
<tr *ngFor="let policy of (getResourcePolicies() | async)?.payload?.page; trackById">
|
||||||
<th scope="row">{{policy.id}}</th>
|
<th scope="row">
|
||||||
|
{{policy.id}}
|
||||||
|
<button class="btn btn-link pt-0 pb-0" (click)="editResourcePolicy(policy)">
|
||||||
|
{{'resource-policies.table.headers.edit' | translate}}
|
||||||
|
</button>
|
||||||
|
</th>
|
||||||
<td>{{policy.name}}</td>
|
<td>{{policy.name}}</td>
|
||||||
<td>{{policy.action}}</td>
|
<td>{{policy.action}}</td>
|
||||||
|
<td *ngIf="(hasEPerson(policy) | async)">
|
||||||
|
{{getEPersonName(policy) | async}}
|
||||||
|
</td>
|
||||||
|
<td *ngIf="!(hasEPerson(policy) | async)"></td>
|
||||||
<td *ngIf="(hasGroup(policy) | async)">
|
<td *ngIf="(hasGroup(policy) | async)">
|
||||||
{{getGroupName(policy) | async}}
|
{{getGroupName(policy) | async}}
|
||||||
<button class="btn btn-link pt-0 pb-0" (click)="redirectToGroupEditPage(policy)">
|
<button class="btn btn-link pt-0 pb-0" (click)="redirectToGroupEditPage(policy)">
|
||||||
{{'resource-policies.table.headers.group.edit' | translate}}
|
{{'resource-policies.table.headers.edit' | translate}}
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
<td *ngIf="!(hasGroup(policy) | async)"></td>
|
<td *ngIf="!(hasGroup(policy) | async)"></td>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
|
import { ChangeDetectorRef, Component, Input, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
|
||||||
import { Observable, Subscription } from 'rxjs';
|
import { Observable, Subscription } from 'rxjs';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
@@ -13,6 +13,8 @@ import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
|
|||||||
import { Group } from '../../core/eperson/models/group.model';
|
import { Group } from '../../core/eperson/models/group.model';
|
||||||
import { GroupDataService } from '../../core/eperson/group-data.service';
|
import { GroupDataService } from '../../core/eperson/group-data.service';
|
||||||
import { hasValue, isNotEmpty } from '../empty.util';
|
import { hasValue, isNotEmpty } from '../empty.util';
|
||||||
|
import { EPerson } from '../../core/eperson/models/eperson.model';
|
||||||
|
import { EPersonDataService } from '../../core/eperson/eperson-data.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-resource-policies',
|
selector: 'ds-resource-policies',
|
||||||
@@ -51,15 +53,21 @@ export class ResourcePoliciesComponent implements OnInit, OnDestroy {
|
|||||||
/**
|
/**
|
||||||
* Initialize instance variables
|
* Initialize instance variables
|
||||||
*
|
*
|
||||||
|
* @param {ChangeDetectorRef} cdr
|
||||||
* @param {DSONameService} dsoNameService
|
* @param {DSONameService} dsoNameService
|
||||||
|
* @param {EPersonDataService} ePersonService
|
||||||
* @param {GroupDataService} groupService
|
* @param {GroupDataService} groupService
|
||||||
* @param {ResourcePolicyService} resourcePolicyService
|
* @param {ResourcePolicyService} resourcePolicyService
|
||||||
|
* @param {ActivatedRoute} route
|
||||||
* @param {Router} router
|
* @param {Router} router
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
|
private cdr: ChangeDetectorRef,
|
||||||
private dsoNameService: DSONameService,
|
private dsoNameService: DSONameService,
|
||||||
|
private ePersonService: EPersonDataService,
|
||||||
private groupService: GroupDataService,
|
private groupService: GroupDataService,
|
||||||
private resourcePolicyService: ResourcePolicyService,
|
private resourcePolicyService: ResourcePolicyService,
|
||||||
|
private route: ActivatedRoute,
|
||||||
private router: Router
|
private router: Router
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
@@ -74,6 +82,34 @@ export class ResourcePoliciesComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirect to resource policy creation page
|
||||||
|
*/
|
||||||
|
createResourcePolicy(): void {
|
||||||
|
this.router.navigate([`../${this.resourceUUID}/create`], { relativeTo: this.route })
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirect to resource policy editing page
|
||||||
|
*
|
||||||
|
* @param policy The resource policy
|
||||||
|
*/
|
||||||
|
editResourcePolicy(policy: ResourcePolicy): void {
|
||||||
|
this.router.navigate([`../${this.resourceUUID}/${policy.id}/edit`], { relativeTo: this.route })
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the ePerson's name which the given policy is linked to
|
||||||
|
*
|
||||||
|
* @param policy The resource policy
|
||||||
|
*/
|
||||||
|
getEPersonName(policy: ResourcePolicy): Observable<string> {
|
||||||
|
return this.ePersonService.findByHref(policy._links.eperson.href).pipe(
|
||||||
|
getFirstSucceededRemoteDataPayload(),
|
||||||
|
map((eperson: EPerson) => this.dsoNameService.getName(eperson))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the group's name which the given policy is linked to
|
* Return the group's name which the given policy is linked to
|
||||||
*
|
*
|
||||||
@@ -82,8 +118,7 @@ export class ResourcePoliciesComponent implements OnInit, OnDestroy {
|
|||||||
getGroupName(policy: ResourcePolicy): Observable<string> {
|
getGroupName(policy: ResourcePolicy): Observable<string> {
|
||||||
return this.groupService.findByHref(policy._links.group.href).pipe(
|
return this.groupService.findByHref(policy._links.group.href).pipe(
|
||||||
getFirstSucceededRemoteDataPayload(),
|
getFirstSucceededRemoteDataPayload(),
|
||||||
// A group has not dc.title metadata so is not possible to use DSONameService to retrieve name
|
map((group: Group) => this.dsoNameService.getName(group))
|
||||||
map((group: Group) => group.name)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,6 +131,19 @@ export class ResourcePoliciesComponent implements OnInit, OnDestroy {
|
|||||||
return this.resourcePolicies$;
|
return this.resourcePolicies$;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the given policy is linked to a ePerson
|
||||||
|
*
|
||||||
|
* @param policy The resource policy
|
||||||
|
* @return an observable that emits true when the policy is linked to a ePerson, false otherwise
|
||||||
|
*/
|
||||||
|
hasEPerson(policy): Observable<boolean> {
|
||||||
|
return this.ePersonService.findByHref(policy._links.eperson.href).pipe(
|
||||||
|
getFirstSucceededRemoteDataPayload(),
|
||||||
|
map((eperson: EPerson) => isNotEmpty(eperson))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the given policy is linked to a group
|
* Check whether the given policy is linked to a group
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user