[ADF-2504] Add read-only mode for the content meta-data component (#3089)

* Add read-only mode for the content meta-data component

* Multi parameter

* Fix input param name
This commit is contained in:
Popovics András 2018-03-20 12:24:30 +00:00 committed by Eugenio Romano
parent afb91cf062
commit f5d58178db
6 changed files with 35 additions and 2 deletions

View File

@ -27,6 +27,8 @@ The different aspects and their properties to be shown can be configured as appl
| --- | --- | --- | --- | | --- | --- | --- | --- |
| node | MinimalNodeEntryEntity | - | (**required**) The node entity to fetch metadata about | | node | MinimalNodeEntryEntity | - | (**required**) The node entity to fetch metadata about |
| displayEmpty | boolean | false | Display empty values in card view or not | | displayEmpty | boolean | false | Display empty values in card view or not |
| readOnly | boolean | true | Whether the edit button to be shown or not |
| multi | boolean | false | multi parameter of the underlying material expansion panel |
| preset | string | "*" | The metadata preset's name, which defines aspects and their properties | | preset | string | "*" | The metadata preset's name, which defines aspects and their properties |
## Details ## Details

View File

@ -5,12 +5,13 @@
[displayEmpty]="displayEmpty" [displayEmpty]="displayEmpty"
[editable]="editable" [editable]="editable"
[expanded]="expanded" [expanded]="expanded"
[multi]="multi"
[preset]="preset"> [preset]="preset">
</adf-content-metadata> </adf-content-metadata>
</mat-card-content> </mat-card-content>
<mat-card-footer class="adf-content-metadata-card-footer" fxLayout="row" fxLayoutAlign="space-between stretch"> <mat-card-footer class="adf-content-metadata-card-footer" fxLayout="row" fxLayoutAlign="space-between stretch">
<div> <div>
<button mat-icon-button (click)="toggleEdit()" data-automation-id="mata-data-card-toggle-edit"> <button *ngIf="!readOnly" mat-icon-button (click)="toggleEdit()" data-automation-id="mata-data-card-toggle-edit">
<mat-icon>mode_edit</mat-icon> <mat-icon>mode_edit</mat-icon>
</button> </button>
</div> </div>

View File

@ -114,6 +114,14 @@ describe('ContentMetadataCardComponent', () => {
expect(contentMetadataComponent.editable).toBe(true); expect(contentMetadataComponent.editable).toBe(true);
}); });
it('should pass through the multi to the underlying component', () => {
component.multi = true;
fixture.detectChanges();
const contentMetadataComponent = fixture.debugElement.query(By.directive(ContentMetadataComponent)).componentInstance;
expect(contentMetadataComponent.multi).toBe(true);
});
it('should pass through the expanded to the underlying component', () => { it('should pass through the expanded to the underlying component', () => {
component.expanded = true; component.expanded = true;
fixture.detectChanges(); fixture.detectChanges();
@ -170,4 +178,17 @@ describe('ContentMetadataCardComponent', () => {
expect(buttonLabel.nativeElement.innerText.trim()).toBe('ADF_VIEWER.SIDEBAR.METADATA.LESS_INFORMATION'); expect(buttonLabel.nativeElement.innerText.trim()).toBe('ADF_VIEWER.SIDEBAR.METADATA.LESS_INFORMATION');
}); });
it('should show the edit button by default', () => {
const button = fixture.debugElement.query(By.css('[data-automation-id="mata-data-card-toggle-edit"]'));
expect(button).not.toBeNull();
});
it('should hode the edit button in readOnly is true', () => {
component.readOnly = true;
fixture.detectChanges();
const button = fixture.debugElement.query(By.css('[data-automation-id="mata-data-card-toggle-edit"]'));
expect(button).toBeNull();
});
}); });

View File

@ -35,6 +35,12 @@ export class ContentMetadataCardComponent {
@Input() @Input()
preset: string; preset: string;
@Input()
readOnly = false;
@Input()
multi = false;
editable: boolean = false; editable: boolean = false;
expanded: boolean = false; expanded: boolean = false;

View File

@ -1,5 +1,5 @@
<div class="adf-metadata-properties"> <div class="adf-metadata-properties">
<mat-accordion displayMode="flat"> <mat-accordion displayMode="flat" [multi]="multi">
<mat-expansion-panel [expanded]="!expanded" [hideToggle]="!expanded"> <mat-expansion-panel [expanded]="!expanded" [hideToggle]="!expanded">
<mat-expansion-panel-header> <mat-expansion-panel-header>
<mat-panel-title> <mat-panel-title>

View File

@ -44,6 +44,9 @@ export class ContentMetadataComponent implements OnChanges, OnInit {
@Input() @Input()
expanded: boolean = false; expanded: boolean = false;
@Input()
multi = false;
@Input() @Input()
preset: string; preset: string;