forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dspace-cris-2023_02_x' into task/dspace-cris-2023.02.06…
…/DSC-2036 # Conflicts: # package.json
- Loading branch information
Showing
62 changed files
with
1,219 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...-matrix/cris-layout-box-container/boxes/metadata/rendering-types/html/html.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div [class]="field.styleValue"> | ||
<span [innerHTML]="processHtml(metadataValue.value)" class="text-value"></span> | ||
</div> |
Empty file.
92 changes: 92 additions & 0 deletions
92
...trix/cris-layout-box-container/boxes/metadata/rendering-types/html/html.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { By } from '@angular/platform-browser'; | ||
|
||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; | ||
|
||
import { HtmlComponent } from './html.component'; | ||
import { Item } from '../../../../../../../core/shared/item.model'; | ||
import { TranslateLoaderMock } from '../../../../../../../shared/mocks/translate-loader.mock'; | ||
import { DsDatePipe } from '../../../../../../pipes/ds-date.pipe'; | ||
import { LayoutField } from '../../../../../../../core/layout/models/box.model'; | ||
import { MetadataValue } from '../../../../../../../core/shared/metadata.models'; | ||
|
||
describe('HtmlComponent', () => { | ||
let component: HtmlComponent; | ||
let fixture: ComponentFixture<HtmlComponent>; | ||
|
||
const metadataValue = Object.assign(new MetadataValue(), { | ||
'value': 'test item title', | ||
'language': null, | ||
'authority': null, | ||
'confidence': -1, | ||
'place': 0 | ||
}); | ||
|
||
const testItem = Object.assign(new Item(), | ||
{ | ||
type: 'item', | ||
metadata: { | ||
'dc.title': [metadataValue] | ||
}, | ||
uuid: 'test-item-uuid', | ||
} | ||
); | ||
|
||
|
||
const mockField: LayoutField = { | ||
'metadata': 'dc.title', | ||
'label': 'Title', | ||
'rendering': 'html', | ||
'fieldType': 'METADATA', | ||
'style': null, | ||
'styleLabel': 'test-style-label', | ||
'styleValue': 'test-style-value', | ||
'labelAsHeading': false, | ||
'valuesInline': true | ||
}; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [TranslateModule.forRoot({ | ||
loader: { | ||
provide: TranslateLoader, | ||
useClass: TranslateLoaderMock | ||
} | ||
}), BrowserAnimationsModule], | ||
providers: [ | ||
{ provide: 'fieldProvider', useValue: mockField }, | ||
{ provide: 'itemProvider', useValue: testItem }, | ||
{ provide: 'metadataValueProvider', useValue: metadataValue }, | ||
{ provide: 'renderingSubTypeProvider', useValue: '' }, | ||
{ provide: 'tabNameProvider', useValue: '' }, | ||
], | ||
declarations: [HtmlComponent, DsDatePipe] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(HtmlComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('check metadata rendering', (done) => { | ||
const spanValueFound = fixture.debugElement.queryAll(By.css('span.text-value')); | ||
expect(spanValueFound.length).toBe(1); | ||
expect(spanValueFound[0].nativeElement.textContent).toContain(metadataValue.value); | ||
done(); | ||
}); | ||
|
||
it('check value style', (done) => { | ||
const spanValueFound = fixture.debugElement.queryAll(By.css('.test-style-value')); | ||
expect(spanValueFound.length).toBe(1); | ||
done(); | ||
}); | ||
|
||
}); |
27 changes: 27 additions & 0 deletions
27
...ut-matrix/cris-layout-box-container/boxes/metadata/rendering-types/html/html.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
import { FieldRenderingType, MetadataBoxFieldRendering } from '../metadata-box.decorator'; | ||
import { RenderingTypeValueModelComponent } from '../rendering-type-value.model'; | ||
|
||
/** | ||
* This component renders the text metadata fields | ||
*/ | ||
@Component({ | ||
// eslint-disable-next-line @angular-eslint/component-selector | ||
selector: 'span[ds-html]', | ||
templateUrl: './html.component.html', | ||
styleUrls: ['./html.component.scss'] | ||
}) | ||
@MetadataBoxFieldRendering(FieldRenderingType.HTML) | ||
export class HtmlComponent extends RenderingTypeValueModelComponent { | ||
|
||
/** | ||
* If the metadata value does not contain HTML tags then replace newline character with <br> | ||
* @param text | ||
*/ | ||
processHtml(text: string): string { | ||
const htmlTagRegex = /<.*?>/; | ||
return htmlTagRegex.test(text) ? text.replace(/\n/, '<br>') : text; | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
...cris-layout-box-container/boxes/metadata/rendering-types/longhtml/longhtml.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div [class]="field.styleValue"> | ||
<ds-truncatable [id]="truncatableId"> | ||
<ds-truncatable-part [id]="truncatableId" [minLines]="8"> | ||
<span [innerHTML]="processHtml(metadataValue.value)" class="text-value"></span> | ||
</ds-truncatable-part> | ||
</ds-truncatable> | ||
</div> |
Empty file.
Oops, something went wrong.