mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-07 18:25:09 +00:00
Revert "[ADF-4359] - Add the possibility to chose wich panel to show first in info-drawer (#4632)" (#4637)
This reverts commit 6e4adfb09a37caaaf98daab4d7c3cf68ade361c5.
This commit is contained in:
parent
64391a48fa
commit
df26447701
@ -12,14 +12,12 @@
|
|||||||
[multi]="multi"
|
[multi]="multi"
|
||||||
[preset]="customPreset"
|
[preset]="customPreset"
|
||||||
[readOnly]="isReadOnly"
|
[readOnly]="isReadOnly"
|
||||||
[displayAspect]="showAspect"
|
|
||||||
[displayDefaultProperties]="displayDefaultProperties"
|
[displayDefaultProperties]="displayDefaultProperties"
|
||||||
[displayEmpty]="displayEmptyMetadata"></adf-content-metadata-card>
|
[displayEmpty]="displayEmptyMetadata"></adf-content-metadata-card>
|
||||||
|
|
||||||
<adf-content-metadata-card *ngIf="!isPreset" [node]="node"
|
<adf-content-metadata-card *ngIf="!isPreset" [node]="node"
|
||||||
[multi]="multi"
|
[multi]="multi"
|
||||||
[readOnly]="isReadOnly"
|
[readOnly]="isReadOnly"
|
||||||
[displayAspect]="showAspect"
|
|
||||||
[displayDefaultProperties]="displayDefaultProperties"
|
[displayDefaultProperties]="displayDefaultProperties"
|
||||||
[displayEmpty]="displayEmptyMetadata"></adf-content-metadata-card>
|
[displayEmpty]="displayEmptyMetadata"></adf-content-metadata-card>
|
||||||
|
|
||||||
@ -73,19 +71,6 @@
|
|||||||
</mat-slide-toggle>
|
</mat-slide-toggle>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p class="toggle">
|
|
||||||
|
|
||||||
<mat-form-field floatPlaceholder="float">
|
|
||||||
<input matInput
|
|
||||||
placeholder="Display Aspect"
|
|
||||||
[(ngModel)]="desiredAspect">
|
|
||||||
</mat-form-field>
|
|
||||||
|
|
||||||
<button mat-raised-button (click)="applyAspect()" color="primary">
|
|
||||||
Apply Aspect
|
|
||||||
</button>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p class="toggle">
|
<p class="toggle">
|
||||||
<ng-container *ngIf="isPreset">
|
<ng-container *ngIf="isPreset">
|
||||||
<mat-form-field floatPlaceholder="float">
|
<mat-form-field floatPlaceholder="float">
|
||||||
@ -133,7 +118,7 @@
|
|||||||
|
|
||||||
<p class="toggle">
|
<p class="toggle">
|
||||||
<ng-container *ngIf="customName">
|
<ng-container *ngIf="customName">
|
||||||
<mat-form-field floatLabel="never">
|
<mat-form-field floatPlaceholder="float">
|
||||||
<input matInput
|
<input matInput
|
||||||
placeholder="Custom Name"
|
placeholder="Custom Name"
|
||||||
[(ngModel)]="displayName"
|
[(ngModel)]="displayName"
|
||||||
|
@ -55,8 +55,6 @@ export class FileViewComponent implements OnInit {
|
|||||||
isCommentEnabled = false;
|
isCommentEnabled = false;
|
||||||
showTabWithIcon = false;
|
showTabWithIcon = false;
|
||||||
showTabWithIconAndLabel = false;
|
showTabWithIconAndLabel = false;
|
||||||
desiredAspect: string = null;
|
|
||||||
showAspect: string = null;
|
|
||||||
|
|
||||||
constructor(private router: Router,
|
constructor(private router: Router,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
@ -190,8 +188,4 @@ export class FileViewComponent implements OnInit {
|
|||||||
this.isPreset = true;
|
this.isPreset = true;
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
applyAspect() {
|
|
||||||
this.showAspect = this.desiredAspect;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,6 @@ Displays and edits metadata related to a node.
|
|||||||
| preset | `string` | | (required) Name of the metadata preset, which defines aspects and their properties. |
|
| preset | `string` | | (required) Name of the metadata preset, which defines aspects and their properties. |
|
||||||
| readOnly | `boolean` | false | (optional) This flag sets the metadata in read only mode preventing changes. |
|
| readOnly | `boolean` | false | (optional) This flag sets the metadata in read only mode preventing changes. |
|
||||||
| displayDefaultProperties | `boolean` | | (optional) This flag displays/hides the metadata properties. |
|
| displayDefaultProperties | `boolean` | | (optional) This flag displays/hides the metadata properties. |
|
||||||
| displayAspect | `string` | | (optional) This flag displays the desired metadata property in the expanded card |
|
|
||||||
|
|
||||||
## Details
|
## Details
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
[displayEmpty]="displayEmpty"
|
[displayEmpty]="displayEmpty"
|
||||||
[editable]="editable"
|
[editable]="editable"
|
||||||
[multi]="multi"
|
[multi]="multi"
|
||||||
[displayAspect]="displayAspect"
|
|
||||||
[preset]="preset">
|
[preset]="preset">
|
||||||
</adf-content-metadata>
|
</adf-content-metadata>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
|
@ -22,7 +22,6 @@ import { ContentMetadataCardComponent } from './content-metadata-card.component'
|
|||||||
import { ContentMetadataComponent } from '../content-metadata/content-metadata.component';
|
import { ContentMetadataComponent } from '../content-metadata/content-metadata.component';
|
||||||
import { setupTestBed, AllowableOperationsEnum } from '@alfresco/adf-core';
|
import { setupTestBed, AllowableOperationsEnum } from '@alfresco/adf-core';
|
||||||
import { ContentTestingModule } from '../../../testing/content.testing.module';
|
import { ContentTestingModule } from '../../../testing/content.testing.module';
|
||||||
import { SimpleChange } from '@angular/core';
|
|
||||||
|
|
||||||
describe('ContentMetadataCardComponent', () => {
|
describe('ContentMetadataCardComponent', () => {
|
||||||
|
|
||||||
@ -190,17 +189,4 @@ describe('ContentMetadataCardComponent', () => {
|
|||||||
const button = fixture.debugElement.query(By.css('[data-automation-id="meta-data-card-toggle-edit"]'));
|
const button = fixture.debugElement.query(By.css('[data-automation-id="meta-data-card-toggle-edit"]'));
|
||||||
expect(button).not.toBeNull();
|
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();
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* 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 { Node } from '@alfresco/js-api';
|
||||||
import { ContentService, AllowableOperationsEnum } from '@alfresco/adf-core';
|
import { ContentService, AllowableOperationsEnum } from '@alfresco/adf-core';
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ import { ContentService, AllowableOperationsEnum } from '@alfresco/adf-core';
|
|||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
host: { 'class': 'adf-content-metadata-card' }
|
host: { 'class': 'adf-content-metadata-card' }
|
||||||
})
|
})
|
||||||
export class ContentMetadataCardComponent implements OnChanges {
|
export class ContentMetadataCardComponent {
|
||||||
/** (required) The node entity to fetch metadata about */
|
/** (required) The node entity to fetch metadata about */
|
||||||
@Input()
|
@Input()
|
||||||
node: Node;
|
node: Node;
|
||||||
@ -37,12 +37,6 @@ export class ContentMetadataCardComponent implements OnChanges {
|
|||||||
@Input()
|
@Input()
|
||||||
displayEmpty: boolean = false;
|
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
|
/** (required) Name of the metadata preset, which defines aspects
|
||||||
* and their properties.
|
* and their properties.
|
||||||
*/
|
*/
|
||||||
@ -83,12 +77,6 @@ export class ContentMetadataCardComponent implements OnChanges {
|
|||||||
constructor(private contentService: ContentService) {
|
constructor(private contentService: ContentService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
|
||||||
if (changes.displayAspect && changes.displayAspect.currentValue) {
|
|
||||||
this.expanded = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onDisplayDefaultPropertiesChange(): void {
|
onDisplayDefaultPropertiesChange(): void {
|
||||||
this.expanded = !this._displayDefaultProperties;
|
this.expanded = !this._displayDefaultProperties;
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
<mat-accordion displayMode="flat" [multi]="multi">
|
<mat-accordion displayMode="flat" [multi]="multi">
|
||||||
<mat-expansion-panel
|
<mat-expansion-panel
|
||||||
*ngIf="displayDefaultProperties"
|
*ngIf="displayDefaultProperties"
|
||||||
[expanded]="!expanded || !displayAspect"
|
[expanded]="!expanded"
|
||||||
[hideToggle]="!expanded || !displayAspect"
|
[hideToggle]="!expanded"
|
||||||
[attr.data-automation-id]="'adf-metadata-group-properties'" >
|
[attr.data-automation-id]="'adf-metadata-group-properties'" >
|
||||||
<mat-expansion-panel-header>
|
<mat-expansion-panel-header>
|
||||||
<mat-panel-title>
|
<mat-panel-title>
|
||||||
@ -23,7 +23,7 @@
|
|||||||
<div *ngFor="let group of groupedProperties; let first = first;" class="adf-metadata-grouped-properties-container">
|
<div *ngFor="let group of groupedProperties; let first = first;" class="adf-metadata-grouped-properties-container">
|
||||||
<mat-expansion-panel *ngIf="showGroup(group) || editable"
|
<mat-expansion-panel *ngIf="showGroup(group) || editable"
|
||||||
[attr.data-automation-id]="'adf-metadata-group-' + group.title"
|
[attr.data-automation-id]="'adf-metadata-group-' + group.title"
|
||||||
[expanded]="canExpandTheCard(group) || !displayDefaultProperties && first">
|
[expanded]="!displayDefaultProperties && first">
|
||||||
<mat-expansion-panel-header>
|
<mat-expansion-panel-header>
|
||||||
<mat-panel-title>
|
<mat-panel-title>
|
||||||
{{ group.title | translate }}
|
{{ group.title | translate }}
|
||||||
|
@ -27,12 +27,10 @@ import {
|
|||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { throwError, of } from 'rxjs';
|
import { throwError, of } from 'rxjs';
|
||||||
import { ContentTestingModule } from '../../../testing/content.testing.module';
|
import { ContentTestingModule } from '../../../testing/content.testing.module';
|
||||||
import { mockGroupProperties } from './mock-data';
|
|
||||||
|
|
||||||
describe('ContentMetadataComponent', () => {
|
describe('ContentMetadataComponent', () => {
|
||||||
let component: ContentMetadataComponent;
|
let component: ContentMetadataComponent;
|
||||||
let fixture: ComponentFixture<ContentMetadataComponent>;
|
let fixture: ComponentFixture<ContentMetadataComponent>;
|
||||||
let contentMetadataService: ContentMetadataService;
|
|
||||||
let node: Node;
|
let node: Node;
|
||||||
let folderNode: Node;
|
let folderNode: Node;
|
||||||
const preset = 'custom-preset';
|
const preset = 'custom-preset';
|
||||||
@ -45,7 +43,6 @@ describe('ContentMetadataComponent', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(ContentMetadataComponent);
|
fixture = TestBed.createComponent(ContentMetadataComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
contentMetadataService = TestBed.get(ContentMetadataService);
|
|
||||||
node = <Node> {
|
node = <Node> {
|
||||||
id: 'node-id',
|
id: 'node-id',
|
||||||
aspectNames: [],
|
aspectNames: [],
|
||||||
@ -150,10 +147,11 @@ describe('ContentMetadataComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Properties loading', () => {
|
describe('Properties loading', () => {
|
||||||
let expectedNode;
|
let expectedNode, contentMetadataService: ContentMetadataService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
expectedNode = Object.assign({}, node, { name: 'some-modified-value' });
|
expectedNode = Object.assign({}, node, { name: 'some-modified-value' });
|
||||||
|
contentMetadataService = TestBed.get(ContentMetadataService);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -296,72 +294,4 @@ describe('ContentMetadataComponent', () => {
|
|||||||
expect(component.displayDefaultProperties).toBe(true);
|
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<ContentMetadataComponent>, properties: string = 'properties') {
|
|
||||||
return fixture.debugElement.query(By.css(`[data-automation-id="adf-metadata-group-${properties}"]`));
|
|
||||||
}
|
|
||||||
|
@ -61,10 +61,6 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
@Input()
|
@Input()
|
||||||
displayDefaultProperties: boolean = true;
|
displayDefaultProperties: boolean = true;
|
||||||
|
|
||||||
/** (Optional) shows the given aspect in the expanded card */
|
|
||||||
@Input()
|
|
||||||
displayAspect: string = null;
|
|
||||||
|
|
||||||
basicProperties$: Observable<CardViewItem[]>;
|
basicProperties$: Observable<CardViewItem[]>;
|
||||||
groupedProperties$: Observable<CardViewGroup[]>;
|
groupedProperties$: Observable<CardViewGroup[]>;
|
||||||
disposableNodeUpdate: Subscription;
|
disposableNodeUpdate: Subscription;
|
||||||
@ -122,8 +118,4 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
this.disposableNodeUpdate.unsubscribe();
|
this.disposableNodeUpdate.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
public canExpandTheCard(group: CardViewGroup): boolean {
|
|
||||||
return group.title === this.displayAspect;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
];
|
|
Loading…
x
Reference in New Issue
Block a user