[ACA-99] Viewer actions (#203)

* "toggle favorite" action

* copy and move actions

* move actions to the "more" menu
This commit is contained in:
Denys Vuika
2018-02-27 15:30:24 +00:00
committed by GitHub
parent 0b5dc47de9
commit 3a55411f40
5 changed files with 60 additions and 16 deletions

View File

@@ -57,6 +57,14 @@ export class ContentManagementService {
return this.nodeHasPermission(node, 'delete');
}
canMoveNode(node: Node): boolean {
return this.nodeHasPermission(node, 'delete');
}
canCopyNode(node: Node): boolean {
return true;
}
async deleteNode(node: Node) {
if (this.canDeleteNode(node)) {
try {

View File

@@ -9,15 +9,42 @@
(navigateBefore)="onNavigateBefore()"
(navigateNext)="onNavigateNext()">
<adf-viewer-toolbar-actions>
<adf-viewer-more-actions>
<button mat-icon-button
[disabled]="!canDeleteFile()"
(click)="deleteFile()"
title="{{ 'APP.ACTIONS.DELETE' | translate }}">
<mat-icon>delete</mat-icon>
<button
mat-menu-item
#selection="adfFavorite"
[adf-node-favorite]="selectedEntities">
<mat-icon [ngClass]="{ 'icon-highlight': selection.hasFavorites() }">
{{ selection.hasFavorites() ? 'star' :'star_border' }}
</mat-icon>
<span>{{ 'APP.ACTIONS.FAVORITE' | translate }}</span>
</button>
</adf-viewer-toolbar-actions>
<button
mat-menu-item
*ngIf="canCopyFile()"
[app-copy-node]="selectedEntities">
<mat-icon>content_copy</mat-icon>
<span>{{ 'APP.ACTIONS.COPY' | translate }}</span>
</button>
<button
mat-menu-item
*ngIf="canMoveFile()"
[app-move-node]="selectedEntities">
<mat-icon>library_books</mat-icon>
<span>{{ 'APP.ACTIONS.MOVE' | translate }}</span>
</button>
<button
mat-menu-item
*ngIf="canDeleteFile()"
(click)="deleteFile()">
<mat-icon>delete</mat-icon>
<span>{{ 'APP.ACTIONS.DELETE' | translate }}</span>
</button>
</adf-viewer-more-actions>
</adf-viewer>
</ng-container>

View File

@@ -29,7 +29,7 @@ import { RouterTestingModule } from '@angular/router/testing';
import { TestBed, async, ComponentFixture } from '@angular/core/testing';
import {
AlfrescoApiService, UserPreferencesService, TranslationService, TranslationMock,
AppConfigService, StorageService, CookieService, NotificationService
AppConfigService, StorageService, CookieService, NotificationService, NodeFavoriteDirective
} from '@alfresco/adf-core';
import { TranslateModule } from '@ngx-translate/core';
import { HttpClientModule } from '@angular/common/http';
@@ -67,7 +67,8 @@ describe('PreviewComponent', () => {
ContentManagementService
],
declarations: [
PreviewComponent
PreviewComponent,
NodeFavoriteDirective
],
schemas: [ NO_ERRORS_SCHEMA ]
})

View File

@@ -26,7 +26,7 @@
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { AlfrescoApiService, UserPreferencesService, ObjectUtils } from '@alfresco/adf-core';
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
import { Node, MinimalNodeEntity } from 'alfresco-js-api';
import { ContentManagementService } from '../../common/services/content-management.service';
@Component({
@@ -39,7 +39,7 @@ import { ContentManagementService } from '../../common/services/content-manageme
})
export class PreviewComponent implements OnInit {
node: MinimalNodeEntryEntity;
node: Node;
previewLocation: string = null;
routesSkipNavigation = [ 'shared', 'recent-files', 'favorites' ];
navigateSource: string = null;
@@ -51,6 +51,8 @@ export class PreviewComponent implements OnInit {
nextNodeId: string;
navigateMultiple = false;
selectedEntities: MinimalNodeEntity[] = [];
constructor(private router: Router,
private route: ActivatedRoute,
private apiService: AlfrescoApiService,
@@ -93,8 +95,10 @@ export class PreviewComponent implements OnInit {
if (id) {
try {
this.node = await this.apiService.nodesApi.getNodeInfo(id, {
include: [ 'allowableOperations']
include: ['allowableOperations']
});
this.selectedEntities = [{ entry: this.node }];
if (this.node && this.node.isFile) {
const nearest = await this.getNearestNodes(this.node.id, this.node.parentId);
@@ -331,4 +335,12 @@ export class PreviewComponent implements OnInit {
} catch {
}
}
canMoveFile(): boolean {
return this.content.canMoveNode(this.node);
}
canCopyFile(): boolean {
return this.content.canCopyNode(this.node);
}
}

View File

@@ -54,10 +54,6 @@ adf-document-list {
}
}
.adf-no-content-container {
border: none !important;
}
.adf-datatable-header:first-of-type, .adf-datatable-header.adf-data-table-cell--image,
.adf-data-table-cell:first-of-type, .adf-data-table-cell.adf-data-table-cell--image {
padding-left: 24px;