mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACA-903] Working copy is incorrectly displayed for a file locked for… (#110)
* [ACA-903] Working copy is incorrectly displayed for a file locked for offline editing -use locked icon for locked nodes -do not allow locked nodes to be selected * [ACA-903] fix failing tests
This commit is contained in:
committed by
Cilibiu Bogdan
parent
e1c027ba67
commit
38b4a83673
@@ -98,8 +98,10 @@
|
||||
[contentActions]="false"
|
||||
[navigate]="false"
|
||||
[selectionMode]="'multiple'"
|
||||
[imageResolver]="imageResolver"
|
||||
|
||||
(node-dblclick)="onNodeDoubleClick($event.detail?.node?.entry)">
|
||||
(node-dblclick)="onNodeDoubleClick($event)"
|
||||
(node-select)="onNodeSelect($event)">
|
||||
|
||||
<data-columns>
|
||||
<data-column
|
||||
|
@@ -262,7 +262,7 @@ describe('FilesComponent', () => {
|
||||
it('calls getNode api with node id', () => {
|
||||
component.fetchNodes('nodeId');
|
||||
|
||||
expect(nodesApi.getNodeChildren).toHaveBeenCalledWith('nodeId', {});
|
||||
expect(nodesApi.getNodeChildren).toHaveBeenCalledWith('nodeId', jasmine.any(Object));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -303,7 +303,14 @@ describe('FilesComponent', () => {
|
||||
spyOn(router, 'navigate').and.stub();
|
||||
node.isFile = true;
|
||||
|
||||
component.onNodeDoubleClick(<any> node);
|
||||
const event: any = {
|
||||
detail: {
|
||||
node: {
|
||||
entry: node
|
||||
}
|
||||
}
|
||||
};
|
||||
component.onNodeDoubleClick(event);
|
||||
|
||||
expect(router.navigate).toHaveBeenCalledWith(['/preview', node.id]);
|
||||
});
|
||||
@@ -312,9 +319,17 @@ describe('FilesComponent', () => {
|
||||
spyOn(component, 'navigate').and.stub();
|
||||
node.isFolder = true;
|
||||
|
||||
component.onNodeDoubleClick(<any> node);
|
||||
|
||||
expect(component.navigate).toHaveBeenCalled();
|
||||
const event: any = {
|
||||
detail: {
|
||||
node: {
|
||||
entry: node
|
||||
}
|
||||
}
|
||||
};
|
||||
component.onNodeDoubleClick(event);
|
||||
|
||||
expect(component.navigate).toHaveBeenCalledWith(node.id);
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -16,13 +16,14 @@
|
||||
*/
|
||||
|
||||
import { Observable, Subscription } from 'rxjs/Rx';
|
||||
import { Component, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core';
|
||||
import { Component, OnInit, OnDestroy, ChangeDetectorRef, ViewChild } from '@angular/core';
|
||||
import { Router, ActivatedRoute, Params } from '@angular/router';
|
||||
import { MinimalNodeEntity, MinimalNodeEntryEntity, PathElementEntity, NodePaging, PathElement } from 'alfresco-js-api';
|
||||
import {
|
||||
UploadService, FileUploadEvent, NodesApiService,
|
||||
ContentService, AlfrescoApiService, UserPreferencesService
|
||||
} from '@alfresco/adf-core';
|
||||
import { DocumentListComponent, ShareDataRow } from '@alfresco/adf-content-services';
|
||||
|
||||
import { BrowsingFilesService } from '../../common/services/browsing-files.service';
|
||||
import { ContentManagementService } from '../../common/services/content-management.service';
|
||||
@@ -34,6 +35,9 @@ import { PageComponent } from '../page.component';
|
||||
templateUrl: './files.component.html'
|
||||
})
|
||||
export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
@ViewChild(DocumentListComponent)
|
||||
documentList: DocumentListComponent;
|
||||
|
||||
private routeData: any = {};
|
||||
isValidPath = true;
|
||||
|
||||
@@ -105,7 +109,13 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
fetchNodes(parentNodeId?: string, options: any = {}): Observable<NodePaging> {
|
||||
return this.nodesApi.getNodeChildren(parentNodeId, options);
|
||||
const defaults = {
|
||||
include: [ 'isLocked' ]
|
||||
};
|
||||
|
||||
const queryOptions = Object.assign(defaults, options);
|
||||
|
||||
return this.nodesApi.getNodeChildren(parentNodeId, queryOptions);
|
||||
}
|
||||
|
||||
navigate(nodeId: string = null) {
|
||||
@@ -120,14 +130,50 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
onNodeDoubleClick(node: MinimalNodeEntryEntity) {
|
||||
if (node) {
|
||||
if (node.isFolder) {
|
||||
this.navigate(node.id);
|
||||
onNodeDoubleClick(event) {
|
||||
if (!!event.detail && !!event.detail.node) {
|
||||
|
||||
const node: MinimalNodeEntryEntity = event.detail.node.entry;
|
||||
if (node) {
|
||||
|
||||
if (node.isFolder) {
|
||||
this.navigate(node.id);
|
||||
}
|
||||
|
||||
if (node.isLocked) {
|
||||
event.preventDefault();
|
||||
|
||||
} else if (node.isFile) {
|
||||
this.router.navigate(['/preview', node.id]);
|
||||
}
|
||||
}
|
||||
|
||||
if (node.isFile) {
|
||||
this.router.navigate(['/preview', node.id]);
|
||||
}
|
||||
}
|
||||
|
||||
onNodeSelect(event) {
|
||||
if (!!event.detail && !!event.detail.node) {
|
||||
|
||||
const node: MinimalNodeEntryEntity = event.detail.node.entry;
|
||||
if (node && node.isLocked) {
|
||||
this.unSelectLockedNodes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unSelectLockedNodes() {
|
||||
this.documentList.selection = this.documentList.selection.filter(item => !item.entry.isLocked);
|
||||
|
||||
const dataTable = this.documentList.dataTable;
|
||||
if (dataTable && dataTable.data) {
|
||||
const rows = dataTable.data.getRows();
|
||||
|
||||
if (rows && rows.length > 0) {
|
||||
rows.forEach(r => {
|
||||
if (r.getValue('isLocked')) {
|
||||
r.isSelected = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -267,4 +313,13 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private imageResolver(row: ShareDataRow): string | null {
|
||||
const entry: MinimalNodeEntryEntity = row.node.entry;
|
||||
|
||||
if (entry.isLocked) {
|
||||
return '/assets/images/ic_lock_black_24dp_1x.png';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
BIN
src/assets/images/ic_lock_black_24dp_1x.png
Normal file
BIN
src/assets/images/ic_lock_black_24dp_1x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 205 B |
Reference in New Issue
Block a user