mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 15:03:07 +00:00
Merge pull request #1476 from 4Science/CST-5064
Show submitter in version history table
This commit is contained in:
@@ -47,6 +47,12 @@ export class Version extends DSpaceObject {
|
|||||||
@autoserialize
|
@autoserialize
|
||||||
summary: string;
|
summary: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the submitter of this version
|
||||||
|
*/
|
||||||
|
@autoserialize
|
||||||
|
submitterName: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Date this version was created
|
* The Date this version was created
|
||||||
*/
|
*/
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">{{"item.version.history.table.version" | translate}}</th>
|
<th scope="col">{{"item.version.history.table.version" | translate}}</th>
|
||||||
<th scope="col" *ngIf="(hasEpersons$ | async)">{{"item.version.history.table.editor" | translate}}</th>
|
<th scope="col" *ngIf="(showSubmitter() | async)">{{"item.version.history.table.editor" | translate}}</th>
|
||||||
<th scope="col">{{"item.version.history.table.date" | translate}}</th>
|
<th scope="col">{{"item.version.history.table.date" | translate}}</th>
|
||||||
<th scope="col">{{"item.version.history.table.summary" | translate}}</th>
|
<th scope="col">{{"item.version.history.table.summary" | translate}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -87,10 +87,8 @@
|
|||||||
</ng-container>
|
</ng-container>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</td>
|
</td>
|
||||||
<td *ngIf="(hasEpersons$ | async)" class="version-row-element-editor">
|
<td class="version-row-element-editor" *ngIf="(showSubmitter() | async)">
|
||||||
<span *ngVar="(version?.eperson | async)?.payload as eperson">
|
{{version?.submitterName}}
|
||||||
<a *ngIf="eperson" [href]="'mailto:' + eperson?.email">{{eperson?.name}}</a>
|
|
||||||
</span>
|
|
||||||
</td>
|
</td>
|
||||||
<td class="version-row-element-date">
|
<td class="version-row-element-date">
|
||||||
{{version?.created | date : 'yyyy-MM-dd HH:mm:ss'}}
|
{{version?.created | date : 'yyyy-MM-dd HH:mm:ss'}}
|
||||||
|
@@ -24,6 +24,7 @@ import { AuthorizationDataService } from '../../../core/data/feature-authorizati
|
|||||||
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||||
import { WorkspaceitemDataService } from '../../../core/submission/workspaceitem-data.service';
|
import { WorkspaceitemDataService } from '../../../core/submission/workspaceitem-data.service';
|
||||||
import { WorkflowItemDataService } from '../../../core/submission/workflowitem-data.service';
|
import { WorkflowItemDataService } from '../../../core/submission/workflowitem-data.service';
|
||||||
|
import { ConfigurationDataService } from '../../../core/data/configuration-data.service';
|
||||||
|
|
||||||
describe('ItemVersionsComponent', () => {
|
describe('ItemVersionsComponent', () => {
|
||||||
let component: ItemVersionsComponent;
|
let component: ItemVersionsComponent;
|
||||||
@@ -34,6 +35,7 @@ describe('ItemVersionsComponent', () => {
|
|||||||
let workspaceItemDataService: WorkspaceitemDataService;
|
let workspaceItemDataService: WorkspaceitemDataService;
|
||||||
let workflowItemDataService: WorkflowItemDataService;
|
let workflowItemDataService: WorkflowItemDataService;
|
||||||
let versionService: VersionDataService;
|
let versionService: VersionDataService;
|
||||||
|
let configurationService: ConfigurationDataService;
|
||||||
|
|
||||||
const versionHistory = Object.assign(new VersionHistory(), {
|
const versionHistory = Object.assign(new VersionHistory(), {
|
||||||
id: '1',
|
id: '1',
|
||||||
@@ -109,6 +111,10 @@ describe('ItemVersionsComponent', () => {
|
|||||||
findById: EMPTY,
|
findById: EMPTY,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const configurationServiceSpy = jasmine.createSpyObj('configurationService', {
|
||||||
|
findByPropertyName: of(true),
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
@@ -125,6 +131,7 @@ describe('ItemVersionsComponent', () => {
|
|||||||
{provide: VersionDataService, useValue: versionServiceSpy},
|
{provide: VersionDataService, useValue: versionServiceSpy},
|
||||||
{provide: WorkspaceitemDataService, useValue: workspaceItemDataServiceSpy},
|
{provide: WorkspaceitemDataService, useValue: workspaceItemDataServiceSpy},
|
||||||
{provide: WorkflowItemDataService, useValue: workflowItemDataServiceSpy},
|
{provide: WorkflowItemDataService, useValue: workflowItemDataServiceSpy},
|
||||||
|
{provide: ConfigurationDataService, useValue: configurationServiceSpy},
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
@@ -135,6 +142,7 @@ describe('ItemVersionsComponent', () => {
|
|||||||
workspaceItemDataService = TestBed.inject(WorkspaceitemDataService);
|
workspaceItemDataService = TestBed.inject(WorkspaceitemDataService);
|
||||||
workflowItemDataService = TestBed.inject(WorkflowItemDataService);
|
workflowItemDataService = TestBed.inject(WorkflowItemDataService);
|
||||||
versionService = TestBed.inject(VersionDataService);
|
versionService = TestBed.inject(VersionDataService);
|
||||||
|
configurationService = TestBed.inject(ConfigurationDataService);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@@ -5,7 +5,6 @@ import { RemoteData } from '../../../core/data/remote-data';
|
|||||||
import {
|
import {
|
||||||
BehaviorSubject,
|
BehaviorSubject,
|
||||||
combineLatest,
|
combineLatest,
|
||||||
combineLatest as observableCombineLatest,
|
|
||||||
Observable,
|
Observable,
|
||||||
of,
|
of,
|
||||||
Subscription,
|
Subscription,
|
||||||
@@ -48,6 +47,7 @@ import { ItemVersionsSharedService } from './item-versions-shared.service';
|
|||||||
import { WorkspaceItem } from '../../../core/submission/models/workspaceitem.model';
|
import { WorkspaceItem } from '../../../core/submission/models/workspaceitem.model';
|
||||||
import { WorkspaceitemDataService } from '../../../core/submission/workspaceitem-data.service';
|
import { WorkspaceitemDataService } from '../../../core/submission/workspaceitem-data.service';
|
||||||
import { WorkflowItemDataService } from '../../../core/submission/workflowitem-data.service';
|
import { WorkflowItemDataService } from '../../../core/submission/workflowitem-data.service';
|
||||||
|
import { ConfigurationDataService } from '../../../core/data/configuration-data.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-item-versions',
|
selector: 'ds-item-versions',
|
||||||
@@ -180,6 +180,7 @@ export class ItemVersionsComponent implements OnInit {
|
|||||||
private authorizationService: AuthorizationDataService,
|
private authorizationService: AuthorizationDataService,
|
||||||
private workspaceItemDataService: WorkspaceitemDataService,
|
private workspaceItemDataService: WorkspaceitemDataService,
|
||||||
private workflowItemDataService: WorkflowItemDataService,
|
private workflowItemDataService: WorkflowItemDataService,
|
||||||
|
private configurationService: ConfigurationDataService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,6 +376,36 @@ export class ItemVersionsComponent implements OnInit {
|
|||||||
return this.authorizationService.isAuthorized(FeatureID.CanEditVersion, version.self);
|
return this.authorizationService.isAuthorized(FeatureID.CanEditVersion, version.self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show submitter in version history table
|
||||||
|
*/
|
||||||
|
showSubmitter() {
|
||||||
|
|
||||||
|
const includeSubmitter$ = this.configurationService.findByPropertyName('versioning.item.history.include.submitter').pipe(
|
||||||
|
getFirstSucceededRemoteDataPayload(),
|
||||||
|
map((configurationProperty) => configurationProperty.values[0]),
|
||||||
|
startWith(false),
|
||||||
|
);
|
||||||
|
|
||||||
|
const isAdmin$ = combineLatest([
|
||||||
|
this.authorizationService.isAuthorized(FeatureID.IsCollectionAdmin),
|
||||||
|
this.authorizationService.isAuthorized(FeatureID.IsCommunityAdmin),
|
||||||
|
this.authorizationService.isAuthorized(FeatureID.AdministratorOf),
|
||||||
|
]).pipe(
|
||||||
|
map(([isCollectionAdmin, isCommunityAdmin, isSiteAdmin]) => {
|
||||||
|
return isCollectionAdmin || isCommunityAdmin || isSiteAdmin;
|
||||||
|
}),
|
||||||
|
take(1),
|
||||||
|
);
|
||||||
|
|
||||||
|
return combineLatest([includeSubmitter$, isAdmin$]).pipe(
|
||||||
|
map(([includeSubmitter, isAdmin]) => {
|
||||||
|
return includeSubmitter && isAdmin;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the current user can delete the version
|
* Check if the current user can delete the version
|
||||||
* @param version
|
* @param version
|
||||||
@@ -389,7 +420,7 @@ export class ItemVersionsComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
getAllVersions(versionHistory$: Observable<VersionHistory>): void {
|
getAllVersions(versionHistory$: Observable<VersionHistory>): void {
|
||||||
const currentPagination = this.paginationService.getCurrentPagination(this.options.id, this.options);
|
const currentPagination = this.paginationService.getCurrentPagination(this.options.id, this.options);
|
||||||
observableCombineLatest([versionHistory$, currentPagination]).pipe(
|
combineLatest([versionHistory$, currentPagination]).pipe(
|
||||||
switchMap(([versionHistory, options]: [VersionHistory, PaginationComponentOptions]) => {
|
switchMap(([versionHistory, options]: [VersionHistory, PaginationComponentOptions]) => {
|
||||||
return this.versionHistoryService.getVersions(versionHistory.id,
|
return this.versionHistoryService.getVersions(versionHistory.id,
|
||||||
new PaginatedSearchOptions({pagination: Object.assign({}, options, {currentPage: options.currentPage})}),
|
new PaginatedSearchOptions({pagination: Object.assign({}, options, {currentPage: options.currentPage})}),
|
||||||
@@ -486,7 +517,7 @@ export class ItemVersionsComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
this.itemPageRoutes$ = this.versionsRD$.pipe(
|
this.itemPageRoutes$ = this.versionsRD$.pipe(
|
||||||
getAllSucceededRemoteDataPayload(),
|
getAllSucceededRemoteDataPayload(),
|
||||||
switchMap((versions) => observableCombineLatest(...versions.page.map((version) => version.item.pipe(getAllSucceededRemoteDataPayload())))),
|
switchMap((versions) => combineLatest(versions.page.map((version) => version.item.pipe(getAllSucceededRemoteDataPayload())))),
|
||||||
map((versions) => {
|
map((versions) => {
|
||||||
const itemPageRoutes = {};
|
const itemPageRoutes = {};
|
||||||
versions.forEach((item) => itemPageRoutes[item.uuid] = getItemPageRoute(item));
|
versions.forEach((item) => itemPageRoutes[item.uuid] = getItemPageRoute(item));
|
||||||
|
Reference in New Issue
Block a user