[ACA-1548][ACA-1802] add actions to viewer toolbar via extensions (#637)

* [ACA-1548] rename viewer toolbar extension of More menu

* [ACA-1548][ACA-1802] add actions to the viewer toolbar via extensions
This commit is contained in:
Suzana Dirla
2018-09-17 13:14:27 +01:00
committed by Denys Vuika
parent 2f4048a859
commit e373064fd1
6 changed files with 52 additions and 7 deletions
+8 -2
View File
@@ -358,8 +358,14 @@
"items": { "$ref": "#/definitions/contentActionRef" }, "items": { "$ref": "#/definitions/contentActionRef" },
"minItems": 1 "minItems": 1
}, },
"toolbar": { "toolbarMoreMenu": {
"description": "Toolbar entries", "description": "Toolbar entries from the More actions menu",
"type": "array",
"items": { "$ref": "#/definitions/contentActionRef" },
"minItems": 1
},
"toolbarActions": {
"description": "Toolbar entries from outside the More menu",
"type": "array", "type": "array",
"items": { "$ref": "#/definitions/contentActionRef" }, "items": { "$ref": "#/definitions/contentActionRef" },
"minItems": 1 "minItems": 1
+2
View File
@@ -59,6 +59,7 @@ export abstract class PageComponent implements OnInit, OnDestroy {
sharedPreviewUrl$: Observable<string>; sharedPreviewUrl$: Observable<string>;
actions: Array<ContentActionRef> = []; actions: Array<ContentActionRef> = [];
viewerToolbarActions: Array<ContentActionRef> = []; viewerToolbarActions: Array<ContentActionRef> = [];
viewerToolbarMoreActions: Array<ContentActionRef> = [];
canUpdateNode = false; canUpdateNode = false;
canUpload = false; canUpload = false;
@@ -89,6 +90,7 @@ export abstract class PageComponent implements OnInit, OnDestroy {
this.selection = selection; this.selection = selection;
this.actions = this.extensions.getAllowedToolbarActions(); this.actions = this.extensions.getAllowedToolbarActions();
this.viewerToolbarActions = this.extensions.getViewerToolbarActions(); this.viewerToolbarActions = this.extensions.getViewerToolbarActions();
this.viewerToolbarMoreActions = this.extensions.getViewerToolbarMoreActions();
this.canUpdateNode = this.canUpdateNode =
this.selection.count === 1 && this.selection.count === 1 &&
this.content.canUpdateNode(selection.first); this.content.canUpdateNode(selection.first);
@@ -22,8 +22,14 @@
</ng-container> </ng-container>
</adf-viewer-open-with> </adf-viewer-open-with>
<adf-viewer-more-actions> <adf-viewer-toolbar-actions>
<ng-container *ngFor="let action of viewerToolbarActions; trackBy: trackByActionId"> <ng-container *ngFor="let action of viewerToolbarActions; trackBy: trackByActionId">
<aca-toolbar-action [actionRef]="action"></aca-toolbar-action>
</ng-container>
</adf-viewer-toolbar-actions>
<adf-viewer-more-actions>
<ng-container *ngFor="let action of viewerToolbarMoreActions; trackBy: trackByActionId">
<aca-toolbar-action type="menu-item" [actionRef]="action"></aca-toolbar-action> <aca-toolbar-action type="menu-item" [actionRef]="action"></aca-toolbar-action>
</ng-container> </ng-container>
</adf-viewer-more-actions> </adf-viewer-more-actions>
+12 -1
View File
@@ -58,6 +58,7 @@ export class AppExtensionService implements RuleContext {
toolbarActions: Array<ContentActionRef> = []; toolbarActions: Array<ContentActionRef> = [];
viewerToolbarActions: Array<ContentActionRef> = []; viewerToolbarActions: Array<ContentActionRef> = [];
viewerToolbarMoreActions: Array<ContentActionRef> = [];
viewerContentExtensions: Array<ViewerExtensionRef> = []; viewerContentExtensions: Array<ViewerExtensionRef> = [];
contextMenuActions: Array<ContentActionRef> = []; contextMenuActions: Array<ContentActionRef> = [];
openWithActions: Array<ContentActionRef> = []; openWithActions: Array<ContentActionRef> = [];
@@ -99,7 +100,11 @@ export class AppExtensionService implements RuleContext {
); );
this.viewerToolbarActions = this.loader.getContentActions( this.viewerToolbarActions = this.loader.getContentActions(
config, config,
'features.viewer.toolbar' 'features.viewer.toolbarActions'
);
this.viewerToolbarMoreActions = this.loader.getContentActions(
config,
'features.viewer.toolbarMoreMenu'
); );
this.viewerContentExtensions = this.loader.getElements<ViewerExtensionRef>( this.viewerContentExtensions = this.loader.getElements<ViewerExtensionRef>(
config, config,
@@ -226,6 +231,12 @@ export class AppExtensionService implements RuleContext {
); );
} }
getViewerToolbarMoreActions(): Array<ContentActionRef> {
return this.viewerToolbarMoreActions.filter(action =>
this.filterByRules(action)
);
}
getAllowedContextMenuActions(): Array<ContentActionRef> { getAllowedContextMenuActions(): Array<ContentActionRef> {
return this.contextMenuActions.filter(action => this.filterByRules(action)); return this.contextMenuActions.filter(action => this.filterByRules(action));
} }
+15 -1
View File
@@ -626,7 +626,21 @@
} }
], ],
"viewer": { "viewer": {
"toolbar": [ "toolbarActions": [
{
"id": "app.viewer.share",
"order": 100,
"title": "APP.ACTIONS.SHARE",
"icon": "share",
"actions": {
"click": "SHARE_NODE"
},
"rules": {
"visible": "app.selection.file.canShare"
}
}
],
"toolbarMoreMenu": [
{ {
"id": "app.viewer.favorite.add", "id": "app.viewer.favorite.add",
"order": 100, "order": 100,
+8 -2
View File
@@ -358,8 +358,14 @@
"items": { "$ref": "#/definitions/contentActionRef" }, "items": { "$ref": "#/definitions/contentActionRef" },
"minItems": 1 "minItems": 1
}, },
"toolbar": { "toolbarMoreMenu": {
"description": "Toolbar entries", "description": "Toolbar entries from the More actions menu",
"type": "array",
"items": { "$ref": "#/definitions/contentActionRef" },
"minItems": 1
},
"toolbarActions": {
"description": "Toolbar entries from outside the More menu",
"type": "array", "type": "array",
"items": { "$ref": "#/definitions/contentActionRef" }, "items": { "$ref": "#/definitions/contentActionRef" },
"minItems": 1 "minItems": 1