diff --git a/src/app.config.json b/src/app.config.json
index 372c1a261..a63abcfcc 100644
--- a/src/app.config.json
+++ b/src/app.config.json
@@ -64,6 +64,11 @@
"type": "EDIT_FOLDER",
"payload": null
},
+ {
+ "id": "aca:actions/download",
+ "type": "DOWNLOAD_NODES",
+ "payload": null
+ },
{
"id": "aca:actions/info",
@@ -202,8 +207,20 @@
},
{
"disabled": false,
- "id": "aca:toolbar/edit-folder",
+ "id": "aca:toolbar/download",
"order": 20,
+ "title": "APP.ACTIONS.DOWNLOAD",
+ "icon": "get_app",
+ "target": {
+ "types": ["folder", "file"],
+ "permissions": [],
+ "action": "aca:actions/download"
+ }
+ },
+ {
+ "disabled": false,
+ "id": "aca:toolbar/edit-folder",
+ "order": 30,
"title": "APP.ACTIONS.EDIT",
"icon": "create",
"target": {
@@ -213,6 +230,7 @@
}
},
+
{
"disabled": false,
"id": "aca:action3",
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index c3c5937ab..81316b2f1 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -71,7 +71,6 @@ import { ExperimentalGuard } from './common/services/experimental-guard.service'
import { InfoDrawerComponent } from './components/info-drawer/info-drawer.component';
import { EditFolderDirective } from './directives/edit-folder.directive';
-import { DownloadNodesDirective } from './directives/download-nodes.directive';
import { AppStoreModule } from './store/app-store.module';
import { PaginationDirective } from './directives/pagination.directive';
import { DocumentListDirective } from './directives/document-list.directive';
@@ -134,7 +133,6 @@ import { SearchResultsRowComponent } from './components/search/search-results-ro
InfoDrawerComponent,
SharedLinkViewComponent,
EditFolderDirective,
- DownloadNodesDirective,
PaginationDirective,
DocumentListDirective,
ExperimentalDirective
diff --git a/src/app/components/favorites/favorites.component.html b/src/app/components/favorites/favorites.component.html
index 78a200c0e..975c562af 100644
--- a/src/app/components/favorites/favorites.component.html
+++ b/src/app/components/favorites/favorites.component.html
@@ -38,7 +38,7 @@
mat-icon-button
color="primary"
title="{{ 'APP.ACTIONS.DOWNLOAD' | translate }}"
- [adfNodeDownload]="selection.nodes">
+ (click)="downloadSelection()">
get_app
diff --git a/src/app/components/files/files.component.html b/src/app/components/files/files.component.html
index 4af65c28b..a718f2bfe 100644
--- a/src/app/components/files/files.component.html
+++ b/src/app/components/files/files.component.html
@@ -41,7 +41,7 @@
color="primary"
mat-icon-button
title="{{ 'APP.ACTIONS.DOWNLOAD' | translate }}"
- [adfNodeDownload]="selection.nodes">
+ (click)="downloadSelection()">
get_app
diff --git a/src/app/components/page.component.ts b/src/app/components/page.component.ts
index 363f1c769..0bc69dca6 100644
--- a/src/app/components/page.component.ts
+++ b/src/app/components/page.component.ts
@@ -30,7 +30,7 @@ import { Store } from '@ngrx/store';
import { MinimalNodeEntity, MinimalNodeEntryEntity } from 'alfresco-js-api';
import { takeUntil } from 'rxjs/operators';
import { Subject, Subscription } from 'rxjs/Rx';
-import { ViewNodeAction, SetSelectedNodesAction } from '../store/actions';
+import { ViewNodeAction, SetSelectedNodesAction, DownloadNodesAction } from '../store/actions';
import { appSelection, sharedUrl, currentFolder } from '../store/selectors/app.selectors';
import { AppStore } from '../store/states/app.state';
import { SelectionState } from '../store/states/selection.state';
@@ -154,6 +154,10 @@ export abstract class PageComponent implements OnInit, OnDestroy {
this.documentList.display = this.displayMode;
}
+ downloadSelection() {
+ this.store.dispatch(new DownloadNodesAction());
+ }
+
// this is where each application decides how to treat an action and what to do
// the ACA maps actions to the NgRx actions as an example
runAction(actionId: string) {
diff --git a/src/app/components/recent-files/recent-files.component.html b/src/app/components/recent-files/recent-files.component.html
index 8996f4693..9b6493944 100644
--- a/src/app/components/recent-files/recent-files.component.html
+++ b/src/app/components/recent-files/recent-files.component.html
@@ -38,7 +38,7 @@
mat-icon-button
color="primary"
title="{{ 'APP.ACTIONS.DOWNLOAD' | translate }}"
- [adfNodeDownload]="selection.nodes">
+ (click)="downloadSelection()">
get_app
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 6041de430..ac2eeb0ce 100644
--- a/src/app/components/search/search-results/search-results.component.html
+++ b/src/app/components/search/search-results/search-results.component.html
@@ -29,7 +29,7 @@
color="primary"
mat-icon-button
title="{{ 'APP.ACTIONS.DOWNLOAD' | translate }}"
- [acaDownloadNodes]="selection.nodes">
+ (click)="downloadSelection()">
get_app
diff --git a/src/app/components/shared-files/shared-files.component.html b/src/app/components/shared-files/shared-files.component.html
index 001c4da8d..91c196ec9 100644
--- a/src/app/components/shared-files/shared-files.component.html
+++ b/src/app/components/shared-files/shared-files.component.html
@@ -38,7 +38,7 @@
color="primary"
mat-icon-button
title="{{ 'APP.ACTIONS.DOWNLOAD' | translate }}"
- [adfNodeDownload]="selection.nodes">
+ (click)="downloadSelection()">
get_app
diff --git a/src/app/directives/download-nodes.directive.ts b/src/app/directives/download-nodes.directive.ts
deleted file mode 100644
index ea2d61dc7..000000000
--- a/src/app/directives/download-nodes.directive.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-/*!
- * @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 { Directive, HostListener, Input } from '@angular/core';
-import { Store } from '@ngrx/store';
-import { AppStore } from '../store/states/app.state';
-import { MinimalNodeEntity } from 'alfresco-js-api';
-import { DownloadNodesAction } from '../store/actions';
-
-@Directive({
- selector: '[acaDownloadNodes]'
-})
-export class DownloadNodesDirective {
- // tslint:disable-next-line:no-input-rename
- @Input('acaDownloadNodes')
- nodes: Array | MinimalNodeEntity;
-
- constructor(private store: Store) {}
-
- @HostListener('click')
- onClick() {
- const targets = Array.isArray(this.nodes) ? this.nodes : [this.nodes];
- const toDownload = targets.map(node => {
- const { id, nodeId, name, isFile, isFolder } = node.entry;
-
- return {
- id: nodeId || id,
- name,
- isFile,
- isFolder
- };
- });
-
- this.store.dispatch(new DownloadNodesAction(toDownload));
- }
-}
diff --git a/src/app/store/actions/node.actions.ts b/src/app/store/actions/node.actions.ts
index 6a8b54380..958a5fd44 100644
--- a/src/app/store/actions/node.actions.ts
+++ b/src/app/store/actions/node.actions.ts
@@ -63,7 +63,7 @@ export class PurgeDeletedNodesAction implements Action {
export class DownloadNodesAction implements Action {
readonly type = DOWNLOAD_NODES;
- constructor(public payload: NodeInfo[] = []) {}
+ constructor(public payload: MinimalNodeEntity[] = []) {}
}
export class CreateFolderAction implements Action {
diff --git a/src/app/store/effects/download.effects.ts b/src/app/store/effects/download.effects.ts
index 72a6d1dbb..fecfc0650 100644
--- a/src/app/store/effects/download.effects.ts
+++ b/src/app/store/effects/download.effects.ts
@@ -31,10 +31,15 @@ import { map } from 'rxjs/operators';
import { DownloadNodesAction, DOWNLOAD_NODES } from '../actions';
import { NodeInfo } from '../models';
import { ContentApiService } from '../../services/content-api.service';
+import { MinimalNodeEntity } from 'alfresco-js-api';
+import { Store } from '@ngrx/store';
+import { AppStore } from '../states';
+import { appSelection } from '../selectors/app.selectors';
@Injectable()
export class DownloadEffects {
constructor(
+ private store: Store,
private actions$: Actions,
private contentApi: ContentApiService,
private dialog: MatDialog
@@ -42,15 +47,35 @@ export class DownloadEffects {
@Effect({ dispatch: false })
downloadNode$ = this.actions$.pipe(
- ofType(DOWNLOAD_NODES),
- map(action => {
- if (action.payload && action.payload.length > 0) {
- this.downloadNodes(action.payload);
- }
- })
+ ofType(DOWNLOAD_NODES),
+ map(action => {
+ if (action.payload && action.payload.length > 0) {
+ this.downloadNodes(action.payload);
+ } else {
+ this.store
+ .select(appSelection)
+ .take(1)
+ .subscribe(selection => {
+ if (selection && !selection.isEmpty) {
+ this.downloadNodes(selection.nodes);
+ }
+ });
+ }
+ })
);
- private downloadNodes(nodes: Array) {
+ private downloadNodes(toDownload: Array) {
+ const nodes = toDownload.map(node => {
+ const { id, nodeId, name, isFile, isFolder } = node.entry;
+
+ return {
+ id: nodeId || id,
+ name,
+ isFile,
+ isFolder
+ };
+ });
+
if (!nodes || nodes.length === 0) {
return;
}