mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
[ACA-4205] reload on sorting only for server mode (#6420)
* reload on sorting only for server mode * cleanup demo shell / files
This commit is contained in:
parent
5b603ee018
commit
31bac2da24
@ -15,19 +15,15 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { Component, Input, OnInit, OnChanges, OnDestroy, Optional, EventEmitter, ViewChild, SimpleChanges, Output } from '@angular/core';
|
||||||
Component, Input, OnInit, OnChanges, OnDestroy, Optional,
|
|
||||||
EventEmitter, ViewChild, SimpleChanges, Output
|
|
||||||
} from '@angular/core';
|
|
||||||
import { Location } from '@angular/common';
|
import { Location } from '@angular/common';
|
||||||
|
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { ActivatedRoute, Params, Router } from '@angular/router';
|
import { ActivatedRoute, Params, Router } from '@angular/router';
|
||||||
import { MinimalNodeEntity, NodePaging, Pagination, MinimalNodeEntryEntity, SiteEntry, SearchEntry, NodeEntry } from '@alfresco/js-api';
|
import { MinimalNodeEntity, NodePaging, Pagination, MinimalNodeEntryEntity, SiteEntry, SearchEntry, NodeEntry } from '@alfresco/js-api';
|
||||||
import {
|
import {
|
||||||
AlfrescoApiService, AuthenticationService, AppConfigService, AppConfigValues, ContentService, TranslationService, FolderCreatedEvent, LogService, NotificationService,
|
AlfrescoApiService, AuthenticationService, AppConfigService, AppConfigValues, ContentService, FolderCreatedEvent, LogService, NotificationService,
|
||||||
UploadService, DataRow, UserPreferencesService,
|
UploadService, DataRow, UserPreferencesService,
|
||||||
PaginationComponent, FormValues, DisplayMode, ShowHeaderMode, InfinitePaginationComponent, HighlightDirective,
|
PaginationComponent, FormValues, DisplayMode, ShowHeaderMode, InfinitePaginationComponent,
|
||||||
SharedLinksApiService,
|
SharedLinksApiService,
|
||||||
FormRenderingService,
|
FormRenderingService,
|
||||||
FileUploadEvent
|
FileUploadEvent
|
||||||
@ -204,9 +200,6 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
@ViewChild(InfinitePaginationComponent, { static: true })
|
@ViewChild(InfinitePaginationComponent, { static: true })
|
||||||
infinitePaginationComponent: InfinitePaginationComponent;
|
infinitePaginationComponent: InfinitePaginationComponent;
|
||||||
|
|
||||||
@ViewChild(HighlightDirective)
|
|
||||||
highlighter: HighlightDirective;
|
|
||||||
|
|
||||||
permissionsStyle: PermissionStyleModel[] = [];
|
permissionsStyle: PermissionStyleModel[] = [];
|
||||||
infiniteScrolling: boolean;
|
infiniteScrolling: boolean;
|
||||||
stickyHeader: boolean;
|
stickyHeader: boolean;
|
||||||
@ -226,7 +219,6 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
private contentService: ContentService,
|
private contentService: ContentService,
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
private location: Location,
|
private location: Location,
|
||||||
private translateService: TranslationService,
|
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private appConfig: AppConfigService,
|
private appConfig: AppConfigService,
|
||||||
@ -402,12 +394,10 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handlePermissionError(event: any) {
|
handlePermissionError(event: any) {
|
||||||
this.translateService.get('PERMISSION.LACKOF', {
|
this.notificationService.showError('PERMISSION.LACKOF', null, {
|
||||||
permission: event.permission,
|
permission: event.permission,
|
||||||
action: event.action,
|
action: event.action,
|
||||||
type: event.type
|
type: event.type
|
||||||
}).subscribe((message) => {
|
|
||||||
this.openSnackMessageError(message);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,25 +419,24 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
|
|
||||||
onContentActionError(errors: any) {
|
onContentActionError(errors: any) {
|
||||||
const errorStatusCode = JSON.parse(errors.message).error.statusCode;
|
const errorStatusCode = JSON.parse(errors.message).error.statusCode;
|
||||||
let translatedErrorMessage: any;
|
let message: string;
|
||||||
|
|
||||||
switch (errorStatusCode) {
|
switch (errorStatusCode) {
|
||||||
case 403:
|
case 403:
|
||||||
translatedErrorMessage = this.translateService.instant('OPERATION.ERROR.PERMISSION');
|
message = 'OPERATION.ERROR.PERMISSION';
|
||||||
break;
|
break;
|
||||||
case 409:
|
case 409:
|
||||||
translatedErrorMessage = this.translateService.instant('OPERATION.ERROR.CONFLICT');
|
message = 'OPERATION.ERROR.CONFLICT';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
translatedErrorMessage = this.translateService.instant('OPERATION.ERROR.UNKNOWN');
|
message = 'OPERATION.ERROR.UNKNOWN';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.openSnackMessageError(translatedErrorMessage);
|
this.openSnackMessageError(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
onContentActionSuccess(message: string) {
|
onContentActionSuccess(message: string) {
|
||||||
const translatedMessage: any = this.translateService.instant(message);
|
this.openSnackMessageInfo(message);
|
||||||
this.openSnackMessageInfo(translatedMessage);
|
|
||||||
this.documentList.reload();
|
this.documentList.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,31 +458,30 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
|
|
||||||
if (this.contentService.hasAllowableOperations(contentEntry, 'update')) {
|
if (this.contentService.hasAllowableOperations(contentEntry, 'update')) {
|
||||||
this.dialog.open(VersionManagerDialogAdapterComponent, {
|
this.dialog.open(VersionManagerDialogAdapterComponent, {
|
||||||
data: { contentEntry: contentEntry, showComments: showComments, allowDownload: allowDownload },
|
data: { contentEntry, showComments, allowDownload },
|
||||||
panelClass: 'adf-version-manager-dialog',
|
panelClass: 'adf-version-manager-dialog',
|
||||||
width: '630px'
|
width: '630px'
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const translatedErrorMessage: any = this.translateService.instant('OPERATION.ERROR.PERMISSION');
|
this.openSnackMessageError('OPERATION.ERROR.PERMISSION');
|
||||||
this.openSnackMessageError(translatedErrorMessage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onManageMetadata(event: any) {
|
onManageMetadata(event: any) {
|
||||||
const contentEntry = event.value.entry;
|
const contentEntry = event.value.entry;
|
||||||
|
const displayEmptyMetadata = this.displayEmptyMetadata;
|
||||||
|
|
||||||
if (this.contentService.hasAllowableOperations(contentEntry, 'update')) {
|
if (this.contentService.hasAllowableOperations(contentEntry, 'update')) {
|
||||||
this.dialog.open(MetadataDialogAdapterComponent, {
|
this.dialog.open(MetadataDialogAdapterComponent, {
|
||||||
data: {
|
data: {
|
||||||
contentEntry: contentEntry,
|
contentEntry,
|
||||||
displayEmptyMetadata: this.displayEmptyMetadata
|
displayEmptyMetadata
|
||||||
},
|
},
|
||||||
panelClass: 'adf-metadata-manager-dialog',
|
panelClass: 'adf-metadata-manager-dialog',
|
||||||
width: '630px'
|
width: '630px'
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const translatedErrorMessage: any = this.translateService.instant('OPERATION.ERROR.PERMISSION');
|
this.openSnackMessageError('OPERATION.ERROR.PERMISSION');
|
||||||
this.openSnackMessageError(translatedErrorMessage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,17 +489,17 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
this.currentFolderId = site.entry.guid;
|
this.currentFolderId = site.entry.guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasSelection(selection: Array<MinimalNodeEntity>): boolean {
|
hasSelection(selection: Array<any>): boolean {
|
||||||
return selection && selection.length > 0;
|
return selection && selection.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasOneFileSelected(): boolean {
|
hasOneFileSelected(): boolean {
|
||||||
const selection: Array<MinimalNodeEntity> = this.documentList.selection;
|
const selection = this.documentList.selection;
|
||||||
return selection && selection.length === 1 && selection[0].entry.isFile;
|
return selection && selection.length === 1 && selection[0].entry.isFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
userHasPermissionToManageVersions(): boolean {
|
userHasPermissionToManageVersions(): boolean {
|
||||||
const selection: Array<MinimalNodeEntity> = this.documentList.selection;
|
const selection = this.documentList.selection;
|
||||||
return this.contentService.hasAllowableOperations(selection[0].entry, 'update');
|
return this.contentService.hasAllowableOperations(selection[0].entry, 'update');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -606,7 +594,6 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
|
|
||||||
canDownloadNode(node: MinimalNodeEntity): boolean {
|
canDownloadNode(node: MinimalNodeEntity): boolean {
|
||||||
return node && node.entry && node.entry.name === 'custom';
|
return node && node.entry && node.entry.name === 'custom';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onBeginUpload(event: UploadFilesEvent) {
|
onBeginUpload(event: UploadFilesEvent) {
|
||||||
@ -656,8 +643,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
width: '630px'
|
width: '630px'
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const translatedErrorMessage: any = this.translateService.instant('OPERATION.ERROR.PERMISSION');
|
this.openSnackMessageError('OPERATION.ERROR.PERMISSION');
|
||||||
this.openSnackMessageError(translatedErrorMessage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
* before delivering it.
|
* before delivering it.
|
||||||
*/
|
*/
|
||||||
@Input()
|
@Input()
|
||||||
sortingMode = 'server';
|
sortingMode: 'server' | 'client' = 'server';
|
||||||
|
|
||||||
/** The inline style to apply to every row. See
|
/** The inline style to apply to every row. See
|
||||||
* the Angular NgStyle
|
* the Angular NgStyle
|
||||||
@ -707,8 +707,11 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
|
|
||||||
onSortingChanged(event: CustomEvent) {
|
onSortingChanged(event: CustomEvent) {
|
||||||
this.orderBy = this.buildOrderByArray(event.detail.sortingKey, event.detail.direction);
|
this.orderBy = this.buildOrderByArray(event.detail.sortingKey, event.detail.direction);
|
||||||
this.reload();
|
|
||||||
this.sortingSubject.next([this.additionalSorting, event.detail]);
|
this.sortingSubject.next([this.additionalSorting, event.detail]);
|
||||||
|
|
||||||
|
if (this.sortingMode === 'server') {
|
||||||
|
this.reload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildOrderByArray(currentKey: string, currentDirection: string): string[] {
|
private buildOrderByArray(currentKey: string, currentDirection: string): string[] {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user