mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 14:03:06 +00:00
refactor, adapt breadcrumbs for non admin users, fix translations
This commit is contained in:
@@ -3,6 +3,7 @@ import { Breadcrumb } from '../../breadcrumbs/breadcrumb/breadcrumb.model';
|
|||||||
import { getTestScheduler } from 'jasmine-marbles';
|
import { getTestScheduler } from 'jasmine-marbles';
|
||||||
import { PublicationClaimBreadcrumbService } from './publication-claim-breadcrumb.service';
|
import { PublicationClaimBreadcrumbService } from './publication-claim-breadcrumb.service';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
||||||
|
import { of } from 'rxjs';
|
||||||
|
|
||||||
describe('PublicationClaimBreadcrumbService', () => {
|
describe('PublicationClaimBreadcrumbService', () => {
|
||||||
let service: PublicationClaimBreadcrumbService;
|
let service: PublicationClaimBreadcrumbService;
|
||||||
@@ -17,6 +18,10 @@ describe('PublicationClaimBreadcrumbService', () => {
|
|||||||
findById: (str) => createSuccessfulRemoteDataObject$(str),
|
findById: (str) => createSuccessfulRemoteDataObject$(str),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let authorizationService: any = {
|
||||||
|
isAuthorized: (str) => of(true),
|
||||||
|
};
|
||||||
|
|
||||||
let exampleKey;
|
let exampleKey;
|
||||||
|
|
||||||
const ADMIN_PUBLICATION_CLAIMS_PATH = 'admin/notifications/publication-claim';
|
const ADMIN_PUBLICATION_CLAIMS_PATH = 'admin/notifications/publication-claim';
|
||||||
@@ -32,7 +37,7 @@ describe('PublicationClaimBreadcrumbService', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
service = new PublicationClaimBreadcrumbService(dataService,dsoNameService,translateService);
|
service = new PublicationClaimBreadcrumbService(dataService,dsoNameService,translateService, authorizationService);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getBreadcrumbs', () => {
|
describe('getBreadcrumbs', () => {
|
||||||
|
@@ -1,12 +1,14 @@
|
|||||||
import { Breadcrumb } from '../../breadcrumbs/breadcrumb/breadcrumb.model';
|
import { Breadcrumb } from '../../breadcrumbs/breadcrumb/breadcrumb.model';
|
||||||
import { BreadcrumbsProviderService } from './breadcrumbsProviderService';
|
import { BreadcrumbsProviderService } from './breadcrumbsProviderService';
|
||||||
import { Observable } from 'rxjs';
|
import { combineLatest, Observable } from 'rxjs';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { ItemDataService } from '../data/item-data.service';
|
import { ItemDataService } from '../data/item-data.service';
|
||||||
import { getFirstCompletedRemoteData } from '../shared/operators';
|
import { getFirstCompletedRemoteData } from '../shared/operators';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { DSONameService } from './dso-name.service';
|
import { DSONameService } from './dso-name.service';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { AuthorizationDataService } from '../data/feature-authorization/authorization-data.service';
|
||||||
|
import { FeatureID } from '../data/feature-authorization/feature-id';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -22,7 +24,8 @@ export class PublicationClaimBreadcrumbService implements BreadcrumbsProviderSer
|
|||||||
|
|
||||||
constructor(private dataService: ItemDataService,
|
constructor(private dataService: ItemDataService,
|
||||||
private dsoNameService: DSONameService,
|
private dsoNameService: DSONameService,
|
||||||
private tranlsateService: TranslateService) {
|
private tranlsateService: TranslateService,
|
||||||
|
protected authorizationService: AuthorizationDataService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -31,11 +34,11 @@ export class PublicationClaimBreadcrumbService implements BreadcrumbsProviderSer
|
|||||||
* @param key The key used to resolve the breadcrumb
|
* @param key The key used to resolve the breadcrumb
|
||||||
*/
|
*/
|
||||||
getBreadcrumbs(key: string): Observable<Breadcrumb[]> {
|
getBreadcrumbs(key: string): Observable<Breadcrumb[]> {
|
||||||
return this.dataService.findById(key).pipe(
|
return combineLatest([this.dataService.findById(key).pipe(getFirstCompletedRemoteData()),this.authorizationService.isAuthorized(FeatureID.AdministratorOf)]).pipe(
|
||||||
getFirstCompletedRemoteData(),
|
map(([item, isAdmin]) => {
|
||||||
map((item) => {
|
const itemName = this.dsoNameService.getName(item.payload);
|
||||||
return [new Breadcrumb(this.tranlsateService.instant(this.ADMIN_PUBLICATION_CLAIMS_BREADCRUMB_KEY), this.ADMIN_PUBLICATION_CLAIMS_PATH),
|
return isAdmin ? [new Breadcrumb(this.tranlsateService.instant(this.ADMIN_PUBLICATION_CLAIMS_BREADCRUMB_KEY), this.ADMIN_PUBLICATION_CLAIMS_PATH),
|
||||||
new Breadcrumb(this.dsoNameService.getName(item.payload), undefined)];
|
new Breadcrumb(itemName, undefined)] : [new Breadcrumb(itemName, undefined)];
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -75,7 +75,8 @@ export class SuggestionTargetsEffects {
|
|||||||
}),
|
}),
|
||||||
catchError((errors) => of(errors))
|
catchError((errors) => of(errors))
|
||||||
);
|
);
|
||||||
})), { dispatch: false });
|
}))
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the effect class variables.
|
* Initialize the effect class variables.
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<ng-container *ngIf="(suggestionsRD$ | async) as suggestions">
|
<ng-container *ngIf="(suggestionsRD$ | async) as suggestions">
|
||||||
<ng-container *ngFor="let suggestion of suggestions" class="alert alert-info">
|
<ng-container *ngFor="let suggestion of suggestions" class="alert alert-info">
|
||||||
<div class="alert alert-success d-block" *ngIf="suggestion.total > 0">
|
<div class="alert alert-success d-block" *ngIf="suggestion.total > 0">
|
||||||
<div [innerHTML]="'mydspace.notification.suggestion.page' | translate: getNotificationSuggestionInterpolation(suggestion)">
|
<div [innerHTML]="'notification.suggestion.page' | translate: getNotificationSuggestionInterpolation(suggestion)">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@@ -12,10 +12,10 @@
|
|||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<div class="mb-3 mt-3">
|
<div class="mb-3 mt-3">
|
||||||
<button class="btn btn-light" (click)="onToggleSelectAll(suggestionsRD.page)">Select / Deselect All</button>
|
<button class="btn mr-2 btn-light" (click)="onToggleSelectAll(suggestionsRD.page)">Select / Deselect All</button>
|
||||||
<em>({{ getSelectedSuggestionsCount() }})</em>
|
<em>({{ getSelectedSuggestionsCount() }})</em>
|
||||||
<ds-suggestion-actions *ngIf="getSelectedSuggestionsCount() > 0"
|
<ds-suggestion-actions *ngIf="getSelectedSuggestionsCount() > 0"
|
||||||
class="mt-2 ml-2"
|
class="m-2"
|
||||||
[isBulk]="true"
|
[isBulk]="true"
|
||||||
[isCollectionFixed]="isCollectionFixed(suggestionsRD.page)"
|
[isCollectionFixed]="isCollectionFixed(suggestionsRD.page)"
|
||||||
(approveAndImport)="approveAndImportAllSelected($event)"
|
(approveAndImport)="approveAndImportAllSelected($event)"
|
||||||
@@ -42,6 +42,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</ds-pagination>
|
</ds-pagination>
|
||||||
</div>
|
</div>
|
||||||
|
<div *ngIf="suggestionsRD?.pageInfo?.totalElements === 0">{{ 'suggestion.count.missing' | translate }}</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -172,12 +172,12 @@ export class SuggestionsPageComponent implements OnInit {
|
|||||||
this.selectedSuggestions = {};
|
this.selectedSuggestions = {};
|
||||||
if (results.success > 0) {
|
if (results.success > 0) {
|
||||||
this.notificationService.success(
|
this.notificationService.success(
|
||||||
this.translateService.get('suggestion.notMine.bulk.success',
|
this.translateService.get('suggestion.ignoreSuggestion.bulk.success',
|
||||||
{count: results.success}));
|
{count: results.success}));
|
||||||
}
|
}
|
||||||
if (results.fails > 0) {
|
if (results.fails > 0) {
|
||||||
this.notificationService.error(
|
this.notificationService.error(
|
||||||
this.translateService.get('suggestion.notMine.bulk.error',
|
this.translateService.get('suggestion.ignoreSuggestion.bulk.error',
|
||||||
{count: results.fails}));
|
{count: results.fails}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -3596,7 +3596,7 @@
|
|||||||
|
|
||||||
"suggestion.approveAndImport.bulk": "Approve & import Selected",
|
"suggestion.approveAndImport.bulk": "Approve & import Selected",
|
||||||
|
|
||||||
".suggestion.approveAndImport.bulk.success": "{{ count }} suggestions have been imported successfully ",
|
"suggestion.approveAndImport.bulk.success": "{{ count }} suggestions have been imported successfully ",
|
||||||
|
|
||||||
"suggestion.approveAndImport.bulk.error": "{{ count }} suggestions haven't been imported due to unexpected server errors",
|
"suggestion.approveAndImport.bulk.error": "{{ count }} suggestions haven't been imported due to unexpected server errors",
|
||||||
|
|
||||||
@@ -3620,6 +3620,8 @@
|
|||||||
|
|
||||||
"suggestion.from.source": "from the ",
|
"suggestion.from.source": "from the ",
|
||||||
|
|
||||||
|
"suggestion.count.missing": "You have no publication claims left",
|
||||||
|
|
||||||
"suggestion.totalScore": "Total Score",
|
"suggestion.totalScore": "Total Score",
|
||||||
|
|
||||||
"suggestion.type.openaire": "OpenAIRE",
|
"suggestion.type.openaire": "OpenAIRE",
|
||||||
|
@@ -304,8 +304,9 @@ export class DefaultAppConfig implements AppConfig {
|
|||||||
// source: 'suggestionSource',
|
// source: 'suggestionSource',
|
||||||
// collectionId: 'collectionUUID'
|
// collectionId: 'collectionUUID'
|
||||||
// }
|
// }
|
||||||
// If not mapped the suggestion service won't be able to approve and import the related suggestion
|
// This is used as a default fallback in case there aren't collections where to import the suggestion
|
||||||
// or load the fixed suggestions collections that can be configured here adding the source and the UUID of the collection
|
// If not mapped the user will be allowed to import the suggestions only in the provided options, shown clicking the button "Approve and import"
|
||||||
|
// If not mapped and no options available for import the user won't be able to import the suggestions.
|
||||||
];
|
];
|
||||||
|
|
||||||
// Theme Config
|
// Theme Config
|
||||||
|
Reference in New Issue
Block a user