mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
[CST-7755] Modified the changes related to the reload the object and authorization
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<ds-listable-object-component-loader *ngIf="item$ | async"
|
<ds-listable-object-component-loader *ngIf="item$ | async"
|
||||||
[object]="item$ | async"
|
[object]="item$ | async"
|
||||||
|
[supervisionOrders]="supervisionOrder$ | async"
|
||||||
[viewMode]="viewModes.ListElement"
|
[viewMode]="viewModes.ListElement"
|
||||||
[index]="index"
|
[index]="index"
|
||||||
[linkType]="linkType"
|
[linkType]="linkType"
|
||||||
|
@@ -15,6 +15,7 @@ import { WorkflowItemSearchResult } from '../../../../../shared/object-collectio
|
|||||||
import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service';
|
import { DSONameService } from '../../../../../core/breadcrumbs/dso-name.service';
|
||||||
import { APP_CONFIG, AppConfig } from '../../../../../../config/app-config.interface';
|
import { APP_CONFIG, AppConfig } from '../../../../../../config/app-config.interface';
|
||||||
import { WorkspaceItemSearchResult } from '../../../../../shared/object-collection/shared/workspace-item-search-result.model';
|
import { WorkspaceItemSearchResult } from '../../../../../shared/object-collection/shared/workspace-item-search-result.model';
|
||||||
|
import { SupervisionOrder } from '../../../../../core/supervision-order/models/supervision-order.model';
|
||||||
|
|
||||||
@listableObjectComponent(WorkflowItemSearchResult, ViewMode.ListElement, Context.AdminWorkflowSearch)
|
@listableObjectComponent(WorkflowItemSearchResult, ViewMode.ListElement, Context.AdminWorkflowSearch)
|
||||||
@listableObjectComponent(WorkspaceItemSearchResult, ViewMode.ListElement, Context.AdminWorkflowSearch)
|
@listableObjectComponent(WorkspaceItemSearchResult, ViewMode.ListElement, Context.AdminWorkflowSearch)
|
||||||
@@ -33,6 +34,11 @@ export class WorkflowItemSearchResultAdminWorkflowListElementComponent extends S
|
|||||||
*/
|
*/
|
||||||
public item$: Observable<Item>;
|
public item$: Observable<Item>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The supervision orders linked to the workflow item
|
||||||
|
*/
|
||||||
|
public supervisionOrder$: Observable<SupervisionOrder>;
|
||||||
|
|
||||||
constructor(private linkService: LinkService,
|
constructor(private linkService: LinkService,
|
||||||
protected truncatableService: TruncatableService,
|
protected truncatableService: TruncatableService,
|
||||||
protected dsoNameService: DSONameService,
|
protected dsoNameService: DSONameService,
|
||||||
@@ -47,6 +53,7 @@ export class WorkflowItemSearchResultAdminWorkflowListElementComponent extends S
|
|||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
this.dso = this.linkService.resolveLink(this.dso, followLink('item'));
|
this.dso = this.linkService.resolveLink(this.dso, followLink('item'));
|
||||||
|
this.supervisionOrder$ = (this.dso.supervisionOrders as Observable<RemoteData<SupervisionOrder>>)?.pipe(getAllSucceededRemoteData(), getRemoteDataPayload());
|
||||||
this.item$ = (this.dso.item as Observable<RemoteData<Item>>).pipe(getAllSucceededRemoteData(), getRemoteDataPayload());
|
this.item$ = (this.dso.item as Observable<RemoteData<Item>>).pipe(getAllSucceededRemoteData(), getRemoteDataPayload());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf, of } from 'rxjs';
|
||||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||||
import { JournalIssueSearchResultListElementComponent } from './journal-issue-search-result-list-element.component';
|
import { JournalIssueSearchResultListElementComponent } from './journal-issue-search-result-list-element.component';
|
||||||
import { Item } from '../../../../../core/shared/item.model';
|
import { Item } from '../../../../../core/shared/item.model';
|
||||||
@@ -18,9 +18,24 @@ import { PageInfo } from '../../../../../core/shared/page-info.model';
|
|||||||
import { buildPaginatedList } from '../../../../../core/data/paginated-list.model';
|
import { buildPaginatedList } from '../../../../../core/data/paginated-list.model';
|
||||||
import { GroupMock } from '../../../../../shared/testing/group-mock';
|
import { GroupMock } from '../../../../../shared/testing/group-mock';
|
||||||
import { hot } from 'jasmine-marbles';
|
import { hot } from 'jasmine-marbles';
|
||||||
|
import { AuthService } from '../../../../../core/auth/auth.service';
|
||||||
|
import { AuthorizationDataService } from '../../../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { EPersonDataService } from '../../../../../core/eperson/eperson-data.service';
|
||||||
|
import { ResourcePolicyDataService } from '../../../../../core/resource-policy/resource-policy-data.service';
|
||||||
|
import { AuthServiceStub } from '../../../../../shared/testing/auth-service.stub';
|
||||||
|
import { EPersonMock } from '../../../../../shared/testing/eperson.mock';
|
||||||
|
|
||||||
let journalIssueListElementComponent: JournalIssueSearchResultListElementComponent;
|
let journalIssueListElementComponent: JournalIssueSearchResultListElementComponent;
|
||||||
let fixture: ComponentFixture<JournalIssueSearchResultListElementComponent>;
|
let fixture: ComponentFixture<JournalIssueSearchResultListElementComponent>;
|
||||||
|
let authorizationService = jasmine.createSpyObj('authorizationService', {
|
||||||
|
isAuthorized: observableOf(true)
|
||||||
|
});
|
||||||
|
|
||||||
|
const authService: AuthServiceStub = Object.assign(new AuthServiceStub(), {
|
||||||
|
getAuthenticatedUserFromStore: () => {
|
||||||
|
return of(EPersonMock);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const mockItemWithMetadata: ItemSearchResult = Object.assign(
|
const mockItemWithMetadata: ItemSearchResult = Object.assign(
|
||||||
new ItemSearchResult(),
|
new ItemSearchResult(),
|
||||||
@@ -133,6 +148,10 @@ describe('JournalIssueSearchResultListElementComponent', () => {
|
|||||||
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
||||||
{ provide: NotificationsService, useValue: {}},
|
{ provide: NotificationsService, useValue: {}},
|
||||||
{ provide: TranslateService, useValue: {}},
|
{ provide: TranslateService, useValue: {}},
|
||||||
|
{ provide: ResourcePolicyDataService, useValue: {}},
|
||||||
|
{ provide: AuthService, useValue: authService},
|
||||||
|
{ provide: EPersonDataService, useValue: {}},
|
||||||
|
{ provide: AuthorizationDataService, useValue: authorizationService},
|
||||||
{ provide: DSONameService, useClass: DSONameServiceMock },
|
{ provide: DSONameService, useClass: DSONameServiceMock },
|
||||||
{ provide: APP_CONFIG, useValue: environmentUseThumbs }
|
{ provide: APP_CONFIG, useValue: environmentUseThumbs }
|
||||||
],
|
],
|
||||||
@@ -227,6 +246,10 @@ describe('JournalIssueSearchResultListElementComponent', () => {
|
|||||||
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
||||||
{provide: NotificationsService, useValue: {}},
|
{provide: NotificationsService, useValue: {}},
|
||||||
{provide: TranslateService, useValue: {}},
|
{provide: TranslateService, useValue: {}},
|
||||||
|
{provide: ResourcePolicyDataService, useValue: {}},
|
||||||
|
{provide: AuthService, useValue: authService},
|
||||||
|
{provide: EPersonDataService, useValue: {}},
|
||||||
|
{provide: AuthorizationDataService, useValue: authorizationService},
|
||||||
{provide: DSONameService, useClass: DSONameServiceMock},
|
{provide: DSONameService, useClass: DSONameServiceMock},
|
||||||
{ provide: APP_CONFIG, useValue: enviromentNoThumbs }
|
{ provide: APP_CONFIG, useValue: enviromentNoThumbs }
|
||||||
],
|
],
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf, of } from 'rxjs';
|
||||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||||
import { Item } from '../../../../../core/shared/item.model';
|
import { Item } from '../../../../../core/shared/item.model';
|
||||||
import { JournalVolumeSearchResultListElementComponent } from './journal-volume-search-result-list-element.component';
|
import { JournalVolumeSearchResultListElementComponent } from './journal-volume-search-result-list-element.component';
|
||||||
@@ -18,10 +18,24 @@ import { PageInfo } from '../../../../../core/shared/page-info.model';
|
|||||||
import { buildPaginatedList } from '../../../../../core/data/paginated-list.model';
|
import { buildPaginatedList } from '../../../../../core/data/paginated-list.model';
|
||||||
import { GroupMock } from '../../../../../shared/testing/group-mock';
|
import { GroupMock } from '../../../../../shared/testing/group-mock';
|
||||||
import { hot } from 'jasmine-marbles';
|
import { hot } from 'jasmine-marbles';
|
||||||
|
import { ResourcePolicyDataService } from '../../../../../core/resource-policy/resource-policy-data.service';
|
||||||
|
import { AuthService } from '../../../../../core/auth/auth.service';
|
||||||
|
import { EPersonDataService } from '../../../../../core/eperson/eperson-data.service';
|
||||||
|
import { AuthorizationDataService } from '../../../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { AuthServiceStub } from '../../../../../shared/testing/auth-service.stub';
|
||||||
|
import { EPersonMock } from '../../../../../shared/testing/eperson.mock';
|
||||||
|
|
||||||
let journalVolumeListElementComponent: JournalVolumeSearchResultListElementComponent;
|
let journalVolumeListElementComponent: JournalVolumeSearchResultListElementComponent;
|
||||||
let fixture: ComponentFixture<JournalVolumeSearchResultListElementComponent>;
|
let fixture: ComponentFixture<JournalVolumeSearchResultListElementComponent>;
|
||||||
|
let authorizationService = jasmine.createSpyObj('authorizationService', {
|
||||||
|
isAuthorized: observableOf(true)
|
||||||
|
});
|
||||||
|
|
||||||
|
const authService: AuthServiceStub = Object.assign(new AuthServiceStub(), {
|
||||||
|
getAuthenticatedUserFromStore: () => {
|
||||||
|
return of(EPersonMock);
|
||||||
|
}
|
||||||
|
});
|
||||||
const mockItemWithMetadata: ItemSearchResult = Object.assign(
|
const mockItemWithMetadata: ItemSearchResult = Object.assign(
|
||||||
new ItemSearchResult(),
|
new ItemSearchResult(),
|
||||||
{
|
{
|
||||||
@@ -132,6 +146,10 @@ describe('JournalVolumeSearchResultListElementComponent', () => {
|
|||||||
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
||||||
{ provide: NotificationsService, useValue: {}},
|
{ provide: NotificationsService, useValue: {}},
|
||||||
{ provide: TranslateService, useValue: {}},
|
{ provide: TranslateService, useValue: {}},
|
||||||
|
{ provide: ResourcePolicyDataService, useValue: {}},
|
||||||
|
{ provide: AuthService, useValue: authService},
|
||||||
|
{ provide: EPersonDataService, useValue: {}},
|
||||||
|
{ provide: AuthorizationDataService, useValue: authorizationService},
|
||||||
{ provide: DSONameService, useClass: DSONameServiceMock },
|
{ provide: DSONameService, useClass: DSONameServiceMock },
|
||||||
{ provide: APP_CONFIG, useValue: environmentUseThumbs }
|
{ provide: APP_CONFIG, useValue: environmentUseThumbs }
|
||||||
],
|
],
|
||||||
@@ -225,6 +243,10 @@ describe('JournalVolumeSearchResultListElementComponent', () => {
|
|||||||
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
||||||
{provide: NotificationsService, useValue: {}},
|
{provide: NotificationsService, useValue: {}},
|
||||||
{provide: TranslateService, useValue: {}},
|
{provide: TranslateService, useValue: {}},
|
||||||
|
{provide: ResourcePolicyDataService, useValue: {}},
|
||||||
|
{provide: AuthService, useValue: authService},
|
||||||
|
{provide: EPersonDataService, useValue: {}},
|
||||||
|
{provide: AuthorizationDataService, useValue: authorizationService},
|
||||||
{provide: DSONameService, useClass: DSONameServiceMock},
|
{provide: DSONameService, useClass: DSONameServiceMock},
|
||||||
{ provide: APP_CONFIG, useValue: enviromentNoThumbs }
|
{ provide: APP_CONFIG, useValue: enviromentNoThumbs }
|
||||||
],
|
],
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf, of } from 'rxjs';
|
||||||
import { JournalSearchResultListElementComponent } from './journal-search-result-list-element.component';
|
import { JournalSearchResultListElementComponent } from './journal-search-result-list-element.component';
|
||||||
import { Item } from '../../../../../core/shared/item.model';
|
import { Item } from '../../../../../core/shared/item.model';
|
||||||
import { TruncatePipe } from '../../../../../shared/utils/truncate.pipe';
|
import { TruncatePipe } from '../../../../../shared/utils/truncate.pipe';
|
||||||
@@ -18,9 +18,24 @@ import { PageInfo } from '../../../../../core/shared/page-info.model';
|
|||||||
import { buildPaginatedList } from '../../../../../core/data/paginated-list.model';
|
import { buildPaginatedList } from '../../../../../core/data/paginated-list.model';
|
||||||
import { GroupMock } from '../../../../../shared/testing/group-mock';
|
import { GroupMock } from '../../../../../shared/testing/group-mock';
|
||||||
import { hot } from 'jasmine-marbles';
|
import { hot } from 'jasmine-marbles';
|
||||||
|
import { AuthServiceStub } from '../../../../../shared/testing/auth-service.stub';
|
||||||
|
import { AuthService } from '../../../../../core/auth/auth.service';
|
||||||
|
import { AuthorizationDataService } from '../../../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { EPersonDataService } from '../../../../../core/eperson/eperson-data.service';
|
||||||
|
import { ResourcePolicyDataService } from '../../../../../core/resource-policy/resource-policy-data.service';
|
||||||
|
import { EPersonMock } from '../../../../../shared/testing/eperson.mock';
|
||||||
|
|
||||||
let journalListElementComponent: JournalSearchResultListElementComponent;
|
let journalListElementComponent: JournalSearchResultListElementComponent;
|
||||||
let fixture: ComponentFixture<JournalSearchResultListElementComponent>;
|
let fixture: ComponentFixture<JournalSearchResultListElementComponent>;
|
||||||
|
let authorizationService = jasmine.createSpyObj('authorizationService', {
|
||||||
|
isAuthorized: observableOf(true)
|
||||||
|
});
|
||||||
|
|
||||||
|
const authService: AuthServiceStub = Object.assign(new AuthServiceStub(), {
|
||||||
|
getAuthenticatedUserFromStore: () => {
|
||||||
|
return of(EPersonMock);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const mockItemWithMetadata: ItemSearchResult = Object.assign(
|
const mockItemWithMetadata: ItemSearchResult = Object.assign(
|
||||||
new ItemSearchResult(),
|
new ItemSearchResult(),
|
||||||
@@ -128,6 +143,10 @@ describe('JournalSearchResultListElementComponent', () => {
|
|||||||
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
||||||
{ provide: NotificationsService, useValue: {}},
|
{ provide: NotificationsService, useValue: {}},
|
||||||
{ provide: TranslateService, useValue: {}},
|
{ provide: TranslateService, useValue: {}},
|
||||||
|
{ provide: ResourcePolicyDataService, useValue: {}},
|
||||||
|
{ provide: AuthService, useValue: authService},
|
||||||
|
{ provide: EPersonDataService, useValue: {}},
|
||||||
|
{ provide: AuthorizationDataService, useValue: authorizationService},
|
||||||
{ provide: DSONameService, useClass: DSONameServiceMock },
|
{ provide: DSONameService, useClass: DSONameServiceMock },
|
||||||
{ provide: APP_CONFIG, useValue: environmentUseThumbs }
|
{ provide: APP_CONFIG, useValue: environmentUseThumbs }
|
||||||
],
|
],
|
||||||
@@ -197,6 +216,10 @@ describe('JournalSearchResultListElementComponent', () => {
|
|||||||
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
||||||
{provide: NotificationsService, useValue: {}},
|
{provide: NotificationsService, useValue: {}},
|
||||||
{provide: TranslateService, useValue: {}},
|
{provide: TranslateService, useValue: {}},
|
||||||
|
{provide: ResourcePolicyDataService, useValue: {}},
|
||||||
|
{provide: AuthService, useValue: authService},
|
||||||
|
{provide: EPersonDataService, useValue: {}},
|
||||||
|
{provide: AuthorizationDataService, useValue: authorizationService},
|
||||||
{provide: DSONameService, useClass: DSONameServiceMock},
|
{provide: DSONameService, useClass: DSONameServiceMock},
|
||||||
{ provide: APP_CONFIG, useValue: enviromentNoThumbs }
|
{ provide: APP_CONFIG, useValue: enviromentNoThumbs }
|
||||||
],
|
],
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf, of } from 'rxjs';
|
||||||
import { OrgUnitSearchResultListElementComponent } from './org-unit-search-result-list-element.component';
|
import { OrgUnitSearchResultListElementComponent } from './org-unit-search-result-list-element.component';
|
||||||
import { Item } from '../../../../../core/shared/item.model';
|
import { Item } from '../../../../../core/shared/item.model';
|
||||||
import { TruncatePipe } from '../../../../../shared/utils/truncate.pipe';
|
import { TruncatePipe } from '../../../../../shared/utils/truncate.pipe';
|
||||||
@@ -19,9 +19,24 @@ import { PageInfo } from '../../../../../core/shared/page-info.model';
|
|||||||
import { buildPaginatedList } from '../../../../../core/data/paginated-list.model';
|
import { buildPaginatedList } from '../../../../../core/data/paginated-list.model';
|
||||||
import { GroupMock } from '../../../../../shared/testing/group-mock';
|
import { GroupMock } from '../../../../../shared/testing/group-mock';
|
||||||
import { hot } from 'jasmine-marbles';
|
import { hot } from 'jasmine-marbles';
|
||||||
|
import { AuthService } from '../../../../../core/auth/auth.service';
|
||||||
|
import { AuthorizationDataService } from '../../../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { EPersonDataService } from '../../../../../core/eperson/eperson-data.service';
|
||||||
|
import { ResourcePolicyDataService } from '../../../../../core/resource-policy/resource-policy-data.service';
|
||||||
|
import { AuthServiceStub } from '../../../../../shared/testing/auth-service.stub';
|
||||||
|
import { EPersonMock } from '../../../../../shared/testing/eperson.mock';
|
||||||
|
|
||||||
let orgUnitListElementComponent: OrgUnitSearchResultListElementComponent;
|
let orgUnitListElementComponent: OrgUnitSearchResultListElementComponent;
|
||||||
let fixture: ComponentFixture<OrgUnitSearchResultListElementComponent>;
|
let fixture: ComponentFixture<OrgUnitSearchResultListElementComponent>;
|
||||||
|
let authorizationService = jasmine.createSpyObj('authorizationService', {
|
||||||
|
isAuthorized: observableOf(true)
|
||||||
|
});
|
||||||
|
|
||||||
|
const authService: AuthServiceStub = Object.assign(new AuthServiceStub(), {
|
||||||
|
getAuthenticatedUserFromStore: () => {
|
||||||
|
return of(EPersonMock);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const mockItemWithMetadata: ItemSearchResult = Object.assign(
|
const mockItemWithMetadata: ItemSearchResult = Object.assign(
|
||||||
new ItemSearchResult(),
|
new ItemSearchResult(),
|
||||||
@@ -133,6 +148,10 @@ describe('OrgUnitSearchResultListElementComponent', () => {
|
|||||||
{ provide: TruncatableService, useValue: {} },
|
{ provide: TruncatableService, useValue: {} },
|
||||||
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
||||||
{ provide: NotificationsService, useValue: {}},
|
{ provide: NotificationsService, useValue: {}},
|
||||||
|
{ provide: ResourcePolicyDataService, useValue: {}},
|
||||||
|
{ provide: AuthService, useValue: authService},
|
||||||
|
{ provide: EPersonDataService, useValue: {}},
|
||||||
|
{ provide: AuthorizationDataService, useValue: authorizationService},
|
||||||
{ provide: DSONameService, useClass: DSONameServiceMock },
|
{ provide: DSONameService, useClass: DSONameServiceMock },
|
||||||
{ provide: APP_CONFIG, useValue: environmentUseThumbs }
|
{ provide: APP_CONFIG, useValue: environmentUseThumbs }
|
||||||
],
|
],
|
||||||
@@ -208,6 +227,10 @@ describe('OrgUnitSearchResultListElementComponent', () => {
|
|||||||
{provide: TruncatableService, useValue: {}},
|
{provide: TruncatableService, useValue: {}},
|
||||||
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
||||||
{provide: NotificationsService, useValue: {}},
|
{provide: NotificationsService, useValue: {}},
|
||||||
|
{provide: ResourcePolicyDataService, useValue: {}},
|
||||||
|
{provide: AuthService, useValue: authService},
|
||||||
|
{provide: EPersonDataService, useValue: {}},
|
||||||
|
{provide: AuthorizationDataService, useValue: authorizationService},
|
||||||
{provide: DSONameService, useClass: DSONameServiceMock},
|
{provide: DSONameService, useClass: DSONameServiceMock},
|
||||||
{ provide: APP_CONFIG, useValue: enviromentNoThumbs }
|
{ provide: APP_CONFIG, useValue: enviromentNoThumbs }
|
||||||
],
|
],
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf, of } from 'rxjs';
|
||||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||||
import { PersonSearchResultListElementComponent } from './person-search-result-list-element.component';
|
import { PersonSearchResultListElementComponent } from './person-search-result-list-element.component';
|
||||||
import { Item } from '../../../../../core/shared/item.model';
|
import { Item } from '../../../../../core/shared/item.model';
|
||||||
@@ -19,12 +19,27 @@ import { hot } from 'jasmine-marbles';
|
|||||||
import { PageInfo } from '../../../../../core/shared/page-info.model';
|
import { PageInfo } from '../../../../../core/shared/page-info.model';
|
||||||
import { GroupMock } from '../../../../../shared/testing/group-mock';
|
import { GroupMock } from '../../../../../shared/testing/group-mock';
|
||||||
import { buildPaginatedList } from '../../../../../core/data/paginated-list.model';
|
import { buildPaginatedList } from '../../../../../core/data/paginated-list.model';
|
||||||
|
import { AuthServiceStub } from '../../../../../shared/testing/auth-service.stub';
|
||||||
|
import { EPersonMock } from '../../../../../shared/testing/eperson.mock';
|
||||||
|
import { ResourcePolicyDataService } from '../../../../../core/resource-policy/resource-policy-data.service';
|
||||||
|
import { AuthService } from '../../../../../core/auth/auth.service';
|
||||||
|
import { AuthorizationDataService } from '../../../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { EPersonDataService } from '../../../../../core/eperson/eperson-data.service';
|
||||||
|
|
||||||
let personListElementComponent: PersonSearchResultListElementComponent;
|
let personListElementComponent: PersonSearchResultListElementComponent;
|
||||||
let fixture: ComponentFixture<PersonSearchResultListElementComponent>;
|
let fixture: ComponentFixture<PersonSearchResultListElementComponent>;
|
||||||
const supervisionOrderDataService: any = jasmine.createSpyObj('supervisionOrderDataService', {
|
const supervisionOrderDataService: any = jasmine.createSpyObj('supervisionOrderDataService', {
|
||||||
searchByItem: jasmine.createSpy('searchByItem'),
|
searchByItem: jasmine.createSpy('searchByItem'),
|
||||||
});
|
});
|
||||||
|
let authorizationService = jasmine.createSpyObj('authorizationService', {
|
||||||
|
isAuthorized: observableOf(true)
|
||||||
|
});
|
||||||
|
|
||||||
|
const authService: AuthServiceStub = Object.assign(new AuthServiceStub(), {
|
||||||
|
getAuthenticatedUserFromStore: () => {
|
||||||
|
return of(EPersonMock);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const mockItemWithMetadata: ItemSearchResult = Object.assign(
|
const mockItemWithMetadata: ItemSearchResult = Object.assign(
|
||||||
new ItemSearchResult(),
|
new ItemSearchResult(),
|
||||||
@@ -132,6 +147,10 @@ describe('PersonSearchResultListElementComponent', () => {
|
|||||||
{ provide: TruncatableService, useValue: {} },
|
{ provide: TruncatableService, useValue: {} },
|
||||||
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
||||||
{ provide: NotificationsService, useValue: {} },
|
{ provide: NotificationsService, useValue: {} },
|
||||||
|
{ provide: ResourcePolicyDataService, useValue: {}},
|
||||||
|
{ provide: AuthService, useValue: authService},
|
||||||
|
{ provide: EPersonDataService, useValue: {}},
|
||||||
|
{ provide: AuthorizationDataService, useValue: authorizationService},
|
||||||
{ provide: DSONameService, useClass: DSONameServiceMock },
|
{ provide: DSONameService, useClass: DSONameServiceMock },
|
||||||
{ provide: APP_CONFIG, useValue: environmentUseThumbs }
|
{ provide: APP_CONFIG, useValue: environmentUseThumbs }
|
||||||
],
|
],
|
||||||
@@ -207,6 +226,10 @@ describe('PersonSearchResultListElementComponent', () => {
|
|||||||
{provide: TruncatableService, useValue: {}},
|
{provide: TruncatableService, useValue: {}},
|
||||||
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService},
|
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService},
|
||||||
{provide: NotificationsService, useValue: {}},
|
{provide: NotificationsService, useValue: {}},
|
||||||
|
{provide: ResourcePolicyDataService, useValue: {}},
|
||||||
|
{provide: AuthService, useValue: authService},
|
||||||
|
{provide: EPersonDataService, useValue: {}},
|
||||||
|
{provide: AuthorizationDataService, useValue: authorizationService},
|
||||||
{provide: DSONameService, useClass: DSONameServiceMock},
|
{provide: DSONameService, useClass: DSONameServiceMock},
|
||||||
{ provide: APP_CONFIG, useValue: enviromentNoThumbs }
|
{ provide: APP_CONFIG, useValue: enviromentNoThumbs }
|
||||||
],
|
],
|
||||||
|
@@ -13,6 +13,10 @@ import { SupervisionOrderDataService } from '../../../../../core/supervision-ord
|
|||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { NotificationsService } from '../../../../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../../../../shared/notifications/notifications.service';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { ResourcePolicyDataService } from '../../../../../core/resource-policy/resource-policy-data.service';
|
||||||
|
import { AuthService } from '../../../../../core/auth/auth.service';
|
||||||
|
import { EPersonDataService } from '../../../../../core/eperson/eperson-data.service';
|
||||||
|
import { AuthorizationDataService } from '../../../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
|
||||||
@listableObjectComponent('PersonSearchResult', ViewMode.ListElement)
|
@listableObjectComponent('PersonSearchResult', ViewMode.ListElement)
|
||||||
@Component({
|
@Component({
|
||||||
@@ -33,8 +37,12 @@ export class PersonSearchResultListElementComponent extends ItemSearchResultList
|
|||||||
protected modalService: NgbModal,
|
protected modalService: NgbModal,
|
||||||
protected notificationsService: NotificationsService,
|
protected notificationsService: NotificationsService,
|
||||||
protected translateService: TranslateService,
|
protected translateService: TranslateService,
|
||||||
|
protected resourcePolicyService: ResourcePolicyDataService,
|
||||||
|
protected authService: AuthService,
|
||||||
|
protected epersonService: EPersonDataService,
|
||||||
|
protected authorizationService: AuthorizationDataService
|
||||||
) {
|
) {
|
||||||
super(truncatableService, dsoNameService, appConfig, supervisionOrderDataService, modalService, notificationsService, translateService);
|
super(truncatableService, dsoNameService, appConfig, supervisionOrderDataService, modalService, notificationsService, translateService, resourcePolicyService, authService, epersonService, authorizationService);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf, of } from 'rxjs';
|
||||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||||
import { ProjectSearchResultListElementComponent } from './project-search-result-list-element.component';
|
import { ProjectSearchResultListElementComponent } from './project-search-result-list-element.component';
|
||||||
import { Item } from '../../../../../core/shared/item.model';
|
import { Item } from '../../../../../core/shared/item.model';
|
||||||
@@ -18,9 +18,24 @@ import { PageInfo } from '../../../../../core/shared/page-info.model';
|
|||||||
import { buildPaginatedList } from '../../../../../core/data/paginated-list.model';
|
import { buildPaginatedList } from '../../../../../core/data/paginated-list.model';
|
||||||
import { GroupMock } from '../../../../../shared/testing/group-mock';
|
import { GroupMock } from '../../../../../shared/testing/group-mock';
|
||||||
import { hot } from 'jasmine-marbles';
|
import { hot } from 'jasmine-marbles';
|
||||||
|
import { AuthService } from '../../../../../core/auth/auth.service';
|
||||||
|
import { AuthorizationDataService } from '../../../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { EPersonDataService } from '../../../../../core/eperson/eperson-data.service';
|
||||||
|
import { ResourcePolicyDataService } from '../../../../../core/resource-policy/resource-policy-data.service';
|
||||||
|
import { AuthServiceStub } from '../../../../../shared/testing/auth-service.stub';
|
||||||
|
import { EPersonMock } from '../../../../../shared/testing/eperson.mock';
|
||||||
|
|
||||||
let projectListElementComponent: ProjectSearchResultListElementComponent;
|
let projectListElementComponent: ProjectSearchResultListElementComponent;
|
||||||
let fixture: ComponentFixture<ProjectSearchResultListElementComponent>;
|
let fixture: ComponentFixture<ProjectSearchResultListElementComponent>;
|
||||||
|
let authorizationService = jasmine.createSpyObj('authorizationService', {
|
||||||
|
isAuthorized: observableOf(true)
|
||||||
|
});
|
||||||
|
|
||||||
|
const authService: AuthServiceStub = Object.assign(new AuthServiceStub(), {
|
||||||
|
getAuthenticatedUserFromStore: () => {
|
||||||
|
return of(EPersonMock);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const mockItemWithMetadata: ItemSearchResult = Object.assign(
|
const mockItemWithMetadata: ItemSearchResult = Object.assign(
|
||||||
new ItemSearchResult(),
|
new ItemSearchResult(),
|
||||||
@@ -127,6 +142,10 @@ describe('ProjectSearchResultListElementComponent', () => {
|
|||||||
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
||||||
{ provide: NotificationsService, useValue: {}},
|
{ provide: NotificationsService, useValue: {}},
|
||||||
{ provide: TranslateService, useValue: {}},
|
{ provide: TranslateService, useValue: {}},
|
||||||
|
{ provide: ResourcePolicyDataService, useValue: {}},
|
||||||
|
{ provide: AuthService, useValue: authService},
|
||||||
|
{ provide: EPersonDataService, useValue: {}},
|
||||||
|
{ provide: AuthorizationDataService, useValue: authorizationService},
|
||||||
{ provide: DSONameService, useClass: DSONameServiceMock },
|
{ provide: DSONameService, useClass: DSONameServiceMock },
|
||||||
{ provide: APP_CONFIG, useValue: environmentUseThumbs }
|
{ provide: APP_CONFIG, useValue: environmentUseThumbs }
|
||||||
],
|
],
|
||||||
@@ -196,6 +215,10 @@ describe('ProjectSearchResultListElementComponent', () => {
|
|||||||
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
||||||
{provide: NotificationsService, useValue: {}},
|
{provide: NotificationsService, useValue: {}},
|
||||||
{provide: TranslateService, useValue: {}},
|
{provide: TranslateService, useValue: {}},
|
||||||
|
{provide: ResourcePolicyDataService, useValue: {}},
|
||||||
|
{provide: AuthService, useValue: authService},
|
||||||
|
{provide: EPersonDataService, useValue: {}},
|
||||||
|
{provide: AuthorizationDataService, useValue: authorizationService},
|
||||||
{provide: DSONameService, useClass: DSONameServiceMock},
|
{provide: DSONameService, useClass: DSONameServiceMock},
|
||||||
{ provide: APP_CONFIG, useValue: enviromentNoThumbs }
|
{ provide: APP_CONFIG, useValue: enviromentNoThumbs }
|
||||||
|
|
||||||
|
@@ -7,6 +7,7 @@ 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 { SupervisionOrder } from '../../../../core/supervision-order/models/supervision-order.model';
|
import { SupervisionOrder } from '../../../../core/supervision-order/models/supervision-order.model';
|
||||||
import { SupervisionOrderDataService } from '../../../../core/supervision-order/supervision-order-data.service';
|
import { SupervisionOrderDataService } from '../../../../core/supervision-order/supervision-order-data.service';
|
||||||
|
import { followLink } from '../../../../shared/utils/follow-link-config.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to wrap a dropdown - for type of order -
|
* Component to wrap a dropdown - for type of order -
|
||||||
@@ -76,6 +77,7 @@ export class SupervisionGroupSelectorComponent {
|
|||||||
getFirstCompletedRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
).subscribe(rd => {
|
).subscribe(rd => {
|
||||||
if (rd.state === 'Success') {
|
if (rd.state === 'Success') {
|
||||||
|
this.supervisionOrderDataService.searchByItem(this.itemUUID, null, null, followLink('group'));
|
||||||
this.notificationsService.success(this.translateService.get('supervision-group-selector.notification.create.success.title', { name: this.selectedGroup.name }));
|
this.notificationsService.success(this.translateService.get('supervision-group-selector.notification.create.success.title', { name: this.selectedGroup.name }));
|
||||||
} else {
|
} else {
|
||||||
this.notificationsService.error(
|
this.notificationsService.error(
|
||||||
|
@@ -13,7 +13,7 @@ import {
|
|||||||
ViewChild
|
ViewChild
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
|
||||||
import { Subscription } from 'rxjs';
|
import { Observable, Subscription } from 'rxjs';
|
||||||
import { take } from 'rxjs/operators';
|
import { take } from 'rxjs/operators';
|
||||||
|
|
||||||
import { ListableObject } from '../listable-object.model';
|
import { ListableObject } from '../listable-object.model';
|
||||||
@@ -41,6 +41,11 @@ export class ListableObjectComponentLoaderComponent implements OnInit, OnChanges
|
|||||||
*/
|
*/
|
||||||
@Input() object: ListableObject;
|
@Input() object: ListableObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The supervision order to determine supervision orders
|
||||||
|
*/
|
||||||
|
@Input() supervisionOrders: Observable<any>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The index of the object in the list
|
* The index of the object in the list
|
||||||
*/
|
*/
|
||||||
@@ -123,6 +128,7 @@ export class ListableObjectComponentLoaderComponent implements OnInit, OnChanges
|
|||||||
*/
|
*/
|
||||||
protected inAndOutputNames: string[] = [
|
protected inAndOutputNames: string[] = [
|
||||||
'object',
|
'object',
|
||||||
|
'supervisionOrders',
|
||||||
'index',
|
'index',
|
||||||
'linkType',
|
'linkType',
|
||||||
'listID',
|
'listID',
|
||||||
|
@@ -16,6 +16,11 @@ export class AbstractListableElementComponent<T extends ListableObject> {
|
|||||||
*/
|
*/
|
||||||
@Input() object: T;
|
@Input() object: T;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The supervision orders to render in this list element
|
||||||
|
*/
|
||||||
|
@Input() supervisionOrders: T;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The link type to determine the type of link rendered in this element
|
* The link type to determine the type of link rendered in this element
|
||||||
*/
|
*/
|
||||||
|
@@ -1 +1 @@
|
|||||||
<ds-item-search-result-list-element [showLabel]="showLabel" [object]="{ indexableObject: object, hitHighlights: {} }" [linkType]="linkType"></ds-item-search-result-list-element>
|
<ds-item-search-result-list-element [showLabel]="showLabel" [object]="{ indexableObject: object, hitHighlights: {} }" [supervisionOrders]="supervisionOrders" [linkType]="linkType"></ds-item-search-result-list-element>
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf, of } from 'rxjs';
|
||||||
import { ItemSearchResultListElementComponent } from './item-search-result-list-element.component';
|
import { ItemSearchResultListElementComponent } from './item-search-result-list-element.component';
|
||||||
import { Item } from '../../../../../../core/shared/item.model';
|
import { Item } from '../../../../../../core/shared/item.model';
|
||||||
import { TruncatePipe } from '../../../../../utils/truncate.pipe';
|
import { TruncatePipe } from '../../../../../utils/truncate.pipe';
|
||||||
@@ -13,14 +13,39 @@ import { APP_CONFIG } from '../../../../../../../config/app-config.interface';
|
|||||||
import { SupervisionOrderDataService } from '../../../../../../core/supervision-order/supervision-order-data.service';
|
import { SupervisionOrderDataService } from '../../../../../../core/supervision-order/supervision-order-data.service';
|
||||||
import { NotificationsService } from '../../../../../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../../../../../shared/notifications/notifications.service';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { createSuccessfulRemoteDataObject } from '../../../../../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../../../../../shared/remote-data.utils';
|
||||||
import { PageInfo } from '../../../../../../core/shared/page-info.model';
|
import { PageInfo } from '../../../../../../core/shared/page-info.model';
|
||||||
import { buildPaginatedList } from '../../../../../../core/data/paginated-list.model';
|
import { buildPaginatedList } from '../../../../../../core/data/paginated-list.model';
|
||||||
import { GroupMock } from '../../../../../../shared/testing/group-mock';
|
import { GroupMock } from '../../../../../../shared/testing/group-mock';
|
||||||
import { hot } from 'jasmine-marbles';
|
import { hot } from 'jasmine-marbles';
|
||||||
|
import { AuthService } from '../../../../../../core/auth/auth.service';
|
||||||
|
import { AuthorizationDataService } from '../../../../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { EPersonDataService } from '../../../../../../core/eperson/eperson-data.service';
|
||||||
|
import { ResourcePolicyDataService } from '../../../../../../core/resource-policy/resource-policy-data.service';
|
||||||
|
import { AuthServiceStub } from '../../../../../../shared/testing/auth-service.stub';
|
||||||
|
import { EPersonMock } from '../../../../../../shared/testing/eperson.mock';
|
||||||
|
import { EPerson } from 'src/app/core/eperson/models/eperson.model';
|
||||||
|
import { createPaginatedList } from 'src/app/shared/testing/utils.test';
|
||||||
|
|
||||||
let publicationListElementComponent: ItemSearchResultListElementComponent;
|
let publicationListElementComponent: ItemSearchResultListElementComponent;
|
||||||
let fixture: ComponentFixture<ItemSearchResultListElementComponent>;
|
let fixture: ComponentFixture<ItemSearchResultListElementComponent>;
|
||||||
|
let authorizationService = jasmine.createSpyObj('authorizationService', {
|
||||||
|
isAuthorized: observableOf(true)
|
||||||
|
});
|
||||||
|
|
||||||
|
const authService: AuthServiceStub = Object.assign(new AuthServiceStub(), {
|
||||||
|
getAuthenticatedUserFromStore: () => {
|
||||||
|
return of(EPersonMock);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const user = Object.assign(new EPerson(), {
|
||||||
|
id: 'userId',
|
||||||
|
groups: createSuccessfulRemoteDataObject$(createPaginatedList([])),
|
||||||
|
_links: { self: { href: 'test.com/uuid/1234567654321' } }
|
||||||
|
});
|
||||||
|
const epersonService = jasmine.createSpyObj('epersonService', {
|
||||||
|
findById: createSuccessfulRemoteDataObject$(user),
|
||||||
|
});
|
||||||
|
|
||||||
const mockItemWithMetadata: ItemSearchResult = Object.assign(new ItemSearchResult(), {
|
const mockItemWithMetadata: ItemSearchResult = Object.assign(new ItemSearchResult(), {
|
||||||
indexableObject:
|
indexableObject:
|
||||||
@@ -135,6 +160,10 @@ describe('ItemSearchResultListElementComponent', () => {
|
|||||||
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
{ provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
||||||
{ provide: NotificationsService, useValue: {}},
|
{ provide: NotificationsService, useValue: {}},
|
||||||
{ provide: TranslateService, useValue: {}},
|
{ provide: TranslateService, useValue: {}},
|
||||||
|
{ provide: ResourcePolicyDataService, useValue: {}},
|
||||||
|
{ provide: AuthService, useValue: authService},
|
||||||
|
{ provide: EPersonDataService, useValue: epersonService},
|
||||||
|
{ provide: AuthorizationDataService, useValue: authorizationService},
|
||||||
{ provide: DSONameService, useClass: DSONameServiceMock },
|
{ provide: DSONameService, useClass: DSONameServiceMock },
|
||||||
{ provide: APP_CONFIG, useValue: environmentUseThumbs }
|
{ provide: APP_CONFIG, useValue: environmentUseThumbs }
|
||||||
],
|
],
|
||||||
@@ -288,6 +317,10 @@ describe('ItemSearchResultListElementComponent', () => {
|
|||||||
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
{provide: SupervisionOrderDataService, useValue: supervisionOrderDataService },
|
||||||
{provide: NotificationsService, useValue: {}},
|
{provide: NotificationsService, useValue: {}},
|
||||||
{provide: TranslateService, useValue: {}},
|
{provide: TranslateService, useValue: {}},
|
||||||
|
{provide: ResourcePolicyDataService, useValue: {}},
|
||||||
|
{provide: AuthService, useValue: authService},
|
||||||
|
{provide: EPersonDataService, useValue: epersonService},
|
||||||
|
{provide: AuthorizationDataService, useValue: authorizationService},
|
||||||
{provide: DSONameService, useClass: DSONameServiceMock},
|
{provide: DSONameService, useClass: DSONameServiceMock},
|
||||||
{ provide: APP_CONFIG, useValue: enviromentNoThumbs }
|
{ provide: APP_CONFIG, useValue: enviromentNoThumbs }
|
||||||
],
|
],
|
||||||
|
@@ -10,7 +10,7 @@ import { TruncatableService } from '../../../../../../shared/truncatable/truncat
|
|||||||
import { DSONameService } from '../../../../../../core/breadcrumbs/dso-name.service';
|
import { DSONameService } from '../../../../../../core/breadcrumbs/dso-name.service';
|
||||||
import { AppConfig, APP_CONFIG } from '../../../../../../../config/app-config.interface';
|
import { AppConfig, APP_CONFIG } from '../../../../../../../config/app-config.interface';
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { combineLatest, map, Observable, switchMap, take } from 'rxjs';
|
import { combineLatest, filter, map, Observable, switchMap, take } from 'rxjs';
|
||||||
import { ConfirmationModalComponent } from '../../../../../../shared/confirmation-modal/confirmation-modal.component';
|
import { ConfirmationModalComponent } from '../../../../../../shared/confirmation-modal/confirmation-modal.component';
|
||||||
import { hasValue } from '../../../../../../shared/empty.util';
|
import { hasValue } from '../../../../../../shared/empty.util';
|
||||||
import { NotificationsService } from '../../../../../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../../../../../shared/notifications/notifications.service';
|
||||||
@@ -19,6 +19,13 @@ import { followLink } from '../../../../../../shared/utils/follow-link-config.mo
|
|||||||
import { getAllSucceededRemoteListPayload, getFirstSucceededRemoteDataPayload } from '../../../../../../core/shared/operators';
|
import { getAllSucceededRemoteListPayload, getFirstSucceededRemoteDataPayload } from '../../../../../../core/shared/operators';
|
||||||
import { SupervisionOrder } from '../../../../../../core/supervision-order/models/supervision-order.model';
|
import { SupervisionOrder } from '../../../../../../core/supervision-order/models/supervision-order.model';
|
||||||
import { Group } from '../../../../../../core/eperson/models/group.model';
|
import { Group } from '../../../../../../core/eperson/models/group.model';
|
||||||
|
import { ResourcePolicyDataService } from '../../../../../../core/resource-policy/resource-policy-data.service';
|
||||||
|
import { getAllSucceededRemoteData, getRemoteDataPayload } from '../../../../../../core/shared/operators';
|
||||||
|
import { AuthService } from '../../../../../../core/auth/auth.service';
|
||||||
|
import { EPerson } from '../../../../../../core/eperson/models/eperson.model';
|
||||||
|
import { EPersonDataService } from '../../../../../../core/eperson/eperson-data.service';
|
||||||
|
import { AuthorizationDataService } from '../../../../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { FeatureID } from '../../../../../../core/data/feature-authorization/feature-id';
|
||||||
|
|
||||||
@listableObjectComponent('PublicationSearchResult', ViewMode.ListElement)
|
@listableObjectComponent('PublicationSearchResult', ViewMode.ListElement)
|
||||||
@listableObjectComponent(ItemSearchResult, ViewMode.ListElement)
|
@listableObjectComponent(ItemSearchResult, ViewMode.ListElement)
|
||||||
@@ -48,6 +55,11 @@ export class ItemSearchResultListElementComponent extends SearchResultListElemen
|
|||||||
*/
|
*/
|
||||||
supervisionOrder$: Observable<{ supervisionOrder: SupervisionOrder; group: Group; }[]>;
|
supervisionOrder$: Observable<{ supervisionOrder: SupervisionOrder; group: Group; }[]>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The groups the user belongs to
|
||||||
|
*/
|
||||||
|
groups: Group[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected truncatableService: TruncatableService,
|
protected truncatableService: TruncatableService,
|
||||||
protected dsoNameService: DSONameService,
|
protected dsoNameService: DSONameService,
|
||||||
@@ -56,24 +68,63 @@ export class ItemSearchResultListElementComponent extends SearchResultListElemen
|
|||||||
protected modalService: NgbModal,
|
protected modalService: NgbModal,
|
||||||
protected notificationsService: NotificationsService,
|
protected notificationsService: NotificationsService,
|
||||||
protected translateService: TranslateService,
|
protected translateService: TranslateService,
|
||||||
|
protected resourcePolicyService: ResourcePolicyDataService,
|
||||||
|
protected authService: AuthService,
|
||||||
|
protected epersonService: EPersonDataService,
|
||||||
|
protected authorizationService: AuthorizationDataService
|
||||||
) { super(truncatableService, dsoNameService, appConfig); }
|
) { super(truncatableService, dsoNameService, appConfig); }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
this.showThumbnails = this.appConfig.browseBy.showThumbnails;
|
this.showThumbnails = this.appConfig.browseBy.showThumbnails;
|
||||||
|
let isAdmin = false;
|
||||||
|
this.authorizationService.isAuthorized(FeatureID.AdministratorOf).subscribe(isadmin => {
|
||||||
|
isAdmin = isadmin;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.authService.getAuthenticatedUserFromStore().pipe(
|
||||||
|
filter((user: EPerson) => hasValue(user.id)),
|
||||||
|
switchMap((user: EPerson) => this.epersonService.findById(user.id, true, true, followLink('groups'))),
|
||||||
|
getAllSucceededRemoteData(),
|
||||||
|
getRemoteDataPayload(),
|
||||||
|
switchMap((user: EPerson) => user.groups),
|
||||||
|
).subscribe(groups => {
|
||||||
|
this.groups = groups?.payload?.page;
|
||||||
|
});
|
||||||
|
|
||||||
this.itemPageRoute = getItemPageRoute(this.dso);
|
this.itemPageRoute = getItemPageRoute(this.dso);
|
||||||
|
if (this.supervisionOrders) {
|
||||||
|
this.resourcePolicyService.searchByResource(
|
||||||
|
this.dso.uuid, null, false, true,
|
||||||
|
followLink('eperson'), followLink('group')
|
||||||
|
).pipe(
|
||||||
|
getAllSucceededRemoteData(),
|
||||||
|
).subscribe((result) => {
|
||||||
this.supervisionOrder$ = this.supervisionOrderDataService.searchByItem(this.dso.uuid, null, null, followLink('group')).pipe(
|
this.supervisionOrder$ = this.supervisionOrderDataService.searchByItem(this.dso.uuid, null, null, followLink('group')).pipe(
|
||||||
getAllSucceededRemoteListPayload(),
|
getAllSucceededRemoteListPayload(),
|
||||||
switchMap((supervisionOrders: SupervisionOrder[]) => {
|
switchMap((supervisionOrders: SupervisionOrder[]) => {
|
||||||
const supervisionOrdersArray = supervisionOrders.map((supervisionOrder: SupervisionOrder) => {
|
const supervisionOrdersArray = supervisionOrders.map((supervisionOrder: SupervisionOrder) => {
|
||||||
return supervisionOrder.group.pipe(
|
return supervisionOrder.group.pipe(
|
||||||
getFirstSucceededRemoteDataPayload(),
|
getFirstSucceededRemoteDataPayload(),
|
||||||
map((group: Group) => ({ supervisionOrder, group }))
|
map((group: Group) => {
|
||||||
|
let isAuthorized = false;
|
||||||
|
result.payload.page.forEach(resourcePolicy => {
|
||||||
|
resourcePolicy.group.subscribe(res => {
|
||||||
|
if (isAdmin || (res.payload && res.payload.uuid === group.uuid && this.groups.find(groups => groups.uuid === group.uuid))) {
|
||||||
|
isAuthorized = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return isAuthorized ? ({ supervisionOrder, group }) : null;
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
return combineLatest(supervisionOrdersArray);
|
return combineLatest(supervisionOrdersArray).pipe(
|
||||||
})
|
map(array => array.filter(hasValue))
|
||||||
);
|
);
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,6 +146,7 @@ export class ItemSearchResultListElementComponent extends SearchResultListElemen
|
|||||||
this.supervisionOrderDataService.delete(supervisionOrder.supervisionOrder.id)
|
this.supervisionOrderDataService.delete(supervisionOrder.supervisionOrder.id)
|
||||||
.subscribe((rd: boolean) => {
|
.subscribe((rd: boolean) => {
|
||||||
if (rd) {
|
if (rd) {
|
||||||
|
this.supervisionOrderDataService.searchByItem(this.dso.uuid, null, null, followLink('group'));
|
||||||
this.notificationsService.success(this.translateService.get(this.messagePrefix + '.notification.deleted.success', { name: supervisionOrder.group._name }));
|
this.notificationsService.success(this.translateService.get(this.messagePrefix + '.notification.deleted.success', { name: supervisionOrder.group._name }));
|
||||||
} else {
|
} else {
|
||||||
this.notificationsService.error(
|
this.notificationsService.error(
|
||||||
|
@@ -399,15 +399,20 @@ export class SearchComponent implements OnInit {
|
|||||||
private retrieveSearchResults(searchOptions: PaginatedSearchOptions) {
|
private retrieveSearchResults(searchOptions: PaginatedSearchOptions) {
|
||||||
this.resultsRD$.next(null);
|
this.resultsRD$.next(null);
|
||||||
this.lastSearchOptions = searchOptions;
|
this.lastSearchOptions = searchOptions;
|
||||||
|
let followLinks = [
|
||||||
|
followLink<Item>('thumbnail', { isOptional: true }),
|
||||||
|
followLink<SubmissionObject>('item', { isOptional: true }, followLink<Item>('thumbnail', { isOptional: true })) as any,
|
||||||
|
followLink<Item>('accessStatus', { isOptional: true, shouldEmbed: environment.item.showAccessStatuses }),
|
||||||
|
];
|
||||||
|
if (this.configuration === 'supervision') {
|
||||||
|
followLinks.push(followLink<WorkspaceItem>('supervisionOrders', { isOptional: true }) as any);
|
||||||
|
}
|
||||||
this.service.search(
|
this.service.search(
|
||||||
searchOptions,
|
searchOptions,
|
||||||
undefined,
|
undefined,
|
||||||
this.useCachedVersionIfAvailable,
|
this.useCachedVersionIfAvailable,
|
||||||
true,
|
true,
|
||||||
followLink<Item>('thumbnail', { isOptional: true }),
|
...followLinks
|
||||||
followLink<SubmissionObject>('item', { isOptional: true }, followLink<Item>('thumbnail', { isOptional: true })) as any,
|
|
||||||
followLink<WorkspaceItem>('supervisionOrders', { isOptional: true }) as any,
|
|
||||||
followLink<Item>('accessStatus', { isOptional: true, shouldEmbed: environment.item.showAccessStatuses }),
|
|
||||||
).pipe(getFirstCompletedRemoteData())
|
).pipe(getFirstCompletedRemoteData())
|
||||||
.subscribe((results: RemoteData<SearchObjects<DSpaceObject>>) => {
|
.subscribe((results: RemoteData<SearchObjects<DSpaceObject>>) => {
|
||||||
if (results.hasSucceeded) {
|
if (results.hasSucceeded) {
|
||||||
|
Reference in New Issue
Block a user