diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 4432d2ad3..ba7c26561 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -40,7 +40,6 @@ import { AppComponent } from './app.component'; import { APP_ROUTES } from './app.routes'; import { GenericErrorComponent } from './components/generic-error/generic-error.component'; -import { LoginComponent } from './components/login/login.component'; import { FilesComponent } from './components/files/files.component'; import { FavoritesComponent } from './components/favorites/favorites.component'; import { LibrariesComponent } from './components/libraries/libraries.component'; @@ -52,7 +51,6 @@ import { SidenavViewsManagerDirective } from './components/layout/sidenav-views- import { CurrentUserComponent } from './components/current-user/current-user.component'; import { SearchInputComponent } from './components/search/search-input/search-input.component'; import { SearchInputControlComponent } from './components/search/search-input-control/search-input-control.component'; -import { SidenavComponent } from './components/sidenav/sidenav.component'; import { LocationLinkComponent } from './components/location-link/location-link.component'; import { SharedLinkViewComponent } from './components/shared-link-view/shared-link-view.component'; import { NodeVersionsDialogComponent } from './dialogs/node-versions/node-versions.dialog'; @@ -78,6 +76,8 @@ import { DirectivesModule } from './directives/directives.module'; import { ContextMenuModule } from './components/context-menu/context-menu.module'; import { ExtensionsModule } from '@alfresco/adf-extensions'; import { AppToolbarModule } from './components/toolbar/toolbar.module'; +import { AppCreateMenuModule } from './components/create-menu/create-menu.module'; +import { AppSidenavModule } from './components/sidenav/sidenav.module'; @NgModule({ imports: [ @@ -100,18 +100,18 @@ import { AppToolbarModule } from './components/toolbar/toolbar.module'; DirectivesModule, ContextMenuModule.forRoot(), AppInfoDrawerModule, - AppToolbarModule + AppToolbarModule, + AppSidenavModule, + AppCreateMenuModule ], declarations: [ AppComponent, GenericErrorComponent, - LoginComponent, LayoutComponent, SidenavViewsManagerDirective, CurrentUserComponent, SearchInputComponent, SearchInputControlComponent, - SidenavComponent, FilesComponent, FavoritesComponent, LibrariesComponent, diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 17e257929..e952ab102 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -36,7 +36,6 @@ import { RecentFilesComponent } from './components/recent-files/recent-files.com import { SharedFilesComponent } from './components/shared-files/shared-files.component'; import { TrashcanComponent } from './components/trashcan/trashcan.component'; -import { LoginComponent } from './components/login/login.component'; import { GenericErrorComponent } from './components/generic-error/generic-error.component'; import { SearchResultsComponent } from './components/search/search-results/search-results.component'; @@ -45,7 +44,7 @@ import { ProfileResolver } from './services/profile.resolver'; export const APP_ROUTES: Routes = [ { path: 'login', - component: LoginComponent, + loadChildren: 'src/app/components/login/login.module#AppLoginModule', data: { title: 'APP.SIGN_IN' } diff --git a/src/app/components/context-menu/context-menu.component.ts b/src/app/components/context-menu/context-menu.component.ts index 646817cdb..65a5f15a5 100644 --- a/src/app/components/context-menu/context-menu.component.ts +++ b/src/app/components/context-menu/context-menu.component.ts @@ -43,7 +43,7 @@ import { appSelection } from '../../store/selectors/app.selectors'; import { Store } from '@ngrx/store'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; -import { SelectionState, ContentActionRef } from '@alfresco/adf-extensions'; +import { ContentActionRef } from '@alfresco/adf-extensions'; import { ContextMenuOverlayRef } from './context-menu-overlay'; import { contextMenuAnimation } from './animations'; @@ -65,7 +65,6 @@ import { ContextMenuItemDirective } from './context-menu-item.directive'; }) export class ContextMenuComponent implements OnInit, OnDestroy, AfterViewInit { private onDestroy$: Subject = new Subject(); - private selection: SelectionState; private _keyManager: FocusKeyManager; actions: Array = []; @@ -114,11 +113,7 @@ export class ContextMenuComponent implements OnInit, OnDestroy, AfterViewInit { } runAction(actionId: string) { - const context = { - selection: this.selection - }; - - this.extensions.runActionById(actionId, context); + this.extensions.runActionById(actionId); this.contextMenuOverlayRef.close(); } @@ -133,7 +128,6 @@ export class ContextMenuComponent implements OnInit, OnDestroy, AfterViewInit { .pipe(takeUntil(this.onDestroy$)) .subscribe(selection => { if (selection.count) { - this.selection = selection; this.actions = this.extensions.getAllowedContextMenuActions(); } }); diff --git a/src/app/components/create-menu/create-menu.component.html b/src/app/components/create-menu/create-menu.component.html new file mode 100644 index 000000000..f111cbae7 --- /dev/null +++ b/src/app/components/create-menu/create-menu.component.html @@ -0,0 +1,14 @@ + + arrow_drop_down +
+ queue +
+
+ + + +
+
diff --git a/src/app/components/create-menu/create-menu.component.scss b/src/app/components/create-menu/create-menu.component.scss new file mode 100644 index 000000000..3482e076b --- /dev/null +++ b/src/app/components/create-menu/create-menu.component.scss @@ -0,0 +1,3 @@ +.app-create-menu { + width: 100%; +} diff --git a/src/app/components/create-menu/create-menu.component.ts b/src/app/components/create-menu/create-menu.component.ts new file mode 100644 index 000000000..4edbf01a9 --- /dev/null +++ b/src/app/components/create-menu/create-menu.component.ts @@ -0,0 +1,77 @@ +/*! + * @license + * Alfresco Example Content Application + * + * Copyright (C) 2005 - 2018 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 . + */ + +import { + Component, + Input, + OnInit, + OnDestroy, + ViewEncapsulation +} from '@angular/core'; +import { ContentActionRef } from '@alfresco/adf-extensions'; +import { AppStore } from '../../store/states'; +import { AppExtensionService } from '../../extensions/extension.service'; +import { Store } from '@ngrx/store'; +import { currentFolder } from '../../store/selectors/app.selectors'; +import { takeUntil } from 'rxjs/operators'; +import { Subject } from 'rxjs'; + +@Component({ + selector: 'app-create-menu', + templateUrl: 'create-menu.component.html', + styleUrls: ['./create-menu.component.scss'], + encapsulation: ViewEncapsulation.None, + host: { class: 'app-create-menu' } +}) +export class CreateMenuComponent implements OnInit, OnDestroy { + createActions: Array = []; + onDestroy$: Subject = new Subject(); + + @Input() + showLabel: boolean; + + constructor( + private store: Store, + private extensions: AppExtensionService + ) {} + + ngOnInit() { + this.store + .select(currentFolder) + .pipe(takeUntil(this.onDestroy$)) + .subscribe(() => { + this.createActions = this.extensions.getCreateActions(); + }); + } + + ngOnDestroy() { + this.onDestroy$.next(true); + this.onDestroy$.complete(); + } + + trackById(index: number, obj: { id: string }) { + return obj.id; + } +} diff --git a/src/app/components/create-menu/create-menu.module.ts b/src/app/components/create-menu/create-menu.module.ts new file mode 100644 index 000000000..f0211c9f1 --- /dev/null +++ b/src/app/components/create-menu/create-menu.module.ts @@ -0,0 +1,37 @@ +/*! + * @license + * Alfresco Example Content Application + * + * Copyright (C) 2005 - 2018 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 . + */ + +import { NgModule } from '@angular/core'; +import { CreateMenuComponent } from './create-menu.component'; +import { CommonModule } from '@angular/common'; +import { CoreModule } from '@alfresco/adf-core'; +import { AppToolbarModule } from '../toolbar/toolbar.module'; + +@NgModule({ + imports: [CommonModule, CoreModule.forChild(), AppToolbarModule], + declarations: [CreateMenuComponent], + exports: [CreateMenuComponent] +}) +export class AppCreateMenuModule {} diff --git a/src/app/components/favorites/favorites.component.html b/src/app/components/favorites/favorites.component.html index f42330fe8..1e0f15ef0 100644 --- a/src/app/components/favorites/favorites.component.html +++ b/src/app/components/favorites/favorites.component.html @@ -7,7 +7,7 @@ - + diff --git a/src/app/components/files/files.component.html b/src/app/components/files/files.component.html index 7c3c6f56b..16ffc2131 100644 --- a/src/app/components/files/files.component.html +++ b/src/app/components/files/files.component.html @@ -9,7 +9,7 @@ - + diff --git a/src/app/components/libraries/libraries.component.html b/src/app/components/libraries/libraries.component.html index 6f0dfe557..05bfaf91e 100644 --- a/src/app/components/libraries/libraries.component.html +++ b/src/app/components/libraries/libraries.component.html @@ -8,7 +8,7 @@ - + diff --git a/src/app/components/login/login.module.ts b/src/app/components/login/login.module.ts new file mode 100644 index 000000000..c1e5b1129 --- /dev/null +++ b/src/app/components/login/login.module.ts @@ -0,0 +1,43 @@ +/*! + * @license + * Alfresco Example Content Application + * + * Copyright (C) 2005 - 2018 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 . + */ + +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { CoreModule } from '@alfresco/adf-core'; +import { LoginComponent } from './login.component'; +import { Routes, RouterModule } from '@angular/router'; + +const routes: Routes = [ + { + path: '', + component: LoginComponent + } +]; + +@NgModule({ + imports: [CommonModule, CoreModule.forChild(), RouterModule.forChild(routes)], + declarations: [LoginComponent] +}) +export class AppLoginModule {} diff --git a/src/app/components/preview/preview.component.html b/src/app/components/preview/preview.component.html index ce72e4a8c..634d1a474 100644 --- a/src/app/components/preview/preview.component.html +++ b/src/app/components/preview/preview.component.html @@ -18,13 +18,13 @@ - + - + diff --git a/src/app/components/recent-files/recent-files.component.html b/src/app/components/recent-files/recent-files.component.html index f2c92eb9e..b34b078da 100644 --- a/src/app/components/recent-files/recent-files.component.html +++ b/src/app/components/recent-files/recent-files.component.html @@ -7,7 +7,7 @@ - + diff --git a/src/app/components/search/search-results/search-results.component.html b/src/app/components/search/search-results/search-results.component.html index 382b7432d..cd7f83dca 100644 --- a/src/app/components/search/search-results/search-results.component.html +++ b/src/app/components/search/search-results/search-results.component.html @@ -4,7 +4,7 @@ - + diff --git a/src/app/components/shared-files/shared-files.component.html b/src/app/components/shared-files/shared-files.component.html index b3e589a02..d85b6881a 100644 --- a/src/app/components/shared-files/shared-files.component.html +++ b/src/app/components/shared-files/shared-files.component.html @@ -7,7 +7,7 @@ - + diff --git a/src/app/components/sidenav/sidenav.component.html b/src/app/components/sidenav/sidenav.component.html index 5ce534892..6b9cab8d5 100644 --- a/src/app/components/sidenav/sidenav.component.html +++ b/src/app/components/sidenav/sidenav.component.html @@ -1,21 +1,6 @@
- - arrow_drop_down -
- queue -
-
- - - -
-
+
. */ -import { Subject } from 'rxjs'; -import { Component, Input, OnInit, OnDestroy } from '@angular/core'; +import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core'; import { AppExtensionService } from '../../extensions/extension.service'; -import { Store } from '@ngrx/store'; -import { AppStore } from '../../store/states'; -import { currentFolder } from '../../store/selectors/app.selectors'; -import { takeUntil } from 'rxjs/operators'; -import { ContentActionRef, NavBarGroupRef } from '@alfresco/adf-extensions'; +import { NavBarGroupRef } from '@alfresco/adf-extensions'; @Component({ selector: 'app-sidenav', templateUrl: './sidenav.component.html', - styleUrls: ['./sidenav.component.scss'] + styleUrls: ['./sidenav.component.scss'], + encapsulation: ViewEncapsulation.None, + host: { class: 'app-sidenav' } }) -export class SidenavComponent implements OnInit, OnDestroy { +export class SidenavComponent implements OnInit { @Input() showLabel: boolean; groups: Array = []; - createActions: Array = []; - onDestroy$: Subject = new Subject(); - constructor( - private store: Store, - private extensions: AppExtensionService - ) {} + constructor(private extensions: AppExtensionService) {} ngOnInit() { this.groups = this.extensions.getNavigationGroups(); - - this.store - .select(currentFolder) - .pipe(takeUntil(this.onDestroy$)) - .subscribe(() => { - this.createActions = this.extensions.getCreateActions(); - }); - } - - ngOnDestroy() { - this.onDestroy$.next(true); - this.onDestroy$.complete(); } trackById(index: number, obj: { id: string }) { diff --git a/src/app/components/sidenav/sidenav.module.ts b/src/app/components/sidenav/sidenav.module.ts new file mode 100644 index 000000000..fdceebc4e --- /dev/null +++ b/src/app/components/sidenav/sidenav.module.ts @@ -0,0 +1,43 @@ +/*! + * @license + * Alfresco Example Content Application + * + * Copyright (C) 2005 - 2018 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 . + */ + +import { NgModule } from '@angular/core'; +import { AppCreateMenuModule } from '../create-menu/create-menu.module'; +import { CommonModule } from '@angular/common'; +import { SidenavComponent } from './sidenav.component'; +import { CoreModule } from '@alfresco/adf-core'; +import { RouterModule } from '@angular/router'; + +@NgModule({ + imports: [ + CommonModule, + CoreModule.forChild(), + RouterModule, + AppCreateMenuModule + ], + declarations: [SidenavComponent], + exports: [SidenavComponent] +}) +export class AppSidenavModule {} diff --git a/src/app/components/toolbar/document-display-mode/document-display-mode.component.ts b/src/app/components/toolbar/document-display-mode/document-display-mode.component.ts index c30925fae..d9c2f748e 100644 --- a/src/app/components/toolbar/document-display-mode/document-display-mode.component.ts +++ b/src/app/components/toolbar/document-display-mode/document-display-mode.component.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { Component } from '@angular/core'; +import { Component, ViewEncapsulation } from '@angular/core'; import { Observable } from 'rxjs'; import { Store } from '@ngrx/store'; import { AppStore } from '../../../store/states'; @@ -40,7 +40,9 @@ import { ToggleDocumentDisplayMode } from '../../../store/actions'; view_comfy list - ` + `, + encapsulation: ViewEncapsulation.None, + host: { class: 'app-document-display-mode' } }) export class DocumentDisplayModeComponent { displayMode$: Observable; diff --git a/src/app/components/toolbar/toggle-favorite/toggle-favorite.component.ts b/src/app/components/toolbar/toggle-favorite/toggle-favorite.component.ts index 6d02b70b1..55a547ced 100644 --- a/src/app/components/toolbar/toggle-favorite/toggle-favorite.component.ts +++ b/src/app/components/toolbar/toggle-favorite/toggle-favorite.component.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { Component } from '@angular/core'; +import { Component, ViewEncapsulation } from '@angular/core'; import { Store } from '@ngrx/store'; import { AppStore } from '../../../store/states'; import { appSelection } from '../../../store/selectors/app.selectors'; @@ -43,7 +43,9 @@ import { ContentManagementService } from '../../../services/content-management.s star_border {{ 'APP.ACTIONS.FAVORITE' | translate }} - ` + `, + encapsulation: ViewEncapsulation.None, + host: { class: 'app-toggle-favorite' } }) export class ToggleFavoriteComponent { selection$: Observable; diff --git a/src/app/components/toolbar/toggle-info-drawer/toggle-info-drawer.component.ts b/src/app/components/toolbar/toggle-info-drawer/toggle-info-drawer.component.ts index 990c4127a..4d9f609ec 100644 --- a/src/app/components/toolbar/toggle-info-drawer/toggle-info-drawer.component.ts +++ b/src/app/components/toolbar/toggle-info-drawer/toggle-info-drawer.component.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { Component } from '@angular/core'; +import { Component, ViewEncapsulation } from '@angular/core'; import { Observable } from 'rxjs'; import { Store } from '@ngrx/store'; import { AppStore } from '../../../store/states'; @@ -40,7 +40,9 @@ import { ToggleInfoDrawerAction } from '../../../store/actions'; (click)="onClick()"> info_outline - ` + `, + encapsulation: ViewEncapsulation.None, + host: { class: 'app-toggle-info-drawer' } }) export class ToggleInfoDrawerComponent { infoDrawerOpened$: Observable; diff --git a/src/app/components/toolbar/toolbar-action/toolbar-action.component.html b/src/app/components/toolbar/toolbar-action/toolbar-action.component.html index b8e747c56..36d720518 100644 --- a/src/app/components/toolbar/toolbar-action/toolbar-action.component.html +++ b/src/app/components/toolbar/toolbar-action/toolbar-action.component.html @@ -1,43 +1,20 @@ - + - + - + - - + - - - - - - - - - - - - - - + - + diff --git a/src/app/components/toolbar/toolbar-action/toolbar-action.component.ts b/src/app/components/toolbar/toolbar-action/toolbar-action.component.ts index eb46f53ae..23f5036db 100644 --- a/src/app/components/toolbar/toolbar-action/toolbar-action.component.ts +++ b/src/app/components/toolbar/toolbar-action/toolbar-action.component.ts @@ -29,10 +29,7 @@ import { ChangeDetectionStrategy, Input } from '@angular/core'; -import { AppStore } from '../../../store/states'; -import { Store } from '@ngrx/store'; import { ContentActionRef } from '@alfresco/adf-extensions'; -import { AppExtensionService } from '../../../extensions/extension.service'; @Component({ selector: 'aca-toolbar-action', @@ -44,15 +41,7 @@ import { AppExtensionService } from '../../../extensions/extension.service'; export class ToolbarActionComponent { @Input() type = 'icon-button'; + @Input() - entry: ContentActionRef; - - constructor( - protected store: Store, - protected extensions: AppExtensionService - ) {} - - trackByActionId(index: number, action: ContentActionRef) { - return action.id; - } + actionRef: ContentActionRef; } diff --git a/src/app/components/toolbar/toolbar-button/toolbar-button.component.html b/src/app/components/toolbar/toolbar-button/toolbar-button.component.html index a8b484f68..896928bf7 100644 --- a/src/app/components/toolbar/toolbar-button/toolbar-button.component.html +++ b/src/app/components/toolbar/toolbar-button/toolbar-button.component.html @@ -10,19 +10,6 @@ - + diff --git a/src/app/components/toolbar/toolbar-button/toolbar-button.component.ts b/src/app/components/toolbar/toolbar-button/toolbar-button.component.ts index 15b67bd50..6226a7dd8 100644 --- a/src/app/components/toolbar/toolbar-button/toolbar-button.component.ts +++ b/src/app/components/toolbar/toolbar-button/toolbar-button.component.ts @@ -23,12 +23,8 @@ * along with Alfresco. If not, see . */ -import { Component, Input } from '@angular/core'; +import { Component, Input, ViewEncapsulation } from '@angular/core'; import { ContentActionRef } from '@alfresco/adf-extensions'; -import { Store } from '@ngrx/store'; -import { AppStore } from '../../../store/states'; -import { appSelection } from '../../../store/selectors/app.selectors'; -import { take } from 'rxjs/operators'; import { AppExtensionService } from '../../../extensions/extension.service'; export enum ToolbarButtonType { @@ -38,27 +34,29 @@ export enum ToolbarButtonType { @Component({ selector: 'app-toolbar-button', - templateUrl: 'toolbar-button.component.html' + templateUrl: 'toolbar-button.component.html', + encapsulation: ViewEncapsulation.None, + host: { class: 'app-toolbar-button' } }) export class ToolbarButtonComponent { @Input() type: ToolbarButtonType = ToolbarButtonType.ICON_BUTTON; + @Input() actionRef: ContentActionRef; - constructor( - protected store: Store, - private extensions: AppExtensionService - ) {} + constructor(private extensions: AppExtensionService) {} runAction() { - this.store - .select(appSelection) - .pipe(take(1)) - .subscribe(selection => { - this.extensions.runActionById(this.actionRef.actions.click, { - selection - }); - }); + if (this.hasClickAction(this.actionRef)) { + this.extensions.runActionById(this.actionRef.actions.click); + } + } + + private hasClickAction(actionRef: ContentActionRef): boolean { + if (actionRef && actionRef.actions && actionRef.actions.click) { + return true; + } + return false; } } diff --git a/src/app/components/toolbar/toolbar-menu-item/toolbar-menu-item.component.html b/src/app/components/toolbar/toolbar-menu-item/toolbar-menu-item.component.html new file mode 100644 index 000000000..247c9b680 --- /dev/null +++ b/src/app/components/toolbar/toolbar-menu-item/toolbar-menu-item.component.html @@ -0,0 +1,14 @@ + diff --git a/src/app/components/toolbar/toolbar-menu-item/toolbar-menu-item.component.ts b/src/app/components/toolbar/toolbar-menu-item/toolbar-menu-item.component.ts new file mode 100644 index 000000000..b822e59c1 --- /dev/null +++ b/src/app/components/toolbar/toolbar-menu-item/toolbar-menu-item.component.ts @@ -0,0 +1,54 @@ +/*! + * @license + * Alfresco Example Content Application + * + * Copyright (C) 2005 - 2018 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 . + */ + +import { Component, Input, ViewEncapsulation } from '@angular/core'; +import { ContentActionRef } from '@alfresco/adf-extensions'; +import { AppExtensionService } from '../../../extensions/extension.service'; + +@Component({ + selector: 'app-toolbar-menu-item', + templateUrl: 'toolbar-menu-item.component.html', + encapsulation: ViewEncapsulation.None, + host: { class: 'app-toolbar-menu-item' } +}) +export class ToolbarMenuItemComponent { + @Input() + actionRef: ContentActionRef; + + constructor(private extensions: AppExtensionService) {} + + runAction() { + if (this.hasClickAction(this.actionRef)) { + this.extensions.runActionById(this.actionRef.actions.click); + } + } + + private hasClickAction(actionRef: ContentActionRef): boolean { + if (actionRef && actionRef.actions && actionRef.actions.click) { + return true; + } + return false; + } +} diff --git a/src/app/components/toolbar/toolbar-menu/toolbar-menu.component.html b/src/app/components/toolbar/toolbar-menu/toolbar-menu.component.html new file mode 100644 index 000000000..1e47435cc --- /dev/null +++ b/src/app/components/toolbar/toolbar-menu/toolbar-menu.component.html @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + diff --git a/src/app/components/toolbar/toolbar-menu/toolbar-menu.component.ts b/src/app/components/toolbar/toolbar-menu/toolbar-menu.component.ts new file mode 100644 index 000000000..634c583a5 --- /dev/null +++ b/src/app/components/toolbar/toolbar-menu/toolbar-menu.component.ts @@ -0,0 +1,50 @@ +/*! + * @license + * Alfresco Example Content Application + * + * Copyright (C) 2005 - 2018 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 . + */ + +import { Component, Input, ViewEncapsulation } from '@angular/core'; +import { ContentActionRef } from '@alfresco/adf-extensions'; + +@Component({ + selector: 'app-toolbar-menu', + templateUrl: 'toolbar-menu.component.html', + encapsulation: ViewEncapsulation.None, + host: { class: 'app-toolbar-menu' } +}) +export class ToolbarMenuComponent { + @Input() + actionRef: ContentActionRef; + + get hasChildren(): boolean { + return ( + this.actionRef && + this.actionRef.children && + this.actionRef.children.length > 0 + ); + } + + trackById(index: number, obj: { id: string }) { + return obj.id; + } +} diff --git a/src/app/components/toolbar/toolbar.module.ts b/src/app/components/toolbar/toolbar.module.ts index 32e9b62da..0ff8fb02d 100644 --- a/src/app/components/toolbar/toolbar.module.ts +++ b/src/app/components/toolbar/toolbar.module.ts @@ -32,6 +32,8 @@ import { CoreModule } from '@alfresco/adf-core'; import { ToolbarButtonComponent } from './toolbar-button/toolbar-button.component'; import { ToolbarActionComponent } from './toolbar-action/toolbar-action.component'; import { ExtensionsModule } from '@alfresco/adf-extensions'; +import { ToolbarMenuItemComponent } from './toolbar-menu-item/toolbar-menu-item.component'; +import { ToolbarMenuComponent } from './toolbar-menu/toolbar-menu.component'; export function components() { return [ @@ -39,7 +41,9 @@ export function components() { ToggleFavoriteComponent, ToggleInfoDrawerComponent, ToolbarButtonComponent, - ToolbarActionComponent + ToolbarActionComponent, + ToolbarMenuItemComponent, + ToolbarMenuComponent ]; } diff --git a/src/app/components/trashcan/trashcan.component.html b/src/app/components/trashcan/trashcan.component.html index 947d9868e..84f3c29a0 100644 --- a/src/app/components/trashcan/trashcan.component.html +++ b/src/app/components/trashcan/trashcan.component.html @@ -7,7 +7,7 @@ - +
diff --git a/src/app/extensions/extension.service.ts b/src/app/extensions/extension.service.ts index 33908a166..f4004c113 100644 --- a/src/app/extensions/extension.service.ts +++ b/src/app/extensions/extension.service.ts @@ -244,10 +244,13 @@ export class AppExtensionService implements RuleContext { return true; } - runActionById(id: string, context?: any) { + runActionById(id: string) { const action = this.extensions.getActionById(id); if (action) { const { type, payload } = action; + const context = { + selection: this.selection + }; const expression = this.extensions.runExpression(payload, context); this.store.dispatch({ type, payload: expression });