mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
[ACA-2365] infodrawer metadata in expanded card (#1090)
* feat(info-drawer):- infodrawer default metadata in expanded card * * test added * * initial state fixed * * package updated with beta
This commit is contained in:
@@ -24,23 +24,36 @@
|
||||
*/
|
||||
|
||||
import { MetadataTabComponent } from './metadata-tab.component';
|
||||
import { NodePermissionService } from '@alfresco/aca-shared';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { AppTestingModule } from '../../../testing/app-testing.module';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
import { ContentMetadataModule } from '@alfresco/adf-content-services';
|
||||
import { Store } from '@ngrx/store';
|
||||
import {
|
||||
SetInfoDrawerMetadataAspectAction,
|
||||
AppState
|
||||
} from '@alfresco/aca-shared/store';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
describe('MetadataTabComponent', () => {
|
||||
let nodePermissionService: NodePermissionService;
|
||||
let fixture: ComponentFixture<MetadataTabComponent>;
|
||||
let component: MetadataTabComponent;
|
||||
let store: Store<AppState>;
|
||||
|
||||
setupTestBed({
|
||||
imports: [AppTestingModule, ContentMetadataModule],
|
||||
declarations: [MetadataTabComponent]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
nodePermissionService = new NodePermissionService();
|
||||
const appConfig = <any>{ config: { 'content-metadata': {} } };
|
||||
const extension = <any>{ contentMetadata: {} };
|
||||
fixture = TestBed.createComponent(MetadataTabComponent);
|
||||
store = TestBed.get(Store);
|
||||
component = fixture.componentInstance;
|
||||
});
|
||||
|
||||
component = new MetadataTabComponent(
|
||||
nodePermissionService,
|
||||
extension,
|
||||
appConfig
|
||||
);
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
describe('canUpdateNode()', () => {
|
||||
@@ -87,4 +100,25 @@ describe('MetadataTabComponent', () => {
|
||||
expect(component.canUpdateNode).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('displayAspect', () => {
|
||||
it('show pass empty when store is in initial state', () => {
|
||||
const initialState = fixture.debugElement.query(
|
||||
By.css('adf-content-metadata-card')
|
||||
);
|
||||
expect(initialState.componentInstance.displayAspect).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should update the exif if store got updated', () => {
|
||||
store.dispatch(new SetInfoDrawerMetadataAspectAction('EXIF'));
|
||||
component.displayAspect$.subscribe(aspect => {
|
||||
expect(aspect).toBe('EXIF');
|
||||
});
|
||||
fixture.detectChanges();
|
||||
const initialState = fixture.debugElement.query(
|
||||
By.css('adf-content-metadata-card')
|
||||
);
|
||||
expect(initialState.componentInstance.displayAspect).toBe('EXIF');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -26,9 +26,12 @@
|
||||
import { Component, Input, ViewEncapsulation } from '@angular/core';
|
||||
import { MinimalNodeEntryEntity } from '@alfresco/js-api';
|
||||
import { NodePermissionService } from '@alfresco/aca-shared';
|
||||
import { AppStore, infoDrawerMetadataAspect } from '@alfresco/aca-shared/store';
|
||||
import { AppExtensionService } from '../../../extensions/extension.service';
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
import { isLocked } from '../../../utils/node.utils';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-tab',
|
||||
@@ -37,6 +40,7 @@ import { isLocked } from '../../../utils/node.utils';
|
||||
[readOnly]="!canUpdateNode"
|
||||
[preset]="'custom'"
|
||||
[node]="node"
|
||||
[displayAspect]="displayAspect$ | async"
|
||||
>
|
||||
</adf-content-metadata-card>
|
||||
`,
|
||||
@@ -47,10 +51,13 @@ export class MetadataTabComponent {
|
||||
@Input()
|
||||
node: MinimalNodeEntryEntity;
|
||||
|
||||
displayAspect$: Observable<string>;
|
||||
|
||||
constructor(
|
||||
private permission: NodePermissionService,
|
||||
protected extensions: AppExtensionService,
|
||||
private appConfig: AppConfigService
|
||||
private appConfig: AppConfigService,
|
||||
private store: Store<AppStore>
|
||||
) {
|
||||
try {
|
||||
this.appConfig.config[
|
||||
@@ -62,6 +69,7 @@ export class MetadataTabComponent {
|
||||
'- could not change content-metadata from app.config'
|
||||
);
|
||||
}
|
||||
this.displayAspect$ = this.store.select(infoDrawerMetadataAspect);
|
||||
}
|
||||
|
||||
get canUpdateNode(): boolean {
|
||||
|
||||
@@ -47,6 +47,7 @@ export const INITIAL_APP_STATE: AppState = {
|
||||
currentFolder: null
|
||||
},
|
||||
infoDrawerOpened: false,
|
||||
infoDrawerMetadataAspect: '',
|
||||
showFacetFilter: true,
|
||||
documentDisplayMode: 'list',
|
||||
repository: <any>{
|
||||
|
||||
@@ -36,7 +36,8 @@ import {
|
||||
SetInitialStateAction,
|
||||
SetSelectedNodesAction,
|
||||
SetRepositoryInfoAction,
|
||||
SetInfoDrawerStateAction
|
||||
SetInfoDrawerStateAction,
|
||||
SetInfoDrawerMetadataAspectAction
|
||||
} from '@alfresco/aca-shared/store';
|
||||
import { INITIAL_APP_STATE } from '../initial-state';
|
||||
|
||||
@@ -71,6 +72,11 @@ export function appReducer(
|
||||
case AppActionTypes.SetInfoDrawerState:
|
||||
newState = setInfoDrawer(state, <SetInfoDrawerStateAction>action);
|
||||
break;
|
||||
case AppActionTypes.SetInfoDrawerMetadataAspect:
|
||||
newState = setInfoDrawerAspect(state, <SetInfoDrawerMetadataAspectAction>(
|
||||
action
|
||||
));
|
||||
break;
|
||||
case AppActionTypes.ToggleDocumentDisplayMode:
|
||||
newState = toggleDocumentDisplayMode(state);
|
||||
break;
|
||||
@@ -245,6 +251,15 @@ function setInfoDrawer(state: AppState, action: SetInfoDrawerStateAction) {
|
||||
return newState;
|
||||
}
|
||||
|
||||
function setInfoDrawerAspect(
|
||||
state: AppState,
|
||||
action: SetInfoDrawerMetadataAspectAction
|
||||
) {
|
||||
const newState = Object.assign({}, state);
|
||||
newState.infoDrawerMetadataAspect = action.payload;
|
||||
return newState;
|
||||
}
|
||||
|
||||
function updateRepositoryStatus(
|
||||
state: AppState,
|
||||
action: SetRepositoryInfoAction
|
||||
|
||||
Reference in New Issue
Block a user