[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:
dhrn
2019-05-01 18:52:11 +05:30
committed by Denys Vuika
parent f45145f3a6
commit 6d3b6407bc
11 changed files with 139 additions and 58 deletions

65
package-lock.json generated
View File

@@ -5,33 +5,33 @@
"requires": true,
"dependencies": {
"@alfresco/adf-content-services": {
"version": "3.2.0-beta7",
"resolved": "https://registry.npmjs.org/@alfresco/adf-content-services/-/adf-content-services-3.2.0-beta7.tgz",
"integrity": "sha512-GQLAtCOB0Q4GY+0W2YFB8W5JWh519U0RTshpaqs9Bi9JbpbbfSR50+EA4M6w1AQLm9rWy/9LCeQ819CyOpMRpw==",
"version": "3.2.0-beta8",
"resolved": "https://registry.npmjs.org/@alfresco/adf-content-services/-/adf-content-services-3.2.0-beta8.tgz",
"integrity": "sha512-K/IY00t2MR84MujVlDPnBLOCq7zklqoDeRa8+dEf6DhHgdfwTOK2aUGObITdlQ1rhTbSSl0llVAUkkHdtgCYmg==",
"requires": {
"tslib": "^1.9.0"
}
},
"@alfresco/adf-core": {
"version": "3.2.0-beta7",
"resolved": "https://registry.npmjs.org/@alfresco/adf-core/-/adf-core-3.2.0-beta7.tgz",
"integrity": "sha512-hSSJCK+Rezur7CWQjeT0uihzSuq+3cUR/qQEVGehNVte0y/bw6ceJWW+00sKS6ICU0byQDDAjsOqPuEMshqchg==",
"version": "3.2.0-beta8",
"resolved": "https://registry.npmjs.org/@alfresco/adf-core/-/adf-core-3.2.0-beta8.tgz",
"integrity": "sha512-WC1m5HaFCrLbJQBnqrlGeb1UJ3MRHb1F0Ok7HgXmT7FSQwltBO54bJ5Ve2ttQ4xQJnJGMsHpzVncjmmV0LTiiA==",
"requires": {
"tslib": "^1.9.0"
}
},
"@alfresco/adf-extensions": {
"version": "3.2.0-beta7",
"resolved": "https://registry.npmjs.org/@alfresco/adf-extensions/-/adf-extensions-3.2.0-beta7.tgz",
"integrity": "sha512-2KxNnnCDXu619jV3eslX685j/CkZl2C+BfwEHNP7v5q9eCh4tJ4r5LALvRHnJ44BsRojvJrNG23VND/X4tS2Ng==",
"version": "3.2.0-beta8",
"resolved": "https://registry.npmjs.org/@alfresco/adf-extensions/-/adf-extensions-3.2.0-beta8.tgz",
"integrity": "sha512-PCv5zPo94O753s+SPLzzlzW9SJ1mRw4CwN8hY8xCTGGIQuSbaHnrTmgUIBHwp0gYVxcbQEULGymNSOz3e0Nslw==",
"requires": {
"tslib": "^1.9.0"
}
},
"@alfresco/js-api": {
"version": "3.2.0-beta7",
"resolved": "https://registry.npmjs.org/@alfresco/js-api/-/js-api-3.2.0-beta7.tgz",
"integrity": "sha512-8vWkFdi7qeSBjtk4ogEwEO1ApemcXAckPcPKmWWb2thbCyuW4JhDNa7+csPezuxYgIrhrEk+awRXN+b4xVDmaw==",
"version": "3.2.0-beta8",
"resolved": "https://registry.npmjs.org/@alfresco/js-api/-/js-api-3.2.0-beta8.tgz",
"integrity": "sha512-bXxBrP86akor52Fdse3Oj8Z1cS8RZsAlQrldSF3+HvgBhofEigldas7qYvK4RibkFw5tWBJhKVfd1LMfDuaVbg==",
"requires": {
"event-emitter": "0.3.4",
"superagent": "3.8.2"
@@ -4959,8 +4959,7 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"aproba": {
"version": "1.2.0",
@@ -4981,14 +4980,12 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -5003,20 +5000,17 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"core-util-is": {
"version": "1.0.2",
@@ -5133,8 +5127,7 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"ini": {
"version": "1.3.5",
@@ -5146,7 +5139,6 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@@ -5161,7 +5153,6 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@@ -5169,14 +5160,12 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@@ -5195,7 +5184,6 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@@ -5276,8 +5264,7 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"object-assign": {
"version": "4.1.1",
@@ -5289,7 +5276,6 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@@ -5375,8 +5361,7 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"safer-buffer": {
"version": "2.1.2",
@@ -5412,7 +5397,6 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@@ -5432,7 +5416,6 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@@ -5476,14 +5459,12 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"yallist": {
"version": "3.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
}
}
},

View File

@@ -37,10 +37,10 @@
},
"private": true,
"dependencies": {
"@alfresco/adf-content-services": "3.2.0-beta7",
"@alfresco/adf-core": "3.2.0-beta7",
"@alfresco/adf-extensions": "3.2.0-beta7",
"@alfresco/js-api": "3.2.0-beta7",
"@alfresco/adf-content-services": "3.2.0-beta8",
"@alfresco/adf-core": "3.2.0-beta8",
"@alfresco/adf-extensions": "3.2.0-beta8",
"@alfresco/js-api": "3.2.0-beta8",
"@angular/animations": "7.2.13",
"@angular/cdk": "^7.3.7",
"@angular/common": "7.2.13",

View File

@@ -39,6 +39,7 @@ export enum AppActionTypes {
Logout = 'LOGOUT',
ReloadDocumentList = 'RELOAD_DOCUMENT_LIST',
SetInfoDrawerState = 'SET_INFO_DRAWER_STATE',
SetInfoDrawerMetadataAspect = 'SET_INFO_DRAWER_METADATA_ASPECT',
CloseModalDialogs = 'CLOSE_MODAL_DIALOGS'
}

View File

@@ -0,0 +1,34 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2019 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Action } from '@ngrx/store';
export const SET_INFO_DRAWER_METADATA_ASPECT =
'SET_INFO_DRAWER_METADATA_ASPECT';
export class SetInfoDrawerMetadataAspectAction implements Action {
readonly type = SET_INFO_DRAWER_METADATA_ASPECT;
constructor(public payload: string) {}
}

View File

@@ -31,6 +31,7 @@ export * from './actions/search.actions';
export * from './actions/snackbar.actions';
export * from './actions/upload.actions';
export * from './actions/viewer.actions';
export * from './actions/metadata-aspect.actions';
export * from './effects/dialog.effects';
export * from './effects/router.effects';

View File

@@ -128,3 +128,8 @@ export const getRuleContext = createSelector(
};
}
);
export const infoDrawerMetadataAspect = createSelector(
selectApp,
state => state.infoDrawerMetadataAspect
);

View File

@@ -40,6 +40,7 @@ export interface AppState {
user: ProfileState;
navigation: NavigationState;
infoDrawerOpened: boolean;
infoDrawerMetadataAspect: string;
showFacetFilter: boolean;
documentDisplayMode: string;
repository: RepositoryInfo;

View File

@@ -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');
});
});
});

View File

@@ -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 {

View File

@@ -47,6 +47,7 @@ export const INITIAL_APP_STATE: AppState = {
currentFolder: null
},
infoDrawerOpened: false,
infoDrawerMetadataAspect: '',
showFacetFilter: true,
documentDisplayMode: 'list',
repository: <any>{

View File

@@ -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