[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 15:14:27 +03:00 committed by Denys Vuika
parent 2f4048a859
commit e373064fd1
6 changed files with 52 additions and 7 deletions

View File

@ -358,8 +358,14 @@
"items": { "$ref": "#/definitions/contentActionRef" },
"minItems": 1
},
"toolbar": {
"description": "Toolbar entries",
"toolbarMoreMenu": {
"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",
"items": { "$ref": "#/definitions/contentActionRef" },
"minItems": 1

View File

@ -59,6 +59,7 @@ export abstract class PageComponent implements OnInit, OnDestroy {
sharedPreviewUrl$: Observable<string>;
actions: Array<ContentActionRef> = [];
viewerToolbarActions: Array<ContentActionRef> = [];
viewerToolbarMoreActions: Array<ContentActionRef> = [];
canUpdateNode = false;
canUpload = false;
@ -89,6 +90,7 @@ export abstract class PageComponent implements OnInit, OnDestroy {
this.selection = selection;
this.actions = this.extensions.getAllowedToolbarActions();
this.viewerToolbarActions = this.extensions.getViewerToolbarActions();
this.viewerToolbarMoreActions = this.extensions.getViewerToolbarMoreActions();
this.canUpdateNode =
this.selection.count === 1 &&
this.content.canUpdateNode(selection.first);

View File

@ -22,8 +22,14 @@
</ng-container>
</adf-viewer-open-with>
<adf-viewer-more-actions>
<adf-viewer-toolbar-actions>
<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>
</ng-container>
</adf-viewer-more-actions>

View File

@ -58,6 +58,7 @@ export class AppExtensionService implements RuleContext {
toolbarActions: Array<ContentActionRef> = [];
viewerToolbarActions: Array<ContentActionRef> = [];
viewerToolbarMoreActions: Array<ContentActionRef> = [];
viewerContentExtensions: Array<ViewerExtensionRef> = [];
contextMenuActions: Array<ContentActionRef> = [];
openWithActions: Array<ContentActionRef> = [];
@ -99,7 +100,11 @@ export class AppExtensionService implements RuleContext {
);
this.viewerToolbarActions = this.loader.getContentActions(
config,
'features.viewer.toolbar'
'features.viewer.toolbarActions'
);
this.viewerToolbarMoreActions = this.loader.getContentActions(
config,
'features.viewer.toolbarMoreMenu'
);
this.viewerContentExtensions = this.loader.getElements<ViewerExtensionRef>(
config,
@ -226,6 +231,12 @@ export class AppExtensionService implements RuleContext {
);
}
getViewerToolbarMoreActions(): Array<ContentActionRef> {
return this.viewerToolbarMoreActions.filter(action =>
this.filterByRules(action)
);
}
getAllowedContextMenuActions(): Array<ContentActionRef> {
return this.contextMenuActions.filter(action => this.filterByRules(action));
}

View File

@ -626,7 +626,21 @@
}
],
"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",
"order": 100,

View File

@ -358,8 +358,14 @@
"items": { "$ref": "#/definitions/contentActionRef" },
"minItems": 1
},
"toolbar": {
"description": "Toolbar entries",
"toolbarMoreMenu": {
"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",
"items": { "$ref": "#/definitions/contentActionRef" },
"minItems": 1