Skip to content

Commit

Permalink
Merged dspace-cris-7 into DSC-1408
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Barbasso committed Dec 5, 2023
2 parents b513c55 + 4724dfc commit e6a7165
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 126 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dspace-angular",
"version": "2023.02.00-SNAPSHOT",
"version": "2023.02.01-SNAPSHOT",
"scripts": {
"ng": "ng",
"config:watch": "nodemon",
Expand Down
18 changes: 2 additions & 16 deletions src/app/breadcrumbs/breadcrumbs.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,11 @@
</nav>

<ng-template #breadcrumb let-text="text" let-url="url">
<li class="breadcrumb-item" *ngVar="(text | translate) as label">
<div class="breadcrumb-item-limiter">
<a [routerLink]="url" class="text-truncate"
[ngbTooltip]="label | dsBreadcrumbTooltip"
placement="bottom"
>{{label | dsTruncateText}}</a>
</div>
</li>
<li class="breadcrumb-item"><div class="breadcrumb-item-limiter"><a [routerLink]="url" class="text-truncate" [ngbTooltip]="text | translate" placement="bottom" >{{text | translate}}</a></div></li>
</ng-template>

<ng-template #activeBreadcrumb let-text="text">
<li class="breadcrumb-item active" aria-current="page" *ngVar="(text | translate) as label">
<div class="breadcrumb-item-limiter">
<div class="text-truncate"
[ngbTooltip]="label | dsBreadcrumbTooltip"
placement="bottom"
>{{label | dsTruncateText}}</div>
</div>
</li>
<li class="breadcrumb-item active" aria-current="page"><div class="breadcrumb-item-limiter"><div class="text-truncate">{{text | translate}}</div></div></li>
</ng-template>
</ng-container>

47 changes: 5 additions & 42 deletions src/app/breadcrumbs/breadcrumbs.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,22 @@ import { TranslateLoaderMock } from '../shared/testing/translate-loader.mock';
import { RouterTestingModule } from '@angular/router/testing';
import { of as observableOf } from 'rxjs';
import { DebugElement } from '@angular/core';
import { BreadcrumbTooltipPipe } from './breadcrumb/breadcrumb-tooltip.pipe';
import { TruncateBreadcrumbItemCharactersPipe } from './breadcrumb/truncate-breadcrumb-item-characters.pipe';
import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';

describe('BreadcrumbsComponent', () => {
let component: BreadcrumbsComponent;
let fixture: ComponentFixture<BreadcrumbsComponent>;
let breadcrumbsServiceMock: BreadcrumbsService;
let truncateTextPipe: TruncateBreadcrumbItemCharactersPipe;

const expectBreadcrumb = (listItem: DebugElement, text: string, url: string) => {
const anchor = listItem.query(By.css('a'));
const truncatedText = truncateTextPipe.transform(text);

if (url == null) {
expect(anchor).toBeNull();
// remove leading whitespace characters
const textWithoutSpaces = listItem.nativeElement.innerHTML.trimStart().replace(/^\s+/, '');
expect(textWithoutSpaces).toEqual(truncatedText);
expect(listItem.nativeElement.innerHTML).toEqual(text);
} else {
expect(anchor).toBeInstanceOf(DebugElement);
expect(anchor.attributes.href).toEqual(url);
// remove leading whitespace characters
const textWithoutSpaces = anchor.nativeElement.innerHTML.trimStart().replace(/^\s+/, '');
expect(textWithoutSpaces).toEqual(truncatedText);
expect(anchor.nativeElement.innerHTML).toEqual(text);
}
};

Expand All @@ -43,7 +35,6 @@ describe('BreadcrumbsComponent', () => {
// NOTE: a root breadcrumb is automatically rendered
new Breadcrumb('bc 1', 'example.com'),
new Breadcrumb('bc 2', 'another.com'),
new Breadcrumb('breadcrumb to be truncated', 'truncated.com'),
]),
showBreadcrumbs$: observableOf(true),
} as BreadcrumbsService;
Expand All @@ -52,11 +43,8 @@ describe('BreadcrumbsComponent', () => {
declarations: [
BreadcrumbsComponent,
VarDirective,
BreadcrumbTooltipPipe,
TruncateBreadcrumbItemCharactersPipe,
],
imports: [
NgbTooltipModule,
RouterTestingModule.withRoutes([]),
TranslateModule.forRoot({
loader: {
Expand All @@ -67,12 +55,10 @@ describe('BreadcrumbsComponent', () => {
],
providers: [
{ provide: BreadcrumbsService, useValue: breadcrumbsServiceMock },
{ provide: TruncateBreadcrumbItemCharactersPipe, useClass: TruncateBreadcrumbItemCharactersPipe },
],
}).compileComponents();

fixture = TestBed.createComponent(BreadcrumbsComponent);
truncateTextPipe = TestBed.inject(TruncateBreadcrumbItemCharactersPipe);
component = fixture.componentInstance;
fixture.detectChanges();
}));
Expand All @@ -81,35 +67,12 @@ describe('BreadcrumbsComponent', () => {
expect(component).toBeTruthy();
});

it('should render the breadcrumbs accordingly', () => {
it('should render the breadcrumbs', () => {
const breadcrumbs = fixture.debugElement.queryAll(By.css('.breadcrumb-item'));
expect(breadcrumbs.length).toBe(4);
expect(breadcrumbs.length).toBe(3);
expectBreadcrumb(breadcrumbs[0], 'home.breadcrumbs', '/');
expectBreadcrumb(breadcrumbs[1], 'bc 1', '/example.com');
expectBreadcrumb(breadcrumbs[2].query(By.css('.text-truncate')), 'bc 2', null);
expectBreadcrumb(breadcrumbs[3].query(By.css('.text-truncate')), 'breadcrumb...', null);
});

it('should show tooltip only for truncated text', () => {
const breadcrumbs = fixture.debugElement.queryAll(By.css('.breadcrumb-item .text-truncate'));
expect(breadcrumbs.length).toBe(4);

const truncatable = breadcrumbs[3];
truncatable.triggerEventHandler('mouseenter', null);
fixture.detectChanges();
let tooltip = truncatable.parent.query(By.css('div.tooltip-inner'));
expect(tooltip).not.toBeNull();
expect(tooltip.nativeElement.innerText).toBe('breadcrumb to be truncated');
truncatable.triggerEventHandler('mouseleave', null);
fixture.detectChanges();

const notTruncatable = breadcrumbs[2];
notTruncatable.triggerEventHandler('mouseenter', null);
fixture.detectChanges();
const tooltip2 = notTruncatable.parent.query(By.css('div.tooltip-inner'));
expect(tooltip2).toBeNull();
notTruncatable.triggerEventHandler('mouseleave', null);
fixture.detectChanges();
});

});
6 changes: 0 additions & 6 deletions src/app/root.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ import {
import { FooterModule } from './footer/footer.module';
import { SocialModule } from './social/social.module';
import { ExploreModule } from './shared/explore/explore.module';
import { BreadcrumbTooltipPipe } from './breadcrumbs/breadcrumb/breadcrumb-tooltip.pipe';
import {
TruncateBreadcrumbItemCharactersPipe
} from './breadcrumbs/breadcrumb/truncate-breadcrumb-item-characters.pipe';
import { OpenaireModule } from './openaire/openaire.module';

const IMPORTS = [
Expand Down Expand Up @@ -89,8 +85,6 @@ const DECLARATIONS = [
ThemedPageErrorComponent,
PageErrorComponent,
ContextHelpToggleComponent,
TruncateBreadcrumbItemCharactersPipe,
BreadcrumbTooltipPipe
];

const EXPORTS = [
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/context-menu/context-menu.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="d-flex space-children-mr justify-content-end" *ngIf="((isAuthenticated | async) || isItem()) && contextMenuObject">
<div class="d-flex space-children-mr justify-content-end" *ngIf="contextMenuObject">
<ng-container *ngFor="let entry of (getStandAloneMenuEntries() | async)">
<ng-container *ngComponentOutlet="entry; injector: objectInjector;"></ng-container>
</ng-container>
Expand Down
36 changes: 10 additions & 26 deletions src/app/shared/context-menu/context-menu.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/t
import { By } from '@angular/platform-browser';

import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
import { cold } from 'jasmine-marbles';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { Store } from '@ngrx/store';
import { of } from 'rxjs';
Expand Down Expand Up @@ -155,13 +154,13 @@ describe('ContextMenuComponent', () => {
done();
});

it('should display d-none', (done) => {
it('should use d-none', (done) => {
const menu = fixture.debugElement.query(By.css('div.d-none'));
expect(menu).not.toBeNull();
done();
});

it('should not display d-inline-block', (done) => {
it('should not use d-inline-block', (done) => {
const menu = fixture.debugElement.query(By.css('div.d-inline-block'));
expect(menu).toBeNull();
done();
Expand All @@ -173,11 +172,6 @@ describe('ContextMenuComponent', () => {
done();
});

it('should check the authorization of the current user', (done) => {
expect(component.isAuthenticated).toBeObservable(cold('a', { a: true }));
done();
});

it('should not have menu entries when are disabled on rest side', (done) => {
component.contextMenuObjectType = DSpaceObjectType.COMMUNITY;
configurationDataService.findByPropertyName.and.returnValues(
Expand Down Expand Up @@ -218,34 +212,29 @@ describe('ContextMenuComponent', () => {
done();
});

it('should not display context menu', (done) => {
it('should display context menu', (done) => {
const menu = fixture.debugElement.query(By.css('button#context-menu'));
expect(menu).not.toBeNull();
done();
});

it('should display d-none', (done) => {
it('should use d-none', (done) => {
const menu = fixture.debugElement.query(By.css('div.d-none'));
expect(menu).not.toBeNull();
done();
});

it('should not display d-inline-block', (done) => {
it('should not use d-inline-block', (done) => {
const menu = fixture.debugElement.query(By.css('div.d-inline-block'));
expect(menu).toBeNull();
done();
});

it('should not display stand alone buttons', (done) => {
it('should display stand alone buttons', (done) => {
const menu = fixture.debugElement.query(By.css('button.btn-primary'));
expect(menu).not.toBeNull();
done();
});

it('should check the authorization of the current user', (done) => {
expect(component.isAuthenticated).toBeObservable(cold('a', { a: false }));
done();
});
});

describe('and the object type is not ITEM', () => {
Expand All @@ -259,9 +248,9 @@ describe('ContextMenuComponent', () => {
done();
});

it('should not display context menu', (done) => {
it('should display context menu', (done) => {
const menu = fixture.debugElement.query(By.css('button#context-menu'));
expect(menu).toBeNull();
expect(menu).not.toBeNull();
done();
});

Expand All @@ -271,14 +260,9 @@ describe('ContextMenuComponent', () => {
done();
});

it('should not display d-none', (done) => {
it('should display d-none', (done) => {
const menu = fixture.debugElement.query(By.css('div.d-none'));
expect(menu).toBeNull();
done();
});

it('should check the authorization of the current user', (done) => {
expect(component.isAuthenticated).toBeObservable(cold('a', { a: false }));
expect(menu).not.toBeNull();
done();
});
});
Expand Down
16 changes: 2 additions & 14 deletions src/app/shared/context-menu/context-menu.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { ChangeDetectorRef, Component, Inject, Injector, Input, OnInit } from '@angular/core';
import { DOCUMENT } from '@angular/common';

import { select, Store } from '@ngrx/store';
import { from, Observable } from 'rxjs';
import { concatMap, filter, map, reduce, take } from 'rxjs/operators';

import { CoreState } from '../../core/core-state.model';
import { isAuthenticated } from '../../core/auth/selectors';
import { DSpaceObject } from '../../core/shared/dspace-object.model';
import { DSpaceObjectType } from '../../core/shared/dspace-object-type.model';
import { ContextMenuEntryRenderOptions, getContextMenuEntriesForDSOType } from './context-menu.decorator';
Expand Down Expand Up @@ -39,12 +36,6 @@ export class ContextMenuComponent implements OnInit {
*/
@Input() contextMenuObjectType: DSpaceObjectType;

/**
* Whether user is authenticated.
* @type {Observable<string>}
*/
public isAuthenticated: Observable<boolean>;

/**
* Injector to inject a menu entry component with the @Input parameters
* @type {Injector}
Expand All @@ -61,16 +52,15 @@ export class ContextMenuComponent implements OnInit {
* Initialize instance variables
*
* @param {Document} _document
* @param {ChangeDetectorRef} cdr
* @param {ConfigurationDataService} configurationService
* @param {Injector} injector
* @param {Store<CoreState>} store
*/
constructor(
@Inject(DOCUMENT) private _document: Document,
private cdr: ChangeDetectorRef,
private configurationService: ConfigurationDataService,
private injector: Injector,
private store: Store<CoreState>
private injector: Injector
) {
}

Expand All @@ -82,8 +72,6 @@ export class ContextMenuComponent implements OnInit {
],
parent: this.injector
});
// set isAuthenticated
this.isAuthenticated = this.store.pipe(select(isAuthenticated));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/app/shared/form/builder/form-builder.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,9 @@ export class FormBuilderService extends DynamicFormService {
const newGroup = this.createFormGroup(groupModel.group, null, groupModel);
const previousKey = Object.keys(previousGroup.getRawValue())[0];
const newKey = Object.keys(newGroup.getRawValue())[0];

if (!isObjectEmpty(previousGroup.getRawValue()[previousKey])) {
newGroup.get(newKey).setValue(previousGroup.getRawValue()[previousKey]);
const rawValue = previousGroup.getRawValue()[previousKey];
if (!isObjectEmpty(rawValue)) {
newGroup.get(newKey).patchValue(rawValue);
}

formArray.insert(index, newGroup);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,19 @@ <h5 *ngIf="metadata[fileTitleKey].indexOf(entry) === 0">
</ng-container>
</ng-container>


<div class="mt-1" *ngIf="fileFormat">
{{'admin.registries.bitstream-formats.edit.head' | translate:{format: fileFormat} }}
<span class="font-weight-bold">{{'submission.sections.upload.format' | translate}} :</span><span> {{fileFormat}} </span>
</div>
<div class="mt-1" *ngIf="fileCheckSum">
Checksum {{fileCheckSum.checkSumAlgorithm}}: {{fileCheckSum.value}}
<span class="font-weight-bold">{{'submission.sections.upload.checksum' | translate}} ({{fileData.checkSum.checkSumAlgorithm}}) <i class="far fa-question-circle text-info hint" #hint="ngbTooltip"
container="body"
placement="top"
[ngbTooltip]="tipContent"
triggers="manual"
[autoClose]="false"
(click)="hint.toggle();$event.preventDefault();"></i> :</span><span> {{fileData.checkSum.value}} </span>
</div>
<span class="clearfix"></span>
<span class="font-weight-bold">{{'submission.sections.upload.checksum' | translate}} ({{fileData.checkSum.checkSumAlgorithm}}) <i class="far fa-question-circle text-info hint" #hint="ngbTooltip"
container="body"
placement="top"
[ngbTooltip]="tipContent"
triggers="manual"
[autoClose]="false"
(click)="hint.toggle();$event.preventDefault();"></i> :</span><span> {{fileData.checkSum.value}} </span>
<span class="clearfix"></span>
<ds-submission-section-upload-access-conditions [accessConditions]="fileData.accessConditions"></ds-submission-section-upload-access-conditions>
</div>

Expand Down
6 changes: 5 additions & 1 deletion src/assets/i18n/en.json5
Original file line number Diff line number Diff line change
Expand Up @@ -2105,7 +2105,7 @@

"error.validation.custom-url.invalid-characters": "The custom url contains invalid characters.",

"error.validation.license.notgranted": "You must grant this license to complete your submission. If you are unable to grant this license at this time you may save your work and return later or remove the submission.",
"error.validation.license.required": "You must grant this license to complete your submission. If you are unable to grant this license at this time you may save your work and return later or remove the submission.",

"error.validation.pattern": "This input is restricted by the current pattern: {{ pattern }}.",

Expand Down Expand Up @@ -2137,6 +2137,8 @@

"error.validation.notRepeatable": "This field is not repeatable, please choose only one value and discard the others.",

"error.validation.detect-duplicate": "The handling of the detected duplicates is mandatory",

"event.listelement.badge": "Event",


Expand Down Expand Up @@ -6280,6 +6282,8 @@

"submission.sections.toggle.aria.close": "Collapse {{sectionHeader}} section",

"submission.sections.upload.format": "Bitstream format",

"submission.sections.upload.checksum": "Checksum",

"submission.sections.upload.delete.confirm.cancel": "Cancel",
Expand Down
Loading

0 comments on commit e6a7165

Please sign in to comment.