diff --git a/demo-shell/src/app/components/file-view/file-view.component.html b/demo-shell/src/app/components/file-view/file-view.component.html index d14163bbaf..c2586757cd 100644 --- a/demo-shell/src/app/components/file-view/file-view.component.html +++ b/demo-shell/src/app/components/file-view/file-view.component.html @@ -12,14 +12,12 @@ [multi]="multi" [preset]="customPreset" [readOnly]="isReadOnly" - [displayAspect]="showAspect" [displayDefaultProperties]="displayDefaultProperties" [displayEmpty]="displayEmptyMetadata"> @@ -73,19 +71,6 @@

-

- - - - - - -

-

@@ -133,7 +118,7 @@

- + diff --git a/lib/content-services/content-metadata/components/content-metadata-card/content-metadata-card.component.spec.ts b/lib/content-services/content-metadata/components/content-metadata-card/content-metadata-card.component.spec.ts index 0e5bb7ab4f..7c1f730fa1 100644 --- a/lib/content-services/content-metadata/components/content-metadata-card/content-metadata-card.component.spec.ts +++ b/lib/content-services/content-metadata/components/content-metadata-card/content-metadata-card.component.spec.ts @@ -22,7 +22,6 @@ import { ContentMetadataCardComponent } from './content-metadata-card.component' import { ContentMetadataComponent } from '../content-metadata/content-metadata.component'; import { setupTestBed, AllowableOperationsEnum } from '@alfresco/adf-core'; import { ContentTestingModule } from '../../../testing/content.testing.module'; -import { SimpleChange } from '@angular/core'; describe('ContentMetadataCardComponent', () => { @@ -190,17 +189,4 @@ describe('ContentMetadataCardComponent', () => { const button = fixture.debugElement.query(By.css('[data-automation-id="meta-data-card-toggle-edit"]')); expect(button).not.toBeNull(); }); - - it('should expand the card when custom display aspect is valid', () => { - expect(component.expanded).toBeFalsy(); - - let displayAspect = new SimpleChange(null , 'EXIF', true); - component.ngOnChanges({ displayAspect }); - expect(component.expanded).toBeTruthy(); - - displayAspect = new SimpleChange('EXIF' , null, false); - component.ngOnChanges({ displayAspect }); - expect(component.expanded).toBeTruthy(); - }); - }); diff --git a/lib/content-services/content-metadata/components/content-metadata-card/content-metadata-card.component.ts b/lib/content-services/content-metadata/components/content-metadata-card/content-metadata-card.component.ts index ddd2f99577..54084f0db3 100644 --- a/lib/content-services/content-metadata/components/content-metadata-card/content-metadata-card.component.ts +++ b/lib/content-services/content-metadata/components/content-metadata-card/content-metadata-card.component.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { Component, Input, OnChanges, SimpleChanges, ViewEncapsulation } from '@angular/core'; +import { Component, Input, ViewEncapsulation } from '@angular/core'; import { Node } from '@alfresco/js-api'; import { ContentService, AllowableOperationsEnum } from '@alfresco/adf-core'; @@ -26,7 +26,7 @@ import { ContentService, AllowableOperationsEnum } from '@alfresco/adf-core'; encapsulation: ViewEncapsulation.None, host: { 'class': 'adf-content-metadata-card' } }) -export class ContentMetadataCardComponent implements OnChanges { +export class ContentMetadataCardComponent { /** (required) The node entity to fetch metadata about */ @Input() node: Node; @@ -37,12 +37,6 @@ export class ContentMetadataCardComponent implements OnChanges { @Input() displayEmpty: boolean = false; - /** (optional) This flag displays desired aspect when open for the first time - * fields. - */ - @Input() - displayAspect: string = null; - /** (required) Name of the metadata preset, which defines aspects * and their properties. */ @@ -83,12 +77,6 @@ export class ContentMetadataCardComponent implements OnChanges { constructor(private contentService: ContentService) { } - ngOnChanges(changes: SimpleChanges): void { - if (changes.displayAspect && changes.displayAspect.currentValue) { - this.expanded = true; - } - } - onDisplayDefaultPropertiesChange(): void { this.expanded = !this._displayDefaultProperties; } diff --git a/lib/content-services/content-metadata/components/content-metadata/content-metadata.component.html b/lib/content-services/content-metadata/components/content-metadata/content-metadata.component.html index 8f4876110a..e1c344b2c9 100644 --- a/lib/content-services/content-metadata/components/content-metadata/content-metadata.component.html +++ b/lib/content-services/content-metadata/components/content-metadata/content-metadata.component.html @@ -2,8 +2,8 @@ @@ -23,7 +23,7 @@

+ [expanded]="!displayDefaultProperties && first"> {{ group.title | translate }} diff --git a/lib/content-services/content-metadata/components/content-metadata/content-metadata.component.spec.ts b/lib/content-services/content-metadata/components/content-metadata/content-metadata.component.spec.ts index a3fe638500..ac6bfd0dec 100644 --- a/lib/content-services/content-metadata/components/content-metadata/content-metadata.component.spec.ts +++ b/lib/content-services/content-metadata/components/content-metadata/content-metadata.component.spec.ts @@ -27,12 +27,10 @@ import { } from '@alfresco/adf-core'; import { throwError, of } from 'rxjs'; import { ContentTestingModule } from '../../../testing/content.testing.module'; -import { mockGroupProperties } from './mock-data'; describe('ContentMetadataComponent', () => { let component: ContentMetadataComponent; let fixture: ComponentFixture; - let contentMetadataService: ContentMetadataService; let node: Node; let folderNode: Node; const preset = 'custom-preset'; @@ -45,7 +43,6 @@ describe('ContentMetadataComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(ContentMetadataComponent); component = fixture.componentInstance; - contentMetadataService = TestBed.get(ContentMetadataService); node = { id: 'node-id', aspectNames: [], @@ -150,10 +147,11 @@ describe('ContentMetadataComponent', () => { }); describe('Properties loading', () => { - let expectedNode; + let expectedNode, contentMetadataService: ContentMetadataService; beforeEach(() => { expectedNode = Object.assign({}, node, { name: 'some-modified-value' }); + contentMetadataService = TestBed.get(ContentMetadataService); fixture.detectChanges(); }); @@ -296,72 +294,4 @@ describe('ContentMetadataComponent', () => { expect(component.displayDefaultProperties).toBe(true); }); }); - - describe('Expand the panel', () => { - let expectedNode; - - beforeEach(() => { - expectedNode = Object.assign({}, node, {name: 'some-modified-value'}); - spyOn(contentMetadataService, 'getGroupedProperties').and.returnValue(of(mockGroupProperties)); - component.ngOnChanges({node: new SimpleChange(node, expectedNode, false)}); - }); - - it('should open and update drawer with expand section dynamically', async(() => { - component.displayAspect = 'EXIF'; - component.expanded = true; - component.displayEmpty = true; - - fixture.detectChanges(); - const defaultProp = queryDom(fixture); - const exifProp = queryDom(fixture, 'EXIF'); - const customProp = queryDom(fixture, 'CUSTOM'); - expect(defaultProp.componentInstance.expanded).toBeFalsy(); - expect(exifProp.componentInstance.expanded).toBeTruthy(); - expect(customProp.componentInstance.expanded).toBeFalsy(); - - component.displayAspect = 'CUSTOM'; - fixture.detectChanges(); - const updatedDefault = queryDom(fixture); - const updatedExif = queryDom(fixture, 'EXIF'); - const updatedCustom = queryDom(fixture, 'CUSTOM'); - expect(updatedDefault.componentInstance.expanded).toBeFalsy(); - expect(updatedExif.componentInstance.expanded).toBeFalsy(); - expect(updatedCustom.componentInstance.expanded).toBeTruthy(); - - })); - - it('should not expand anything if input is wrong', async(() => { - component.displayAspect = 'XXXX'; - component.expanded = true; - component.displayEmpty = true; - - fixture.detectChanges(); - const defaultProp = queryDom(fixture); - const exifProp = queryDom(fixture, 'EXIF'); - const customProp = queryDom(fixture, 'CUSTOM'); - expect(defaultProp.componentInstance.expanded).toBeFalsy(); - expect(exifProp.componentInstance.expanded).toBeFalsy(); - expect(customProp.componentInstance.expanded).toBeFalsy(); - - })); - - it('should expand the properties section when input is null', async(() => { - component.displayAspect = null; - component.expanded = true; - component.displayEmpty = true; - - fixture.detectChanges(); - const defaultProp = queryDom(fixture); - const exifProp = queryDom(fixture, 'EXIF'); - const customProp = queryDom(fixture, 'CUSTOM'); - expect(defaultProp.componentInstance.expanded).toBeTruthy(); - expect(exifProp.componentInstance.expanded).toBeFalsy(); - expect(customProp.componentInstance.expanded).toBeFalsy(); - - })); - }); }); - -function queryDom(fixture: ComponentFixture, properties: string = 'properties') { - return fixture.debugElement.query(By.css(`[data-automation-id="adf-metadata-group-${properties}"]`)); -} diff --git a/lib/content-services/content-metadata/components/content-metadata/content-metadata.component.ts b/lib/content-services/content-metadata/components/content-metadata/content-metadata.component.ts index b6d769cafb..d3c4004263 100644 --- a/lib/content-services/content-metadata/components/content-metadata/content-metadata.component.ts +++ b/lib/content-services/content-metadata/components/content-metadata/content-metadata.component.ts @@ -61,10 +61,6 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy { @Input() displayDefaultProperties: boolean = true; - /** (Optional) shows the given aspect in the expanded card */ - @Input() - displayAspect: string = null; - basicProperties$: Observable; groupedProperties$: Observable; disposableNodeUpdate: Subscription; @@ -122,8 +118,4 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy { this.disposableNodeUpdate.unsubscribe(); } - public canExpandTheCard(group: CardViewGroup): boolean { - return group.title === this.displayAspect; - } - } diff --git a/lib/content-services/content-metadata/components/content-metadata/mock-data.ts b/lib/content-services/content-metadata/components/content-metadata/mock-data.ts deleted file mode 100644 index 4ea3974bcd..0000000000 --- a/lib/content-services/content-metadata/components/content-metadata/mock-data.ts +++ /dev/null @@ -1,74 +0,0 @@ -/*! - * @license - * Copyright 2019 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export const mockGroupProperties = [ - { - 'title': 'EXIF', - 'properties': [ - { - 'label': 'Image Width', - 'value': 363, - 'key': 'properties.exif:pixelXDimension', - 'default': null, - 'editable': true, - 'clickable': false, - 'icon': '', - 'data': null, - 'type': 'int', - 'multiline': false, - 'pipes': [], - 'clickCallBack': null, - displayValue: 400 - }, - { - 'label': 'Image Height', - 'value': 400, - 'key': 'properties.exif:pixelYDimension', - 'default': null, - 'editable': true, - 'clickable': false, - 'icon': '', - 'data': null, - 'type': 'int', - 'multiline': false, - 'pipes': [], - 'clickCallBack': null, - displayValue: 400 - } - ] - }, - { - 'title': 'CUSTOM', - 'properties': [ - { - 'label': 'Height', - 'value': 400, - 'key': 'properties.custom:abc', - 'default': null, - 'editable': true, - 'clickable': false, - 'icon': '', - 'data': null, - 'type': 'int', - 'multiline': false, - 'pipes': [], - 'clickCallBack': null, - displayValue: 400 - } - ] - } -];