mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-19 17:14:45 +00:00
[ACA-1060] [Recent Files] Working copy is incorrectly displayed for a file locked for offline editing (#128)
-moved common code to PageComponent to avoid duplication -used the imageResolver and onNodeSelect on recent files also
This commit is contained in:
parent
d4a55c5b95
commit
ebd1d840f8
@ -101,7 +101,7 @@
|
|||||||
[imageResolver]="imageResolver"
|
[imageResolver]="imageResolver"
|
||||||
|
|
||||||
(node-dblclick)="onNodeDoubleClick($event)"
|
(node-dblclick)="onNodeDoubleClick($event)"
|
||||||
(node-select)="onNodeSelect($event)">
|
(node-select)="onNodeSelect($event, documentList)">
|
||||||
|
|
||||||
<data-columns>
|
<data-columns>
|
||||||
<data-column
|
<data-column
|
||||||
|
@ -24,14 +24,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Observable, Subscription } from 'rxjs/Rx';
|
import { Observable, Subscription } from 'rxjs/Rx';
|
||||||
import { Component, OnInit, OnDestroy, ViewChild, NgZone } from '@angular/core';
|
import { Component, OnInit, OnDestroy, NgZone } from '@angular/core';
|
||||||
import { Router, ActivatedRoute, Params } from '@angular/router';
|
import { Router, ActivatedRoute, Params } from '@angular/router';
|
||||||
import { MinimalNodeEntity, MinimalNodeEntryEntity, PathElementEntity, NodePaging, PathElement } from 'alfresco-js-api';
|
import { MinimalNodeEntity, MinimalNodeEntryEntity, PathElementEntity, NodePaging, PathElement } from 'alfresco-js-api';
|
||||||
import {
|
import {
|
||||||
UploadService, FileUploadEvent, NodesApiService,
|
UploadService, FileUploadEvent, NodesApiService,
|
||||||
ContentService, AlfrescoApiService, UserPreferencesService
|
ContentService, AlfrescoApiService, UserPreferencesService
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { DocumentListComponent, ShareDataRow } from '@alfresco/adf-content-services';
|
|
||||||
|
|
||||||
import { BrowsingFilesService } from '../../common/services/browsing-files.service';
|
import { BrowsingFilesService } from '../../common/services/browsing-files.service';
|
||||||
import { ContentManagementService } from '../../common/services/content-management.service';
|
import { ContentManagementService } from '../../common/services/content-management.service';
|
||||||
@ -43,8 +42,6 @@ import { PageComponent } from '../page.component';
|
|||||||
templateUrl: './files.component.html'
|
templateUrl: './files.component.html'
|
||||||
})
|
})
|
||||||
export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||||
@ViewChild(DocumentListComponent)
|
|
||||||
documentList: DocumentListComponent;
|
|
||||||
|
|
||||||
private routeData: any = {};
|
private routeData: any = {};
|
||||||
isValidPath = true;
|
isValidPath = true;
|
||||||
@ -147,7 +144,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
|||||||
this.navigate(node.id);
|
this.navigate(node.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.isLocked) {
|
if (PageComponent.isLockedNode(node)) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
} else if (node.isFile) {
|
} else if (node.isFile) {
|
||||||
@ -158,33 +155,6 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onBreadcrumbNavigate(route: PathElementEntity) {
|
onBreadcrumbNavigate(route: PathElementEntity) {
|
||||||
// todo: review this approach once 5.2.3 is out
|
// todo: review this approach once 5.2.3 is out
|
||||||
if (this.nodePath && this.nodePath.length > 2) {
|
if (this.nodePath && this.nodePath.length > 2) {
|
||||||
@ -316,13 +286,4 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
import { MinimalNodeEntity, MinimalNodeEntryEntity, NodePaging, Pagination } from 'alfresco-js-api';
|
import { MinimalNodeEntity, MinimalNodeEntryEntity, NodePaging, Pagination } from 'alfresco-js-api';
|
||||||
import { UserPreferencesService } from '@alfresco/adf-core';
|
import { UserPreferencesService } from '@alfresco/adf-core';
|
||||||
|
import { ShareDataRow } from '@alfresco/adf-content-services';
|
||||||
|
|
||||||
export abstract class PageComponent {
|
export abstract class PageComponent {
|
||||||
|
|
||||||
@ -38,6 +39,10 @@ export abstract class PageComponent {
|
|||||||
|
|
||||||
node: MinimalNodeEntryEntity;
|
node: MinimalNodeEntryEntity;
|
||||||
|
|
||||||
|
static isLockedNode(node) {
|
||||||
|
return node.isLocked || (node.properties && node.properties['cm:lockType'] === 'READ_ONLY_LOCK');
|
||||||
|
}
|
||||||
|
|
||||||
abstract fetchNodes(parentNodeId?: string, options?: any): void;
|
abstract fetchNodes(parentNodeId?: string, options?: any): void;
|
||||||
|
|
||||||
constructor(private preferences: UserPreferencesService) {
|
constructor(private preferences: UserPreferencesService) {
|
||||||
@ -137,4 +142,46 @@ export abstract class PageComponent {
|
|||||||
onChangePageSize(event: Pagination): void {
|
onChangePageSize(event: Pagination): void {
|
||||||
this.preferences.paginationSize = event.maxItems;
|
this.preferences.paginationSize = event.maxItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onNodeSelect(event, documentList) {
|
||||||
|
if (!!event.detail && !!event.detail.node) {
|
||||||
|
|
||||||
|
const node: MinimalNodeEntryEntity = event.detail.node.entry;
|
||||||
|
if (node && PageComponent.isLockedNode(node)) {
|
||||||
|
this.unSelectLockedNodes(documentList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unSelectLockedNodes(documentList) {
|
||||||
|
documentList.selection = documentList.selection.filter(item => !PageComponent.isLockedNode(item.entry));
|
||||||
|
|
||||||
|
const dataTable = documentList.dataTable;
|
||||||
|
if (dataTable && dataTable.data) {
|
||||||
|
const rows = dataTable.data.getRows();
|
||||||
|
|
||||||
|
if (rows && rows.length > 0) {
|
||||||
|
rows.forEach(r => {
|
||||||
|
if (this.isLockedRow(r)) {
|
||||||
|
r.isSelected = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
isLockedRow(row) {
|
||||||
|
return row.getValue('isLocked') ||
|
||||||
|
(row.getValue('properties') && row.getValue('properties')['cm:lockType'] === 'READ_ONLY_LOCK');
|
||||||
|
}
|
||||||
|
|
||||||
|
imageResolver(row: ShareDataRow): string | null {
|
||||||
|
const entry: MinimalNodeEntryEntity = row.node.entry;
|
||||||
|
|
||||||
|
if (PageComponent.isLockedNode(entry)) {
|
||||||
|
return '/assets/images/ic_lock_black_24dp_1x.png';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,9 @@
|
|||||||
[sorting]="[ 'modifiedAt', 'desc' ]"
|
[sorting]="[ 'modifiedAt', 'desc' ]"
|
||||||
[contextMenuActions]="true"
|
[contextMenuActions]="true"
|
||||||
[contentActions]="false"
|
[contentActions]="false"
|
||||||
(node-dblclick)="onNodeDoubleClick($event.detail?.node?.entry)">
|
[imageResolver]="imageResolver"
|
||||||
|
(node-dblclick)="onNodeDoubleClick($event.detail?.node?.entry)"
|
||||||
|
(node-select)="onNodeSelect($event, documentList)">
|
||||||
|
|
||||||
<empty-folder-content>
|
<empty-folder-content>
|
||||||
<ng-template>
|
<ng-template>
|
||||||
|
@ -63,7 +63,10 @@ export class RecentFilesComponent extends PageComponent implements OnInit, OnDes
|
|||||||
}
|
}
|
||||||
|
|
||||||
onNodeDoubleClick(node: MinimalNodeEntryEntity) {
|
onNodeDoubleClick(node: MinimalNodeEntryEntity) {
|
||||||
if (node && node.isFile) {
|
if (node && PageComponent.isLockedNode(node)) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
} else if (node && node.isFile) {
|
||||||
this.router.navigate(['/preview', node.id]);
|
this.router.navigate(['/preview', node.id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user