mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-16 06:23:03 +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 { PublicationClaimBreadcrumbService } from './publication-claim-breadcrumb.service';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('PublicationClaimBreadcrumbService', () => {
|
||||
let service: PublicationClaimBreadcrumbService;
|
||||
@@ -17,6 +18,10 @@ describe('PublicationClaimBreadcrumbService', () => {
|
||||
findById: (str) => createSuccessfulRemoteDataObject$(str),
|
||||
};
|
||||
|
||||
let authorizationService: any = {
|
||||
isAuthorized: (str) => of(true),
|
||||
};
|
||||
|
||||
let exampleKey;
|
||||
|
||||
const ADMIN_PUBLICATION_CLAIMS_PATH = 'admin/notifications/publication-claim';
|
||||
@@ -32,7 +37,7 @@ describe('PublicationClaimBreadcrumbService', () => {
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
service = new PublicationClaimBreadcrumbService(dataService,dsoNameService,translateService);
|
||||
service = new PublicationClaimBreadcrumbService(dataService,dsoNameService,translateService, authorizationService);
|
||||
});
|
||||
|
||||
describe('getBreadcrumbs', () => {
|
||||
|
@@ -1,12 +1,14 @@
|
||||
import { Breadcrumb } from '../../breadcrumbs/breadcrumb/breadcrumb.model';
|
||||
import { BreadcrumbsProviderService } from './breadcrumbsProviderService';
|
||||
import { Observable } from 'rxjs';
|
||||
import { combineLatest, Observable } from 'rxjs';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ItemDataService } from '../data/item-data.service';
|
||||
import { getFirstCompletedRemoteData } from '../shared/operators';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { DSONameService } from './dso-name.service';
|
||||
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,
|
||||
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
|
||||
*/
|
||||
getBreadcrumbs(key: string): Observable<Breadcrumb[]> {
|
||||
return this.dataService.findById(key).pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
map((item) => {
|
||||
return [new Breadcrumb(this.tranlsateService.instant(this.ADMIN_PUBLICATION_CLAIMS_BREADCRUMB_KEY), this.ADMIN_PUBLICATION_CLAIMS_PATH),
|
||||
new Breadcrumb(this.dsoNameService.getName(item.payload), undefined)];
|
||||
return combineLatest([this.dataService.findById(key).pipe(getFirstCompletedRemoteData()),this.authorizationService.isAuthorized(FeatureID.AdministratorOf)]).pipe(
|
||||
map(([item, isAdmin]) => {
|
||||
const itemName = this.dsoNameService.getName(item.payload);
|
||||
return isAdmin ? [new Breadcrumb(this.tranlsateService.instant(this.ADMIN_PUBLICATION_CLAIMS_BREADCRUMB_KEY), this.ADMIN_PUBLICATION_CLAIMS_PATH),
|
||||
new Breadcrumb(itemName, undefined)] : [new Breadcrumb(itemName, undefined)];
|
||||
})
|
||||
);
|
||||
}
|
||||
|
@@ -75,7 +75,8 @@ export class SuggestionTargetsEffects {
|
||||
}),
|
||||
catchError((errors) => of(errors))
|
||||
);
|
||||
})), { dispatch: false });
|
||||
}))
|
||||
);
|
||||
|
||||
/**
|
||||
* Initialize the effect class variables.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<ng-container *ngIf="(suggestionsRD$ | async) as suggestions">
|
||||
<ng-container *ngFor="let suggestion of suggestions" class="alert alert-info">
|
||||
<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>
|
||||
</ng-container>
|
||||
|
@@ -12,10 +12,10 @@
|
||||
</h1>
|
||||
|
||||
<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>
|
||||
<ds-suggestion-actions *ngIf="getSelectedSuggestionsCount() > 0"
|
||||
class="mt-2 ml-2"
|
||||
class="m-2"
|
||||
[isBulk]="true"
|
||||
[isCollectionFixed]="isCollectionFixed(suggestionsRD.page)"
|
||||
(approveAndImport)="approveAndImportAllSelected($event)"
|
||||
@@ -42,6 +42,7 @@
|
||||
</ul>
|
||||
</ds-pagination>
|
||||
</div>
|
||||
<div *ngIf="suggestionsRD?.pageInfo?.totalElements === 0">{{ 'suggestion.count.missing' | translate }}</div>
|
||||
</ng-container>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -172,12 +172,12 @@ export class SuggestionsPageComponent implements OnInit {
|
||||
this.selectedSuggestions = {};
|
||||
if (results.success > 0) {
|
||||
this.notificationService.success(
|
||||
this.translateService.get('suggestion.notMine.bulk.success',
|
||||
this.translateService.get('suggestion.ignoreSuggestion.bulk.success',
|
||||
{count: results.success}));
|
||||
}
|
||||
if (results.fails > 0) {
|
||||
this.notificationService.error(
|
||||
this.translateService.get('suggestion.notMine.bulk.error',
|
||||
this.translateService.get('suggestion.ignoreSuggestion.bulk.error',
|
||||
{count: results.fails}));
|
||||
}
|
||||
});
|
||||
|
@@ -3596,7 +3596,7 @@
|
||||
|
||||
"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",
|
||||
|
||||
@@ -3620,6 +3620,8 @@
|
||||
|
||||
"suggestion.from.source": "from the ",
|
||||
|
||||
"suggestion.count.missing": "You have no publication claims left",
|
||||
|
||||
"suggestion.totalScore": "Total Score",
|
||||
|
||||
"suggestion.type.openaire": "OpenAIRE",
|
||||
|
@@ -304,8 +304,9 @@ export class DefaultAppConfig implements AppConfig {
|
||||
// source: 'suggestionSource',
|
||||
// collectionId: 'collectionUUID'
|
||||
// }
|
||||
// If not mapped the suggestion service won't be able to approve and import the related suggestion
|
||||
// or load the fixed suggestions collections that can be configured here adding the source and the UUID of the collection
|
||||
// This is used as a default fallback in case there aren't collections where to import the suggestion
|
||||
// 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
|
||||
|
Reference in New Issue
Block a user