mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
[ACS-5839] migrate to latest JS-API types (#8859)
* [ci:force] migrate Minimal Node to Node * [ci:force] remove js-api wrappers and use real types * [ci:force] remove js-api wrappers and use real types * [ci:force] fix linting errors * [ci:force] fix linting errors * [ci:force] security fixes * [ci:force] sonarcloud bug fixes * [ci:force] dead code elimination, sonar suggested fixes
This commit is contained in:
parent
a5b05b3e5f
commit
3b4ce3b857
@ -31,7 +31,7 @@ import {
|
|||||||
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 } from '@alfresco/js-api';
|
import { NodeEntry, NodePaging, Pagination, Node, SiteEntry, SearchEntry } from '@alfresco/js-api';
|
||||||
import {
|
import {
|
||||||
NotificationService,
|
NotificationService,
|
||||||
DataRow,
|
DataRow,
|
||||||
@ -71,12 +71,9 @@ const DEFAULT_FOLDER_TO_SHOW = '-my-';
|
|||||||
templateUrl: './files.component.html',
|
templateUrl: './files.component.html',
|
||||||
styleUrls: ['./files.component.scss'],
|
styleUrls: ['./files.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
providers: [
|
providers: [{ provide: FormRenderingService, useClass: ProcessFormRenderingService }]
|
||||||
{provide: FormRenderingService, useClass: ProcessFormRenderingService}
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
|
|
||||||
protected onDestroy$ = new Subject<boolean>();
|
protected onDestroy$ = new Subject<boolean>();
|
||||||
|
|
||||||
errorMessage: string = null;
|
errorMessage: string = null;
|
||||||
@ -88,9 +85,9 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
includeFields = ['isFavorite', 'isLocked', 'aspectNames', 'definition'];
|
includeFields = ['isFavorite', 'isLocked', 'aspectNames', 'definition'];
|
||||||
|
|
||||||
selectionModes = [
|
selectionModes = [
|
||||||
{value: 'none', viewValue: 'None'},
|
{ value: 'none', viewValue: 'None' },
|
||||||
{value: 'single', viewValue: 'Single'},
|
{ value: 'single', viewValue: 'Single' },
|
||||||
{value: 'multiple', viewValue: 'Multiple'}
|
{ value: 'multiple', viewValue: 'Multiple' }
|
||||||
];
|
];
|
||||||
|
|
||||||
// The identifier of a node. You can also use one of these well-known aliases: -my- | -shared- | -root-
|
// The identifier of a node. You can also use one of these well-known aliases: -my- | -shared- | -root-
|
||||||
@ -199,13 +196,13 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
@Output()
|
@Output()
|
||||||
deleteElementSuccess: EventEmitter<any> = new EventEmitter();
|
deleteElementSuccess: EventEmitter<any> = new EventEmitter();
|
||||||
|
|
||||||
@ViewChild('documentList', {static: true})
|
@ViewChild('documentList', { static: true })
|
||||||
documentList: DocumentListComponent;
|
documentList: DocumentListComponent;
|
||||||
|
|
||||||
@ViewChild('standardPagination')
|
@ViewChild('standardPagination')
|
||||||
standardPagination: PaginationComponent;
|
standardPagination: PaginationComponent;
|
||||||
|
|
||||||
@ViewChild(InfinitePaginationComponent, {static: true})
|
@ViewChild(InfinitePaginationComponent, { static: true })
|
||||||
infinitePaginationComponent: InfinitePaginationComponent;
|
infinitePaginationComponent: InfinitePaginationComponent;
|
||||||
|
|
||||||
permissionsStyle: PermissionStyleModel[] = [];
|
permissionsStyle: PermissionStyleModel[] = [];
|
||||||
@ -217,7 +214,8 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
displayEmptyMetadata = false;
|
displayEmptyMetadata = false;
|
||||||
hyperlinkNavigation = false;
|
hyperlinkNavigation = false;
|
||||||
|
|
||||||
constructor(private notificationService: NotificationService,
|
constructor(
|
||||||
|
private notificationService: NotificationService,
|
||||||
private uploadService: UploadService,
|
private uploadService: UploadService,
|
||||||
private contentService: ContentService,
|
private contentService: ContentService,
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
@ -228,8 +226,8 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
@Optional() private route: ActivatedRoute,
|
@Optional() private route: ActivatedRoute,
|
||||||
private contentMetadataService: ContentMetadataService,
|
private contentMetadataService: ContentMetadataService,
|
||||||
private dialogAspectListService: DialogAspectListService,
|
private dialogAspectListService: DialogAspectListService,
|
||||||
private nodeService: NodesApiService) {
|
private nodeService: NodesApiService
|
||||||
}
|
) {}
|
||||||
|
|
||||||
showFile(event) {
|
showFile(event) {
|
||||||
const entry = event.value.entry;
|
const entry = event.value.entry;
|
||||||
@ -273,25 +271,15 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
this.onFileUploadEvent(value[0]);
|
this.onFileUploadEvent(value[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.uploadService.fileUploadDeleted
|
this.uploadService.fileUploadDeleted.pipe(takeUntil(this.onDestroy$)).subscribe((value) => this.onFileUploadEvent(value));
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
|
||||||
.subscribe(value => this.onFileUploadEvent(value));
|
|
||||||
|
|
||||||
this.contentService.folderCreated
|
this.contentService.folderCreated.pipe(takeUntil(this.onDestroy$)).subscribe((value) => this.onFolderCreated(value));
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
|
||||||
.subscribe(value => this.onFolderCreated(value));
|
|
||||||
|
|
||||||
this.contentService.folderCreate
|
this.contentService.folderCreate.pipe(takeUntil(this.onDestroy$)).subscribe((value) => this.onFolderAction(value));
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
|
||||||
.subscribe(value => this.onFolderAction(value));
|
|
||||||
|
|
||||||
this.contentService.folderEdit
|
this.contentService.folderEdit.pipe(takeUntil(this.onDestroy$)).subscribe((value) => this.onFolderAction(value));
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
|
||||||
.subscribe(value => this.onFolderAction(value));
|
|
||||||
|
|
||||||
this.contentMetadataService.error
|
this.contentMetadataService.error.pipe(takeUntil(this.onDestroy$)).subscribe((err: { message: string }) => {
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
|
||||||
.subscribe((err: { message: string }) => {
|
|
||||||
this.notificationService.showError(err.message);
|
this.notificationService.showError(err.message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -326,9 +314,9 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
} as Pagination;
|
} as Pagination;
|
||||||
}
|
}
|
||||||
|
|
||||||
getCurrentDocumentListNode(): MinimalNodeEntity[] {
|
getCurrentDocumentListNode(): NodeEntry[] {
|
||||||
if (this.documentList.folderNode) {
|
if (this.documentList.folderNode) {
|
||||||
return [{entry: this.documentList.folderNode}];
|
return [{ entry: this.documentList.folderNode }];
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@ -416,7 +404,7 @@ 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, showComments, allowDownload},
|
data: { contentEntry, showComments, allowDownload },
|
||||||
panelClass: 'adf-version-manager-dialog',
|
panelClass: 'adf-version-manager-dialog',
|
||||||
width: '630px'
|
width: '630px'
|
||||||
});
|
});
|
||||||
@ -427,7 +415,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
|
|
||||||
onAspectUpdate(event: any) {
|
onAspectUpdate(event: any) {
|
||||||
this.dialogAspectListService.openAspectListDialog(event.value.entry.id).subscribe((aspectList) => {
|
this.dialogAspectListService.openAspectListDialog(event.value.entry.id).subscribe((aspectList) => {
|
||||||
this.nodeService.updateNode(event.value.entry.id, {aspectNames: [...aspectList]}).subscribe(() => {
|
this.nodeService.updateNode(event.value.entry.id, { aspectNames: [...aspectList] }).subscribe(() => {
|
||||||
this.openSnackMessageInfo('Node Aspects Updated');
|
this.openSnackMessageInfo('Node Aspects Updated');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -476,7 +464,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
canEditFolder(selection: Array<MinimalNodeEntity>): boolean {
|
canEditFolder(selection: Array<NodeEntry>): boolean {
|
||||||
if (selection && selection.length === 1) {
|
if (selection && selection.length === 1) {
|
||||||
const entry = selection[0].entry;
|
const entry = selection[0].entry;
|
||||||
|
|
||||||
@ -487,7 +475,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
canCreateContent(parentNode: MinimalNodeEntryEntity): boolean {
|
canCreateContent(parentNode: Node): boolean {
|
||||||
if (parentNode) {
|
if (parentNode) {
|
||||||
return this.contentService.hasAllowableOperations(parentNode, 'create');
|
return this.contentService.hasAllowableOperations(parentNode, 'create');
|
||||||
}
|
}
|
||||||
@ -521,10 +509,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
|
|
||||||
toggleGalleryView(): void {
|
toggleGalleryView(): void {
|
||||||
this.displayMode = this.displayMode === DisplayMode.List ? DisplayMode.Gallery : DisplayMode.List;
|
this.displayMode = this.displayMode === DisplayMode.List ? DisplayMode.Gallery : DisplayMode.List;
|
||||||
const url = this
|
const url = this.router.createUrlTree(['/files', this.currentFolderId, 'display', this.displayMode]).toString();
|
||||||
.router
|
|
||||||
.createUrlTree(['/files', this.currentFolderId, 'display', this.displayMode])
|
|
||||||
.toString();
|
|
||||||
|
|
||||||
this.location.go(url);
|
this.location.go(url);
|
||||||
}
|
}
|
||||||
@ -611,7 +596,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
objectFromMap[filter.key] = paramValue;
|
objectFromMap[filter.key] = paramValue;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.router.navigate([], {relativeTo: this.route, queryParams: objectFromMap});
|
this.router.navigate([], { relativeTo: this.route, queryParams: objectFromMap });
|
||||||
}
|
}
|
||||||
|
|
||||||
clearFilterNavigation() {
|
clearFilterNavigation() {
|
||||||
|
@ -17,20 +17,17 @@
|
|||||||
|
|
||||||
import { Component, Inject, ViewEncapsulation } from '@angular/core';
|
import { Component, Inject, ViewEncapsulation } from '@angular/core';
|
||||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||||
import { MinimalNodeEntryEntity } from '@alfresco/js-api';
|
import { Node } from '@alfresco/js-api';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: './metadata-dialog-adapter.component.html',
|
templateUrl: './metadata-dialog-adapter.component.html',
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class MetadataDialogAdapterComponent {
|
export class MetadataDialogAdapterComponent {
|
||||||
|
contentEntry: Node;
|
||||||
public contentEntry: MinimalNodeEntryEntity;
|
|
||||||
|
|
||||||
displayEmptyMetadata = false;
|
displayEmptyMetadata = false;
|
||||||
|
|
||||||
constructor(@Inject(MAT_DIALOG_DATA) data: any,
|
constructor(@Inject(MAT_DIALOG_DATA) data: any, private containingDialog?: MatDialogRef<MetadataDialogAdapterComponent>) {
|
||||||
private containingDialog?: MatDialogRef<MetadataDialogAdapterComponent>) {
|
|
||||||
this.contentEntry = data.contentEntry;
|
this.contentEntry = data.contentEntry;
|
||||||
this.displayEmptyMetadata = data.displayEmptyMetadata;
|
this.displayEmptyMetadata = data.displayEmptyMetadata;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import { Component, Inject, ViewEncapsulation } from '@angular/core';
|
import { Component, Inject, ViewEncapsulation } from '@angular/core';
|
||||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||||
import { MinimalNodeEntryEntity } from '@alfresco/js-api';
|
import { Node } from '@alfresco/js-api';
|
||||||
import { PreviewService } from '../../services/preview.service';
|
import { PreviewService } from '../../services/preview.service';
|
||||||
import { NotificationService } from '@alfresco/adf-core';
|
import { NotificationService } from '@alfresco/adf-core';
|
||||||
import { FileUploadErrorEvent } from '@alfresco/adf-content-services';
|
import { FileUploadErrorEvent } from '@alfresco/adf-content-services';
|
||||||
@ -27,19 +27,19 @@ import { FileUploadErrorEvent } from '@alfresco/adf-content-services';
|
|||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class VersionManagerDialogAdapterComponent {
|
export class VersionManagerDialogAdapterComponent {
|
||||||
|
contentEntry: Node;
|
||||||
public contentEntry: MinimalNodeEntryEntity;
|
newFileVersion: File;
|
||||||
public newFileVersion: File;
|
|
||||||
|
|
||||||
showComments = true;
|
showComments = true;
|
||||||
allowDownload = true;
|
allowDownload = true;
|
||||||
readOnly = false;
|
readOnly = false;
|
||||||
showVersionComparison = false;
|
showVersionComparison = false;
|
||||||
|
|
||||||
constructor(private previewService: PreviewService,
|
constructor(
|
||||||
|
private previewService: PreviewService,
|
||||||
private notificationService: NotificationService,
|
private notificationService: NotificationService,
|
||||||
@Inject(MAT_DIALOG_DATA) data: any,
|
@Inject(MAT_DIALOG_DATA) data: any,
|
||||||
private containingDialog?: MatDialogRef<VersionManagerDialogAdapterComponent>) {
|
private containingDialog?: MatDialogRef<VersionManagerDialogAdapterComponent>
|
||||||
|
) {
|
||||||
this.contentEntry = data.contentEntry;
|
this.contentEntry = data.contentEntry;
|
||||||
this.newFileVersion = data.hasOwnProperty('newFileVersion') ? data.newFileVersion : this.newFileVersion;
|
this.newFileVersion = data.hasOwnProperty('newFileVersion') ? data.newFileVersion : this.newFileVersion;
|
||||||
this.showComments = data.hasOwnProperty('showComments') ? data.showComments : this.showComments;
|
this.showComments = data.hasOwnProperty('showComments') ? data.showComments : this.showComments;
|
||||||
@ -47,8 +47,7 @@ export class VersionManagerDialogAdapterComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uploadError(event: FileUploadErrorEvent) {
|
uploadError(event: FileUploadErrorEvent) {
|
||||||
const errorMessage = event.error;
|
this.notificationService.showError(event.error);
|
||||||
this.notificationService.showError(errorMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { MinimalNodeEntity } from '@alfresco/js-api';
|
import { NodeEntry } from '@alfresco/js-api';
|
||||||
import { PreviewService } from '../../services/preview.service';
|
import { PreviewService } from '../../services/preview.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -26,9 +26,7 @@ import { PreviewService } from '../../services/preview.service';
|
|||||||
styleUrls: ['./search-bar.component.scss']
|
styleUrls: ['./search-bar.component.scss']
|
||||||
})
|
})
|
||||||
export class SearchBarComponent {
|
export class SearchBarComponent {
|
||||||
|
constructor(public router: Router, private preview: PreviewService) {}
|
||||||
constructor(public router: Router, private preview: PreviewService) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the user submits the search, e.g. hits enter or clicks submit
|
* Called when the user submits the search, e.g. hits enter or clicks submit
|
||||||
@ -37,17 +35,19 @@ export class SearchBarComponent {
|
|||||||
*/
|
*/
|
||||||
onSearchSubmit(event: KeyboardEvent) {
|
onSearchSubmit(event: KeyboardEvent) {
|
||||||
const value = (event.target as HTMLInputElement).value;
|
const value = (event.target as HTMLInputElement).value;
|
||||||
this.router.navigate(['/search', {
|
this.router.navigate([
|
||||||
|
'/search',
|
||||||
|
{
|
||||||
q: value
|
q: value
|
||||||
}]);
|
}
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
onItemClicked(event: MinimalNodeEntity) {
|
onItemClicked(event: NodeEntry) {
|
||||||
if (event.entry.isFile) {
|
if (event.entry.isFile) {
|
||||||
this.preview.showResource(event.entry.id);
|
this.preview.showResource(event.entry.id);
|
||||||
} else if (event.entry.isFolder) {
|
} else if (event.entry.isFolder) {
|
||||||
this.router.navigate(['/files', event.entry.id]);
|
this.router.navigate(['/files', event.entry.id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ will trigger the same action.) You can also add your own handler by implementing
|
|||||||
`execute` event.
|
`execute` event.
|
||||||
|
|
||||||
Note that you can use _both_ a built-in handler and your own `execute`
|
Note that you can use _both_ a built-in handler and your own `execute`
|
||||||
function in the same action. The `execute` function is passed a [`NodeMinimalEntry`](../../../lib/content-services/src/lib/document-list/models/document-library.model.ts) as its
|
function in the same action. The `execute` function is passed a **NodeEntry** as its
|
||||||
parameter. For
|
parameter. For
|
||||||
example, with `handler="delete"` you could use `execute` to show a message with the name,
|
example, with `handler="delete"` you could use `execute` to show a message with the name,
|
||||||
type, and other details of the item just deleted:
|
type, and other details of the item just deleted:
|
||||||
|
@ -15,11 +15,11 @@ Extends from [`BaseCardViewUpdate`](../../../lib/core/src/lib/card-view/interfac
|
|||||||
```ts
|
```ts
|
||||||
export interface BaseCardViewContentUpdate {
|
export interface BaseCardViewContentUpdate {
|
||||||
itemUpdated$: Subject<UpdateNotification>;
|
itemUpdated$: Subject<UpdateNotification>;
|
||||||
updatedAspect$: Subject<MinimalNode>;
|
updatedAspect$: Subject<Node>;
|
||||||
|
|
||||||
update(property: CardViewBaseItemModel, newValue: any);
|
update(property: CardViewBaseItemModel, newValue: any);
|
||||||
updateElement(notification: CardViewBaseItemModel);
|
updateElement(notification: CardViewBaseItemModel);
|
||||||
updateNodeAspect(node: MinimalNode);
|
updateNodeAspect(node: Node);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ constructor(private contentDialogService: ContentNodeDialogService){}
|
|||||||
yourFunctionOnCopyOrMove(){
|
yourFunctionOnCopyOrMove(){
|
||||||
this.contentDialogService
|
this.contentDialogService
|
||||||
.openCopyMoveDialog(actionName, targetNode, neededPermissionForAction)
|
.openCopyMoveDialog(actionName, targetNode, neededPermissionForAction)
|
||||||
.subscribe((selections: MinimalNode[]) => {
|
.subscribe((selections: Node[]) => {
|
||||||
// place your action here on operation success!
|
// place your action here on operation success!
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -106,73 +106,6 @@ and the
|
|||||||
[REST API Explorer](https://api-explorer.alfresco.com/api-explorer/#/nodes)
|
[REST API Explorer](https://api-explorer.alfresco.com/api-explorer/#/nodes)
|
||||||
for more information.
|
for more information.
|
||||||
|
|
||||||
### Getting node information
|
|
||||||
|
|
||||||
The `getNode` method gives access to the [`MinimalNode`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodeMinimalEntry.md) object that represents the
|
|
||||||
details of a node:
|
|
||||||
|
|
||||||
```ts
|
|
||||||
interface MinimalNode extends Node {
|
|
||||||
id: string;
|
|
||||||
parentId: string;
|
|
||||||
name: string;
|
|
||||||
nodeType: string;
|
|
||||||
isFolder: boolean;
|
|
||||||
isFile: boolean;
|
|
||||||
modifiedAt: Date;
|
|
||||||
modifiedByUser: UserInfo;
|
|
||||||
createdAt: Date;
|
|
||||||
createdByUser: UserInfo;
|
|
||||||
content: ContentInfo;
|
|
||||||
path: PathInfoEntity;
|
|
||||||
properties: NodeProperties;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
This provides useful information about the node, such as its name, creation and
|
|
||||||
modification dates, etc. Also, the `id` and `parentId` properties contain the node
|
|
||||||
ID strings for the current node and its enclosing folder.
|
|
||||||
|
|
||||||
Sometimes, a [`MinimalNode`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodeMinimalEntry.md) is provided directly, for example, the `folderNode` property
|
|
||||||
of a [Document List component](../../content-services/components/document-list.component.md) or the data context of a
|
|
||||||
[Document List row](../../content-services/components/document-list.component.md#underlying-node-object). In these cases,
|
|
||||||
you might pass the `id` or `parentId` as a [route parameter](https://angular.io/guide/router)
|
|
||||||
to a page describing the node in full detail. The component receiving the node ID can
|
|
||||||
use the [Nodes Api service](nodes-api.service.md) to "decode" the ID string into a [`MinimalNode`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodeMinimalEntry.md):
|
|
||||||
|
|
||||||
```ts
|
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
|
||||||
import { NodesApiService } from '@alfresco/adf-core';
|
|
||||||
import { MinimalNode } from '@alfresco/js-api';
|
|
||||||
...
|
|
||||||
|
|
||||||
export class RepositoryDetailsPageComponent implements OnInit {
|
|
||||||
nodeId: string;
|
|
||||||
nodeName: string;
|
|
||||||
isFile: boolean;
|
|
||||||
...
|
|
||||||
|
|
||||||
constructor(private router: Router,
|
|
||||||
private activatedRoute: ActivatedRoute,
|
|
||||||
private nodeService: NodesApiService) {
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.nodeId = this.activatedRoute.snapshot.params['node-id'];
|
|
||||||
this.nodeService.getNode(this.nodeId).subscribe((entry: MinimalNode) => {
|
|
||||||
const node: MinimalNode = entry;
|
|
||||||
this.nodeName = node.name;
|
|
||||||
this.isFile = node.isFile;
|
|
||||||
...
|
|
||||||
});
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
You can supply a number of extra options using the `options` parameter. See the
|
|
||||||
[getNode](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodesApi.md#getNode)
|
|
||||||
page in the Alfresco JS API docs for more information.
|
|
||||||
|
|
||||||
### Getting folder node contents
|
### Getting folder node contents
|
||||||
|
|
||||||
The `getNodeChildren` method returns the contents of a folder
|
The `getNodeChildren` method returns the contents of a folder
|
||||||
|
@ -133,9 +133,9 @@ to _alfresco-1002_ as follows:
|
|||||||
You then need to pass the node as the input `values` object with the other properties:
|
You then need to pass the node as the input `values` object with the other properties:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
let node: MinimalNode = null;
|
let node: Node = null;
|
||||||
|
|
||||||
this.nodesApiService.getNode(NODE_ID).subscribe((minimalNode) => this.node = minimalNode);
|
this.nodesApiService.getNode(NODE_ID).subscribe((res) => this.node = res);
|
||||||
|
|
||||||
const formValues: FormValues = {
|
const formValues: FormValues = {
|
||||||
'file' : node
|
'file' : node
|
||||||
|
@ -24,10 +24,11 @@ import { ContentTestingModule } from '../testing/content.testing.module';
|
|||||||
import { AspectListDialogComponentData } from './aspect-list-dialog-data.interface';
|
import { AspectListDialogComponentData } from './aspect-list-dialog-data.interface';
|
||||||
import { AspectListService } from './services/aspect-list.service';
|
import { AspectListService } from './services/aspect-list.service';
|
||||||
import { delay } from 'rxjs/operators';
|
import { delay } from 'rxjs/operators';
|
||||||
import { AspectEntry, MinimalNode } from '@alfresco/js-api';
|
import { AspectEntry, Node } from '@alfresco/js-api';
|
||||||
import { NodesApiService } from '../common/services/nodes-api.service';
|
import { NodesApiService } from '../common/services/nodes-api.service';
|
||||||
|
|
||||||
const aspectListMock: AspectEntry[] = [{
|
const aspectListMock: AspectEntry[] = [
|
||||||
|
{
|
||||||
entry: {
|
entry: {
|
||||||
parentId: 'frs:aspectZero',
|
parentId: 'frs:aspectZero',
|
||||||
id: 'frs:AspectOne',
|
id: 'frs:AspectOne',
|
||||||
@ -46,8 +47,8 @@ const aspectListMock: AspectEntry[] = [{
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
entry: {
|
entry: {
|
||||||
parentId: 'frs:AspectZer',
|
parentId: 'frs:AspectZer',
|
||||||
id: 'frs:SecondAspect',
|
id: 'frs:SecondAspect',
|
||||||
@ -66,9 +67,11 @@ const aspectListMock: AspectEntry[] = [{
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}];
|
}
|
||||||
|
];
|
||||||
|
|
||||||
const customAspectListMock: AspectEntry[] = [{
|
const customAspectListMock: AspectEntry[] = [
|
||||||
|
{
|
||||||
entry: {
|
entry: {
|
||||||
parentId: 'cst:customAspect',
|
parentId: 'cst:customAspect',
|
||||||
id: 'cst:customAspect',
|
id: 'cst:customAspect',
|
||||||
@ -87,7 +90,8 @@ const customAspectListMock: AspectEntry[] = [{
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}];
|
}
|
||||||
|
];
|
||||||
|
|
||||||
describe('AspectListDialogComponent', () => {
|
describe('AspectListDialogComponent', () => {
|
||||||
let fixture: ComponentFixture<AspectListDialogComponent>;
|
let fixture: ComponentFixture<AspectListDialogComponent>;
|
||||||
@ -97,10 +101,9 @@ describe('AspectListDialogComponent', () => {
|
|||||||
const event = new KeyboardEvent('keydown', {
|
const event = new KeyboardEvent('keydown', {
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
keyCode: 27
|
keyCode: 27
|
||||||
} as KeyboardEventInit );
|
} as KeyboardEventInit);
|
||||||
|
|
||||||
describe('Without passing node id', () => {
|
describe('Without passing node id', () => {
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
data = {
|
data = {
|
||||||
title: 'Title',
|
title: 'Title',
|
||||||
@ -110,11 +113,7 @@ describe('AspectListDialogComponent', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [TranslateModule.forRoot(), ContentTestingModule, MatDialogModule],
|
||||||
TranslateModule.forRoot(),
|
|
||||||
ContentTestingModule,
|
|
||||||
MatDialogModule
|
|
||||||
],
|
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: MAT_DIALOG_DATA, useValue: data },
|
{ provide: MAT_DIALOG_DATA, useValue: data },
|
||||||
{
|
{
|
||||||
@ -156,7 +155,9 @@ describe('AspectListDialogComponent', () => {
|
|||||||
expect(dialogTitle).not.toBeNull();
|
expect(dialogTitle).not.toBeNull();
|
||||||
expect(dialogTitle.innerText).toBe(data.title);
|
expect(dialogTitle.innerText).toBe(data.title);
|
||||||
|
|
||||||
const dialogDescription = fixture.nativeElement.querySelector('[data-automation-id="aspect-list-dialog-title"] .adf-aspect-list-dialog-description');
|
const dialogDescription = fixture.nativeElement.querySelector(
|
||||||
|
'[data-automation-id="aspect-list-dialog-title"] .adf-aspect-list-dialog-description'
|
||||||
|
);
|
||||||
expect(dialogDescription).not.toBeNull();
|
expect(dialogDescription).not.toBeNull();
|
||||||
expect(dialogDescription.innerText).toBe(data.description);
|
expect(dialogDescription.innerText).toBe(data.description);
|
||||||
|
|
||||||
@ -228,7 +229,11 @@ describe('AspectListDialogComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should complete the select stream Cancel button is clicked', (done) => {
|
it('should complete the select stream Cancel button is clicked', (done) => {
|
||||||
data.select.subscribe(() => { }, () => { }, () => done());
|
data.select.subscribe(
|
||||||
|
() => {},
|
||||||
|
() => {},
|
||||||
|
() => done()
|
||||||
|
);
|
||||||
const cancelButton: HTMLButtonElement = fixture.nativeElement.querySelector('#aspect-list-dialog-actions-cancel');
|
const cancelButton: HTMLButtonElement = fixture.nativeElement.querySelector('#aspect-list-dialog-actions-cancel');
|
||||||
expect(cancelButton).toBeDefined();
|
expect(cancelButton).toBeDefined();
|
||||||
cancelButton.click();
|
cancelButton.click();
|
||||||
@ -237,7 +242,6 @@ describe('AspectListDialogComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Passing the node id', () => {
|
describe('Passing the node id', () => {
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
data = {
|
data = {
|
||||||
title: 'Title',
|
title: 'Title',
|
||||||
@ -248,11 +252,7 @@ describe('AspectListDialogComponent', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [TranslateModule.forRoot(), ContentTestingModule, MatDialogModule],
|
||||||
TranslateModule.forRoot(),
|
|
||||||
ContentTestingModule,
|
|
||||||
MatDialogModule
|
|
||||||
],
|
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: MAT_DIALOG_DATA, useValue: data },
|
{ provide: MAT_DIALOG_DATA, useValue: data },
|
||||||
{
|
{
|
||||||
@ -274,7 +274,9 @@ describe('AspectListDialogComponent', () => {
|
|||||||
spyOn(aspectListService, 'getAspects').and.returnValue(of([...aspectListMock, ...customAspectListMock]));
|
spyOn(aspectListService, 'getAspects').and.returnValue(of([...aspectListMock, ...customAspectListMock]));
|
||||||
spyOn(aspectListService, 'getVisibleAspects').and.returnValue(['frs:AspectOne']);
|
spyOn(aspectListService, 'getVisibleAspects').and.returnValue(['frs:AspectOne']);
|
||||||
spyOn(aspectListService, 'getCustomAspects').and.returnValue(of(customAspectListMock));
|
spyOn(aspectListService, 'getCustomAspects').and.returnValue(of(customAspectListMock));
|
||||||
spyOn(nodeService, 'getNode').and.returnValue(of(new MinimalNode({ id: 'fake-node-id', aspectNames: ['frs:AspectOne', 'cst:customAspect'] })).pipe(delay(0)));
|
spyOn(nodeService, 'getNode').and.returnValue(
|
||||||
|
of(new Node({ id: 'fake-node-id', aspectNames: ['frs:AspectOne', 'cst:customAspect'] })).pipe(delay(0))
|
||||||
|
);
|
||||||
fixture = TestBed.createComponent(AspectListDialogComponent);
|
fixture = TestBed.createComponent(AspectListDialogComponent);
|
||||||
fixture.componentInstance.data.select = new Subject<string[]>();
|
fixture.componentInstance.data.select = new Subject<string[]>();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -326,5 +328,4 @@ describe('AspectListDialogComponent', () => {
|
|||||||
expect(applyButton.disabled).toBe(false);
|
expect(applyButton.disabled).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { MinimalNode } from '@alfresco/js-api';
|
import { Node } from '@alfresco/js-api';
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { TestBed } from '@angular/core/testing';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { NodesApiService } from '../../common/services/nodes-api.service';
|
import { NodesApiService } from '../../common/services/nodes-api.service';
|
||||||
@ -27,7 +27,6 @@ import { CardViewContentUpdateService } from '../../common/services/card-view-co
|
|||||||
import { TagService } from '@alfresco/adf-content-services';
|
import { TagService } from '@alfresco/adf-content-services';
|
||||||
|
|
||||||
describe('NodeAspectService', () => {
|
describe('NodeAspectService', () => {
|
||||||
|
|
||||||
let dialogAspectListService: DialogAspectListService;
|
let dialogAspectListService: DialogAspectListService;
|
||||||
let nodeAspectService: NodeAspectService;
|
let nodeAspectService: NodeAspectService;
|
||||||
let nodeApiService: NodesApiService;
|
let nodeApiService: NodesApiService;
|
||||||
@ -35,10 +34,7 @@ describe('NodeAspectService', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [TranslateModule.forRoot(), ContentTestingModule]
|
||||||
TranslateModule.forRoot(),
|
|
||||||
ContentTestingModule
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
dialogAspectListService = TestBed.inject(DialogAspectListService);
|
dialogAspectListService = TestBed.inject(DialogAspectListService);
|
||||||
nodeAspectService = TestBed.inject(NodeAspectService);
|
nodeAspectService = TestBed.inject(NodeAspectService);
|
||||||
@ -81,7 +77,7 @@ describe('NodeAspectService', () => {
|
|||||||
expect(nodeUpdated.id).toBe('fake-node-id');
|
expect(nodeUpdated.id).toBe('fake-node-id');
|
||||||
expect(nodeUpdated.aspectNames).toEqual(['a', 'b', 'c']);
|
expect(nodeUpdated.aspectNames).toEqual(['a', 'b', 'c']);
|
||||||
});
|
});
|
||||||
const fakeNode = new MinimalNode({ id: 'fake-node-id', aspectNames: ['a', 'b', 'c'] });
|
const fakeNode = new Node({ id: 'fake-node-id', aspectNames: ['a', 'b', 'c'] });
|
||||||
spyOn(dialogAspectListService, 'openAspectListDialog').and.returnValue(of(['a', 'b', 'c']));
|
spyOn(dialogAspectListService, 'openAspectListDialog').and.returnValue(of(['a', 'b', 'c']));
|
||||||
spyOn(nodeApiService, 'updateNode').and.returnValue(of(fakeNode));
|
spyOn(nodeApiService, 'updateNode').and.returnValue(of(fakeNode));
|
||||||
nodeAspectService.updateNodeAspects('fake-node-id');
|
nodeAspectService.updateNodeAspects('fake-node-id');
|
||||||
@ -92,7 +88,7 @@ describe('NodeAspectService', () => {
|
|||||||
expect(nodeUpdated.id).toBe('fake-node-id');
|
expect(nodeUpdated.id).toBe('fake-node-id');
|
||||||
expect(nodeUpdated.aspectNames).toEqual(['a', 'b', 'c']);
|
expect(nodeUpdated.aspectNames).toEqual(['a', 'b', 'c']);
|
||||||
});
|
});
|
||||||
const fakeNode = new MinimalNode({ id: 'fake-node-id', aspectNames: ['a', 'b', 'c'] });
|
const fakeNode = new Node({ id: 'fake-node-id', aspectNames: ['a', 'b', 'c'] });
|
||||||
spyOn(dialogAspectListService, 'openAspectListDialog').and.returnValue(of(['a', 'b', 'c']));
|
spyOn(dialogAspectListService, 'openAspectListDialog').and.returnValue(of(['a', 'b', 'c']));
|
||||||
spyOn(nodeApiService, 'updateNode').and.returnValue(of(fakeNode));
|
spyOn(nodeApiService, 'updateNode').and.returnValue(of(fakeNode));
|
||||||
nodeAspectService.updateNodeAspects('fake-node-id');
|
nodeAspectService.updateNodeAspects('fake-node-id');
|
||||||
@ -101,7 +97,7 @@ describe('NodeAspectService', () => {
|
|||||||
it('should call emit on refresh from TagService', () => {
|
it('should call emit on refresh from TagService', () => {
|
||||||
const tagService = TestBed.inject(TagService);
|
const tagService = TestBed.inject(TagService);
|
||||||
spyOn(dialogAspectListService, 'openAspectListDialog').and.returnValue(of([]));
|
spyOn(dialogAspectListService, 'openAspectListDialog').and.returnValue(of([]));
|
||||||
const node = new MinimalNode({ id: 'fake-node-id', aspectNames: ['a', 'b', 'c'] });
|
const node = new Node({ id: 'fake-node-id', aspectNames: ['a', 'b', 'c'] });
|
||||||
spyOn(nodeApiService, 'updateNode').and.returnValue(of(node));
|
spyOn(nodeApiService, 'updateNode').and.returnValue(of(node));
|
||||||
spyOn(tagService.refresh, 'emit');
|
spyOn(tagService.refresh, 'emit');
|
||||||
nodeAspectService.updateNodeAspects('some node id', 'some-selector');
|
nodeAspectService.updateNodeAspects('some node id', 'some-selector');
|
||||||
|
@ -15,19 +15,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, ViewChild, ViewEncapsulation, OnDestroy } from '@angular/core';
|
||||||
Component,
|
|
||||||
EventEmitter,
|
|
||||||
Input,
|
|
||||||
OnChanges,
|
|
||||||
OnInit,
|
|
||||||
Output,
|
|
||||||
ViewChild,
|
|
||||||
ViewEncapsulation,
|
|
||||||
OnDestroy
|
|
||||||
} from '@angular/core';
|
|
||||||
import { MatSelect } from '@angular/material/select';
|
import { MatSelect } from '@angular/material/select';
|
||||||
import { Node, PathElementEntity } from '@alfresco/js-api';
|
import { Node, PathElement } from '@alfresco/js-api';
|
||||||
import { DocumentListComponent } from '../document-list/components/document-list.component';
|
import { DocumentListComponent } from '../document-list/components/document-list.component';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
@ -40,7 +30,6 @@ import { takeUntil } from 'rxjs/operators';
|
|||||||
host: { class: 'adf-breadcrumb' }
|
host: { class: 'adf-breadcrumb' }
|
||||||
})
|
})
|
||||||
export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy {
|
export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
|
|
||||||
/** Active node, builds UI based on folderNode.path.elements collection. */
|
/** Active node, builds UI based on folderNode.path.elements collection. */
|
||||||
@Input()
|
@Input()
|
||||||
folderNode: Node = null;
|
folderNode: Node = null;
|
||||||
@ -79,10 +68,10 @@ export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
@Input()
|
@Input()
|
||||||
maxItems: number;
|
maxItems: number;
|
||||||
|
|
||||||
previousNodes: PathElementEntity[];
|
previousNodes: PathElement[];
|
||||||
lastNodes: PathElementEntity[];
|
lastNodes: PathElement[];
|
||||||
|
|
||||||
route: PathElementEntity[] = [];
|
route: PathElement[] = [];
|
||||||
|
|
||||||
private onDestroy$ = new Subject<boolean>();
|
private onDestroy$ = new Subject<boolean>();
|
||||||
|
|
||||||
@ -96,15 +85,13 @@ export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
|
|
||||||
/** Emitted when the user clicks on a breadcrumb. */
|
/** Emitted when the user clicks on a breadcrumb. */
|
||||||
@Output()
|
@Output()
|
||||||
navigate = new EventEmitter<PathElementEntity>();
|
navigate = new EventEmitter<PathElement>();
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.transform = this.transform ? this.transform : null;
|
this.transform = this.transform ? this.transform : null;
|
||||||
|
|
||||||
if (this.target) {
|
if (this.target) {
|
||||||
this.target.$folderNode
|
this.target.$folderNode.pipe(takeUntil(this.onDestroy$)).subscribe((folderNode: Node) => {
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
|
||||||
.subscribe((folderNode: Node) => {
|
|
||||||
this.folderNode = folderNode;
|
this.folderNode = folderNode;
|
||||||
this.recalculateNodes();
|
this.recalculateNodes();
|
||||||
});
|
});
|
||||||
@ -141,7 +128,7 @@ export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
return !!this.previousNodes;
|
return !!this.previousNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
parseRoute(node: Node): PathElementEntity[] {
|
parseRoute(node: Node): PathElement[] {
|
||||||
if (node && node.path) {
|
if (node && node.path) {
|
||||||
const route = (node.path.elements || []).slice();
|
const route = (node.path.elements || []).slice();
|
||||||
|
|
||||||
@ -149,7 +136,7 @@ export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
id: node.id,
|
id: node.id,
|
||||||
name: node.name,
|
name: node.name,
|
||||||
node
|
node
|
||||||
} as PathElementEntity);
|
} as PathElement);
|
||||||
|
|
||||||
const rootPos = this.getElementPosition(route, this.rootId);
|
const rootPos = this.getElementPosition(route, this.rootId);
|
||||||
if (rootPos > 0) {
|
if (rootPos > 0) {
|
||||||
@ -170,7 +157,7 @@ export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
private getElementPosition(route: PathElementEntity[], nodeId: string): number {
|
private getElementPosition(route: PathElement[], nodeId: string): number {
|
||||||
let position: number = -1;
|
let position: number = -1;
|
||||||
|
|
||||||
if (route && route.length > 0 && nodeId) {
|
if (route && route.length > 0 && nodeId) {
|
||||||
@ -184,7 +171,7 @@ export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
return !this.readOnly && !lastItem;
|
return !this.readOnly && !lastItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
onRoutePathClick(route: PathElementEntity, event?: Event): void {
|
onRoutePathClick(route: PathElement, event?: Event): void {
|
||||||
if (event && event.type === 'click') {
|
if (event && event.type === 'click') {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
@ -192,7 +179,7 @@ export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
this.onRouteClick(route);
|
this.onRouteClick(route);
|
||||||
}
|
}
|
||||||
|
|
||||||
onRouteClick(route: PathElementEntity) {
|
onRouteClick(route: PathElement) {
|
||||||
if (route && !this.readOnly) {
|
if (route && !this.readOnly) {
|
||||||
this.navigate.emit(route);
|
this.navigate.emit(route);
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import { Component, OnChanges, ViewChild, ViewEncapsulation } from '@angular/core';
|
import { Component, OnChanges, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||||
import { MatSelect } from '@angular/material/select';
|
import { MatSelect } from '@angular/material/select';
|
||||||
import { PathElementEntity, Node } from '@alfresco/js-api';
|
import { PathElement, Node } from '@alfresco/js-api';
|
||||||
import { BreadcrumbComponent } from './breadcrumb.component';
|
import { BreadcrumbComponent } from './breadcrumb.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -28,12 +28,11 @@ import { BreadcrumbComponent } from './breadcrumb.component';
|
|||||||
host: { class: 'adf-dropdown-breadcrumb' }
|
host: { class: 'adf-dropdown-breadcrumb' }
|
||||||
})
|
})
|
||||||
export class DropdownBreadcrumbComponent extends BreadcrumbComponent implements OnChanges {
|
export class DropdownBreadcrumbComponent extends BreadcrumbComponent implements OnChanges {
|
||||||
|
|
||||||
@ViewChild('dropdown')
|
@ViewChild('dropdown')
|
||||||
dropdown: MatSelect;
|
dropdown: MatSelect;
|
||||||
|
|
||||||
currentNode: PathElementEntity;
|
currentNode: PathElement;
|
||||||
previousNodes: PathElementEntity[];
|
previousNodes: PathElement[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the current and previous nodes from the route array
|
* Calculate the current and previous nodes from the route array
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AssocChildBody, AssociationBody } from '@alfresco/js-api';
|
import { ChildAssociationBody, AssociationBody } from '@alfresco/js-api';
|
||||||
|
|
||||||
export interface FileUploadProgress {
|
export interface FileUploadProgress {
|
||||||
loaded: number;
|
loaded: number;
|
||||||
@ -63,7 +63,7 @@ export class FileUploadOptions {
|
|||||||
* You can optionally specify an array of **secondaryChildren** to create one or more secondary child associations,
|
* You can optionally specify an array of **secondaryChildren** to create one or more secondary child associations,
|
||||||
* such that the newly created node acts as a parent node.
|
* such that the newly created node acts as a parent node.
|
||||||
*/
|
*/
|
||||||
secondaryChildren?: AssocChildBody[];
|
secondaryChildren?: ChildAssociationBody[];
|
||||||
/**
|
/**
|
||||||
* You can optionally specify an array of **targets** to create one or more peer associations such that the newly created node acts as a source node.
|
* You can optionally specify an array of **targets** to create one or more peer associations such that the newly created node acts as a source node.
|
||||||
*/
|
*/
|
||||||
@ -112,9 +112,13 @@ export class FileModel {
|
|||||||
percent: 0
|
percent: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
this.options = Object.assign({}, {
|
this.options = Object.assign(
|
||||||
|
{},
|
||||||
|
{
|
||||||
newVersion: false
|
newVersion: false
|
||||||
}, options);
|
},
|
||||||
|
options
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
get extension(): string {
|
get extension(): string {
|
||||||
|
@ -15,12 +15,11 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { MinimalNode } from '@alfresco/js-api';
|
import { Node } from '@alfresco/js-api';
|
||||||
import { fakeAsync, TestBed } from '@angular/core/testing';
|
import { fakeAsync, TestBed } from '@angular/core/testing';
|
||||||
import { CardViewContentUpdateService } from './card-view-content-update.service';
|
import { CardViewContentUpdateService } from './card-view-content-update.service';
|
||||||
|
|
||||||
describe('CardViewContentUpdateService', () => {
|
describe('CardViewContentUpdateService', () => {
|
||||||
|
|
||||||
let cardViewContentUpdateService: CardViewContentUpdateService;
|
let cardViewContentUpdateService: CardViewContentUpdateService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -28,8 +27,8 @@ describe('CardViewContentUpdateService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should send updated node when aspect changed', fakeAsync(() => {
|
it('should send updated node when aspect changed', fakeAsync(() => {
|
||||||
const fakeNode: MinimalNode = { id: 'Bigfoot'} as MinimalNode;
|
const fakeNode = { id: 'Bigfoot' } as Node;
|
||||||
cardViewContentUpdateService.updatedAspect$.subscribe((node: MinimalNode) => {
|
cardViewContentUpdateService.updatedAspect$.subscribe((node) => {
|
||||||
expect(node.id).toBe('Bigfoot');
|
expect(node.id).toBe('Bigfoot');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { UpdateNotification, CardViewBaseItemModel, CardViewUpdateService } from '@alfresco/adf-core';
|
import { UpdateNotification, CardViewBaseItemModel, CardViewUpdateService } from '@alfresco/adf-core';
|
||||||
import { MinimalNode } from '@alfresco/js-api';
|
import { Node } from '@alfresco/js-api';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { BaseCardViewContentUpdate } from '../../interfaces/base-card-view-content-update.interface';
|
import { BaseCardViewContentUpdate } from '../../interfaces/base-card-view-content-update.interface';
|
||||||
@ -25,10 +25,8 @@ import { BaseCardViewContentUpdate } from '../../interfaces/base-card-view-conte
|
|||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class CardViewContentUpdateService implements BaseCardViewContentUpdate {
|
export class CardViewContentUpdateService implements BaseCardViewContentUpdate {
|
||||||
|
|
||||||
itemUpdated$ = new Subject<UpdateNotification>();
|
itemUpdated$ = new Subject<UpdateNotification>();
|
||||||
|
updatedAspect$ = new Subject<Node>();
|
||||||
updatedAspect$ = new Subject<MinimalNode>();
|
|
||||||
|
|
||||||
constructor(private cardViewUpdateService: CardViewUpdateService) {
|
constructor(private cardViewUpdateService: CardViewUpdateService) {
|
||||||
this.linkVariables();
|
this.linkVariables();
|
||||||
@ -42,7 +40,7 @@ export class CardViewContentUpdateService implements BaseCardViewContentUpdate {
|
|||||||
this.cardViewUpdateService.updateElement(notification);
|
this.cardViewUpdateService.updateElement(notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateNodeAspect(node: MinimalNode) {
|
updateNodeAspect(node: Node) {
|
||||||
this.updatedAspect$.next(node);
|
this.updatedAspect$.next(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +49,7 @@ export class CardViewContentUpdateService implements BaseCardViewContentUpdate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private linkItemUpdated() {
|
private linkItemUpdated() {
|
||||||
this.cardViewUpdateService.itemUpdated$.subscribe(res => {
|
this.cardViewUpdateService.itemUpdated$.subscribe((res) => {
|
||||||
this.itemUpdated$.next(res);
|
this.itemUpdated$.next(res);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { ContentApi, MinimalNode, Node, NodeEntry } from '@alfresco/js-api';
|
import { ContentApi, Node, NodeEntry } from '@alfresco/js-api';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { AlfrescoApiService, AuthenticationService } from '@alfresco/adf-core';
|
import { AlfrescoApiService, AuthenticationService } from '@alfresco/adf-core';
|
||||||
import { PermissionsEnum } from '../models/permissions.enum';
|
import { PermissionsEnum } from '../models/permissions.enum';
|
||||||
@ -33,10 +33,9 @@ export interface FolderCreatedEvent {
|
|||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class ContentService {
|
export class ContentService {
|
||||||
|
folderCreated = new Subject<FolderCreatedEvent>();
|
||||||
folderCreated: Subject<FolderCreatedEvent> = new Subject<FolderCreatedEvent>();
|
folderCreate = new Subject<Node>();
|
||||||
folderCreate: Subject<MinimalNode> = new Subject<MinimalNode>();
|
folderEdit = new Subject<Node>();
|
||||||
folderEdit: Subject<MinimalNode> = new Subject<MinimalNode>();
|
|
||||||
|
|
||||||
private _contentApi: ContentApi;
|
private _contentApi: ContentApi;
|
||||||
get contentApi(): ContentApi {
|
get contentApi(): ContentApi {
|
||||||
@ -44,10 +43,7 @@ export class ContentService {
|
|||||||
return this._contentApi;
|
return this._contentApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(public authService: AuthenticationService,
|
constructor(public authService: AuthenticationService, public apiService: AlfrescoApiService) {}
|
||||||
public apiService: AlfrescoApiService) {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a content URL for the given node.
|
* Gets a content URL for the given node.
|
||||||
@ -89,17 +85,16 @@ export class ContentService {
|
|||||||
let hasPermissions = false;
|
let hasPermissions = false;
|
||||||
userId = userId ?? this.authService.getEcmUsername();
|
userId = userId ?? this.authService.getEcmUsername();
|
||||||
|
|
||||||
const permissions = [...(node.permissions?.locallySet || []), ...(node.permissions?.inherited || [])]
|
const permissions = [...(node.permissions?.locallySet || []), ...(node.permissions?.inherited || [])].filter(
|
||||||
.filter((currentPermission) => currentPermission.authorityId === userId);
|
(currentPermission) => currentPermission.authorityId === userId
|
||||||
|
);
|
||||||
if (permissions.length) {
|
if (permissions.length) {
|
||||||
if (permission && permission.startsWith('!')) {
|
if (permission && permission.startsWith('!')) {
|
||||||
hasPermissions = !permissions.find((currentPermission) => currentPermission.name === permission.replace('!', ''));
|
hasPermissions = !permissions.find((currentPermission) => currentPermission.name === permission.replace('!', ''));
|
||||||
} else {
|
} else {
|
||||||
hasPermissions = !!permissions.find((currentPermission) => currentPermission.name === permission);
|
hasPermissions = !!permissions.find((currentPermission) => currentPermission.name === permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (permission === PermissionsEnum.CONSUMER) {
|
if (permission === PermissionsEnum.CONSUMER) {
|
||||||
hasPermissions = true;
|
hasPermissions = true;
|
||||||
} else if (permission === PermissionsEnum.NOT_CONSUMER) {
|
} else if (permission === PermissionsEnum.NOT_CONSUMER) {
|
||||||
@ -124,11 +119,12 @@ export class ContentService {
|
|||||||
|
|
||||||
if (node && node.allowableOperations) {
|
if (node && node.allowableOperations) {
|
||||||
if (allowableOperation && allowableOperation.startsWith('!')) {
|
if (allowableOperation && allowableOperation.startsWith('!')) {
|
||||||
hasAllowableOperations = !node.allowableOperations.find((currentOperation) => currentOperation === allowableOperation.replace('!', ''));
|
hasAllowableOperations = !node.allowableOperations.find(
|
||||||
|
(currentOperation) => currentOperation === allowableOperation.replace('!', '')
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
hasAllowableOperations = !!node.allowableOperations.find((currentOperation) => currentOperation === allowableOperation);
|
hasAllowableOperations = !!node.allowableOperations.find((currentOperation) => currentOperation === allowableOperation);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (allowableOperation && allowableOperation.startsWith('!')) {
|
if (allowableOperation && allowableOperation.startsWith('!')) {
|
||||||
hasAllowableOperations = true;
|
hasAllowableOperations = true;
|
||||||
@ -149,5 +145,4 @@ export class ContentService {
|
|||||||
|
|
||||||
return hasAllowableOperations;
|
return hasAllowableOperations;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { MinimalNode, NodeEntry, NodePaging, NodesApi, TrashcanApi, Node } from '@alfresco/js-api';
|
import { NodeEntry, NodePaging, NodesApi, TrashcanApi, Node } from '@alfresco/js-api';
|
||||||
import { Subject, from, Observable, throwError } from 'rxjs';
|
import { Subject, from, Observable, throwError } from 'rxjs';
|
||||||
import { AlfrescoApiService, UserPreferencesService } from '@alfresco/adf-core';
|
import { AlfrescoApiService, UserPreferencesService } from '@alfresco/adf-core';
|
||||||
import { catchError, map } from 'rxjs/operators';
|
import { catchError, map } from 'rxjs/operators';
|
||||||
@ -26,7 +26,6 @@ import { NodeMetadata } from '../models/node-metadata.model';
|
|||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class NodesApiService {
|
export class NodesApiService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Publish/subscribe to events related to node updates.
|
* Publish/subscribe to events related to node updates.
|
||||||
*/
|
*/
|
||||||
@ -44,11 +43,9 @@ export class NodesApiService {
|
|||||||
return this._nodesApi;
|
return this._nodesApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private apiService: AlfrescoApiService,
|
constructor(private apiService: AlfrescoApiService, private preferences: UserPreferencesService) {}
|
||||||
private preferences: UserPreferencesService) {
|
|
||||||
}
|
|
||||||
|
|
||||||
private getEntryFromEntity(entity: NodeEntry) {
|
private getEntryFromEntity(entity: NodeEntry): Node {
|
||||||
return entity.entry;
|
return entity.entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +56,7 @@ export class NodesApiService {
|
|||||||
* @param options Optional parameters supported by JS-API
|
* @param options Optional parameters supported by JS-API
|
||||||
* @returns Node information
|
* @returns Node information
|
||||||
*/
|
*/
|
||||||
getNode(nodeId: string, options: any = {}): Observable<MinimalNode> {
|
getNode(nodeId: string, options: any = {}): Observable<Node> {
|
||||||
const defaults = {
|
const defaults = {
|
||||||
include: ['path', 'properties', 'allowableOperations', 'permissions']
|
include: ['path', 'properties', 'allowableOperations', 'permissions']
|
||||||
};
|
};
|
||||||
@ -86,9 +83,7 @@ export class NodesApiService {
|
|||||||
};
|
};
|
||||||
const queryOptions = Object.assign(defaults, options);
|
const queryOptions = Object.assign(defaults, options);
|
||||||
|
|
||||||
return from(this.nodesApi.listNodeChildren(nodeId, queryOptions)).pipe(
|
return from(this.nodesApi.listNodeChildren(nodeId, queryOptions)).pipe(catchError((err) => throwError(err)));
|
||||||
catchError((err) => throwError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,7 +94,7 @@ export class NodesApiService {
|
|||||||
* @param options Optional parameters supported by JS-API
|
* @param options Optional parameters supported by JS-API
|
||||||
* @returns Details of the new node
|
* @returns Details of the new node
|
||||||
*/
|
*/
|
||||||
createNode(parentNodeId: string, nodeBody: any, options: any = {}): Observable<MinimalNode> {
|
createNode(parentNodeId: string, nodeBody: any, options: any = {}): Observable<Node> {
|
||||||
return from(this.nodesApi.createNode(parentNodeId, nodeBody, options)).pipe(
|
return from(this.nodesApi.createNode(parentNodeId, nodeBody, options)).pipe(
|
||||||
map(this.getEntryFromEntity),
|
map(this.getEntryFromEntity),
|
||||||
catchError((err) => throwError(err))
|
catchError((err) => throwError(err))
|
||||||
@ -114,7 +109,7 @@ export class NodesApiService {
|
|||||||
* @param options Optional parameters supported by JS-API
|
* @param options Optional parameters supported by JS-API
|
||||||
* @returns Details of the new folder
|
* @returns Details of the new folder
|
||||||
*/
|
*/
|
||||||
createFolder(parentNodeId: string, nodeBody: any, options: any = {}): Observable<MinimalNode> {
|
createFolder(parentNodeId: string, nodeBody: any, options: any = {}): Observable<Node> {
|
||||||
const body = Object.assign({ nodeType: 'cm:folder' }, nodeBody);
|
const body = Object.assign({ nodeType: 'cm:folder' }, nodeBody);
|
||||||
return this.createNode(parentNodeId, body, options);
|
return this.createNode(parentNodeId, body, options);
|
||||||
}
|
}
|
||||||
@ -127,7 +122,7 @@ export class NodesApiService {
|
|||||||
* @param options Optional parameters supported by JS-API
|
* @param options Optional parameters supported by JS-API
|
||||||
* @returns Updated node information
|
* @returns Updated node information
|
||||||
*/
|
*/
|
||||||
updateNode(nodeId: string, nodeBody: any, options: any = {}): Observable<MinimalNode> {
|
updateNode(nodeId: string, nodeBody: any, options: any = {}): Observable<Node> {
|
||||||
const defaults = {
|
const defaults = {
|
||||||
include: ['path', 'properties', 'allowableOperations', 'permissions', 'definition']
|
include: ['path', 'properties', 'allowableOperations', 'permissions', 'definition']
|
||||||
};
|
};
|
||||||
@ -147,9 +142,7 @@ export class NodesApiService {
|
|||||||
* @returns Empty result that notifies when the deletion is complete
|
* @returns Empty result that notifies when the deletion is complete
|
||||||
*/
|
*/
|
||||||
deleteNode(nodeId: string, options: any = {}): Observable<any> {
|
deleteNode(nodeId: string, options: any = {}): Observable<any> {
|
||||||
return from(this.nodesApi.deleteNode(nodeId, options)).pipe(
|
return from(this.nodesApi.deleteNode(nodeId, options)).pipe(catchError((err) => throwError(err)));
|
||||||
catchError((err) => throwError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -158,7 +151,7 @@ export class NodesApiService {
|
|||||||
* @param nodeId ID of the node to restore
|
* @param nodeId ID of the node to restore
|
||||||
* @returns Details of the restored node
|
* @returns Details of the restored node
|
||||||
*/
|
*/
|
||||||
restoreNode(nodeId: string): Observable<MinimalNode> {
|
restoreNode(nodeId: string): Observable<Node> {
|
||||||
return from(this.trashcanApi.restoreDeletedNode(nodeId)).pipe(
|
return from(this.trashcanApi.restoreDeletedNode(nodeId)).pipe(
|
||||||
map(this.getEntryFromEntity),
|
map(this.getEntryFromEntity),
|
||||||
catchError((err) => throwError(err))
|
catchError((err) => throwError(err))
|
||||||
@ -172,8 +165,7 @@ export class NodesApiService {
|
|||||||
* @returns Node metadata
|
* @returns Node metadata
|
||||||
*/
|
*/
|
||||||
public getNodeMetadata(nodeId: string): Observable<NodeMetadata> {
|
public getNodeMetadata(nodeId: string): Observable<NodeMetadata> {
|
||||||
return from(this.nodesApi.getNode(nodeId))
|
return from(this.nodesApi.getNode(nodeId)).pipe(map(this.cleanMetadataFromSemicolon));
|
||||||
.pipe(map(this.cleanMetadataFromSemicolon));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -194,7 +186,7 @@ export class NodesApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.createNodeInsideRoot(name || this.generateUuid(), nodeType, properties, path);
|
return this.createNodeInsideRoot(name || window.crypto.randomUUID(), nodeType, properties, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -204,10 +196,7 @@ export class NodesApiService {
|
|||||||
* @returns Content data
|
* @returns Content data
|
||||||
*/
|
*/
|
||||||
getNodeContent(nodeId: string): Observable<any> {
|
getNodeContent(nodeId: string): Observable<any> {
|
||||||
return from(this.nodesApi.getNodeContent(nodeId))
|
return from(this.nodesApi.getNodeContent(nodeId)).pipe(catchError((err) => throwError(err)));
|
||||||
.pipe(
|
|
||||||
catchError((err) => throwError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -229,14 +218,6 @@ export class NodesApiService {
|
|||||||
return from(this.nodesApi.createNode('-root-', body, {}));
|
return from(this.nodesApi.createNode('-root-', body, {}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private generateUuid() {
|
|
||||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
||||||
const r = Math.random() * 16 | 0;
|
|
||||||
const v = c === 'x' ? r : (r & 0x3 | 0x8);
|
|
||||||
return v.toString(16);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private cleanMetadataFromSemicolon(nodeEntry: NodeEntry): NodeMetadata {
|
private cleanMetadataFromSemicolon(nodeEntry: NodeEntry): NodeMetadata {
|
||||||
const metadata = {};
|
const metadata = {};
|
||||||
|
|
||||||
@ -244,9 +225,9 @@ export class NodesApiService {
|
|||||||
for (const key in nodeEntry.entry.properties) {
|
for (const key in nodeEntry.entry.properties) {
|
||||||
if (key) {
|
if (key) {
|
||||||
if (key.indexOf(':') !== -1) {
|
if (key.indexOf(':') !== -1) {
|
||||||
metadata [key.split(':')[1]] = nodeEntry.entry.properties[key];
|
metadata[key.split(':')[1]] = nodeEntry.entry.properties[key];
|
||||||
} else {
|
} else {
|
||||||
metadata [key] = nodeEntry.entry.properties[key];
|
metadata[key] = nodeEntry.entry.properties[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,5 +235,4 @@ export class NodesApiService {
|
|||||||
|
|
||||||
return new NodeMetadata(metadata, nodeEntry.entry.nodeType);
|
return new NodeMetadata(metadata, nodeEntry.entry.nodeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ import { Injectable } from '@angular/core';
|
|||||||
import { from, Observable, throwError } from 'rxjs';
|
import { from, Observable, throwError } from 'rxjs';
|
||||||
import { AlfrescoApiService, LogService } from '@alfresco/adf-core';
|
import { AlfrescoApiService, LogService } from '@alfresco/adf-core';
|
||||||
import {
|
import {
|
||||||
MinimalNode,
|
Node,
|
||||||
SiteBodyCreate,
|
SiteBodyCreate,
|
||||||
SiteEntry,
|
SiteEntry,
|
||||||
SiteGroupEntry,
|
SiteGroupEntry,
|
||||||
@ -38,16 +38,13 @@ import { catchError } from 'rxjs/operators';
|
|||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class SitesService {
|
export class SitesService {
|
||||||
|
|
||||||
private _sitesApi: SitesApi;
|
private _sitesApi: SitesApi;
|
||||||
get sitesApi(): SitesApi {
|
get sitesApi(): SitesApi {
|
||||||
this._sitesApi = this._sitesApi ?? new SitesApi(this.apiService.getInstance());
|
this._sitesApi = this._sitesApi ?? new SitesApi(this.apiService.getInstance());
|
||||||
return this._sitesApi;
|
return this._sitesApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private apiService: AlfrescoApiService,
|
constructor(private apiService: AlfrescoApiService, private logService: LogService) {}
|
||||||
private logService: LogService) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a site
|
* Create a site
|
||||||
@ -56,10 +53,7 @@ export class SitesService {
|
|||||||
* @returns site SiteEntry
|
* @returns site SiteEntry
|
||||||
*/
|
*/
|
||||||
createSite(siteBody: SiteBodyCreate): Observable<SiteEntry> {
|
createSite(siteBody: SiteBodyCreate): Observable<SiteEntry> {
|
||||||
return from(this.sitesApi.createSite(siteBody))
|
return from(this.sitesApi.createSite(siteBody)).pipe(catchError((err: any) => this.handleError(err)));
|
||||||
.pipe(
|
|
||||||
catchError((err: any) => this.handleError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,10 +68,7 @@ export class SitesService {
|
|||||||
include: ['properties']
|
include: ['properties']
|
||||||
};
|
};
|
||||||
const queryOptions = Object.assign({}, defaultOptions, opts);
|
const queryOptions = Object.assign({}, defaultOptions, opts);
|
||||||
return from(this.sitesApi.listSites(queryOptions))
|
return from(this.sitesApi.listSites(queryOptions)).pipe(catchError((err: any) => this.handleError(err)));
|
||||||
.pipe(
|
|
||||||
catchError((err: any) => this.handleError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,10 +79,7 @@ export class SitesService {
|
|||||||
* @returns Information about the site
|
* @returns Information about the site
|
||||||
*/
|
*/
|
||||||
getSite(siteId: string, opts?: any): Observable<SiteEntry | any> {
|
getSite(siteId: string, opts?: any): Observable<SiteEntry | any> {
|
||||||
return from(this.sitesApi.getSite(siteId, opts))
|
return from(this.sitesApi.getSite(siteId, opts)).pipe(catchError((err: any) => this.handleError(err)));
|
||||||
.pipe(
|
|
||||||
catchError((err: any) => this.handleError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,10 +92,7 @@ export class SitesService {
|
|||||||
deleteSite(siteId: string, permanentFlag: boolean = true): Observable<any> {
|
deleteSite(siteId: string, permanentFlag: boolean = true): Observable<any> {
|
||||||
const options: any = {};
|
const options: any = {};
|
||||||
options.permanent = permanentFlag;
|
options.permanent = permanentFlag;
|
||||||
return from(this.sitesApi.deleteSite(siteId, options))
|
return from(this.sitesApi.deleteSite(siteId, options)).pipe(catchError((err: any) => this.handleError(err)));
|
||||||
.pipe(
|
|
||||||
catchError((err: any) => this.handleError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -148,13 +133,10 @@ export class SitesService {
|
|||||||
* @param node Node to look for parent site
|
* @param node Node to look for parent site
|
||||||
* @returns Site guid
|
* @returns Site guid
|
||||||
*/
|
*/
|
||||||
getSiteNameFromNodePath(node: MinimalNode): string {
|
getSiteNameFromNodePath(node: Node): string {
|
||||||
let siteName = '';
|
let siteName = '';
|
||||||
if (node.path && node.path.elements) {
|
if (node.path && node.path.elements) {
|
||||||
const foundNode = node.path
|
const foundNode = node.path.elements.find((pathNode) => pathNode.nodeType === 'st:site' && pathNode.name !== 'Sites');
|
||||||
.elements.find((pathNode: MinimalNode) =>
|
|
||||||
pathNode.nodeType === 'st:site' &&
|
|
||||||
pathNode.name !== 'Sites');
|
|
||||||
siteName = foundNode ? foundNode.name : '';
|
siteName = foundNode ? foundNode.name : '';
|
||||||
}
|
}
|
||||||
return siteName.toLocaleLowerCase();
|
return siteName.toLocaleLowerCase();
|
||||||
@ -167,10 +149,7 @@ export class SitesService {
|
|||||||
* @returns Site membership requests
|
* @returns Site membership requests
|
||||||
*/
|
*/
|
||||||
getSiteMembershipRequests(opts?: any): Observable<SiteMembershipRequestWithPersonPaging> {
|
getSiteMembershipRequests(opts?: any): Observable<SiteMembershipRequestWithPersonPaging> {
|
||||||
return from(this.sitesApi.getSiteMembershipRequests(opts))
|
return from(this.sitesApi.getSiteMembershipRequests(opts)).pipe(catchError((err: any) => this.handleError(err)));
|
||||||
.pipe(
|
|
||||||
catchError((err: any) => this.handleError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -182,10 +161,7 @@ export class SitesService {
|
|||||||
* @return Observable<SiteMemberEntry>
|
* @return Observable<SiteMemberEntry>
|
||||||
*/
|
*/
|
||||||
createSiteMembership(siteId: string, siteMembershipBodyCreate: SiteMembershipBodyCreate, opts?: any): Observable<SiteMemberEntry> {
|
createSiteMembership(siteId: string, siteMembershipBodyCreate: SiteMembershipBodyCreate, opts?: any): Observable<SiteMemberEntry> {
|
||||||
return from(this.sitesApi.createSiteMembership(siteId, siteMembershipBodyCreate, opts))
|
return from(this.sitesApi.createSiteMembership(siteId, siteMembershipBodyCreate, opts)).pipe(catchError((err: any) => this.handleError(err)));
|
||||||
.pipe(
|
|
||||||
catchError((err: any) => this.handleError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -197,9 +173,13 @@ export class SitesService {
|
|||||||
* @param opts Optional parameters
|
* @param opts Optional parameters
|
||||||
* @return Observable<SiteMemberEntry>
|
* @return Observable<SiteMemberEntry>
|
||||||
*/
|
*/
|
||||||
updateSiteMembership(siteId: string, personId: string, siteMembershipBodyUpdate: SiteMembershipBodyUpdate, opts?: any): Observable<SiteMemberEntry> {
|
updateSiteMembership(
|
||||||
return from(this.sitesApi.updateSiteMembership(siteId, personId, siteMembershipBodyUpdate, opts))
|
siteId: string,
|
||||||
.pipe(
|
personId: string,
|
||||||
|
siteMembershipBodyUpdate: SiteMembershipBodyUpdate,
|
||||||
|
opts?: any
|
||||||
|
): Observable<SiteMemberEntry> {
|
||||||
|
return from(this.sitesApi.updateSiteMembership(siteId, personId, siteMembershipBodyUpdate, opts)).pipe(
|
||||||
catchError((err: any) => this.handleError(err))
|
catchError((err: any) => this.handleError(err))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -212,10 +192,7 @@ export class SitesService {
|
|||||||
* @return Null response notifying when the operation is complete
|
* @return Null response notifying when the operation is complete
|
||||||
*/
|
*/
|
||||||
deleteSiteMembership(siteId: string, personId: string): Observable<void> {
|
deleteSiteMembership(siteId: string, personId: string): Observable<void> {
|
||||||
return from(this.sitesApi.deleteSiteMembership(siteId, personId))
|
return from(this.sitesApi.deleteSiteMembership(siteId, personId)).pipe(catchError((err: any) => this.handleError(err)));
|
||||||
.pipe(
|
|
||||||
catchError((err: any) => this.handleError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -227,10 +204,7 @@ export class SitesService {
|
|||||||
* @returns Null response notifying when the operation is complete
|
* @returns Null response notifying when the operation is complete
|
||||||
*/
|
*/
|
||||||
approveSiteMembershipRequest(siteId: string, inviteeId: string, opts?: any): Observable<SiteMembershipRequestWithPersonPaging> {
|
approveSiteMembershipRequest(siteId: string, inviteeId: string, opts?: any): Observable<SiteMembershipRequestWithPersonPaging> {
|
||||||
return from(this.sitesApi.approveSiteMembershipRequest(siteId, inviteeId, opts))
|
return from(this.sitesApi.approveSiteMembershipRequest(siteId, inviteeId, opts)).pipe(catchError((err: any) => this.handleError(err)));
|
||||||
.pipe(
|
|
||||||
catchError((err: any) => this.handleError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -242,10 +216,7 @@ export class SitesService {
|
|||||||
* @returns Null response notifying when the operation is complete
|
* @returns Null response notifying when the operation is complete
|
||||||
*/
|
*/
|
||||||
rejectSiteMembershipRequest(siteId: string, inviteeId: string, opts?: any): Observable<SiteMembershipRequestWithPersonPaging> {
|
rejectSiteMembershipRequest(siteId: string, inviteeId: string, opts?: any): Observable<SiteMembershipRequestWithPersonPaging> {
|
||||||
return from(this.sitesApi.rejectSiteMembershipRequest(siteId, inviteeId, opts))
|
return from(this.sitesApi.rejectSiteMembershipRequest(siteId, inviteeId, opts)).pipe(catchError((err: any) => this.handleError(err)));
|
||||||
.pipe(
|
|
||||||
catchError((err: any) => this.handleError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -256,10 +227,7 @@ export class SitesService {
|
|||||||
* @returns Observable<SiteGroupPaging>
|
* @returns Observable<SiteGroupPaging>
|
||||||
*/
|
*/
|
||||||
listSiteGroups(siteId: string, opts?: any): Observable<SiteGroupPaging> {
|
listSiteGroups(siteId: string, opts?: any): Observable<SiteGroupPaging> {
|
||||||
return from(this.sitesApi.listSiteGroups(siteId, opts))
|
return from(this.sitesApi.listSiteGroups(siteId, opts)).pipe(catchError((err: any) => this.handleError(err)));
|
||||||
.pipe(
|
|
||||||
catchError((err: any) => this.handleError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -270,10 +238,7 @@ export class SitesService {
|
|||||||
* @returns Observable<SiteGroupEntry>
|
* @returns Observable<SiteGroupEntry>
|
||||||
*/
|
*/
|
||||||
createSiteGroupMembership(siteId: string, siteMembershipBodyCreate: SiteMembershipBodyCreate): Observable<SiteGroupEntry> {
|
createSiteGroupMembership(siteId: string, siteMembershipBodyCreate: SiteMembershipBodyCreate): Observable<SiteGroupEntry> {
|
||||||
return from(this.sitesApi.createSiteGroupMembership(siteId, siteMembershipBodyCreate))
|
return from(this.sitesApi.createSiteGroupMembership(siteId, siteMembershipBodyCreate)).pipe(catchError((err: any) => this.handleError(err)));
|
||||||
.pipe(
|
|
||||||
catchError((err: any) => this.handleError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -284,10 +249,7 @@ export class SitesService {
|
|||||||
* @return Observable<SiteGroupEntry>
|
* @return Observable<SiteGroupEntry>
|
||||||
*/
|
*/
|
||||||
getSiteGroupMembership(siteId: string, groupId: string): Observable<SiteGroupEntry> {
|
getSiteGroupMembership(siteId: string, groupId: string): Observable<SiteGroupEntry> {
|
||||||
return from(this.sitesApi.getSiteGroupMembership(siteId, groupId))
|
return from(this.sitesApi.getSiteGroupMembership(siteId, groupId)).pipe(catchError((err: any) => this.handleError(err)));
|
||||||
.pipe(
|
|
||||||
catchError((err: any) => this.handleError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -299,8 +261,7 @@ export class SitesService {
|
|||||||
* @return Observable<SiteGroupEntry>
|
* @return Observable<SiteGroupEntry>
|
||||||
*/
|
*/
|
||||||
updateSiteGroupMembership(siteId: string, groupId: string, siteMembershipBodyUpdate: SiteMembershipBodyUpdate): Observable<SiteGroupEntry> {
|
updateSiteGroupMembership(siteId: string, groupId: string, siteMembershipBodyUpdate: SiteMembershipBodyUpdate): Observable<SiteGroupEntry> {
|
||||||
return from(this.sitesApi.updateSiteGroupMembership(siteId, groupId, siteMembershipBodyUpdate))
|
return from(this.sitesApi.updateSiteGroupMembership(siteId, groupId, siteMembershipBodyUpdate)).pipe(
|
||||||
.pipe(
|
|
||||||
catchError((err: any) => this.handleError(err))
|
catchError((err: any) => this.handleError(err))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -313,10 +274,7 @@ export class SitesService {
|
|||||||
* @return Observable<void>
|
* @return Observable<void>
|
||||||
*/
|
*/
|
||||||
deleteSiteGroupMembership(siteId: string, groupId: string): Observable<void> {
|
deleteSiteGroupMembership(siteId: string, groupId: string): Observable<void> {
|
||||||
return from(this.sitesApi.deleteSiteGroupMembership(siteId, groupId))
|
return from(this.sitesApi.deleteSiteGroupMembership(siteId, groupId)).pipe(catchError((err: any) => this.handleError(err)));
|
||||||
.pipe(
|
|
||||||
catchError((err: any) => this.handleError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleError(error: any): Observable<never> {
|
private handleError(error: any): Observable<never> {
|
||||||
|
@ -18,27 +18,10 @@
|
|||||||
import { ComponentFixture, discardPeriodicTasks, fakeAsync, flush, TestBed, tick } from '@angular/core/testing';
|
import { ComponentFixture, discardPeriodicTasks, fakeAsync, flush, TestBed, tick } from '@angular/core/testing';
|
||||||
import { DebugElement, SimpleChange } from '@angular/core';
|
import { DebugElement, SimpleChange } from '@angular/core';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import {
|
import { Category, CategoryPaging, ClassesApi, Node, Tag, TagBody, TagEntry, TagPaging, TagPagingList } from '@alfresco/js-api';
|
||||||
Category,
|
|
||||||
CategoryPaging,
|
|
||||||
ClassesApi,
|
|
||||||
MinimalNode,
|
|
||||||
Node,
|
|
||||||
Tag,
|
|
||||||
TagBody,
|
|
||||||
TagEntry,
|
|
||||||
TagPaging,
|
|
||||||
TagPagingList
|
|
||||||
} from '@alfresco/js-api';
|
|
||||||
import { ContentMetadataComponent } from './content-metadata.component';
|
import { ContentMetadataComponent } from './content-metadata.component';
|
||||||
import { ContentMetadataService } from '../../services/content-metadata.service';
|
import { ContentMetadataService } from '../../services/content-metadata.service';
|
||||||
import {
|
import { AppConfigService, CardViewBaseItemModel, CardViewComponent, LogService, UpdateNotification } from '@alfresco/adf-core';
|
||||||
AppConfigService,
|
|
||||||
CardViewBaseItemModel,
|
|
||||||
CardViewComponent,
|
|
||||||
LogService,
|
|
||||||
UpdateNotification
|
|
||||||
} from '@alfresco/adf-core';
|
|
||||||
import { NodesApiService } from '../../../common/services/nodes-api.service';
|
import { NodesApiService } from '../../../common/services/nodes-api.service';
|
||||||
import { EMPTY, of, throwError } from 'rxjs';
|
import { EMPTY, of, throwError } from 'rxjs';
|
||||||
import { ContentTestingModule } from '../../../testing/content.testing.module';
|
import { ContentTestingModule } from '../../../testing/content.testing.module';
|
||||||
@ -86,7 +69,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
|
|
||||||
const category1 = new Category({ id: 'test', name: 'testCat' });
|
const category1 = new Category({ id: 'test', name: 'testCat' });
|
||||||
const category2 = new Category({ id: 'test2', name: 'testCat2' });
|
const category2 = new Category({ id: 'test2', name: 'testCat2' });
|
||||||
const categoryPagingResponse: CategoryPaging = { list: { pagination: {}, entries: [ { entry: category1 }, { entry: category2 }]}};
|
const categoryPagingResponse: CategoryPaging = { list: { pagination: {}, entries: [{ entry: category1 }, { entry: category2 }] } };
|
||||||
|
|
||||||
const findTagElements = (): DebugElement[] => fixture.debugElement.queryAll(By.css('.adf-metadata-properties-tag'));
|
const findTagElements = (): DebugElement[] => fixture.debugElement.queryAll(By.css('.adf-metadata-properties-tag'));
|
||||||
|
|
||||||
@ -123,8 +106,8 @@ describe('ContentMetadataComponent', () => {
|
|||||||
|
|
||||||
async function updateAspectProperty(newValue: string): Promise<void> {
|
async function updateAspectProperty(newValue: string): Promise<void> {
|
||||||
component.editable = true;
|
component.editable = true;
|
||||||
const property = {key: 'properties.property-key', value: 'original-value'} as CardViewBaseItemModel;
|
const property = { key: 'properties.property-key', value: 'original-value' } as CardViewBaseItemModel;
|
||||||
const expectedNode = {...node, name: 'some-modified-value'};
|
const expectedNode = { ...node, name: 'some-modified-value' };
|
||||||
spyOn(nodesApiService, 'updateNode').and.returnValue(of(expectedNode));
|
spyOn(nodesApiService, 'updateNode').and.returnValue(of(expectedNode));
|
||||||
|
|
||||||
updateService.update(property, newValue);
|
updateService.update(property, newValue);
|
||||||
@ -139,10 +122,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [TranslateModule.forRoot(), ContentTestingModule],
|
||||||
TranslateModule.forRoot(),
|
|
||||||
ContentTestingModule
|
|
||||||
],
|
|
||||||
providers: [
|
providers: [
|
||||||
{
|
{
|
||||||
provide: LogService,
|
provide: LogService,
|
||||||
@ -247,7 +227,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('nodeAspectUpdate', fakeAsync(() => {
|
it('nodeAspectUpdate', fakeAsync(() => {
|
||||||
const fakeNode = { id: 'fake-minimal-node', aspectNames: ['ft:a', 'ft:b', 'ft:c'], name: 'fake-node'} as MinimalNode;
|
const fakeNode = { id: 'fake-minimal-node', aspectNames: ['ft:a', 'ft:b', 'ft:c'], name: 'fake-node' } as Node;
|
||||||
spyOn(contentMetadataService, 'getGroupedProperties').and.stub();
|
spyOn(contentMetadataService, 'getGroupedProperties').and.stub();
|
||||||
spyOn(contentMetadataService, 'getBasicProperties').and.stub();
|
spyOn(contentMetadataService, 'getBasicProperties').and.stub();
|
||||||
updateService.updateNodeAspect(fakeNode);
|
updateService.updateNodeAspect(fakeNode);
|
||||||
@ -265,13 +245,13 @@ describe('ContentMetadataComponent', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should save changedProperties which delete property and update node on save click', fakeAsync(async () => {
|
it('should save changedProperties which delete property and update node on save click', fakeAsync(async () => {
|
||||||
const expectedNode = {...node, name: 'some-modified-value'};
|
const expectedNode = { ...node, name: 'some-modified-value' };
|
||||||
await updateAspectProperty('');
|
await updateAspectProperty('');
|
||||||
expect(component.node).toEqual({...expectedNode, properties: {}});
|
expect(component.node).toEqual({ ...expectedNode, properties: {} });
|
||||||
expect(nodesApiService.updateNode).toHaveBeenCalled();
|
expect(nodesApiService.updateNode).toHaveBeenCalled();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should call removeTag and assignTagsToNode on TagService on save click', fakeAsync( () => {
|
it('should call removeTag and assignTagsToNode on TagService on save click', fakeAsync(() => {
|
||||||
component.editable = true;
|
component.editable = true;
|
||||||
component.displayTags = true;
|
component.displayTags = true;
|
||||||
const property = { key: 'properties.property-key', value: 'original-value' } as CardViewBaseItemModel;
|
const property = { key: 'properties.property-key', value: 'original-value' } as CardViewBaseItemModel;
|
||||||
@ -300,7 +280,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
expect(tagService.assignTagsToNode).toHaveBeenCalledWith(node.id, [tag1, tag2]);
|
expect(tagService.assignTagsToNode).toHaveBeenCalledWith(node.id, [tag1, tag2]);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should call getTagsByNodeId on TagService on save click', fakeAsync( () => {
|
it('should call getTagsByNodeId on TagService on save click', fakeAsync(() => {
|
||||||
component.editable = true;
|
component.editable = true;
|
||||||
component.displayTags = true;
|
component.displayTags = true;
|
||||||
const property = { key: 'properties.property-key', value: 'original-value' } as CardViewBaseItemModel;
|
const property = { key: 'properties.property-key', value: 'original-value' } as CardViewBaseItemModel;
|
||||||
@ -361,7 +341,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
|
|
||||||
tick(100);
|
tick(100);
|
||||||
expect(component.node).toEqual(expectedNode);
|
expect(component.node).toEqual(expectedNode);
|
||||||
expect(contentMetadataService.openConfirmDialog).toHaveBeenCalledWith({nodeType: 'ft:poppoli'});
|
expect(contentMetadataService.openConfirmDialog).toHaveBeenCalledWith({ nodeType: 'ft:poppoli' });
|
||||||
expect(nodesApiService.updateNode).toHaveBeenCalled();
|
expect(nodesApiService.updateNode).toHaveBeenCalled();
|
||||||
discardPeriodicTasks();
|
discardPeriodicTasks();
|
||||||
}));
|
}));
|
||||||
@ -445,7 +425,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Properties loading', () => {
|
describe('Properties loading', () => {
|
||||||
let expectedNode: MinimalNode;
|
let expectedNode: Node;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
expectedNode = { ...node, name: 'some-modified-value' };
|
expectedNode = { ...node, name: 'some-modified-value' };
|
||||||
@ -537,7 +517,9 @@ describe('ContentMetadataComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
const firstGroupedPropertiesComponent = fixture.debugElement.query(By.css('.adf-metadata-grouped-properties-container adf-card-view')).componentInstance;
|
const firstGroupedPropertiesComponent = fixture.debugElement.query(
|
||||||
|
By.css('.adf-metadata-grouped-properties-container adf-card-view')
|
||||||
|
).componentInstance;
|
||||||
expect(firstGroupedPropertiesComponent.properties).toBe(expectedProperties);
|
expect(firstGroupedPropertiesComponent.properties).toBe(expectedProperties);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -553,7 +535,9 @@ describe('ContentMetadataComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
const basicPropertiesComponent = fixture.debugElement.query(By.css('.adf-metadata-grouped-properties-container adf-card-view')).componentInstance;
|
const basicPropertiesComponent = fixture.debugElement.query(
|
||||||
|
By.css('.adf-metadata-grouped-properties-container adf-card-view')
|
||||||
|
).componentInstance;
|
||||||
expect(basicPropertiesComponent.displayEmpty).toBe(false);
|
expect(basicPropertiesComponent.displayEmpty).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -575,14 +559,17 @@ describe('ContentMetadataComponent', () => {
|
|||||||
component.expanded = true;
|
component.expanded = true;
|
||||||
|
|
||||||
const cardViewGroup = {
|
const cardViewGroup = {
|
||||||
title: 'Group 1', properties: [{
|
title: 'Group 1',
|
||||||
|
properties: [
|
||||||
|
{
|
||||||
data: null,
|
data: null,
|
||||||
default: null,
|
default: null,
|
||||||
displayValue: 'DefaultName',
|
displayValue: 'DefaultName',
|
||||||
icon: '',
|
icon: '',
|
||||||
key: 'properties.cm:default',
|
key: 'properties.cm:default',
|
||||||
label: 'To'
|
label: 'To'
|
||||||
}]
|
}
|
||||||
|
]
|
||||||
};
|
};
|
||||||
spyOn(contentMetadataService, 'getGroupedProperties').and.returnValue(of([{ properties: [cardViewGroup] } as any]));
|
spyOn(contentMetadataService, 'getGroupedProperties').and.returnValue(of([{ properties: [cardViewGroup] } as any]));
|
||||||
|
|
||||||
@ -618,11 +605,10 @@ describe('ContentMetadataComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('Display properties with aspect oriented config', () => {
|
describe('Display properties with aspect oriented config', () => {
|
||||||
let appConfig: AppConfigService;
|
let appConfig: AppConfigService;
|
||||||
let classesApi: ClassesApi;
|
let classesApi: ClassesApi;
|
||||||
let expectedNode: MinimalNode;
|
let expectedNode: Node;
|
||||||
|
|
||||||
const versionableResponse: PropertyGroup = {
|
const versionableResponse: PropertyGroup = {
|
||||||
name: 'cm:versionable',
|
name: 'cm:versionable',
|
||||||
@ -697,21 +683,11 @@ describe('ContentMetadataComponent', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
appConfig = TestBed.inject(AppConfigService);
|
appConfig = TestBed.inject(AppConfigService);
|
||||||
const propertyDescriptorsService = TestBed.inject(
|
const propertyDescriptorsService = TestBed.inject(PropertyDescriptorsService);
|
||||||
PropertyDescriptorsService
|
|
||||||
);
|
|
||||||
classesApi = propertyDescriptorsService['classesApi'];
|
classesApi = propertyDescriptorsService['classesApi'];
|
||||||
expectedNode = {
|
expectedNode = {
|
||||||
...node,
|
...node,
|
||||||
aspectNames: [
|
aspectNames: ['rn:renditioned', 'cm:versionable', 'cm:titled', 'cm:auditable', 'cm:author', 'cm:thumbnailModification', 'exif:exif'],
|
||||||
'rn:renditioned',
|
|
||||||
'cm:versionable',
|
|
||||||
'cm:titled',
|
|
||||||
'cm:auditable',
|
|
||||||
'cm:author',
|
|
||||||
'cm:thumbnailModification',
|
|
||||||
'exif:exif'
|
|
||||||
],
|
|
||||||
name: 'some-modified-value',
|
name: 'some-modified-value',
|
||||||
properties: {
|
properties: {
|
||||||
'exif:pixelXDimension': 1024,
|
'exif:pixelXDimension': 1024,
|
||||||
@ -849,11 +825,15 @@ describe('ContentMetadataComponent', () => {
|
|||||||
|
|
||||||
exifProp.nativeElement.click();
|
exifProp.nativeElement.click();
|
||||||
|
|
||||||
const pixelXDimentionElement = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-label-properties.exif:pixelXDimension"]'));
|
const pixelXDimentionElement = fixture.debugElement.query(
|
||||||
|
By.css('[data-automation-id="card-textitem-label-properties.exif:pixelXDimension"]')
|
||||||
|
);
|
||||||
expect(pixelXDimentionElement).toBeTruthy();
|
expect(pixelXDimentionElement).toBeTruthy();
|
||||||
expect(pixelXDimentionElement.nativeElement.textContent.trim()).toEqual('Image Width');
|
expect(pixelXDimentionElement.nativeElement.textContent.trim()).toEqual('Image Width');
|
||||||
|
|
||||||
const pixelYDimentionElement = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-label-properties.exif:pixelYDimension"]'));
|
const pixelYDimentionElement = fixture.debugElement.query(
|
||||||
|
By.css('[data-automation-id="card-textitem-label-properties.exif:pixelYDimension"]')
|
||||||
|
);
|
||||||
expect(pixelYDimentionElement).toBeTruthy();
|
expect(pixelYDimentionElement).toBeTruthy();
|
||||||
expect(pixelYDimentionElement.nativeElement.textContent.trim()).toEqual('Image Height');
|
expect(pixelYDimentionElement.nativeElement.textContent.trim()).toEqual('Image Height');
|
||||||
});
|
});
|
||||||
@ -880,7 +860,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Expand the panel', () => {
|
describe('Expand the panel', () => {
|
||||||
let expectedNode: MinimalNode;
|
let expectedNode: Node;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
expectedNode = { ...node, name: 'some-modified-value' };
|
expectedNode = { ...node, name: 'some-modified-value' };
|
||||||
@ -948,7 +928,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
describe('events', () => {
|
describe('events', () => {
|
||||||
it('should not propagate the event on left arrows press', () => {
|
it('should not propagate the event on left arrows press', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const event = { keyCode: 37, stopPropagation: () => { } };
|
const event = { keyCode: 37, stopPropagation: () => {} };
|
||||||
spyOn(event, 'stopPropagation').and.stub();
|
spyOn(event, 'stopPropagation').and.stub();
|
||||||
const element = fixture.debugElement.query(By.css('adf-card-view'));
|
const element = fixture.debugElement.query(By.css('adf-card-view'));
|
||||||
element.triggerEventHandler('keydown', event);
|
element.triggerEventHandler('keydown', event);
|
||||||
@ -957,7 +937,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
|
|
||||||
it('should not propagate the event on right arrows press', () => {
|
it('should not propagate the event on right arrows press', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const event = { keyCode: 39, stopPropagation: () => { } };
|
const event = { keyCode: 39, stopPropagation: () => {} };
|
||||||
spyOn(event, 'stopPropagation').and.stub();
|
spyOn(event, 'stopPropagation').and.stub();
|
||||||
const element = fixture.debugElement.query(By.css('adf-card-view'));
|
const element = fixture.debugElement.query(By.css('adf-card-view'));
|
||||||
element.triggerEventHandler('keydown', event);
|
element.triggerEventHandler('keydown', event);
|
||||||
@ -966,7 +946,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
|
|
||||||
it('should propagate the event on other keys press', () => {
|
it('should propagate the event on other keys press', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const event = { keyCode: 40, stopPropagation: () => { } };
|
const event = { keyCode: 40, stopPropagation: () => {} };
|
||||||
spyOn(event, 'stopPropagation').and.stub();
|
spyOn(event, 'stopPropagation').and.stub();
|
||||||
const element = fixture.debugElement.query(By.css('adf-card-view'));
|
const element = fixture.debugElement.query(By.css('adf-card-view'));
|
||||||
element.triggerEventHandler('keydown', event);
|
element.triggerEventHandler('keydown', event);
|
||||||
@ -1141,7 +1121,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
expect(tagsCreator.disabledTagsRemoving).toBeTrue();
|
expect(tagsCreator.disabledTagsRemoving).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have assigned false to disabledTagsRemoving if forkJoin fails', fakeAsync( () => {
|
it('should have assigned false to disabledTagsRemoving if forkJoin fails', fakeAsync(() => {
|
||||||
const property = { key: 'properties.property-key', value: 'original-value' } as CardViewBaseItemModel;
|
const property = { key: 'properties.property-key', value: 'original-value' } as CardViewBaseItemModel;
|
||||||
const expectedNode = { ...node, name: 'some-modified-value' };
|
const expectedNode = { ...node, name: 'some-modified-value' };
|
||||||
spyOn(nodesApiService, 'updateNode').and.returnValue(of(expectedNode));
|
spyOn(nodesApiService, 'updateNode').and.returnValue(of(expectedNode));
|
||||||
@ -1234,7 +1214,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should render categories when ngOnChanges', () => {
|
it('should render categories when ngOnChanges', () => {
|
||||||
component.ngOnChanges({ node: new SimpleChange(undefined, node, false)});
|
component.ngOnChanges({ node: new SimpleChange(undefined, node, false) });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const categories = getCategories();
|
const categories = getCategories();
|
||||||
@ -1256,7 +1236,6 @@ describe('ContentMetadataComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not reload categories in ngOnChanges if node is not changed', () => {
|
it('should not reload categories in ngOnChanges if node is not changed', () => {
|
||||||
|
|
||||||
component.ngOnChanges({});
|
component.ngOnChanges({});
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
@ -1330,12 +1309,12 @@ describe('ContentMetadataComponent', () => {
|
|||||||
|
|
||||||
it('should clear categories and emit event when classifiable changes', (done) => {
|
it('should clear categories and emit event when classifiable changes', (done) => {
|
||||||
component.node.aspectNames = [];
|
component.node.aspectNames = [];
|
||||||
component.ngOnChanges({ node: new SimpleChange(undefined, node, false)});
|
component.ngOnChanges({ node: new SimpleChange(undefined, node, false) });
|
||||||
component.classifiableChanged.subscribe(() => {
|
component.classifiableChanged.subscribe(() => {
|
||||||
expect(component.categories).toEqual([]);
|
expect(component.categories).toEqual([]);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
component.ngOnChanges({ node: new SimpleChange(undefined, node, false)});
|
component.ngOnChanges({ node: new SimpleChange(undefined, node, false) });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should enable discard and save buttons after emitting categories change event', () => {
|
it('should enable discard and save buttons after emitting categories change event', () => {
|
||||||
@ -1357,7 +1336,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
expect(categoriesManagementComponent.disableRemoval).toBeTrue();
|
expect(categoriesManagementComponent.disableRemoval).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not disable removal if forkJoin fails', fakeAsync( () => {
|
it('should not disable removal if forkJoin fails', fakeAsync(() => {
|
||||||
const property = { key: 'properties.property-key', value: 'original-value' } as CardViewBaseItemModel;
|
const property = { key: 'properties.property-key', value: 'original-value' } as CardViewBaseItemModel;
|
||||||
const expectedNode = { ...node, name: 'some-modified-value' };
|
const expectedNode = { ...node, name: 'some-modified-value' };
|
||||||
spyOn(nodesApiService, 'updateNode').and.returnValue(of(expectedNode));
|
spyOn(nodesApiService, 'updateNode').and.returnValue(of(expectedNode));
|
||||||
@ -1393,15 +1372,15 @@ describe('ContentMetadataComponent', () => {
|
|||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(categoriesManagementComponent.categories).toEqual([ category1, category2 ]);
|
expect(categoriesManagementComponent.categories).toEqual([category1, category2]);
|
||||||
expect(categoryService.getCategoryLinksForNode).toHaveBeenCalledWith(node.id);
|
expect(categoryService.getCategoryLinksForNode).toHaveBeenCalledWith(node.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set correct tags after ngOnChanges', () => {
|
it('should set correct tags after ngOnChanges', () => {
|
||||||
component.ngOnChanges({ node: new SimpleChange(undefined, node, false)});
|
component.ngOnChanges({ node: new SimpleChange(undefined, node, false) });
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(categoriesManagementComponent.categories).toEqual([ category1, category2 ]);
|
expect(categoriesManagementComponent.categories).toEqual([category1, category2]);
|
||||||
expect(categoryService.getCategoryLinksForNode).toHaveBeenCalledWith(node.id);
|
expect(categoryService.getCategoryLinksForNode).toHaveBeenCalledWith(node.id);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -18,16 +18,7 @@
|
|||||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||||
import { ComponentFixture, fakeAsync, flush, TestBed, tick } from '@angular/core/testing';
|
import { ComponentFixture, fakeAsync, flush, TestBed, tick } from '@angular/core/testing';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import {
|
import { Node, NodeEntry, NodePaging, RequestScope, ResultSetPaging, SiteEntry, SitePaging } from '@alfresco/js-api';
|
||||||
MinimalNode,
|
|
||||||
Node,
|
|
||||||
NodeEntry,
|
|
||||||
NodePaging,
|
|
||||||
RequestScope,
|
|
||||||
ResultSetPaging,
|
|
||||||
SiteEntry,
|
|
||||||
SitePaging
|
|
||||||
} from '@alfresco/js-api';
|
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { ContentNodeSelectorPanelComponent } from './content-node-selector-panel.component';
|
import { ContentNodeSelectorPanelComponent } from './content-node-selector-panel.component';
|
||||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||||
@ -84,16 +75,12 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [TranslateModule.forRoot(), ContentTestingModule],
|
||||||
TranslateModule.forRoot(),
|
|
||||||
ContentTestingModule
|
|
||||||
],
|
|
||||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('General component features', () => {
|
describe('General component features', () => {
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
fixture = TestBed.createComponent(ContentNodeSelectorPanelComponent);
|
fixture = TestBed.createComponent(ContentNodeSelectorPanelComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
@ -105,10 +92,14 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
searchQueryBuilderService = component.queryBuilderService;
|
searchQueryBuilderService = component.queryBuilderService;
|
||||||
component.queryBuilderService.resetToDefaults();
|
component.queryBuilderService.resetToDefaults();
|
||||||
|
|
||||||
spyOn(nodeService, 'getNode').and.returnValue(of(new MinimalNode({
|
spyOn(nodeService, 'getNode').and.returnValue(
|
||||||
|
of(
|
||||||
|
new Node({
|
||||||
id: 'fake-node',
|
id: 'fake-node',
|
||||||
path: { elements: [{ nodeType: 'st:site', name: 'fake-site' }] }
|
path: { elements: [{ nodeType: 'st:site', name: 'fake-site' }] }
|
||||||
})));
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
searchSpy = spyOn(searchQueryBuilderService, 'execute');
|
searchSpy = spyOn(searchQueryBuilderService, 'execute');
|
||||||
const fakeSite = new SiteEntry({
|
const fakeSite = new SiteEntry({
|
||||||
entry: {
|
entry: {
|
||||||
@ -127,7 +118,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Search functionality', () => {
|
describe('Search functionality', () => {
|
||||||
let getCorrespondingNodeIdsSpy;
|
let getCorrespondingNodeIdsSpy: jasmine.Spy;
|
||||||
let customResourcesService: CustomResourcesService;
|
let customResourcesService: CustomResourcesService;
|
||||||
const entry: Node = { id: 'fakeid' } as Node;
|
const entry: Node = { id: 'fakeid' } as Node;
|
||||||
|
|
||||||
@ -137,19 +128,22 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
component.isSelectionValid = (node: Node) => node.isFile;
|
component.isSelectionValid = (node: Node) => node.isFile;
|
||||||
|
|
||||||
spyOn(documentListService, 'getFolderNode').and.returnValue(of(expectedDefaultFolderNode));
|
spyOn(documentListService, 'getFolderNode').and.returnValue(of(expectedDefaultFolderNode));
|
||||||
spyOn(documentListService, 'getFolder').and.returnValue(of(new NodePaging({
|
spyOn(documentListService, 'getFolder').and.returnValue(
|
||||||
|
of(
|
||||||
|
new NodePaging({
|
||||||
list: {
|
list: {
|
||||||
pagination: {},
|
pagination: {},
|
||||||
entries: [],
|
entries: [],
|
||||||
source: {}
|
source: {}
|
||||||
}
|
}
|
||||||
})));
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: { entries: [] } })));
|
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: { entries: [] } })));
|
||||||
|
|
||||||
customResourcesService = TestBed.inject(CustomResourcesService);
|
customResourcesService = TestBed.inject(CustomResourcesService);
|
||||||
getCorrespondingNodeIdsSpy = spyOn(customResourcesService, 'getCorrespondingNodeIds').and
|
getCorrespondingNodeIdsSpy = spyOn(customResourcesService, 'getCorrespondingNodeIds').and.callFake((id) => {
|
||||||
.callFake((id) => {
|
|
||||||
if (id === '-sites-') {
|
if (id === '-sites-') {
|
||||||
return of(['123456testId', '09876543testId']);
|
return of(['123456testId', '09876543testId']);
|
||||||
}
|
}
|
||||||
@ -259,14 +253,14 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
|
|
||||||
tick(debounceSearch);
|
tick(debounceSearch);
|
||||||
|
|
||||||
expect(searchSpy.calls.count()).toBe(1, 'Search count should be one after only one search');
|
expect(searchSpy.calls.count()).toBe(1);
|
||||||
|
|
||||||
component.siteChanged({ entry: { guid: 'namek' } } as SiteEntry);
|
component.siteChanged({ entry: { guid: 'namek' } } as SiteEntry);
|
||||||
|
|
||||||
const expectedQueryBody = mockQueryBody;
|
const expectedQueryBody = mockQueryBody;
|
||||||
expectedQueryBody.filterQueries = [{ query: `ANCESTOR:'workspace://SpacesStore/namek'` }];
|
expectedQueryBody.filterQueries = [{ query: `ANCESTOR:'workspace://SpacesStore/namek'` }];
|
||||||
|
|
||||||
expect(searchSpy.calls.count()).toBe(2, 'Search count should be two after the site change');
|
expect(searchSpy.calls.count()).toBe(2);
|
||||||
expect(searchSpy).toHaveBeenCalledWith(expectedQueryBody);
|
expect(searchSpy).toHaveBeenCalledWith(expectedQueryBody);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -285,7 +279,9 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
|
|
||||||
const expectedQueryBodyWithSiteChange = mockQueryBody;
|
const expectedQueryBodyWithSiteChange = mockQueryBody;
|
||||||
expectedQueryBodyWithSiteChange.filterQueries = [
|
expectedQueryBodyWithSiteChange.filterQueries = [
|
||||||
{ query: `ANCESTOR:'workspace://SpacesStore/-sites-' OR ANCESTOR:'workspace://SpacesStore/123456testId' OR ANCESTOR:'workspace://SpacesStore/09876543testId'` }
|
{
|
||||||
|
query: `ANCESTOR:'workspace://SpacesStore/-sites-' OR ANCESTOR:'workspace://SpacesStore/123456testId' OR ANCESTOR:'workspace://SpacesStore/09876543testId'`
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
expect(searchSpy).toHaveBeenCalled();
|
expect(searchSpy).toHaveBeenCalled();
|
||||||
@ -302,7 +298,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
tick(debounceSearch);
|
tick(debounceSearch);
|
||||||
|
|
||||||
component.siteChanged({ entry: { guid: '-sites-' } } as SiteEntry);
|
component.siteChanged({ entry: { guid: '-sites-' } } as SiteEntry);
|
||||||
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(1, 'getCorrespondingNodeIdsSpy calls count should be one after the site changes to known alias \'-sites\-');
|
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(1);
|
||||||
expect(getCorrespondingNodeIdsSpy.calls.mostRecent().args[0]).toEqual('-sites-');
|
expect(getCorrespondingNodeIdsSpy.calls.mostRecent().args[0]).toEqual('-sites-');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -329,7 +325,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
|
|
||||||
tick(debounceSearch);
|
tick(debounceSearch);
|
||||||
|
|
||||||
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(0, 'getCorrespondingNodeIdsSpy calls count should be 0 when no site is selected');
|
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(0);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should NOT get the corresponding node ids on search when NO known alias is selected from dropdown', fakeAsync(() => {
|
it('should NOT get the corresponding node ids on search when NO known alias is selected from dropdown', fakeAsync(() => {
|
||||||
@ -350,7 +346,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
typeToSearchBox('vegeta');
|
typeToSearchBox('vegeta');
|
||||||
tick(debounceSearch);
|
tick(debounceSearch);
|
||||||
|
|
||||||
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(0, 'getCorrespondingNodeIdsSpy should not be called');
|
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(0);
|
||||||
|
|
||||||
component.siteChanged({ entry: { guid: 'namek' } } as SiteEntry);
|
component.siteChanged({ entry: { guid: 'namek' } } as SiteEntry);
|
||||||
|
|
||||||
@ -364,8 +360,8 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
const searchIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-icon"]'));
|
const searchIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-icon"]'));
|
||||||
const clearIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-clear"]'));
|
const clearIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-clear"]'));
|
||||||
|
|
||||||
expect(searchIcon).not.toBeNull('Search icon should be in the DOM');
|
expect(searchIcon).not.toBeNull();
|
||||||
expect(clearIcon).toBeNull('Clear icon should NOT be in the DOM');
|
expect(clearIcon).toBeNull();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should show the X (clear) icon without the search icon when the search contains at least one character', fakeAsync(() => {
|
it('should show the X (clear) icon without the search icon when the search contains at least one character', fakeAsync(() => {
|
||||||
@ -378,8 +374,8 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
const searchIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-icon"]'));
|
const searchIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-icon"]'));
|
||||||
const clearIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-clear"]'));
|
const clearIcon = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-clear"]'));
|
||||||
|
|
||||||
expect(searchIcon).toBeNull('Search icon should NOT be in the DOM');
|
expect(searchIcon).toBeNull();
|
||||||
expect(clearIcon).not.toBeNull('Clear icon should be in the DOM');
|
expect(clearIcon).not.toBeNull();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should clear the search field, nodes and chosenNode when clicking on the X (clear) icon', async () => {
|
it('should clear the search field, nodes and chosenNode when clicking on the X (clear) icon', async () => {
|
||||||
@ -420,7 +416,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
spyOn(customResourcesService, 'hasCorrespondingNodeIds').and.returnValue(true);
|
spyOn(customResourcesService, 'hasCorrespondingNodeIds').and.returnValue(true);
|
||||||
const showingSearchSpy = spyOn(component.showingSearch, 'emit');
|
const showingSearchSpy = spyOn(component.showingSearch, 'emit');
|
||||||
|
|
||||||
component.queryBuilderService.execute({ query: { query: 'search' } });
|
await component.queryBuilderService.execute({ query: { query: 'search' } });
|
||||||
|
|
||||||
triggerSearchResults(fakeResultSetPaging);
|
triggerSearchResults(fakeResultSetPaging);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -464,7 +460,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
searchQueryBuilderService.update();
|
searchQueryBuilderService.update();
|
||||||
getCorrespondingNodeIdsSpy.and.throwError('Failed');
|
getCorrespondingNodeIdsSpy.and.throwError('Failed');
|
||||||
const showingSearchSpy = spyOn(component.showingSearch, 'emit');
|
const showingSearchSpy = spyOn(component.showingSearch, 'emit');
|
||||||
component.queryBuilderService.execute({ query: { query: 'search' } });
|
await component.queryBuilderService.execute({ query: { query: 'search' } });
|
||||||
|
|
||||||
triggerSearchResults(fakeResultSetPaging);
|
triggerSearchResults(fakeResultSetPaging);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -481,9 +477,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
component.siteChanged({ entry: { guid: 'my-site-id' } } as SiteEntry);
|
component.siteChanged({ entry: { guid: 'my-site-id' } } as SiteEntry);
|
||||||
|
|
||||||
const expectedQueryBodyWithSiteChange = mockQueryBody;
|
const expectedQueryBodyWithSiteChange = mockQueryBody;
|
||||||
expectedQueryBodyWithSiteChange.filterQueries = [
|
expectedQueryBodyWithSiteChange.filterQueries = [{ query: `ANCESTOR:'workspace://SpacesStore/my-site-id'` }];
|
||||||
{ query: `ANCESTOR:'workspace://SpacesStore/my-site-id'` }
|
|
||||||
];
|
|
||||||
|
|
||||||
expect(searchSpy).toHaveBeenCalledWith(expectedQueryBodyWithSiteChange);
|
expect(searchSpy).toHaveBeenCalledWith(expectedQueryBodyWithSiteChange);
|
||||||
});
|
});
|
||||||
@ -516,9 +510,9 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
tick(debounceSearch);
|
tick(debounceSearch);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(searchSpy.calls.count()).toBe(1, 'no other search has been performed');
|
expect(searchSpy.calls.count()).toBe(1);
|
||||||
expect(component.clearSearch).toHaveBeenCalled();
|
expect(component.clearSearch).toHaveBeenCalled();
|
||||||
expect(component.folderIdToShow).toBe('cat-girl-nuku-nuku', 'back to the folder in which the search was performed');
|
expect(component.folderIdToShow).toBe('cat-girl-nuku-nuku');
|
||||||
flush();
|
flush();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -558,38 +552,40 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
expect(component.folderIdToShow).toBe('namek');
|
expect(component.folderIdToShow).toBe('namek');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should show the current folder\'s content instead of search results if search was not performed', async () => {
|
it('should show the current folder content instead of search results if search was not performed', async () => {
|
||||||
const documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
const documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||||
expect(documentList).not.toBeNull('Document list should be shown');
|
expect(documentList).not.toBeNull();
|
||||||
expect(documentList.componentInstance.currentFolderId).toBe('cat-girl-nuku-nuku');
|
expect(documentList.componentInstance.currentFolderId).toBe('cat-girl-nuku-nuku');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should pass through the rowFilter to the documentList', async () => {
|
it('should pass through the rowFilter to the documentList', async () => {
|
||||||
const filter = (shareDataRow: ShareDataRow) =>
|
const filter = (shareDataRow: ShareDataRow) => shareDataRow.node.entry.name === 'impossible-name';
|
||||||
shareDataRow.node.entry.name === 'impossible-name';
|
|
||||||
|
|
||||||
component.rowFilter = filter;
|
component.rowFilter = filter;
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
const documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||||
expect(documentList).not.toBeNull('Document list should be shown');
|
expect(documentList).not.toBeNull();
|
||||||
expect(documentList.componentInstance.rowFilter({
|
expect(
|
||||||
|
documentList.componentInstance.rowFilter({
|
||||||
node: {
|
node: {
|
||||||
entry: new Node({
|
entry: new Node({
|
||||||
name: 'impossible-name',
|
name: 'impossible-name',
|
||||||
id: 'name'
|
id: 'name'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}))
|
})
|
||||||
.toBe(filter({
|
).toBe(
|
||||||
|
filter({
|
||||||
node: {
|
node: {
|
||||||
entry: new Node({
|
entry: new Node({
|
||||||
name: 'impossible-name',
|
name: 'impossible-name',
|
||||||
id: 'name'
|
id: 'name'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} as ShareDataRow));
|
} as ShareDataRow)
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should pass through the excludeSiteContent to the rowFilter of the documentList', async () => {
|
it('should pass through the excludeSiteContent to the rowFilter of the documentList', async () => {
|
||||||
@ -598,12 +594,11 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
const documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||||
expect(documentList).not.toBeNull('Document list should be shown');
|
expect(documentList).not.toBeNull();
|
||||||
expect(documentList.componentInstance.rowFilter).toBeTruthy('Document list should have had a rowFilter');
|
expect(documentList.componentInstance.rowFilter).toBeTruthy();
|
||||||
|
|
||||||
const testSiteContent = new Node({ id: 'blog-id', properties: { 'st:componentId': 'blog' } });
|
const testSiteContent = new Node({ id: 'blog-id', properties: { 'st:componentId': 'blog' } });
|
||||||
expect(documentList.componentInstance.rowFilter({ node: { entry: testSiteContent } }, null, null))
|
expect(documentList.componentInstance.rowFilter({ node: { entry: testSiteContent } }, null, null)).toBe(false);
|
||||||
.toBe(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should pass through the imageResolver to the documentList', async () => {
|
it('should pass through the imageResolver to the documentList', async () => {
|
||||||
@ -613,7 +608,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
const documentList = fixture.debugElement.query(By.directive(DocumentListComponent));
|
||||||
expect(documentList).not.toBeNull('Document list should be shown');
|
expect(documentList).not.toBeNull();
|
||||||
expect(documentList.componentInstance.imageResolver).toBe(resolver);
|
expect(documentList.componentInstance.imageResolver).toBe(resolver);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -625,7 +620,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const documentList = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-document-list"]'));
|
const documentList = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-document-list"]'));
|
||||||
expect(documentList).not.toBeNull('Document list should be shown');
|
expect(documentList).not.toBeNull();
|
||||||
expect(component.hasValidQuery).toEqual(true);
|
expect(component.hasValidQuery).toEqual(true);
|
||||||
expect(documentList.componentInstance.currentFolderId).toBeNull();
|
expect(documentList.componentInstance.currentFolderId).toBeNull();
|
||||||
done();
|
done();
|
||||||
@ -670,12 +665,12 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
|
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
const clearButton = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-clear"]'));
|
const clearButton = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-clear"]'));
|
||||||
expect(clearButton).not.toBeNull('Clear button should be in DOM');
|
expect(clearButton).not.toBeNull();
|
||||||
clearButton.triggerEventHandler('click', {});
|
clearButton.triggerEventHandler('click', {});
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const documentList = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-document-list"]'));
|
const documentList = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-document-list"]'));
|
||||||
expect(documentList).not.toBeNull('Document list should be shown');
|
expect(documentList).not.toBeNull();
|
||||||
expect(documentList.componentInstance.currentFolderId).toBe('cat-girl-nuku-nuku');
|
expect(documentList.componentInstance.currentFolderId).toBe('cat-girl-nuku-nuku');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -714,7 +709,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Pagination "Load more" button', () => {
|
describe('Pagination "Load more" button', () => {
|
||||||
|
|
||||||
it('should NOT be shown by default', () => {
|
it('should NOT be shown by default', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const pagination = fixture.debugElement.query(By.css('[data-automation-id="adf-infinite-pagination-button"]'));
|
const pagination = fixture.debugElement.query(By.css('[data-automation-id="adf-infinite-pagination-button"]'));
|
||||||
@ -745,7 +739,9 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
const spinnerSelector = By.css('[data-automation-id="content-node-selector-search-pagination"] [data-automation-id="adf-infinite-pagination-spinner"]');
|
const spinnerSelector = By.css(
|
||||||
|
'[data-automation-id="content-node-selector-search-pagination"] [data-automation-id="adf-infinite-pagination-spinner"]'
|
||||||
|
);
|
||||||
const paginationLoading = fixture.debugElement.query(spinnerSelector);
|
const paginationLoading = fixture.debugElement.query(spinnerSelector);
|
||||||
|
|
||||||
expect(paginationLoading).not.toBeNull();
|
expect(paginationLoading).not.toBeNull();
|
||||||
@ -782,6 +778,5 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -18,22 +18,8 @@
|
|||||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||||
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import {
|
import { Node, NodeEntry, NodePaging, ResultSetPaging, SiteEntry, SitePaging, UserInfo } from '@alfresco/js-api';
|
||||||
MinimalNode,
|
import { AppConfigService, DataRow, ThumbnailService, DataColumn } from '@alfresco/adf-core';
|
||||||
Node,
|
|
||||||
NodeEntry,
|
|
||||||
NodePaging,
|
|
||||||
ResultSetPaging,
|
|
||||||
SiteEntry,
|
|
||||||
SitePaging,
|
|
||||||
UserInfo
|
|
||||||
} from '@alfresco/js-api';
|
|
||||||
import {
|
|
||||||
AppConfigService,
|
|
||||||
DataRow,
|
|
||||||
ThumbnailService,
|
|
||||||
DataColumn
|
|
||||||
} from '@alfresco/adf-core';
|
|
||||||
import { ContentService } from '../common/services/content.service';
|
import { ContentService } from '../common/services/content.service';
|
||||||
import { UploadService } from '../common/services/upload.service';
|
import { UploadService } from '../common/services/upload.service';
|
||||||
import { NodesApiService } from '../common/services/nodes-api.service';
|
import { NodesApiService } from '../common/services/nodes-api.service';
|
||||||
@ -91,16 +77,12 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [TranslateModule.forRoot(), ContentTestingModule],
|
||||||
TranslateModule.forRoot(),
|
|
||||||
ContentTestingModule
|
|
||||||
],
|
|
||||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('General component features', () => {
|
describe('General component features', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(ContentNodeSelectorPanelComponent);
|
fixture = TestBed.createComponent(ContentNodeSelectorPanelComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
@ -116,10 +98,14 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
searchQueryBuilderService = component.queryBuilderService;
|
searchQueryBuilderService = component.queryBuilderService;
|
||||||
component.queryBuilderService.resetToDefaults();
|
component.queryBuilderService.resetToDefaults();
|
||||||
|
|
||||||
spyOn(nodeService, 'getNode').and.returnValue(of(new MinimalNode({
|
spyOn(nodeService, 'getNode').and.returnValue(
|
||||||
|
of(
|
||||||
|
new Node({
|
||||||
id: 'fake-node',
|
id: 'fake-node',
|
||||||
path: { elements: [{ nodeType: 'st:site', name: 'fake-site' }] }
|
path: { elements: [{ nodeType: 'st:site', name: 'fake-site' }] }
|
||||||
})));
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
const fakeSite = new SiteEntry({
|
const fakeSite = new SiteEntry({
|
||||||
entry: {
|
entry: {
|
||||||
id: 'fake-site',
|
id: 'fake-site',
|
||||||
@ -136,7 +122,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Site selection', () => {
|
describe('Site selection', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: { entries: [] } })));
|
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: { entries: [] } })));
|
||||||
component.currentFolderId = 'fake-starting-folder';
|
component.currentFolderId = 'fake-starting-folder';
|
||||||
@ -167,7 +152,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Parameters', () => {
|
describe('Parameters', () => {
|
||||||
|
|
||||||
let documentListService: DocumentListService;
|
let documentListService: DocumentListService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -175,14 +159,15 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
|
|
||||||
spyOn(documentListService, 'getFolderNode').and.returnValue(of(new NodeEntry()));
|
spyOn(documentListService, 'getFolderNode').and.returnValue(of(new NodeEntry()));
|
||||||
spyOn(documentListService, 'getFolder').and.returnValue(throwError('No results for test'));
|
spyOn(documentListService, 'getFolder').and.returnValue(throwError('No results for test'));
|
||||||
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({
|
spyOn(sitesService, 'getSites').and.returnValue(
|
||||||
|
of(
|
||||||
|
new SitePaging({
|
||||||
list: {
|
list: {
|
||||||
entries: [
|
entries: [{ entry: { guid: 'namek', id: 'namek' } }, { entry: { guid: 'blog', id: 'blog' } }]
|
||||||
{ entry: { guid: 'namek', id: 'namek' } },
|
|
||||||
{ entry: { guid: 'blog', id: 'blog' } }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
})));
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
component.currentFolderId = 'cat-girl-nuku-nuku';
|
component.currentFolderId = 'cat-girl-nuku-nuku';
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -207,8 +192,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const testSiteContent = new Node({ id: 'blog-id', properties: { 'st:componentId': 'blog' } });
|
const testSiteContent = new Node({ id: 'blog-id', properties: { 'st:componentId': 'blog' } });
|
||||||
expect(component.rowFilter({ node: { entry: testSiteContent } } as any, null, null))
|
expect(component.rowFilter({ node: { entry: testSiteContent } } as any, null, null)).toBe(false, 'did not filter out blog');
|
||||||
.toBe(false, 'did not filter out blog');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should still be able to filter out the exclude site content after rowFilter changes', () => {
|
it('should still be able to filter out the exclude site content after rowFilter changes', () => {
|
||||||
@ -227,13 +211,17 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
properties: { 'st:componentId': 'blog' },
|
properties: { 'st:componentId': 'blog' },
|
||||||
isFile: true
|
isFile: true
|
||||||
});
|
});
|
||||||
expect(component.rowFilter({ node: { entry: testSiteContent } } as any, null, null))
|
expect(component.rowFilter({ node: { entry: testSiteContent } } as any, null, null)).toBe(
|
||||||
.toBe(false, 'did not filter out blog with filterFunction1');
|
false,
|
||||||
|
'did not filter out blog with filterFunction1'
|
||||||
|
);
|
||||||
|
|
||||||
component.rowFilter = filterFunction2;
|
component.rowFilter = filterFunction2;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(component.rowFilter({ node: { entry: testSiteContent } } as any, null, null))
|
expect(component.rowFilter({ node: { entry: testSiteContent } } as any, null, null)).toBe(
|
||||||
.toBe(false, 'did not filter out blog with filterFunction2');
|
false,
|
||||||
|
'did not filter out blog with filterFunction2'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should NOT filter out any site content by default', () => {
|
it('should NOT filter out any site content by default', () => {
|
||||||
@ -245,33 +233,28 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
|
|
||||||
it('should render search input by default', () => {
|
it('should render search input by default', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(fixture.debugElement.nativeElement.querySelector('.adf-content-node-selector-content-input'))
|
expect(fixture.debugElement.nativeElement.querySelector('.adf-content-node-selector-content-input')).not.toBe(null);
|
||||||
.not.toBe(null);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not render search input if `showSearch` is false', () => {
|
it('should not render search input if `showSearch` is false', () => {
|
||||||
component.showSearch = false;
|
component.showSearch = false;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(fixture.debugElement.nativeElement.querySelector('.adf-content-node-selector-content-input'))
|
expect(fixture.debugElement.nativeElement.querySelector('.adf-content-node-selector-content-input')).toBe(null);
|
||||||
.toBe(null);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render sites list dropdown by default', () => {
|
it('should render sites list dropdown by default', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(fixture.debugElement.nativeElement.querySelector('adf-sites-dropdown'))
|
expect(fixture.debugElement.nativeElement.querySelector('adf-sites-dropdown')).not.toBe(null);
|
||||||
.not.toBe(null);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not render sites list dropdown if `showDropdownSiteList` is false', () => {
|
it('should not render sites list dropdown if `showDropdownSiteList` is false', () => {
|
||||||
component.showDropdownSiteList = false;
|
component.showDropdownSiteList = false;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(fixture.debugElement.nativeElement.querySelector('adf-sites-dropdown'))
|
expect(fixture.debugElement.nativeElement.querySelector('adf-sites-dropdown')).toBe(null);
|
||||||
.toBe(null);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Breadcrumbs', () => {
|
describe('Breadcrumbs', () => {
|
||||||
|
|
||||||
let documentListService: DocumentListService;
|
let documentListService: DocumentListService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -292,7 +275,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||||
expect(breadcrumb).not.toBeNull();
|
expect(breadcrumb).not.toBeNull();
|
||||||
expect(breadcrumb.componentInstance.folderNode).toEqual(undefined);
|
expect(breadcrumb.componentInstance.folderNode).toEqual(undefined);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not show the breadcrumb if search was performed as last action', async () => {
|
it('should not show the breadcrumb if search was performed as last action', async () => {
|
||||||
@ -314,7 +296,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||||
expect(breadcrumb).not.toBeNull();
|
expect(breadcrumb).not.toBeNull();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show the breadcrumb in search results for a valid node selection', async () => {
|
it('should show the breadcrumb in search results for a valid node selection', async () => {
|
||||||
@ -377,7 +358,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
name: 'trans-node-name',
|
name: 'trans-node-name',
|
||||||
path: { elements: [{ id: 'testId', name: 'testName' }] }
|
path: { elements: [{ id: 'testId', name: 'testName' }] }
|
||||||
};
|
};
|
||||||
component.breadcrumbTransform = (() => transformedFolderNode);
|
component.breadcrumbTransform = () => transformedFolderNode;
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
@ -391,7 +372,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Chosen node', () => {
|
describe('Chosen node', () => {
|
||||||
|
|
||||||
const entry: Node = { id: 'fakeid' } as Node;
|
const entry: Node = { id: 'fakeid' } as Node;
|
||||||
const nodePage: NodePaging = { list: { pagination: {} } };
|
const nodePage: NodePaging = { list: { pagination: {} } };
|
||||||
let hasAllowableOperations;
|
let hasAllowableOperations;
|
||||||
@ -464,7 +444,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('in the case when isSelectionValid is a custom function for checking permissions,', () => {
|
describe('in the case when isSelectionValid is a custom function for checking permissions,', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
component.isSelectionValid = returnHasPermission;
|
component.isSelectionValid = returnHasPermission;
|
||||||
});
|
});
|
||||||
@ -528,7 +507,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('in the case when isSelectionValid is null', () => {
|
describe('in the case when isSelectionValid is null', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
component.isSelectionValid = null;
|
component.isSelectionValid = null;
|
||||||
});
|
});
|
||||||
@ -579,7 +557,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('in the case when isSelectionValid is not defined', () => {
|
describe('in the case when isSelectionValid is not defined', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
component.isSelectionValid = undefined;
|
component.isSelectionValid = undefined;
|
||||||
});
|
});
|
||||||
@ -632,10 +609,13 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
const isUploadingSpy = spyOn(uploadService, 'isUploading').and.returnValue(true);
|
const isUploadingSpy = spyOn(uploadService, 'isUploading').and.returnValue(true);
|
||||||
const documentListReloadSpy = spyOn(component.documentList, 'reloadWithoutResettingSelection');
|
const documentListReloadSpy = spyOn(component.documentList, 'reloadWithoutResettingSelection');
|
||||||
|
|
||||||
const fakeFileModels = [new FileModel({
|
const fakeFileModels = [
|
||||||
|
new FileModel({
|
||||||
name: 'fake-name',
|
name: 'fake-name',
|
||||||
size: 100
|
size: 100
|
||||||
} as File), new FileModel({ name: 'fake-name-2', size: 200 } as File)];
|
} as File),
|
||||||
|
new FileModel({ name: 'fake-name-2', size: 200 } as File)
|
||||||
|
];
|
||||||
const fileUploadCompleteEvent = new FileUploadCompleteEvent(fakeFileModels[0], 1, fakeFileModels[0], 0);
|
const fileUploadCompleteEvent = new FileUploadCompleteEvent(fakeFileModels[0], 1, fakeFileModels[0], 0);
|
||||||
uploadService.fileUploadComplete.next(fileUploadCompleteEvent);
|
uploadService.fileUploadComplete.next(fileUploadCompleteEvent);
|
||||||
|
|
||||||
@ -698,11 +678,9 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
expect(component.getPreselectNodesBasedOnSelectionMode()).toEqual([]);
|
expect(component.getPreselectNodesBasedOnSelectionMode()).toEqual([]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Search panel', () => {
|
describe('Search panel', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
contentNodeSelectorPanelService.customModels = undefined;
|
contentNodeSelectorPanelService.customModels = undefined;
|
||||||
});
|
});
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import { Component, Inject, OnInit, ViewEncapsulation } from '@angular/core';
|
import { Component, Inject, OnInit, ViewEncapsulation } from '@angular/core';
|
||||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||||
import { DownloadEntry, MinimalNode } from '@alfresco/js-api';
|
import { DownloadEntry } from '@alfresco/js-api';
|
||||||
import { LogService } from '@alfresco/adf-core';
|
import { LogService } from '@alfresco/adf-core';
|
||||||
import { NodesApiService } from '../../common/services/nodes-api.service';
|
import { NodesApiService } from '../../common/services/nodes-api.service';
|
||||||
import { DownloadZipService } from './services/download-zip.service';
|
import { DownloadZipService } from './services/download-zip.service';
|
||||||
@ -31,19 +31,19 @@ import { ContentService } from '../../common/services/content.service';
|
|||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class DownloadZipDialogComponent implements OnInit {
|
export class DownloadZipDialogComponent implements OnInit {
|
||||||
|
|
||||||
// flag for async threads
|
// flag for async threads
|
||||||
cancelled = false;
|
cancelled = false;
|
||||||
downloadId: string;
|
downloadId: string;
|
||||||
|
|
||||||
constructor(private dialogRef: MatDialogRef<DownloadZipDialogComponent>,
|
constructor(
|
||||||
|
private dialogRef: MatDialogRef<DownloadZipDialogComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA)
|
@Inject(MAT_DIALOG_DATA)
|
||||||
public data: any,
|
public data: any,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private downloadZipService: DownloadZipService,
|
private downloadZipService: DownloadZipService,
|
||||||
private nodeService: NodesApiService,
|
private nodeService: NodesApiService,
|
||||||
private contentService: ContentService) {
|
private contentService: ContentService
|
||||||
}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.data && this.data.nodeIds && this.data.nodeIds.length > 0) {
|
if (this.data && this.data.nodeIds && this.data.nodeIds.length > 0) {
|
||||||
@ -63,12 +63,11 @@ export class DownloadZipDialogComponent implements OnInit {
|
|||||||
|
|
||||||
downloadZip(nodeIds: string[]) {
|
downloadZip(nodeIds: string[]) {
|
||||||
if (nodeIds && nodeIds.length > 0) {
|
if (nodeIds && nodeIds.length > 0) {
|
||||||
|
|
||||||
this.downloadZipService.createDownload({ nodeIds }).subscribe((data: DownloadEntry) => {
|
this.downloadZipService.createDownload({ nodeIds }).subscribe((data: DownloadEntry) => {
|
||||||
if (data && data.entry && data.entry.id) {
|
if (data && data.entry && data.entry.id) {
|
||||||
const url = this.contentService.getContentUrl(data.entry.id, true);
|
const url = this.contentService.getContentUrl(data.entry.id, true);
|
||||||
|
|
||||||
this.nodeService.getNode(data.entry.id).subscribe((downloadNode: MinimalNode) => {
|
this.nodeService.getNode(data.entry.id).subscribe((downloadNode) => {
|
||||||
this.logService.log(downloadNode);
|
this.logService.log(downloadNode);
|
||||||
const fileName = downloadNode.name;
|
const fileName = downloadNode.name;
|
||||||
this.downloadId = data.entry.id;
|
this.downloadId = data.entry.id;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Directive, HostListener, Input, OnChanges, Output, EventEmitter } from '@angular/core';
|
import { Directive, HostListener, Input, OnChanges, Output, EventEmitter } from '@angular/core';
|
||||||
import { SiteBody, FavoriteBody, FavoriteEntry, FavoritesApi } from '@alfresco/js-api';
|
import { FavoriteBodyCreate, FavoritesApi } from '@alfresco/js-api';
|
||||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||||
import { LibraryEntity } from '../interfaces/library-entity.interface';
|
import { LibraryEntity } from '../interfaces/library-entity.interface';
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ export class LibraryFavoriteDirective implements OnChanges {
|
|||||||
|
|
||||||
private targetLibrary = null;
|
private targetLibrary = null;
|
||||||
|
|
||||||
_favoritesApi: FavoritesApi;
|
private _favoritesApi: FavoritesApi;
|
||||||
get favoritesApi(): FavoritesApi {
|
get favoritesApi(): FavoritesApi {
|
||||||
this._favoritesApi = this._favoritesApi ?? new FavoritesApi(this.alfrescoApiService.getInstance());
|
this._favoritesApi = this._favoritesApi ?? new FavoritesApi(this.alfrescoApiService.getInstance());
|
||||||
return this._favoritesApi;
|
return this._favoritesApi;
|
||||||
@ -57,8 +57,7 @@ export class LibraryFavoriteDirective implements OnChanges {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private alfrescoApiService: AlfrescoApiService) {
|
constructor(private alfrescoApiService: AlfrescoApiService) {}
|
||||||
}
|
|
||||||
|
|
||||||
ngOnChanges(changes) {
|
ngOnChanges(changes) {
|
||||||
if (!changes.library.currentValue) {
|
if (!changes.library.currentValue) {
|
||||||
@ -87,10 +86,10 @@ export class LibraryFavoriteDirective implements OnChanges {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private addFavorite(favoriteBody: FavoriteBody) {
|
private addFavorite(favoriteBody: FavoriteBodyCreate) {
|
||||||
this.favoritesApi
|
this.favoritesApi
|
||||||
.createFavorite('-me-', favoriteBody)
|
.createFavorite('-me-', favoriteBody)
|
||||||
.then((libraryEntry: FavoriteEntry) => {
|
.then((libraryEntry) => {
|
||||||
this.targetLibrary.isFavorite = true;
|
this.targetLibrary.isFavorite = true;
|
||||||
this.toggle.emit(libraryEntry);
|
this.toggle.emit(libraryEntry);
|
||||||
})
|
})
|
||||||
@ -100,7 +99,7 @@ export class LibraryFavoriteDirective implements OnChanges {
|
|||||||
private removeFavorite(favoriteId: string) {
|
private removeFavorite(favoriteId: string) {
|
||||||
this.favoritesApi
|
this.favoritesApi
|
||||||
.deleteFavorite('-me-', favoriteId)
|
.deleteFavorite('-me-', favoriteId)
|
||||||
.then((libraryBody: SiteBody) => {
|
.then((libraryBody) => {
|
||||||
this.targetLibrary.isFavorite = false;
|
this.targetLibrary.isFavorite = false;
|
||||||
this.toggle.emit(libraryBody);
|
this.toggle.emit(libraryBody);
|
||||||
})
|
})
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
/* eslint-disable @angular-eslint/no-input-rename */
|
/* eslint-disable @angular-eslint/no-input-rename */
|
||||||
|
|
||||||
import { Directive, EventEmitter, HostListener, Input, OnChanges, Output } from '@angular/core';
|
import { Directive, EventEmitter, HostListener, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
|
||||||
import { FavoriteBody, NodeEntry, SharedLinkEntry, Node, SharedLink, FavoritesApi } from '@alfresco/js-api';
|
import { FavoriteBodyCreate, NodeEntry, SharedLinkEntry, Node, SharedLink, FavoritesApi } from '@alfresco/js-api';
|
||||||
import { Observable, from, forkJoin, of } from 'rxjs';
|
import { Observable, from, forkJoin, of } from 'rxjs';
|
||||||
import { catchError, map } from 'rxjs/operators';
|
import { catchError, map } from 'rxjs/operators';
|
||||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||||
@ -30,7 +30,7 @@ import { AlfrescoApiService } from '@alfresco/adf-core';
|
|||||||
export class NodeFavoriteDirective implements OnChanges {
|
export class NodeFavoriteDirective implements OnChanges {
|
||||||
favorites: any[] = [];
|
favorites: any[] = [];
|
||||||
|
|
||||||
_favoritesApi: FavoritesApi;
|
private _favoritesApi: FavoritesApi;
|
||||||
get favoritesApi(): FavoritesApi {
|
get favoritesApi(): FavoritesApi {
|
||||||
this._favoritesApi = this._favoritesApi ?? new FavoritesApi(this.alfrescoApiService.getInstance());
|
this._favoritesApi = this._favoritesApi ?? new FavoritesApi(this.alfrescoApiService.getInstance());
|
||||||
return this._favoritesApi;
|
return this._favoritesApi;
|
||||||
@ -41,20 +41,19 @@ export class NodeFavoriteDirective implements OnChanges {
|
|||||||
selection: NodeEntry[] = [];
|
selection: NodeEntry[] = [];
|
||||||
|
|
||||||
/** Emitted when the favorite setting is complete. */
|
/** Emitted when the favorite setting is complete. */
|
||||||
@Output() toggle: EventEmitter<any> = new EventEmitter();
|
@Output() toggle = new EventEmitter<any>();
|
||||||
|
|
||||||
/** Emitted when the favorite setting fails. */
|
/** Emitted when the favorite setting fails. */
|
||||||
@Output() error: EventEmitter<any> = new EventEmitter();
|
@Output() error = new EventEmitter<any>();
|
||||||
|
|
||||||
@HostListener('click')
|
@HostListener('click')
|
||||||
onClick() {
|
onClick() {
|
||||||
this.toggleFavorite();
|
this.toggleFavorite();
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private alfrescoApiService: AlfrescoApiService) {
|
constructor(private alfrescoApiService: AlfrescoApiService) {}
|
||||||
}
|
|
||||||
|
|
||||||
ngOnChanges(changes) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
if (!changes.selection.currentValue.length) {
|
if (!changes.selection.currentValue.length) {
|
||||||
this.favorites = [];
|
this.favorites = [];
|
||||||
|
|
||||||
@ -81,7 +80,7 @@ export class NodeFavoriteDirective implements OnChanges {
|
|||||||
|
|
||||||
forkJoin(batch).subscribe(
|
forkJoin(batch).subscribe(
|
||||||
() => {
|
() => {
|
||||||
this.favorites.map((selected) => selected.entry.isFavorite = false);
|
this.favorites.forEach((selected) => (selected.entry.isFavorite = false));
|
||||||
this.toggle.emit();
|
this.toggle.emit();
|
||||||
},
|
},
|
||||||
(error) => this.error.emit(error)
|
(error) => this.error.emit(error)
|
||||||
@ -90,12 +89,11 @@ export class NodeFavoriteDirective implements OnChanges {
|
|||||||
|
|
||||||
if (!every) {
|
if (!every) {
|
||||||
const notFavorite = this.favorites.filter((node) => !node.entry.isFavorite);
|
const notFavorite = this.favorites.filter((node) => !node.entry.isFavorite);
|
||||||
const body: FavoriteBody[] = notFavorite.map((node) => this.createFavoriteBody(node));
|
const body = notFavorite.map((node) => this.createFavoriteBody(node));
|
||||||
|
|
||||||
from(this.favoritesApi.createFavorite('-me-', body as any))
|
from(this.favoritesApi.createFavorite('-me-', body as any)).subscribe(
|
||||||
.subscribe(
|
|
||||||
() => {
|
() => {
|
||||||
notFavorite.map((selected) => selected.entry.isFavorite = true);
|
notFavorite.forEach((selected) => (selected.entry.isFavorite = true));
|
||||||
this.toggle.emit();
|
this.toggle.emit();
|
||||||
},
|
},
|
||||||
(error) => this.error.emit(error)
|
(error) => this.error.emit(error)
|
||||||
@ -105,8 +103,7 @@ export class NodeFavoriteDirective implements OnChanges {
|
|||||||
|
|
||||||
markFavoritesNodes(selection: NodeEntry[]) {
|
markFavoritesNodes(selection: NodeEntry[]) {
|
||||||
if (selection.length <= this.favorites.length) {
|
if (selection.length <= this.favorites.length) {
|
||||||
const newFavorites = this.reduce(this.favorites, selection);
|
this.favorites = this.reduce(this.favorites, selection);
|
||||||
this.favorites = newFavorites;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = this.diff(selection, this.favorites);
|
const result = this.diff(selection, this.favorites);
|
||||||
@ -125,8 +122,8 @@ export class NodeFavoriteDirective implements OnChanges {
|
|||||||
return this.favorites.every((selected) => selected.entry.isFavorite);
|
return this.favorites.every((selected) => selected.entry.isFavorite);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getProcessBatch(selection): any[] {
|
private getProcessBatch(selection: NodeEntry[]): Observable<any>[] {
|
||||||
return selection.map((selected: NodeEntry) => this.getFavorite(selected));
|
return selection.map((selected) => this.getFavorite(selected));
|
||||||
}
|
}
|
||||||
|
|
||||||
private getFavorite(selected: NodeEntry | SharedLinkEntry): Observable<any> {
|
private getFavorite(selected: NodeEntry | SharedLinkEntry): Observable<any> {
|
||||||
@ -153,7 +150,8 @@ export class NodeFavoriteDirective implements OnChanges {
|
|||||||
isFavorite: true
|
isFavorite: true
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
catchError(() => of({
|
catchError(() =>
|
||||||
|
of({
|
||||||
entry: {
|
entry: {
|
||||||
id,
|
id,
|
||||||
isFolder,
|
isFolder,
|
||||||
@ -161,14 +159,15 @@ export class NodeFavoriteDirective implements OnChanges {
|
|||||||
name,
|
name,
|
||||||
isFavorite: false
|
isFavorite: false
|
||||||
}
|
}
|
||||||
}))
|
})
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private createFavoriteBody(node): FavoriteBody {
|
private createFavoriteBody(node: NodeEntry): FavoriteBodyCreate {
|
||||||
const type = this.getNodeType(node);
|
const type = this.getNodeType(node);
|
||||||
// shared files have nodeId
|
// shared files have nodeId
|
||||||
const id = node.entry.nodeId || node.entry.id;
|
const id = node.entry['nodeId'] || node.entry.id;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
target: {
|
target: {
|
||||||
@ -179,7 +178,7 @@ export class NodeFavoriteDirective implements OnChanges {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private getNodeType(node): string {
|
private getNodeType(node: NodeEntry): string {
|
||||||
// shared could only be files
|
// shared could only be files
|
||||||
if (!node.entry.isFile && !node.entry.isFolder) {
|
if (!node.entry.isFile && !node.entry.isFolder) {
|
||||||
return 'file';
|
return 'file';
|
||||||
@ -188,15 +187,15 @@ export class NodeFavoriteDirective implements OnChanges {
|
|||||||
return node.entry.isFile ? 'file' : 'folder';
|
return node.entry.isFile ? 'file' : 'folder';
|
||||||
}
|
}
|
||||||
|
|
||||||
private diff(list, patch): any[] {
|
private diff(list: NodeEntry[], patch: any[]): NodeEntry[] {
|
||||||
const ids = patch.map((item) => item.entry.id);
|
const ids = patch.map((item) => item.entry.id);
|
||||||
|
|
||||||
return list.filter((item) => ids.includes(item.entry.id) ? null : item);
|
return list.filter((item) => (ids.includes(item.entry.id) ? null : item));
|
||||||
}
|
}
|
||||||
|
|
||||||
private reduce(patch, comparator): any[] {
|
private reduce(patch: any[], comparator: NodeEntry[]): any[] {
|
||||||
const ids = comparator.map((item) => item.entry.id);
|
const ids = comparator.map((item) => item.entry.id);
|
||||||
|
|
||||||
return patch.filter((item) => ids.includes(item.entry.id) ? item : null);
|
return patch.filter((item) => (ids.includes(item.entry.id) ? item : null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,10 @@ import {
|
|||||||
DataTableModule,
|
DataTableModule,
|
||||||
ObjectDataTableAdapter,
|
ObjectDataTableAdapter,
|
||||||
ShowHeaderMode,
|
ShowHeaderMode,
|
||||||
ThumbnailService, AppConfigService
|
ThumbnailService,
|
||||||
|
AppConfigService
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { ContentService } from '../../common/services/content.service';
|
import { ContentService } from '../../common/services/content.service';
|
||||||
|
|
||||||
import { Subject, of, throwError } from 'rxjs';
|
import { Subject, of, throwError } from 'rxjs';
|
||||||
import {
|
import {
|
||||||
FileNode,
|
FileNode,
|
||||||
@ -45,15 +45,13 @@ import {
|
|||||||
mockNode3
|
mockNode3
|
||||||
} from '../../mock';
|
} from '../../mock';
|
||||||
import { ContentActionModel } from '../models/content-action.model';
|
import { ContentActionModel } from '../models/content-action.model';
|
||||||
import { NodeMinimal, NodeMinimalEntry, NodePaging } from '../models/document-library.model';
|
|
||||||
import { ImageResolver } from './../data/image-resolver.model';
|
import { ImageResolver } from './../data/image-resolver.model';
|
||||||
import { RowFilter } from './../data/row-filter.model';
|
import { RowFilter } from './../data/row-filter.model';
|
||||||
|
|
||||||
import { DocumentListService } from './../services/document-list.service';
|
import { DocumentListService } from './../services/document-list.service';
|
||||||
import { CustomResourcesService } from './../services/custom-resources.service';
|
import { CustomResourcesService } from './../services/custom-resources.service';
|
||||||
import { DocumentListComponent } from './document-list.component';
|
import { DocumentListComponent } from './document-list.component';
|
||||||
import { ContentTestingModule } from '../../testing/content.testing.module';
|
import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||||
import { FavoritePaging, NodeEntry } from '@alfresco/js-api';
|
import { FavoritePaging, NodeEntry, NodePaging, Node } from '@alfresco/js-api';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { DocumentListModule } from '../document-list.module';
|
import { DocumentListModule } from '../document-list.module';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
@ -69,7 +67,6 @@ const mockDialog = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
describe('DocumentList', () => {
|
describe('DocumentList', () => {
|
||||||
|
|
||||||
let documentList: DocumentListComponent;
|
let documentList: DocumentListComponent;
|
||||||
let documentListService: DocumentListService;
|
let documentListService: DocumentListService;
|
||||||
let apiService: AlfrescoApiService;
|
let apiService: AlfrescoApiService;
|
||||||
@ -87,14 +84,9 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [TranslateModule.forRoot(), ContentTestingModule],
|
||||||
TranslateModule.forRoot(),
|
|
||||||
ContentTestingModule
|
|
||||||
],
|
|
||||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||||
providers: [
|
providers: [{ provide: MatDialog, useValue: mockDialog }]
|
||||||
{ provide: MatDialog, useValue: mockDialog }
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
eventMock = {
|
eventMock = {
|
||||||
preventDefault: () => {}
|
preventDefault: () => {}
|
||||||
@ -120,7 +112,9 @@ describe('DocumentList', () => {
|
|||||||
documentList.currentFolderId = 'no-node';
|
documentList.currentFolderId = 'no-node';
|
||||||
|
|
||||||
spyGetSites = spyOn(customResourcesService.sitesApi, 'listSites').and.returnValue(Promise.resolve(fakeGetSitesAnswer));
|
spyGetSites = spyOn(customResourcesService.sitesApi, 'listSites').and.returnValue(Promise.resolve(fakeGetSitesAnswer));
|
||||||
spyFavorite = spyOn(customResourcesService.favoritesApi, 'listFavorites').and.returnValue(Promise.resolve(new FavoritePaging({ list: { entries: [] } })));
|
spyFavorite = spyOn(customResourcesService.favoritesApi, 'listFavorites').and.returnValue(
|
||||||
|
Promise.resolve(new FavoritePaging({ list: { entries: [] } }))
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -128,7 +122,6 @@ describe('DocumentList', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('presets', () => {
|
describe('presets', () => {
|
||||||
|
|
||||||
const validatePreset = (keys: string[]) => {
|
const validatePreset = (keys: string[]) => {
|
||||||
const columns = documentList.data.getColumns();
|
const columns = documentList.data.getColumns();
|
||||||
expect(columns.length).toBe(keys.length);
|
expect(columns.length).toBe(keys.length);
|
||||||
@ -144,14 +137,7 @@ describe('DocumentList', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
validatePreset([
|
validatePreset(['$thumbnail', 'name', 'path', 'content.sizeInBytes', 'archivedAt', 'archivedByUser.displayName']);
|
||||||
'$thumbnail',
|
|
||||||
'name',
|
|
||||||
'path',
|
|
||||||
'content.sizeInBytes',
|
|
||||||
'archivedAt',
|
|
||||||
'archivedByUser.displayName'
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should load -sites- preset', async () => {
|
it('should load -sites- preset', async () => {
|
||||||
@ -160,11 +146,7 @@ describe('DocumentList', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
validatePreset([
|
validatePreset(['$thumbnail', 'title', 'visibility']);
|
||||||
'$thumbnail',
|
|
||||||
'title',
|
|
||||||
'visibility'
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shuld load -mysites- preset', async () => {
|
it('shuld load -mysites- preset', async () => {
|
||||||
@ -173,11 +155,7 @@ describe('DocumentList', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
validatePreset([
|
validatePreset(['$thumbnail', 'title', 'visibility']);
|
||||||
'$thumbnail',
|
|
||||||
'title',
|
|
||||||
'visibility'
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should load -favorites- preset', async () => {
|
it('should load -favorites- preset', async () => {
|
||||||
@ -186,14 +164,7 @@ describe('DocumentList', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
validatePreset([
|
validatePreset(['$thumbnail', 'name', 'path', 'content.sizeInBytes', 'modifiedAt', 'modifiedByUser.displayName']);
|
||||||
'$thumbnail',
|
|
||||||
'name',
|
|
||||||
'path',
|
|
||||||
'content.sizeInBytes',
|
|
||||||
'modifiedAt',
|
|
||||||
'modifiedByUser.displayName'
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should load -recent- preset', async () => {
|
it('should load -recent- preset', async () => {
|
||||||
@ -202,13 +173,7 @@ describe('DocumentList', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
validatePreset([
|
validatePreset(['$thumbnail', 'name', 'path', 'content.sizeInBytes', 'modifiedAt']);
|
||||||
'$thumbnail',
|
|
||||||
'name',
|
|
||||||
'path',
|
|
||||||
'content.sizeInBytes',
|
|
||||||
'modifiedAt'
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should load -sharedlinks- preset', async () => {
|
it('should load -sharedlinks- preset', async () => {
|
||||||
@ -234,13 +199,7 @@ describe('DocumentList', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
validatePreset([
|
validatePreset(['$thumbnail', 'name', 'content.sizeInBytes', 'modifiedAt', 'modifiedByUser.displayName']);
|
||||||
'$thumbnail',
|
|
||||||
'name',
|
|
||||||
'content.sizeInBytes',
|
|
||||||
'modifiedAt',
|
|
||||||
'modifiedByUser.displayName'
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -330,8 +289,7 @@ describe('DocumentList', () => {
|
|||||||
it('should call action handler with node', () => {
|
it('should call action handler with node', () => {
|
||||||
const node = new FileNode();
|
const node = new FileNode();
|
||||||
const action = new ContentActionModel();
|
const action = new ContentActionModel();
|
||||||
action.handler = () => {
|
action.handler = () => {};
|
||||||
};
|
|
||||||
|
|
||||||
spyOn(action, 'handler').and.stub();
|
spyOn(action, 'handler').and.stub();
|
||||||
|
|
||||||
@ -342,8 +300,7 @@ describe('DocumentList', () => {
|
|||||||
it('should call action handler with node and permission', () => {
|
it('should call action handler with node and permission', () => {
|
||||||
const node = new FileNode();
|
const node = new FileNode();
|
||||||
const action = new ContentActionModel();
|
const action = new ContentActionModel();
|
||||||
action.handler = () => {
|
action.handler = () => {};
|
||||||
};
|
|
||||||
action.permission = 'fake-permission';
|
action.permission = 'fake-permission';
|
||||||
spyOn(action, 'handler').and.stub();
|
spyOn(action, 'handler').and.stub();
|
||||||
|
|
||||||
@ -355,8 +312,7 @@ describe('DocumentList', () => {
|
|||||||
it('should call action execute with node if it is defined', () => {
|
it('should call action execute with node if it is defined', () => {
|
||||||
const node = new FileNode();
|
const node = new FileNode();
|
||||||
const action = new ContentActionModel();
|
const action = new ContentActionModel();
|
||||||
action.execute = () => {
|
action.execute = () => {};
|
||||||
};
|
|
||||||
spyOn(action, 'execute').and.stub();
|
spyOn(action, 'execute').and.stub();
|
||||||
|
|
||||||
documentList.executeContentAction(node, action);
|
documentList.executeContentAction(node, action);
|
||||||
@ -369,8 +325,7 @@ describe('DocumentList', () => {
|
|||||||
const node = new FileNode();
|
const node = new FileNode();
|
||||||
const action = new ContentActionModel();
|
const action = new ContentActionModel();
|
||||||
action.handler = () => deleteObservable;
|
action.handler = () => deleteObservable;
|
||||||
action.execute = () => {
|
action.execute = () => {};
|
||||||
};
|
|
||||||
spyOn(action, 'execute').and.stub();
|
spyOn(action, 'execute').and.stub();
|
||||||
|
|
||||||
documentList.executeContentAction(node, action);
|
documentList.executeContentAction(node, action);
|
||||||
@ -482,10 +437,7 @@ describe('DocumentList', () => {
|
|||||||
const documentMenu = new ContentActionModel();
|
const documentMenu = new ContentActionModel();
|
||||||
documentMenu.target = 'document';
|
documentMenu.target = 'document';
|
||||||
|
|
||||||
documentList.actions = [
|
documentList.actions = [folderMenu, documentMenu];
|
||||||
folderMenu,
|
|
||||||
documentMenu
|
|
||||||
];
|
|
||||||
|
|
||||||
let actions = documentList.getNodeActions(new FolderNode());
|
let actions = documentList.getNodeActions(new FolderNode());
|
||||||
expect(actions.length).toBe(1);
|
expect(actions.length).toBe(1);
|
||||||
@ -505,9 +457,7 @@ describe('DocumentList', () => {
|
|||||||
title: 'FileAction'
|
title: 'FileAction'
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.actions = [
|
documentList.actions = [documentMenu];
|
||||||
documentMenu
|
|
||||||
];
|
|
||||||
|
|
||||||
const nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: ['create', 'update'] } };
|
const nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: ['create', 'update'] } };
|
||||||
|
|
||||||
@ -594,9 +544,7 @@ describe('DocumentList', () => {
|
|||||||
title: 'FileAction'
|
title: 'FileAction'
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.actions = [
|
documentList.actions = [documentMenu];
|
||||||
documentMenu
|
|
||||||
];
|
|
||||||
|
|
||||||
const nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: ['create', 'update'] } };
|
const nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: ['create', 'update'] } };
|
||||||
|
|
||||||
@ -614,9 +562,7 @@ describe('DocumentList', () => {
|
|||||||
title: 'FolderAction'
|
title: 'FolderAction'
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.actions = [
|
documentList.actions = [documentMenu];
|
||||||
documentMenu
|
|
||||||
];
|
|
||||||
|
|
||||||
const nodeFile = { entry: { isFolder: true, name: 'xyz', allowableOperations: ['create', 'update'] } };
|
const nodeFile = { entry: { isFolder: true, name: 'xyz', allowableOperations: ['create', 'update'] } };
|
||||||
|
|
||||||
@ -634,9 +580,7 @@ describe('DocumentList', () => {
|
|||||||
title: 'FileAction'
|
title: 'FileAction'
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.actions = [
|
documentList.actions = [documentMenu];
|
||||||
documentMenu
|
|
||||||
];
|
|
||||||
|
|
||||||
const nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: ['create', 'update', 'delete'] } };
|
const nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: ['create', 'update', 'delete'] } };
|
||||||
|
|
||||||
@ -653,9 +597,7 @@ describe('DocumentList', () => {
|
|||||||
title: 'FileAction'
|
title: 'FileAction'
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.actions = [
|
documentList.actions = [documentMenu];
|
||||||
documentMenu
|
|
||||||
];
|
|
||||||
|
|
||||||
const nodeFile = {
|
const nodeFile = {
|
||||||
entry: {
|
entry: {
|
||||||
@ -682,9 +624,7 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
spyOn(apiService.getInstance(), 'getEcmUsername').and.returnValue('lockOwner');
|
spyOn(apiService.getInstance(), 'getEcmUsername').and.returnValue('lockOwner');
|
||||||
|
|
||||||
documentList.actions = [
|
documentList.actions = [documentMenu];
|
||||||
documentMenu
|
|
||||||
];
|
|
||||||
|
|
||||||
const nodeFile = {
|
const nodeFile = {
|
||||||
entry: {
|
entry: {
|
||||||
@ -715,9 +655,7 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
spyOn(apiService.getInstance(), 'getEcmUsername').and.returnValue('jerryTheKillerCow');
|
spyOn(apiService.getInstance(), 'getEcmUsername').and.returnValue('jerryTheKillerCow');
|
||||||
|
|
||||||
documentList.actions = [
|
documentList.actions = [documentMenu];
|
||||||
documentMenu
|
|
||||||
];
|
|
||||||
|
|
||||||
const nodeFile = {
|
const nodeFile = {
|
||||||
entry: {
|
entry: {
|
||||||
@ -747,9 +685,7 @@ describe('DocumentList', () => {
|
|||||||
title: 'FolderAction'
|
title: 'FolderAction'
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.actions = [
|
documentList.actions = [documentMenu];
|
||||||
documentMenu
|
|
||||||
];
|
|
||||||
|
|
||||||
const nodeFile = {
|
const nodeFile = {
|
||||||
entry: {
|
entry: {
|
||||||
@ -773,9 +709,7 @@ describe('DocumentList', () => {
|
|||||||
disableWithNoPermission: false
|
disableWithNoPermission: false
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.actions = [
|
documentList.actions = [documentMenu];
|
||||||
documentMenu
|
|
||||||
];
|
|
||||||
|
|
||||||
const nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: null } };
|
const nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: null } };
|
||||||
|
|
||||||
@ -793,9 +727,7 @@ describe('DocumentList', () => {
|
|||||||
disableWithNoPermission: false
|
disableWithNoPermission: false
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.actions = [
|
documentList.actions = [documentMenu];
|
||||||
documentMenu
|
|
||||||
];
|
|
||||||
|
|
||||||
const nodeFile = { entry: { isFolder: true, name: 'xyz', allowableOperations: null } };
|
const nodeFile = { entry: { isFolder: true, name: 'xyz', allowableOperations: null } };
|
||||||
|
|
||||||
@ -813,9 +745,7 @@ describe('DocumentList', () => {
|
|||||||
disableWithNoPermission: true
|
disableWithNoPermission: true
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.actions = [
|
documentList.actions = [documentMenu];
|
||||||
documentMenu
|
|
||||||
];
|
|
||||||
|
|
||||||
const nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: null } };
|
const nodeFile = { entry: { isFile: true, name: 'xyz', allowableOperations: null } };
|
||||||
|
|
||||||
@ -834,9 +764,7 @@ describe('DocumentList', () => {
|
|||||||
disableWithNoPermission: true
|
disableWithNoPermission: true
|
||||||
});
|
});
|
||||||
|
|
||||||
documentList.actions = [
|
documentList.actions = [documentMenu];
|
||||||
documentMenu
|
|
||||||
];
|
|
||||||
|
|
||||||
const nodeFile = { entry: { isFolder: true, name: 'xyz', allowableOperations: null } };
|
const nodeFile = { entry: { isFolder: true, name: 'xyz', allowableOperations: null } };
|
||||||
|
|
||||||
@ -852,7 +780,7 @@ describe('DocumentList', () => {
|
|||||||
documentButton.target = 'document';
|
documentButton.target = 'document';
|
||||||
documentList.actions = [documentButton];
|
documentList.actions = [documentButton];
|
||||||
|
|
||||||
let node = new NodeMinimalEntry();
|
let node = new NodeEntry();
|
||||||
expect(documentList.getNodeActions(node)).toEqual([]);
|
expect(documentList.getNodeActions(node)).toEqual([]);
|
||||||
|
|
||||||
node = new FileNode();
|
node = new FileNode();
|
||||||
@ -1022,7 +950,7 @@ describe('DocumentList', () => {
|
|||||||
expect(documentList.navigateTo(null)).toBeFalsy();
|
expect(documentList.navigateTo(null)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should perform navigation through corret linked folder', () => {
|
it('should perform navigation through correct linked folder', () => {
|
||||||
const linkFolder = new FolderNode();
|
const linkFolder = new FolderNode();
|
||||||
linkFolder.entry.id = 'link-folder';
|
linkFolder.entry.id = 'link-folder';
|
||||||
linkFolder.entry.nodeType = 'app:folderlink';
|
linkFolder.entry.nodeType = 'app:folderlink';
|
||||||
@ -1040,7 +968,7 @@ describe('DocumentList', () => {
|
|||||||
let called = false;
|
let called = false;
|
||||||
|
|
||||||
documentList.navigationMode = DocumentListComponent.SINGLE_CLICK_NAVIGATION;
|
documentList.navigationMode = DocumentListComponent.SINGLE_CLICK_NAVIGATION;
|
||||||
documentList.preview.subscribe(() => called = true);
|
documentList.preview.subscribe(() => (called = true));
|
||||||
|
|
||||||
documentList.onNodeClick(file);
|
documentList.onNodeClick(file);
|
||||||
expect(called).toBeFalsy();
|
expect(called).toBeFalsy();
|
||||||
@ -1065,7 +993,7 @@ describe('DocumentList', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should display folder content from loadFolder on reload if folderNode defined', () => {
|
it('should display folder content from loadFolder on reload if folderNode defined', () => {
|
||||||
documentList.folderNode = new NodeMinimal();
|
documentList.folderNode = new Node();
|
||||||
|
|
||||||
spyOn(documentList, 'loadFolder').and.callThrough();
|
spyOn(documentList, 'loadFolder').and.callThrough();
|
||||||
documentList.reload();
|
documentList.reload();
|
||||||
@ -1203,7 +1131,7 @@ describe('DocumentList', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should emit [nodeClick] event on row click', () => {
|
it('should emit [nodeClick] event on row click', () => {
|
||||||
const node = new NodeMinimalEntry();
|
const node = new NodeEntry();
|
||||||
|
|
||||||
spyOn(documentList, 'onNodeClick').and.callThrough();
|
spyOn(documentList, 'onNodeClick').and.callThrough();
|
||||||
documentList.onNodeClick(node);
|
documentList.onNodeClick(node);
|
||||||
@ -1211,7 +1139,7 @@ describe('DocumentList', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should emit node-click DOM event', () => {
|
it('should emit node-click DOM event', () => {
|
||||||
const node = new NodeMinimalEntry();
|
const node = new NodeEntry();
|
||||||
|
|
||||||
document.addEventListener('node-click', (res) => {
|
document.addEventListener('node-click', (res) => {
|
||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
@ -1221,7 +1149,7 @@ describe('DocumentList', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should emit [nodeDblClick] event on row double-click', () => {
|
it('should emit [nodeDblClick] event on row double-click', () => {
|
||||||
const node = new NodeMinimalEntry();
|
const node = new NodeEntry();
|
||||||
|
|
||||||
spyOn(documentList, 'onNodeDblClick').and.callThrough();
|
spyOn(documentList, 'onNodeDblClick').and.callThrough();
|
||||||
documentList.onNodeDblClick(node);
|
documentList.onNodeDblClick(node);
|
||||||
@ -1229,7 +1157,7 @@ describe('DocumentList', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should emit node-dblclick DOM event', () => {
|
it('should emit node-dblclick DOM event', () => {
|
||||||
const node = new NodeMinimalEntry();
|
const node = new NodeEntry();
|
||||||
|
|
||||||
document.addEventListener('node-dblclick', (res) => {
|
document.addEventListener('node-dblclick', (res) => {
|
||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
@ -1316,7 +1244,7 @@ describe('DocumentList', () => {
|
|||||||
const error = { message: '{ "error": { "statusCode": 403 } }' };
|
const error = { message: '{ "error": { "statusCode": 403 } }' };
|
||||||
|
|
||||||
documentList.currentFolderId = '1d26e465-dea3-42f3-b415-faa8364b9692';
|
documentList.currentFolderId = '1d26e465-dea3-42f3-b415-faa8364b9692';
|
||||||
documentList.folderNode = new NodeMinimal();
|
documentList.folderNode = new Node();
|
||||||
documentList.folderNode.id = '1d26e465-dea3-42f3-b415-faa8364b9692';
|
documentList.folderNode.id = '1d26e465-dea3-42f3-b415-faa8364b9692';
|
||||||
|
|
||||||
spyFolderNode.and.returnValue(of({ entry: fakeNodeWithNoPermission }));
|
spyFolderNode.and.returnValue(of({ entry: fakeNodeWithNoPermission }));
|
||||||
@ -1330,7 +1258,9 @@ describe('DocumentList', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should allow to perform navigation for virtual sources', () => {
|
it('should allow to perform navigation for virtual sources', () => {
|
||||||
spyFolderNode = spyOn(documentListService, 'loadFolderByNodeId').and.callFake(() => of(new DocumentLoaderNode(null, { list: { pagination: {} } })));
|
spyFolderNode = spyOn(documentListService, 'loadFolderByNodeId').and.callFake(() =>
|
||||||
|
of(new DocumentLoaderNode(null, { list: { pagination: {} } }))
|
||||||
|
);
|
||||||
|
|
||||||
const sources = ['-trashcan-', '-sharedlinks-', '-sites-', '-mysites-', '-favorites-', '-recent-'];
|
const sources = ['-trashcan-', '-sharedlinks-', '-sites-', '-mysites-', '-favorites-', '-recent-'];
|
||||||
const node = new FolderNode('folder');
|
const node = new FolderNode('folder');
|
||||||
@ -1502,13 +1432,17 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
documentList.ngOnChanges({ currentFolderId: new SimpleChange(undefined, 'fake-id', true) });
|
documentList.ngOnChanges({ currentFolderId: new SimpleChange(undefined, 'fake-id', true) });
|
||||||
|
|
||||||
expect(documentListService.getFolder).toHaveBeenCalledWith(null, {
|
expect(documentListService.getFolder).toHaveBeenCalledWith(
|
||||||
|
null,
|
||||||
|
{
|
||||||
where: undefined,
|
where: undefined,
|
||||||
maxItems: 25,
|
maxItems: 25,
|
||||||
skipCount: 0,
|
skipCount: 0,
|
||||||
orderBy: ['isFolder desc', 'name asc'],
|
orderBy: ['isFolder desc', 'name asc'],
|
||||||
rootFolderId: 'fake-id'
|
rootFolderId: 'fake-id'
|
||||||
}, ['test-include']);
|
},
|
||||||
|
['test-include']
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add where in the server request when present', () => {
|
it('should add where in the server request when present', () => {
|
||||||
@ -1518,13 +1452,17 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
documentList.ngOnChanges({ currentFolderId: new SimpleChange(undefined, 'fake-id', true) });
|
documentList.ngOnChanges({ currentFolderId: new SimpleChange(undefined, 'fake-id', true) });
|
||||||
|
|
||||||
expect(documentListService.getFolder).toHaveBeenCalledWith(null, {
|
expect(documentListService.getFolder).toHaveBeenCalledWith(
|
||||||
|
null,
|
||||||
|
{
|
||||||
where: '(isFolder=true)',
|
where: '(isFolder=true)',
|
||||||
maxItems: 25,
|
maxItems: 25,
|
||||||
skipCount: 0,
|
skipCount: 0,
|
||||||
orderBy: ['isFolder desc', 'name asc'],
|
orderBy: ['isFolder desc', 'name asc'],
|
||||||
rootFolderId: 'fake-id'
|
rootFolderId: 'fake-id'
|
||||||
}, ['test-include']);
|
},
|
||||||
|
['test-include']
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add orderBy in the server request', () => {
|
it('should add orderBy in the server request', () => {
|
||||||
@ -1535,13 +1473,17 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
documentList.ngOnChanges({ currentFolderId: new SimpleChange(undefined, 'fake-id', true) });
|
documentList.ngOnChanges({ currentFolderId: new SimpleChange(undefined, 'fake-id', true) });
|
||||||
|
|
||||||
expect(documentListService.getFolder).toHaveBeenCalledWith(null, {
|
expect(documentListService.getFolder).toHaveBeenCalledWith(
|
||||||
|
null,
|
||||||
|
{
|
||||||
maxItems: 25,
|
maxItems: 25,
|
||||||
skipCount: 0,
|
skipCount: 0,
|
||||||
where: null,
|
where: null,
|
||||||
orderBy: ['isFolder desc', 'size desc'],
|
orderBy: ['isFolder desc', 'size desc'],
|
||||||
rootFolderId: 'fake-id'
|
rootFolderId: 'fake-id'
|
||||||
}, ['test-include']);
|
},
|
||||||
|
['test-include']
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reset the pagination when enter in a new folder', () => {
|
it('should reset the pagination when enter in a new folder', () => {
|
||||||
@ -1553,23 +1495,31 @@ describe('DocumentList', () => {
|
|||||||
skipCount: 10
|
skipCount: 10
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(documentListService.getFolder).toHaveBeenCalledWith(null, Object({
|
expect(documentListService.getFolder).toHaveBeenCalledWith(
|
||||||
|
null,
|
||||||
|
Object({
|
||||||
maxItems: 10,
|
maxItems: 10,
|
||||||
skipCount: 10,
|
skipCount: 10,
|
||||||
orderBy: ['isFolder desc', 'name asc'],
|
orderBy: ['isFolder desc', 'name asc'],
|
||||||
rootFolderId: 'no-node',
|
rootFolderId: 'no-node',
|
||||||
where: undefined
|
where: undefined
|
||||||
}), undefined);
|
}),
|
||||||
|
undefined
|
||||||
|
);
|
||||||
|
|
||||||
documentList.onNodeClick(folder);
|
documentList.onNodeClick(folder);
|
||||||
|
|
||||||
expect(documentListService.getFolder).toHaveBeenCalledWith(null, Object({
|
expect(documentListService.getFolder).toHaveBeenCalledWith(
|
||||||
|
null,
|
||||||
|
Object({
|
||||||
maxItems: 25,
|
maxItems: 25,
|
||||||
skipCount: 0,
|
skipCount: 0,
|
||||||
orderBy: ['isFolder desc', 'name asc'],
|
orderBy: ['isFolder desc', 'name asc'],
|
||||||
rootFolderId: 'folder-id',
|
rootFolderId: 'folder-id',
|
||||||
where: undefined
|
where: undefined
|
||||||
}), undefined);
|
}),
|
||||||
|
undefined
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display fileAutoDownload dialog if node size exceeds appConfig.viewer.fileAutoDownloadSizeThresholdInMB', async () => {
|
it('should display fileAutoDownload dialog if node size exceeds appConfig.viewer.fileAutoDownloadSizeThresholdInMB', async () => {
|
||||||
@ -1581,13 +1531,15 @@ describe('DocumentList', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
documentList.navigationMode = DocumentListComponent.SINGLE_CLICK_NAVIGATION;
|
documentList.navigationMode = DocumentListComponent.SINGLE_CLICK_NAVIGATION;
|
||||||
const node = { entry: {
|
const node = {
|
||||||
|
entry: {
|
||||||
...mockNode1,
|
...mockNode1,
|
||||||
content: {
|
content: {
|
||||||
...mockNode1.content,
|
...mockNode1.content,
|
||||||
sizeInBytes: 104857600
|
sizeInBytes: 104857600
|
||||||
}
|
}
|
||||||
} };
|
}
|
||||||
|
};
|
||||||
documentList.onNodeClick(node);
|
documentList.onNodeClick(node);
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -1597,7 +1549,6 @@ describe('DocumentList', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Preselect nodes', () => {
|
describe('Preselect nodes', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(thumbnailService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_created.svg`);
|
spyOn(thumbnailService, 'getMimeTypeIcon').and.returnValue(`assets/images/ft_ic_created.svg`);
|
||||||
});
|
});
|
||||||
@ -1634,7 +1585,10 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
it('should call the datatable select row method for each preselected node', async () => {
|
it('should call the datatable select row method for each preselected node', async () => {
|
||||||
const datatableSelectRowSpy = spyOn(documentList.dataTable, 'selectRow');
|
const datatableSelectRowSpy = spyOn(documentList.dataTable, 'selectRow');
|
||||||
const fakeDatatableRows = [new ShareDataRow(mockPreselectedNodes[0], contentService, null), new ShareDataRow(mockPreselectedNodes[1], contentService, null)];
|
const fakeDatatableRows = [
|
||||||
|
new ShareDataRow(mockPreselectedNodes[0], contentService, null),
|
||||||
|
new ShareDataRow(mockPreselectedNodes[1], contentService, null)
|
||||||
|
];
|
||||||
|
|
||||||
spyOn(documentList, 'preselectRowsOfPreselectedNodes');
|
spyOn(documentList, 'preselectRowsOfPreselectedNodes');
|
||||||
documentList.preselectedRows = fakeDatatableRows;
|
documentList.preselectedRows = fakeDatatableRows;
|
||||||
@ -1665,7 +1619,10 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
it('should return only the first preselected row when selection mode is single', () => {
|
it('should return only the first preselected row when selection mode is single', () => {
|
||||||
documentList.selectionMode = 'single';
|
documentList.selectionMode = 'single';
|
||||||
const fakeDatatableRows = [new ShareDataRow(mockPreselectedNodes[0], contentService, null), new ShareDataRow(mockPreselectedNodes[1], contentService, null)];
|
const fakeDatatableRows = [
|
||||||
|
new ShareDataRow(mockPreselectedNodes[0], contentService, null),
|
||||||
|
new ShareDataRow(mockPreselectedNodes[1], contentService, null)
|
||||||
|
];
|
||||||
documentList.preselectedRows = fakeDatatableRows;
|
documentList.preselectedRows = fakeDatatableRows;
|
||||||
const preselectedRows = documentList.getPreselectedRowsBasedOnSelectionMode();
|
const preselectedRows = documentList.getPreselectedRowsBasedOnSelectionMode();
|
||||||
|
|
||||||
@ -1675,7 +1632,10 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
it('should return all the preselected rows when selection mode is multiple', () => {
|
it('should return all the preselected rows when selection mode is multiple', () => {
|
||||||
documentList.selectionMode = 'multiple';
|
documentList.selectionMode = 'multiple';
|
||||||
const fakeDatatableRows = [new ShareDataRow(mockPreselectedNodes[0], contentService, null), new ShareDataRow(mockPreselectedNodes[1], contentService, null)];
|
const fakeDatatableRows = [
|
||||||
|
new ShareDataRow(mockPreselectedNodes[0], contentService, null),
|
||||||
|
new ShareDataRow(mockPreselectedNodes[1], contentService, null)
|
||||||
|
];
|
||||||
documentList.preselectedRows = fakeDatatableRows;
|
documentList.preselectedRows = fakeDatatableRows;
|
||||||
const preselectedRows = documentList.getPreselectedRowsBasedOnSelectionMode();
|
const preselectedRows = documentList.getPreselectedRowsBasedOnSelectionMode();
|
||||||
|
|
||||||
@ -1692,7 +1652,10 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
it('should the combined selection be only the first preselected row when selection mode is single', () => {
|
it('should the combined selection be only the first preselected row when selection mode is single', () => {
|
||||||
const getSelectionFromAdapterSpy = spyOn(documentList.data, 'getSelectedRows');
|
const getSelectionFromAdapterSpy = spyOn(documentList.data, 'getSelectedRows');
|
||||||
const fakeDatatableRows = [new ShareDataRow(mockPreselectedNodes[0], contentService, null), new ShareDataRow(mockPreselectedNodes[1], contentService, null)];
|
const fakeDatatableRows = [
|
||||||
|
new ShareDataRow(mockPreselectedNodes[0], contentService, null),
|
||||||
|
new ShareDataRow(mockPreselectedNodes[1], contentService, null)
|
||||||
|
];
|
||||||
documentList.preselectedRows = fakeDatatableRows;
|
documentList.preselectedRows = fakeDatatableRows;
|
||||||
documentList.selectionMode = 'single';
|
documentList.selectionMode = 'single';
|
||||||
const selection = documentList.getSelectionBasedOnSelectionMode();
|
const selection = documentList.getSelectionBasedOnSelectionMode();
|
||||||
@ -1703,7 +1666,10 @@ describe('DocumentList', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should get the selection from the adapter when selection mode is multiple', () => {
|
it('should get the selection from the adapter when selection mode is multiple', () => {
|
||||||
const fakeDatatableRows = [new ShareDataRow(mockPreselectedNodes[0], contentService, null), new ShareDataRow(mockPreselectedNodes[1], contentService, null)];
|
const fakeDatatableRows = [
|
||||||
|
new ShareDataRow(mockPreselectedNodes[0], contentService, null),
|
||||||
|
new ShareDataRow(mockPreselectedNodes[1], contentService, null)
|
||||||
|
];
|
||||||
fakeDatatableRows[0].isSelected = true;
|
fakeDatatableRows[0].isSelected = true;
|
||||||
fakeDatatableRows[1].isSelected = false;
|
fakeDatatableRows[1].isSelected = false;
|
||||||
documentList.data.setRows(fakeDatatableRows);
|
documentList.data.setRows(fakeDatatableRows);
|
||||||
@ -1747,7 +1713,10 @@ describe('DocumentList', () => {
|
|||||||
const getRowByNodeIdSpy = spyOn(documentList.data, 'getRowByNodeId').and.callThrough();
|
const getRowByNodeIdSpy = spyOn(documentList.data, 'getRowByNodeId').and.callThrough();
|
||||||
const onNodeUnselectSpy = spyOn(documentList, 'onNodeUnselect');
|
const onNodeUnselectSpy = spyOn(documentList, 'onNodeUnselect');
|
||||||
|
|
||||||
const fakeDatatableRows = [new ShareDataRow(mockPreselectedNodes[0], contentService, null), new ShareDataRow(mockPreselectedNodes[1], contentService, null)];
|
const fakeDatatableRows = [
|
||||||
|
new ShareDataRow(mockPreselectedNodes[0], contentService, null),
|
||||||
|
new ShareDataRow(mockPreselectedNodes[1], contentService, null)
|
||||||
|
];
|
||||||
fakeDatatableRows[0].isSelected = true;
|
fakeDatatableRows[0].isSelected = true;
|
||||||
documentList.data.setRows(fakeDatatableRows);
|
documentList.data.setRows(fakeDatatableRows);
|
||||||
let selection = documentList.data.getSelectedRows();
|
let selection = documentList.data.getSelectedRows();
|
||||||
@ -1766,7 +1735,10 @@ describe('DocumentList', () => {
|
|||||||
it('should preselect the rows of the preselected nodes', () => {
|
it('should preselect the rows of the preselected nodes', () => {
|
||||||
const getRowByNodeIdSpy = spyOn(documentList.data, 'getRowByNodeId').and.callThrough();
|
const getRowByNodeIdSpy = spyOn(documentList.data, 'getRowByNodeId').and.callThrough();
|
||||||
|
|
||||||
const fakeDatatableRows = [new ShareDataRow(mockPreselectedNodes[0], contentService, null), new ShareDataRow(mockPreselectedNodes[1], contentService, null)];
|
const fakeDatatableRows = [
|
||||||
|
new ShareDataRow(mockPreselectedNodes[0], contentService, null),
|
||||||
|
new ShareDataRow(mockPreselectedNodes[1], contentService, null)
|
||||||
|
];
|
||||||
documentList.data.setRows(fakeDatatableRows);
|
documentList.data.setRows(fakeDatatableRows);
|
||||||
|
|
||||||
documentList.selectionMode = 'multiple';
|
documentList.selectionMode = 'multiple';
|
||||||
@ -1840,12 +1812,7 @@ describe('DocumentListComponent rendering', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [CustomTemplateComponent],
|
declarations: [CustomTemplateComponent],
|
||||||
imports: [
|
imports: [TranslateModule.forRoot(), ContentTestingModule, DataTableModule, DocumentListModule]
|
||||||
TranslateModule.forRoot(),
|
|
||||||
ContentTestingModule,
|
|
||||||
DataTableModule,
|
|
||||||
DocumentListModule
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
fixture = TestBed.createComponent(CustomTemplateComponent);
|
fixture = TestBed.createComponent(CustomTemplateComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
@ -1905,5 +1872,4 @@ describe('DocumentListComponent rendering', () => {
|
|||||||
const cell3 = fixture.nativeElement.querySelector('div[title="Id"][data-automation-id="Name 3"]');
|
const cell3 = fixture.nativeElement.querySelector('div[title="Id"][data-automation-id="Name 3"]');
|
||||||
expect(cell3.innerText).toBe('3');
|
expect(cell3.innerText).toBe('3');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -22,16 +22,14 @@ import { SearchHeaderQueryBuilderService } from '../../../search/services/search
|
|||||||
import { FilterSearch } from './../../../search/models/filter-search.interface';
|
import { FilterSearch } from './../../../search/models/filter-search.interface';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
import { NodePaging, MinimalNode } from '@alfresco/js-api';
|
|
||||||
import { ADF_DOCUMENT_PARENT_COMPONENT } from '../document-list.token';
|
import { ADF_DOCUMENT_PARENT_COMPONENT } from '../document-list.token';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-filter-header',
|
selector: 'adf-filter-header',
|
||||||
templateUrl: './filter-header.component.html',
|
templateUrl: './filter-header.component.html',
|
||||||
providers: [{ provide: SEARCH_QUERY_SERVICE_TOKEN, useClass: SearchHeaderQueryBuilderService}]
|
providers: [{ provide: SEARCH_QUERY_SERVICE_TOKEN, useClass: SearchHeaderQueryBuilderService }]
|
||||||
})
|
})
|
||||||
export class FilterHeaderComponent implements OnInit, OnChanges, OnDestroy {
|
export class FilterHeaderComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
|
|
||||||
/** (optional) Initial filter value to sort . */
|
/** (optional) Initial filter value to sort . */
|
||||||
@Input()
|
@Input()
|
||||||
value: any = {};
|
value: any = {};
|
||||||
@ -47,15 +45,15 @@ export class FilterHeaderComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
isFilterServiceActive: boolean;
|
isFilterServiceActive: boolean;
|
||||||
private onDestroy$ = new Subject<boolean>();
|
private onDestroy$ = new Subject<boolean>();
|
||||||
|
|
||||||
constructor(@Inject(ADF_DOCUMENT_PARENT_COMPONENT) private documentList: any,
|
constructor(
|
||||||
@Inject(SEARCH_QUERY_SERVICE_TOKEN) private searchFilterQueryBuilder: SearchHeaderQueryBuilderService) {
|
@Inject(ADF_DOCUMENT_PARENT_COMPONENT) private documentList: any,
|
||||||
|
@Inject(SEARCH_QUERY_SERVICE_TOKEN) private searchFilterQueryBuilder: SearchHeaderQueryBuilderService
|
||||||
|
) {
|
||||||
this.isFilterServiceActive = this.searchFilterQueryBuilder.isFilterServiceActive();
|
this.isFilterServiceActive = this.searchFilterQueryBuilder.isFilterServiceActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.searchFilterQueryBuilder.executed
|
this.searchFilterQueryBuilder.executed.pipe(takeUntil(this.onDestroy$)).subscribe((newNodePaging) => {
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
|
||||||
.subscribe((newNodePaging: NodePaging) => {
|
|
||||||
this.documentList.node = newNodePaging;
|
this.documentList.node = newNodePaging;
|
||||||
this.documentList.reload();
|
this.documentList.reload();
|
||||||
});
|
});
|
||||||
@ -84,24 +82,20 @@ export class FilterHeaderComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initDataPagination() {
|
initDataPagination() {
|
||||||
this.documentList.pagination
|
this.documentList.pagination.pipe(takeUntil(this.onDestroy$)).subscribe((newPagination: PaginationModel) => {
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
|
||||||
.subscribe((newPagination: PaginationModel) => {
|
|
||||||
this.searchFilterQueryBuilder.setupCurrentPagination(newPagination.maxItems, newPagination.skipCount);
|
this.searchFilterQueryBuilder.setupCurrentPagination(newPagination.maxItems, newPagination.skipCount);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initDataSorting() {
|
initDataSorting() {
|
||||||
this.documentList.sortingSubject
|
this.documentList.sortingSubject.pipe(takeUntil(this.onDestroy$)).subscribe((sorting: DataSorting[]) => {
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
|
||||||
.subscribe((sorting: DataSorting[]) => {
|
|
||||||
this.searchFilterQueryBuilder.setSorting(sorting);
|
this.searchFilterQueryBuilder.setSorting(sorting);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private configureSearchParent(currentFolderId: string) {
|
private configureSearchParent(currentFolderId: string) {
|
||||||
if (this.searchFilterQueryBuilder.isCustomSourceNode(currentFolderId)) {
|
if (this.searchFilterQueryBuilder.isCustomSourceNode(currentFolderId)) {
|
||||||
this.searchFilterQueryBuilder.getNodeIdForCustomSource(currentFolderId).subscribe((node: MinimalNode) => {
|
this.searchFilterQueryBuilder.getNodeIdForCustomSource(currentFolderId).subscribe((node) => {
|
||||||
this.initSearchHeader(node.id);
|
this.initSearchHeader(node.id);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -116,7 +110,6 @@ export class FilterHeaderComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
this.searchFilterQueryBuilder.setActiveFilter(columnKey, this.value[columnKey]);
|
this.searchFilterQueryBuilder.setActiveFilter(columnKey, this.value[columnKey]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { DataRow, ObjectUtils, ThumbnailService } from '@alfresco/adf-core';
|
import { DataRow, ObjectUtils, ThumbnailService } from '@alfresco/adf-core';
|
||||||
import { MinimalNode, NodeEntry } from '@alfresco/js-api';
|
import { Node, NodeEntry } from '@alfresco/js-api';
|
||||||
import { PermissionStyleModel } from './../models/permissions-style.model';
|
import { PermissionStyleModel } from './../models/permissions-style.model';
|
||||||
import { ContentService } from './../../common/services/content.service';
|
import { ContentService } from './../../common/services/content.service';
|
||||||
|
|
||||||
@ -38,16 +38,19 @@ export class ShareDataRow implements DataRow {
|
|||||||
this.cache = {};
|
this.cache = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private obj: NodeEntry,
|
constructor(
|
||||||
|
private obj: NodeEntry,
|
||||||
private contentService: ContentService,
|
private contentService: ContentService,
|
||||||
private permissionsStyle: PermissionStyleModel[],
|
private permissionsStyle: PermissionStyleModel[],
|
||||||
private thumbnailService?: ThumbnailService,
|
private thumbnailService?: ThumbnailService,
|
||||||
private allowDropFiles?: boolean) {
|
private allowDropFiles?: boolean
|
||||||
|
) {
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
throw new Error(ERR_OBJECT_NOT_FOUND);
|
throw new Error(ERR_OBJECT_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isDropTarget = allowDropFiles !== undefined ? this.allowDropFiles && this.checkNodeTypeAndPermissions(obj) : this.checkNodeTypeAndPermissions(obj);
|
this.isDropTarget =
|
||||||
|
allowDropFiles !== undefined ? this.allowDropFiles && this.checkNodeTypeAndPermissions(obj) : this.checkNodeTypeAndPermissions(obj);
|
||||||
if (permissionsStyle) {
|
if (permissionsStyle) {
|
||||||
this.cssClass = this.getPermissionClass(obj);
|
this.cssClass = this.getPermissionClass(obj);
|
||||||
}
|
}
|
||||||
@ -62,25 +65,25 @@ export class ShareDataRow implements DataRow {
|
|||||||
let permissionsClasses = '';
|
let permissionsClasses = '';
|
||||||
|
|
||||||
this.permissionsStyle.forEach((currentPermissionsStyle: PermissionStyleModel) => {
|
this.permissionsStyle.forEach((currentPermissionsStyle: PermissionStyleModel) => {
|
||||||
|
if (
|
||||||
if (this.applyPermissionStyleToFolder(nodeEntity.entry, currentPermissionsStyle) || this.applyPermissionStyleToFile(nodeEntity.entry, currentPermissionsStyle)) {
|
this.applyPermissionStyleToFolder(nodeEntity.entry, currentPermissionsStyle) ||
|
||||||
|
this.applyPermissionStyleToFile(nodeEntity.entry, currentPermissionsStyle)
|
||||||
|
) {
|
||||||
if (this.contentService.hasAllowableOperations(nodeEntity.entry, currentPermissionsStyle.permission)) {
|
if (this.contentService.hasAllowableOperations(nodeEntity.entry, currentPermissionsStyle.permission)) {
|
||||||
permissionsClasses += ` ${currentPermissionsStyle.css}`;
|
permissionsClasses += ` ${currentPermissionsStyle.css}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return permissionsClasses;
|
return permissionsClasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
private applyPermissionStyleToFile(node: MinimalNode, currentPermissionsStyle: PermissionStyleModel): boolean {
|
private applyPermissionStyleToFile(node: Node, currentPermissionsStyle: PermissionStyleModel): boolean {
|
||||||
return (currentPermissionsStyle.isFile && node.isFile);
|
return currentPermissionsStyle.isFile && node.isFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
private applyPermissionStyleToFolder(node: MinimalNode, currentPermissionsStyle: PermissionStyleModel): boolean {
|
private applyPermissionStyleToFolder(node: Node, currentPermissionsStyle: PermissionStyleModel): boolean {
|
||||||
return (currentPermissionsStyle.isFolder && node.isFolder);
|
return currentPermissionsStyle.isFolder && node.isFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
isFolderAndHasPermissionToUpload(nodeEntry: NodeEntry): boolean {
|
isFolderAndHasPermissionToUpload(nodeEntry: NodeEntry): boolean {
|
||||||
|
@ -1,85 +0,0 @@
|
|||||||
/*!
|
|
||||||
* @license
|
|
||||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// note: contains only limited subset of available fields
|
|
||||||
|
|
||||||
import { NodeEntry, Node } from '@alfresco/js-api';
|
|
||||||
|
|
||||||
export class NodePaging {
|
|
||||||
list: NodePagingList;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class NodePagingList {
|
|
||||||
pagination: Pagination;
|
|
||||||
entries: NodeMinimalEntry[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export class NodeMinimalEntry implements NodeEntry {
|
|
||||||
entry: NodeMinimal;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Pagination {
|
|
||||||
count: number;
|
|
||||||
hasMoreItems: boolean;
|
|
||||||
totalItems: number;
|
|
||||||
skipCount: number;
|
|
||||||
maxItems: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class NodeMinimal implements Node {
|
|
||||||
id: string;
|
|
||||||
parentId: string;
|
|
||||||
name: string;
|
|
||||||
nodeType: string;
|
|
||||||
isFolder: boolean;
|
|
||||||
isFile: boolean;
|
|
||||||
modifiedAt: Date;
|
|
||||||
modifiedByUser: UserInfo;
|
|
||||||
createdAt: Date;
|
|
||||||
createdByUser: UserInfo;
|
|
||||||
content: ContentInfo;
|
|
||||||
path: PathInfoEntity;
|
|
||||||
properties: NodeProperties = {};
|
|
||||||
aspectNames: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export class UserInfo {
|
|
||||||
displayName: string;
|
|
||||||
id: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ContentInfo {
|
|
||||||
mimeType: string;
|
|
||||||
mimeTypeName: string;
|
|
||||||
sizeInBytes: number;
|
|
||||||
encoding: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class PathInfoEntity {
|
|
||||||
elements: PathElementEntity[];
|
|
||||||
isComplete: boolean;
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class PathElementEntity {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NodeProperties {
|
|
||||||
[key: string]: any;
|
|
||||||
}
|
|
@ -43,7 +43,6 @@ export * from './services/lock.service';
|
|||||||
|
|
||||||
// models
|
// models
|
||||||
export * from './models/content-action.model';
|
export * from './models/content-action.model';
|
||||||
export * from './models/document-library.model';
|
|
||||||
export * from './models/permissions.model';
|
export * from './models/permissions.model';
|
||||||
export * from './models/permissions-style.model';
|
export * from './models/permissions-style.model';
|
||||||
export * from './models/node-action.enum';
|
export * from './models/node-action.enum';
|
||||||
|
@ -19,7 +19,7 @@ import { AlfrescoApiService, LogService, PaginationModel } from '@alfresco/adf-c
|
|||||||
import { NodesApiService } from '../../common/services/nodes-api.service';
|
import { NodesApiService } from '../../common/services/nodes-api.service';
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { MinimalNode, NodeEntry, NodePaging, NodesApi } from '@alfresco/js-api';
|
import { Node, NodeEntry, NodePaging, NodesApi } from '@alfresco/js-api';
|
||||||
import { DocumentLoaderNode } from '../models/document-folder.model';
|
import { DocumentLoaderNode } from '../models/document-folder.model';
|
||||||
import { Observable, from, throwError, forkJoin } from 'rxjs';
|
import { Observable, from, throwError, forkJoin } from 'rxjs';
|
||||||
import { catchError, map } from 'rxjs/operators';
|
import { catchError, map } from 'rxjs/operators';
|
||||||
@ -32,18 +32,18 @@ const ROOT_ID = '-root-';
|
|||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class DocumentListService implements DocumentListLoader {
|
export class DocumentListService implements DocumentListLoader {
|
||||||
|
|
||||||
private _nodesApi: NodesApi;
|
private _nodesApi: NodesApi;
|
||||||
get nodes(): NodesApi {
|
get nodes(): NodesApi {
|
||||||
this._nodesApi = this._nodesApi ?? new NodesApi(this.apiService.getInstance());
|
this._nodesApi = this._nodesApi ?? new NodesApi(this.apiService.getInstance());
|
||||||
return this._nodesApi;
|
return this._nodesApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private nodesApiService: NodesApiService,
|
constructor(
|
||||||
|
private nodesApiService: NodesApiService,
|
||||||
private apiService: AlfrescoApiService,
|
private apiService: AlfrescoApiService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private customResourcesService: CustomResourcesService) {
|
private customResourcesService: CustomResourcesService
|
||||||
}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a node.
|
* Deletes a node.
|
||||||
@ -63,9 +63,7 @@ export class DocumentListService implements DocumentListLoader {
|
|||||||
* @returns NodeEntry for the copied node
|
* @returns NodeEntry for the copied node
|
||||||
*/
|
*/
|
||||||
copyNode(nodeId: string, targetParentId: string): Observable<NodeEntry> {
|
copyNode(nodeId: string, targetParentId: string): Observable<NodeEntry> {
|
||||||
return from(this.nodes.copyNode(nodeId, { targetParentId })).pipe(
|
return from(this.nodes.copyNode(nodeId, { targetParentId })).pipe(catchError((err) => this.handleError(err)));
|
||||||
catchError((err) => this.handleError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,9 +74,7 @@ export class DocumentListService implements DocumentListLoader {
|
|||||||
* @returns NodeEntry for the moved node
|
* @returns NodeEntry for the moved node
|
||||||
*/
|
*/
|
||||||
moveNode(nodeId: string, targetParentId: string): Observable<NodeEntry> {
|
moveNode(nodeId: string, targetParentId: string): Observable<NodeEntry> {
|
||||||
return from(this.nodes.moveNode(nodeId, { targetParentId })).pipe(
|
return from(this.nodes.moveNode(nodeId, { targetParentId })).pipe(catchError((err) => this.handleError(err)));
|
||||||
catchError((err) => this.handleError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,8 +91,9 @@ export class DocumentListService implements DocumentListLoader {
|
|||||||
rootNodeId = opts.rootFolderId;
|
rootNodeId = opts.rootFolderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
const includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', 'aspectNames', ...includeFields]
|
const includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', 'aspectNames', ...includeFields].filter(
|
||||||
.filter((element, index, array) => index === array.indexOf(element));
|
(element, index, array) => index === array.indexOf(element)
|
||||||
|
);
|
||||||
|
|
||||||
const params: any = {
|
const params: any = {
|
||||||
includeSource: true,
|
includeSource: true,
|
||||||
@ -122,9 +119,7 @@ export class DocumentListService implements DocumentListLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return from(this.nodes.listNodeChildren(rootNodeId, params)).pipe(
|
return from(this.nodes.listNodeChildren(rootNodeId, params)).pipe(catchError((err) => this.handleError(err)));
|
||||||
catchError((err) => this.handleError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -134,9 +129,10 @@ export class DocumentListService implements DocumentListLoader {
|
|||||||
* @param includeFields Extra information to include (available options are "aspectNames", "isLink" and "association")
|
* @param includeFields Extra information to include (available options are "aspectNames", "isLink" and "association")
|
||||||
* @returns Details of the folder
|
* @returns Details of the folder
|
||||||
*/
|
*/
|
||||||
getNode(nodeId: string, includeFields: string[] = []): Observable<MinimalNode> {
|
getNode(nodeId: string, includeFields: string[] = []): Observable<Node> {
|
||||||
const includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', 'definition', ...includeFields]
|
const includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', 'definition', ...includeFields].filter(
|
||||||
.filter((element, index, array) => index === array.indexOf(element));
|
(element, index, array) => index === array.indexOf(element)
|
||||||
|
);
|
||||||
|
|
||||||
const opts: any = {
|
const opts: any = {
|
||||||
includeSource: true,
|
includeSource: true,
|
||||||
@ -154,17 +150,16 @@ export class DocumentListService implements DocumentListLoader {
|
|||||||
* @returns Details of the folder
|
* @returns Details of the folder
|
||||||
*/
|
*/
|
||||||
getFolderNode(nodeId: string, includeFields: string[] = []): Observable<NodeEntry> {
|
getFolderNode(nodeId: string, includeFields: string[] = []): Observable<NodeEntry> {
|
||||||
const includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', 'aspectNames', ...includeFields]
|
const includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', 'aspectNames', ...includeFields].filter(
|
||||||
.filter((element, index, array) => index === array.indexOf(element));
|
(element, index, array) => index === array.indexOf(element)
|
||||||
|
);
|
||||||
|
|
||||||
const opts: any = {
|
const opts: any = {
|
||||||
includeSource: true,
|
includeSource: true,
|
||||||
include: includeFieldsRequest
|
include: includeFieldsRequest
|
||||||
};
|
};
|
||||||
|
|
||||||
return from(this.nodes.getNode(nodeId, opts)).pipe(
|
return from(this.nodes.getNode(nodeId, opts)).pipe(catchError((err) => this.handleError(err)));
|
||||||
catchError((err) => this.handleError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isCustomSourceService(nodeId): boolean {
|
isCustomSourceService(nodeId): boolean {
|
||||||
@ -181,28 +176,43 @@ export class DocumentListService implements DocumentListLoader {
|
|||||||
* @param orderBy order by node property
|
* @param orderBy order by node property
|
||||||
* @returns Details of the folder
|
* @returns Details of the folder
|
||||||
*/
|
*/
|
||||||
loadFolderByNodeId(nodeId: string, pagination: PaginationModel, includeFields: string[], where?: string, orderBy?: string[]): Observable<DocumentLoaderNode> {
|
loadFolderByNodeId(
|
||||||
|
nodeId: string,
|
||||||
|
pagination: PaginationModel,
|
||||||
|
includeFields: string[],
|
||||||
|
where?: string,
|
||||||
|
orderBy?: string[]
|
||||||
|
): Observable<DocumentLoaderNode> {
|
||||||
if (this.customResourcesService.isCustomSource(nodeId)) {
|
if (this.customResourcesService.isCustomSource(nodeId)) {
|
||||||
return this.customResourcesService.loadFolderByNodeId(nodeId, pagination, includeFields, where).pipe(
|
return this.customResourcesService
|
||||||
map((result: any) => new DocumentLoaderNode(null, result))
|
.loadFolderByNodeId(nodeId, pagination, includeFields, where)
|
||||||
);
|
.pipe(map((result: any) => new DocumentLoaderNode(null, result)));
|
||||||
} else {
|
} else {
|
||||||
return this.retrieveDocumentNode(nodeId, pagination, includeFields, where, orderBy);
|
return this.retrieveDocumentNode(nodeId, pagination, includeFields, where, orderBy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private retrieveDocumentNode(nodeId: string, pagination: PaginationModel, includeFields: string[], where?: string, orderBy?: string[]): Observable<DocumentLoaderNode> {
|
private retrieveDocumentNode(
|
||||||
|
nodeId: string,
|
||||||
|
pagination: PaginationModel,
|
||||||
|
includeFields: string[],
|
||||||
|
where?: string,
|
||||||
|
orderBy?: string[]
|
||||||
|
): Observable<DocumentLoaderNode> {
|
||||||
return forkJoin([
|
return forkJoin([
|
||||||
this.getFolderNode(nodeId, includeFields),
|
this.getFolderNode(nodeId, includeFields),
|
||||||
this.getFolder(null, {
|
this.getFolder(
|
||||||
|
null,
|
||||||
|
{
|
||||||
maxItems: pagination.maxItems,
|
maxItems: pagination.maxItems,
|
||||||
skipCount: pagination.skipCount,
|
skipCount: pagination.skipCount,
|
||||||
orderBy,
|
orderBy,
|
||||||
rootFolderId: nodeId,
|
rootFolderId: nodeId,
|
||||||
where
|
where
|
||||||
}, includeFields)]).pipe(
|
},
|
||||||
map((results) => new DocumentLoaderNode(results[0], results[1]))
|
includeFields
|
||||||
);
|
)
|
||||||
|
]).pipe(map((results) => new DocumentLoaderNode(results[0], results[1])));
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleError(error: any) {
|
private handleError(error: any) {
|
||||||
|
@ -16,14 +16,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { CardViewBaseItemModel, UpdateNotification } from '@alfresco/adf-core';
|
import { CardViewBaseItemModel, UpdateNotification } from '@alfresco/adf-core';
|
||||||
import { MinimalNode } from '@alfresco/js-api';
|
import { Node } from '@alfresco/js-api';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
|
|
||||||
export interface BaseCardViewContentUpdate {
|
export interface BaseCardViewContentUpdate {
|
||||||
itemUpdated$: Subject<UpdateNotification>;
|
itemUpdated$: Subject<UpdateNotification>;
|
||||||
updatedAspect$: Subject<MinimalNode>;
|
updatedAspect$: Subject<Node>;
|
||||||
|
|
||||||
update(property: CardViewBaseItemModel, newValue: any);
|
update(property: CardViewBaseItemModel, newValue: any);
|
||||||
updateElement(notification: CardViewBaseItemModel);
|
updateElement(notification: CardViewBaseItemModel);
|
||||||
updateNodeAspect(node: MinimalNode);
|
updateNodeAspect(node: Node);
|
||||||
}
|
}
|
||||||
|
@ -15,85 +15,75 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { ContentInfo, Node, NodeEntry, PathInfo } from '@alfresco/js-api';
|
||||||
ContentInfo,
|
|
||||||
NodeMinimal,
|
|
||||||
NodeMinimalEntry,
|
|
||||||
NodePaging,
|
|
||||||
NodePagingList,
|
|
||||||
PathInfoEntity
|
|
||||||
} from '../document-list';
|
|
||||||
|
|
||||||
export class PageNode extends NodePaging {
|
export class FileNode extends NodeEntry {
|
||||||
constructor(entries?: NodeMinimalEntry[]) {
|
|
||||||
super();
|
|
||||||
this.list = new NodePagingList();
|
|
||||||
this.list.entries = entries || [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class FileNode extends NodeMinimalEntry {
|
|
||||||
constructor(name?: string, mimeType?: string, id?: string) {
|
constructor(name?: string, mimeType?: string, id?: string) {
|
||||||
super();
|
super();
|
||||||
this.entry = new NodeMinimal();
|
this.entry = new Node();
|
||||||
this.entry.id = id || 'file-id';
|
this.entry.id = id || 'file-id';
|
||||||
this.entry.isFile = true;
|
this.entry.isFile = true;
|
||||||
this.entry.isFolder = false;
|
this.entry.isFolder = false;
|
||||||
this.entry.name = name;
|
this.entry.name = name;
|
||||||
this.entry.path = new PathInfoEntity();
|
this.entry.path = new PathInfo();
|
||||||
this.entry.content = new ContentInfo();
|
this.entry.content = new ContentInfo();
|
||||||
this.entry.content.mimeType = mimeType || 'text/plain';
|
this.entry.content.mimeType = mimeType || 'text/plain';
|
||||||
|
this.entry.properties = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class FolderNode extends NodeMinimalEntry {
|
export class FolderNode extends NodeEntry {
|
||||||
constructor(name?: string) {
|
constructor(name?: string) {
|
||||||
super();
|
super();
|
||||||
this.entry = new NodeMinimal();
|
this.entry = new Node();
|
||||||
this.entry.id = 'folder-id';
|
this.entry.id = 'folder-id';
|
||||||
this.entry.isFile = false;
|
this.entry.isFile = false;
|
||||||
this.entry.isFolder = true;
|
this.entry.isFolder = true;
|
||||||
this.entry.name = name;
|
this.entry.name = name;
|
||||||
this.entry.path = new PathInfoEntity();
|
this.entry.path = new PathInfo();
|
||||||
this.entry.aspectNames = ['cm:folder'];
|
this.entry.aspectNames = ['cm:folder'];
|
||||||
|
this.entry.properties = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SmartFolderNode extends NodeMinimalEntry {
|
export class SmartFolderNode extends NodeEntry {
|
||||||
constructor(name?: string) {
|
constructor(name?: string) {
|
||||||
super();
|
super();
|
||||||
this.entry = new NodeMinimal();
|
this.entry = new Node();
|
||||||
this.entry.id = 'smart-folder-id';
|
this.entry.id = 'smart-folder-id';
|
||||||
this.entry.isFile = false;
|
this.entry.isFile = false;
|
||||||
this.entry.isFolder = true;
|
this.entry.isFolder = true;
|
||||||
this.entry.name = name;
|
this.entry.name = name;
|
||||||
this.entry.path = new PathInfoEntity();
|
this.entry.path = new PathInfo();
|
||||||
this.entry.aspectNames = ['smf:systemConfigSmartFolder'];
|
this.entry.aspectNames = ['smf:systemConfigSmartFolder'];
|
||||||
|
this.entry.properties = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class RuleFolderNode extends NodeMinimalEntry {
|
export class RuleFolderNode extends NodeEntry {
|
||||||
constructor(name?: string) {
|
constructor(name?: string) {
|
||||||
super();
|
super();
|
||||||
this.entry = new NodeMinimal();
|
this.entry = new Node();
|
||||||
this.entry.id = 'rule-folder-id';
|
this.entry.id = 'rule-folder-id';
|
||||||
this.entry.isFile = false;
|
this.entry.isFile = false;
|
||||||
this.entry.isFolder = true;
|
this.entry.isFolder = true;
|
||||||
this.entry.name = name;
|
this.entry.name = name;
|
||||||
this.entry.path = new PathInfoEntity();
|
this.entry.path = new PathInfo();
|
||||||
this.entry.aspectNames = ['rule:rules'];
|
this.entry.aspectNames = ['rule:rules'];
|
||||||
|
this.entry.properties = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class LinkFolderNode extends NodeMinimalEntry {
|
export class LinkFolderNode extends NodeEntry {
|
||||||
constructor(name?: string) {
|
constructor(name?: string) {
|
||||||
super();
|
super();
|
||||||
this.entry = new NodeMinimal();
|
this.entry = new Node();
|
||||||
this.entry.id = 'link-folder-id';
|
this.entry.id = 'link-folder-id';
|
||||||
this.entry.isFile = false;
|
this.entry.isFile = false;
|
||||||
this.entry.isFolder = true;
|
this.entry.isFolder = true;
|
||||||
this.entry.nodeType = 'app:folderlink';
|
this.entry.nodeType = 'app:folderlink';
|
||||||
this.entry.name = name;
|
this.entry.name = name;
|
||||||
this.entry.path = new PathInfoEntity();
|
this.entry.path = new PathInfo();
|
||||||
|
this.entry.properties = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { MinimalNodeEntryEntity, Version, NodeChildAssociation, Node } from '@alfresco/js-api';
|
import { Version, NodeChildAssociation, Node } from '@alfresco/js-api';
|
||||||
import { NodeEntityEvent } from '../../document-list';
|
import { NodeEntityEvent } from '../../document-list';
|
||||||
|
|
||||||
export interface NewVersionUploaderDialogData {
|
export interface NewVersionUploaderDialogData {
|
||||||
title?: string;
|
title?: string;
|
||||||
node: MinimalNodeEntryEntity;
|
node: Node;
|
||||||
file?: File;
|
file?: File;
|
||||||
currentVersion?: Version;
|
currentVersion?: Version;
|
||||||
showVersionsOnly?: boolean;
|
showVersionsOnly?: boolean;
|
||||||
|
@ -34,11 +34,10 @@ import {
|
|||||||
fakeSiteRoles
|
fakeSiteRoles
|
||||||
} from '../../../mock/permission-list.component.mock';
|
} from '../../../mock/permission-list.component.mock';
|
||||||
import { ContentTestingModule } from '../../../testing/content.testing.module';
|
import { ContentTestingModule } from '../../../testing/content.testing.module';
|
||||||
import { MinimalNode } from '@alfresco/js-api';
|
import { Node } from '@alfresco/js-api';
|
||||||
import { NodesApiService } from '../../../common/services/nodes-api.service';
|
import { NodesApiService } from '../../../common/services/nodes-api.service';
|
||||||
|
|
||||||
describe('PermissionListComponent', () => {
|
describe('PermissionListComponent', () => {
|
||||||
|
|
||||||
let fixture: ComponentFixture<PermissionListComponent>;
|
let fixture: ComponentFixture<PermissionListComponent>;
|
||||||
let component: PermissionListComponent;
|
let component: PermissionListComponent;
|
||||||
let element: HTMLElement;
|
let element: HTMLElement;
|
||||||
@ -51,10 +50,7 @@ describe('PermissionListComponent', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [TranslateModule.forRoot(), ContentTestingModule]
|
||||||
TranslateModule.forRoot(),
|
|
||||||
ContentTestingModule
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
fixture = TestBed.createComponent(PermissionListComponent);
|
fixture = TestBed.createComponent(PermissionListComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
@ -122,10 +118,10 @@ describe('PermissionListComponent', () => {
|
|||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
expect(element.querySelector('.adf-inherit-container .mat-checked')).toBeDefined();
|
expect(element.querySelector('.adf-inherit-container .mat-checked')).toBeDefined();
|
||||||
expect(element.querySelector('.adf-inherit-container h3').textContent.trim())
|
expect(element.querySelector('.adf-inherit-container h3').textContent.trim()).toBe(
|
||||||
.toBe('PERMISSION_MANAGER.LABELS.INHERITED-PERMISSIONS PERMISSION_MANAGER.LABELS.ON');
|
'PERMISSION_MANAGER.LABELS.INHERITED-PERMISSIONS PERMISSION_MANAGER.LABELS.ON'
|
||||||
expect(element.querySelector('span[title="total"]').textContent.trim())
|
);
|
||||||
.toBe('PERMISSION_MANAGER.LABELS.INHERITED-SUBTITLE');
|
expect(element.querySelector('span[title="total"]').textContent.trim()).toBe('PERMISSION_MANAGER.LABELS.INHERITED-SUBTITLE');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should toggle the inherited button', async () => {
|
it('should toggle the inherited button', async () => {
|
||||||
@ -135,10 +131,10 @@ describe('PermissionListComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(element.querySelector('.adf-inherit-container .mat-checked')).toBeDefined();
|
expect(element.querySelector('.adf-inherit-container .mat-checked')).toBeDefined();
|
||||||
expect(element.querySelector('.adf-inherit-container h3').textContent.trim())
|
expect(element.querySelector('.adf-inherit-container h3').textContent.trim()).toBe(
|
||||||
.toBe('PERMISSION_MANAGER.LABELS.INHERITED-PERMISSIONS PERMISSION_MANAGER.LABELS.ON');
|
'PERMISSION_MANAGER.LABELS.INHERITED-PERMISSIONS PERMISSION_MANAGER.LABELS.ON'
|
||||||
expect(element.querySelector('span[title="total"]').textContent.trim())
|
);
|
||||||
.toBe('PERMISSION_MANAGER.LABELS.INHERITED-SUBTITLE');
|
expect(element.querySelector('span[title="total"]').textContent.trim()).toBe('PERMISSION_MANAGER.LABELS.INHERITED-SUBTITLE');
|
||||||
|
|
||||||
spyOn(nodeService, 'updateNode').and.returnValue(of(fakeLocalPermission));
|
spyOn(nodeService, 'updateNode').and.returnValue(of(fakeLocalPermission));
|
||||||
|
|
||||||
@ -148,10 +144,10 @@ describe('PermissionListComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(element.querySelector('.adf-inherit-container .mat-checked')).toBe(null);
|
expect(element.querySelector('.adf-inherit-container .mat-checked')).toBe(null);
|
||||||
expect(element.querySelector('.adf-inherit-container h3').textContent.trim())
|
expect(element.querySelector('.adf-inherit-container h3').textContent.trim()).toBe(
|
||||||
.toBe('PERMISSION_MANAGER.LABELS.INHERITED-PERMISSIONS PERMISSION_MANAGER.LABELS.OFF');
|
'PERMISSION_MANAGER.LABELS.INHERITED-PERMISSIONS PERMISSION_MANAGER.LABELS.OFF'
|
||||||
expect(element.querySelector('span[title="total"]').textContent.trim())
|
);
|
||||||
.toBe('PERMISSION_MANAGER.LABELS.INHERITED-SUBTITLE');
|
expect(element.querySelector('span[title="total"]').textContent.trim()).toBe('PERMISSION_MANAGER.LABELS.INHERITED-SUBTITLE');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not toggle inherited button for read only users', async () => {
|
it('should not toggle inherited button for read only users', async () => {
|
||||||
@ -162,10 +158,10 @@ describe('PermissionListComponent', () => {
|
|||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
expect(element.querySelector('.adf-inherit-container .mat-checked')).toBeDefined();
|
expect(element.querySelector('.adf-inherit-container .mat-checked')).toBeDefined();
|
||||||
expect(element.querySelector('.adf-inherit-container h3').textContent.trim())
|
expect(element.querySelector('.adf-inherit-container h3').textContent.trim()).toBe(
|
||||||
.toBe('PERMISSION_MANAGER.LABELS.INHERITED-PERMISSIONS PERMISSION_MANAGER.LABELS.ON');
|
'PERMISSION_MANAGER.LABELS.INHERITED-PERMISSIONS PERMISSION_MANAGER.LABELS.ON'
|
||||||
expect(element.querySelector('span[title="total"]').textContent.trim())
|
);
|
||||||
.toBe('PERMISSION_MANAGER.LABELS.INHERITED-SUBTITLE');
|
expect(element.querySelector('span[title="total"]').textContent.trim()).toBe('PERMISSION_MANAGER.LABELS.INHERITED-SUBTITLE');
|
||||||
|
|
||||||
spyOn(nodeService, 'updateNode').and.returnValue(of(fakeLocalPermission));
|
spyOn(nodeService, 'updateNode').and.returnValue(of(fakeLocalPermission));
|
||||||
|
|
||||||
@ -176,14 +172,12 @@ describe('PermissionListComponent', () => {
|
|||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
expect(element.querySelector('.adf-inherit-container .mat-checked')).toBeDefined();
|
expect(element.querySelector('.adf-inherit-container .mat-checked')).toBeDefined();
|
||||||
expect(element.querySelector('.adf-inherit-container h3').textContent.trim())
|
expect(element.querySelector('.adf-inherit-container h3').textContent.trim()).toBe(
|
||||||
.toBe('PERMISSION_MANAGER.LABELS.INHERITED-PERMISSIONS PERMISSION_MANAGER.LABELS.ON');
|
'PERMISSION_MANAGER.LABELS.INHERITED-PERMISSIONS PERMISSION_MANAGER.LABELS.ON'
|
||||||
expect(element.querySelector('span[title="total"]').textContent.trim())
|
);
|
||||||
.toBe('PERMISSION_MANAGER.LABELS.INHERITED-SUBTITLE');
|
expect(element.querySelector('span[title="total"]').textContent.trim()).toBe('PERMISSION_MANAGER.LABELS.INHERITED-SUBTITLE');
|
||||||
expect(document.querySelector('.adf-snackbar-message-content').textContent)
|
expect(document.querySelector('.adf-snackbar-message-content').textContent).toContain('PERMISSION_MANAGER.ERROR.NOT-ALLOWED');
|
||||||
.toContain('PERMISSION_MANAGER.ERROR.NOT-ALLOWED');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('locally set permission', () => {
|
describe('locally set permission', () => {
|
||||||
@ -212,7 +206,7 @@ describe('PermissionListComponent', () => {
|
|||||||
expect(element.querySelector('adf-user-name-column').textContent).toContain('GROUP_EVERYONE');
|
expect(element.querySelector('adf-user-name-column').textContent).toContain('GROUP_EVERYONE');
|
||||||
expect(element.querySelector('#adf-select-role-permission').textContent).toContain('Contributor');
|
expect(element.querySelector('#adf-select-role-permission').textContent).toContain('Contributor');
|
||||||
|
|
||||||
const selectBox = fixture.debugElement.query(By.css(('[id="adf-select-role-permission"] .mat-select-trigger')));
|
const selectBox = fixture.debugElement.query(By.css('[id="adf-select-role-permission"] .mat-select-trigger'));
|
||||||
selectBox.triggerEventHandler('click', null);
|
selectBox.triggerEventHandler('click', null);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
@ -234,14 +228,16 @@ describe('PermissionListComponent', () => {
|
|||||||
|
|
||||||
expect(element.querySelector('adf-user-name-column').textContent).toContain('GROUP_site_testsite_SiteManager');
|
expect(element.querySelector('adf-user-name-column').textContent).toContain('GROUP_site_testsite_SiteManager');
|
||||||
expect(element.querySelector('#adf-select-role-permission').textContent).toContain('ADF.ROLES.SITEMANAGER');
|
expect(element.querySelector('#adf-select-role-permission').textContent).toContain('ADF.ROLES.SITEMANAGER');
|
||||||
const deleteButton = element.querySelector<HTMLButtonElement>('[data-automation-id="adf-delete-permission-button-GROUP_site_testsite_SiteManager"]');
|
const deleteButton = element.querySelector<HTMLButtonElement>(
|
||||||
|
'[data-automation-id="adf-delete-permission-button-GROUP_site_testsite_SiteManager"]'
|
||||||
|
);
|
||||||
expect(deleteButton.disabled).toBe(true);
|
expect(deleteButton.disabled).toBe(true);
|
||||||
const otherDeleteButton = element.querySelector<HTMLButtonElement>('[data-automation-id="adf-delete-permission-button-superadminuser"]');
|
const otherDeleteButton = element.querySelector<HTMLButtonElement>('[data-automation-id="adf-delete-permission-button-superadminuser"]');
|
||||||
expect(otherDeleteButton.disabled).toBe(false);
|
expect(otherDeleteButton.disabled).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update the role when another value is chosen', async () => {
|
it('should update the role when another value is chosen', async () => {
|
||||||
spyOn(nodeService, 'updateNode').and.returnValue(of(new MinimalNode({id: 'fake-uwpdated-node'})));
|
spyOn(nodeService, 'updateNode').and.returnValue(of(new Node({ id: 'fake-uwpdated-node' })));
|
||||||
searchQuerySpy.and.returnValue(of(fakeEmptyResponse));
|
searchQuerySpy.and.returnValue(of(fakeEmptyResponse));
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
|
|
||||||
@ -251,7 +247,7 @@ describe('PermissionListComponent', () => {
|
|||||||
expect(element.querySelector('adf-user-name-column').textContent).toContain('GROUP_EVERYONE');
|
expect(element.querySelector('adf-user-name-column').textContent).toContain('GROUP_EVERYONE');
|
||||||
expect(element.querySelector('#adf-select-role-permission').textContent).toContain('Contributor');
|
expect(element.querySelector('#adf-select-role-permission').textContent).toContain('Contributor');
|
||||||
|
|
||||||
const selectBox = fixture.debugElement.query(By.css(('[id="adf-select-role-permission"] .mat-select-trigger')));
|
const selectBox = fixture.debugElement.query(By.css('[id="adf-select-role-permission"] .mat-select-trigger'));
|
||||||
selectBox.triggerEventHandler('click', null);
|
selectBox.triggerEventHandler('click', null);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const options = fixture.debugElement.queryAll(By.css('mat-option'));
|
const options = fixture.debugElement.queryAll(By.css('mat-option'));
|
||||||
@ -259,11 +255,13 @@ describe('PermissionListComponent', () => {
|
|||||||
expect(options.length).toBe(5);
|
expect(options.length).toBe(5);
|
||||||
options[3].triggerEventHandler('click', {});
|
options[3].triggerEventHandler('click', {});
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(nodeService.updateNode).toHaveBeenCalledWith('f472543f-7218-403d-917b-7a5861257244', { permissions: { locallySet: [ { accessStatus: 'ALLOWED', name: 'Editor', authorityId: 'GROUP_EVERYONE' } ] } });
|
expect(nodeService.updateNode).toHaveBeenCalledWith('f472543f-7218-403d-917b-7a5861257244', {
|
||||||
|
permissions: { locallySet: [{ accessStatus: 'ALLOWED', name: 'Editor', authorityId: 'GROUP_EVERYONE' }] }
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should delete the person', async () => {
|
it('should delete the person', async () => {
|
||||||
spyOn(nodeService, 'updateNode').and.returnValue(of(new MinimalNode({id: 'fake-uwpdated-node'})));
|
spyOn(nodeService, 'updateNode').and.returnValue(of(new Node({ id: 'fake-uwpdated-node' })));
|
||||||
searchQuerySpy.and.returnValue(of(fakeEmptyResponse));
|
searchQuerySpy.and.returnValue(of(fakeEmptyResponse));
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
|
|
||||||
@ -277,8 +275,7 @@ describe('PermissionListComponent', () => {
|
|||||||
deleteButton.click();
|
deleteButton.click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(nodeService.updateNode).toHaveBeenCalledWith('f472543f-7218-403d-917b-7a5861257244', { permissions: { locallySet: [ ] } });
|
expect(nodeService.updateNode).toHaveBeenCalledWith('f472543f-7218-403d-917b-7a5861257244', { permissions: { locallySet: [] } });
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -20,7 +20,7 @@ import { AlfrescoApiService, AppConfigService, DataSorting } from '@alfresco/adf
|
|||||||
import { SearchConfiguration } from '../models/search-configuration.interface';
|
import { SearchConfiguration } from '../models/search-configuration.interface';
|
||||||
import { BaseQueryBuilderService } from './base-query-builder.service';
|
import { BaseQueryBuilderService } from './base-query-builder.service';
|
||||||
import { SearchCategory } from '../models/search-category.interface';
|
import { SearchCategory } from '../models/search-category.interface';
|
||||||
import { MinimalNode, QueryBody } from '@alfresco/js-api';
|
import { Node } from '@alfresco/js-api';
|
||||||
import { filter } from 'rxjs/operators';
|
import { filter } from 'rxjs/operators';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { SearchSortingDefinition } from '../models/search-sorting-definition.interface';
|
import { SearchSortingDefinition } from '../models/search-sorting-definition.interface';
|
||||||
@ -31,18 +31,14 @@ import { NodesApiService } from '../../common/services/nodes-api.service';
|
|||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class SearchHeaderQueryBuilderService extends BaseQueryBuilderService {
|
export class SearchHeaderQueryBuilderService extends BaseQueryBuilderService {
|
||||||
|
|
||||||
private customSources = ['-trashcan-', '-sharedlinks-', '-sites-', '-mysites-', '-favorites-', '-recent-', '-my-'];
|
private customSources = ['-trashcan-', '-sharedlinks-', '-sites-', '-mysites-', '-favorites-', '-recent-', '-my-'];
|
||||||
|
|
||||||
activeFilters: FilterSearch[] = [];
|
activeFilters: FilterSearch[] = [];
|
||||||
|
|
||||||
constructor(appConfig: AppConfigService,
|
constructor(appConfig: AppConfigService, alfrescoApiService: AlfrescoApiService, private nodeApiService: NodesApiService) {
|
||||||
alfrescoApiService: AlfrescoApiService,
|
|
||||||
private nodeApiService: NodesApiService) {
|
|
||||||
super(appConfig, alfrescoApiService);
|
super(appConfig, alfrescoApiService);
|
||||||
|
|
||||||
this.updated.pipe(
|
this.updated.pipe(filter((query) => !!query)).subscribe(() => {
|
||||||
filter((query: QueryBody) => !!query)).subscribe(() => {
|
|
||||||
this.execute();
|
this.execute();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -56,9 +52,7 @@ export class SearchHeaderQueryBuilderService extends BaseQueryBuilderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setupCurrentPagination(maxItems: number, skipCount: number) {
|
setupCurrentPagination(maxItems: number, skipCount: number) {
|
||||||
if (!this.paging ||
|
if (!this.paging || (this.paging && this.paging.maxItems !== maxItems) || this.paging.skipCount !== skipCount) {
|
||||||
(this.paging &&
|
|
||||||
this.paging.maxItems !== maxItems || this.paging.skipCount !== skipCount)) {
|
|
||||||
this.paging = { maxItems, skipCount };
|
this.paging = { maxItems, skipCount };
|
||||||
this.execute();
|
this.execute();
|
||||||
}
|
}
|
||||||
@ -118,7 +112,7 @@ export class SearchHeaderQueryBuilderService extends BaseQueryBuilderService {
|
|||||||
|
|
||||||
private getSortingFieldFromColumnName(columnName: string) {
|
private getSortingFieldFromColumnName(columnName: string) {
|
||||||
if (this.sortingOptions.length > 0) {
|
if (this.sortingOptions.length > 0) {
|
||||||
const sortOption: SearchSortingDefinition = this.sortingOptions.find((option: SearchSortingDefinition) => option.key === columnName);
|
const sortOption = this.sortingOptions.find((option) => option.key === columnName);
|
||||||
return sortOption ? sortOption.field : '';
|
return sortOption ? sortOption.field : '';
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
@ -127,25 +121,23 @@ export class SearchHeaderQueryBuilderService extends BaseQueryBuilderService {
|
|||||||
getCategoryForColumn(columnKey: string): SearchCategory {
|
getCategoryForColumn(columnKey: string): SearchCategory {
|
||||||
let foundCategory = null;
|
let foundCategory = null;
|
||||||
if (this.categories !== null) {
|
if (this.categories !== null) {
|
||||||
foundCategory = this.categories.find(
|
foundCategory = this.categories.find((category) => category.columnKey === columnKey);
|
||||||
category => category.columnKey === columnKey
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return foundCategory;
|
return foundCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
setCurrentRootFolderId(currentFolderId: string) {
|
setCurrentRootFolderId(currentFolderId: string) {
|
||||||
const alreadyAddedFilter = this.filterQueries.find(filterQueries =>
|
const alreadyAddedFilter = this.filterQueries.find((filterQueries) => filterQueries.query.includes(currentFolderId));
|
||||||
filterQueries.query.includes(currentFolderId)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (alreadyAddedFilter !== undefined) {
|
if (alreadyAddedFilter !== undefined) {
|
||||||
this.filterQueries = [];
|
this.filterQueries = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.filterQueries = [{
|
this.filterQueries = [
|
||||||
|
{
|
||||||
query: `PARENT:"workspace://SpacesStore/${currentFolderId}"`
|
query: `PARENT:"workspace://SpacesStore/${currentFolderId}"`
|
||||||
}];
|
}
|
||||||
|
];
|
||||||
|
|
||||||
this.execute();
|
this.execute();
|
||||||
}
|
}
|
||||||
@ -154,8 +146,7 @@ export class SearchHeaderQueryBuilderService extends BaseQueryBuilderService {
|
|||||||
return this.customSources.includes(currentNodeId);
|
return this.customSources.includes(currentNodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
getNodeIdForCustomSource(customSourceId: string): Observable<MinimalNode> {
|
getNodeIdForCustomSource(customSourceId: string): Observable<Node> {
|
||||||
return this.nodeApiService.getNode(customSourceId);
|
return this.nodeApiService.getNode(customSourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,19 +16,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export class AlfrescoApiMock {
|
export class AlfrescoApiMock {
|
||||||
|
|
||||||
login() {
|
login() {
|
||||||
return new Promise((resolve) => {
|
return Promise.resolve('TICKET_4479f4d3bb155195879bfbb8d5206f433488a1b1');
|
||||||
resolve('TICKET_4479f4d3bb155195879bfbb8d5206f433488a1b1');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
return new Promise((resolve) => {
|
return Promise.resolve('logout');
|
||||||
resolve('logout');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
changeConfig() {
|
changeConfig() {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
allSourceParams,
|
allSourceParams,
|
||||||
contentSourceParam,
|
contentSourceParam,
|
||||||
fakeMinimalNode,
|
fakeNode,
|
||||||
mockNodeId,
|
mockNodeId,
|
||||||
fakeLocalPngResponse,
|
fakeLocalPngResponse,
|
||||||
onlyLocalParams,
|
onlyLocalParams,
|
||||||
@ -61,13 +61,18 @@ import {
|
|||||||
} from '../../../mocks/attach-file-cloud-widget.mock';
|
} from '../../../mocks/attach-file-cloud-widget.mock';
|
||||||
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
|
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
|
||||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||||
import { ContentModule, ContentNodeSelectorPanelService, NewVersionUploaderDataAction, NewVersionUploaderService } from '@alfresco/adf-content-services';
|
import {
|
||||||
|
ContentModule,
|
||||||
|
ContentNodeSelectorPanelService,
|
||||||
|
NewVersionUploaderDataAction,
|
||||||
|
NewVersionUploaderService
|
||||||
|
} from '@alfresco/adf-content-services';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { of, throwError } from 'rxjs';
|
import { of, throwError } from 'rxjs';
|
||||||
import { FormCloudModule } from '../../../form-cloud.module';
|
import { FormCloudModule } from '../../../form-cloud.module';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
|
||||||
const mockNodeToBeVersioned: any = ({
|
const mockNodeToBeVersioned: any = {
|
||||||
isFile: true,
|
isFile: true,
|
||||||
createdByUser: { id: 'admin', displayName: 'Administrator' },
|
createdByUser: { id: 'admin', displayName: 'Administrator' },
|
||||||
modifiedAt: '2017-05-24T15:08:55.640Z',
|
modifiedAt: '2017-05-24T15:08:55.640Z',
|
||||||
@ -83,10 +88,13 @@ const mockNodeToBeVersioned: any = ({
|
|||||||
path: {
|
path: {
|
||||||
name: '/Company Home/Guest Home',
|
name: '/Company Home/Guest Home',
|
||||||
isComplete: true,
|
isComplete: true,
|
||||||
elements: [{
|
elements: [
|
||||||
|
{
|
||||||
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
|
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
|
||||||
name: 'Company Home'
|
name: 'Company Home'
|
||||||
}, { id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }]
|
},
|
||||||
|
{ id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }
|
||||||
|
]
|
||||||
},
|
},
|
||||||
isFolder: false,
|
isFolder: false,
|
||||||
modifiedByUser: { id: 'admin', displayName: 'Administrator' },
|
modifiedByUser: { id: 'admin', displayName: 'Administrator' },
|
||||||
@ -94,7 +102,7 @@ const mockNodeToBeVersioned: any = ({
|
|||||||
id: '70e1cc6a-6918-468a-b84a-1048093b06fd',
|
id: '70e1cc6a-6918-468a-b84a-1048093b06fd',
|
||||||
properties: { 'cm:versionLabel': '1.0', 'cm:versionType': 'MAJOR' },
|
properties: { 'cm:versionLabel': '1.0', 'cm:versionType': 'MAJOR' },
|
||||||
allowableOperations: ['delete', 'update']
|
allowableOperations: ['delete', 'update']
|
||||||
});
|
};
|
||||||
|
|
||||||
describe('AttachFileCloudWidgetComponent', () => {
|
describe('AttachFileCloudWidgetComponent', () => {
|
||||||
let widget: AttachFileCloudWidgetComponent;
|
let widget: AttachFileCloudWidgetComponent;
|
||||||
@ -115,7 +123,15 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
let newVersionUploaderService: NewVersionUploaderService;
|
let newVersionUploaderService: NewVersionUploaderService;
|
||||||
let notificationService: NotificationService;
|
let notificationService: NotificationService;
|
||||||
|
|
||||||
const createUploadWidgetField = (form: FormModel, fieldId: string, value?: any, params?: any, multiple?: boolean, name?: string, readOnly?: boolean) => {
|
const createUploadWidgetField = (
|
||||||
|
form: FormModel,
|
||||||
|
fieldId: string,
|
||||||
|
value?: any,
|
||||||
|
params?: any,
|
||||||
|
multiple?: boolean,
|
||||||
|
name?: string,
|
||||||
|
readOnly?: boolean
|
||||||
|
) => {
|
||||||
widget.field = new FormFieldModel(form, {
|
widget.field = new FormFieldModel(form, {
|
||||||
type: FormFieldTypes.UPLOAD,
|
type: FormFieldTypes.UPLOAD,
|
||||||
value,
|
value,
|
||||||
@ -134,12 +150,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [TranslateModule.forRoot(), ProcessServiceCloudTestingModule, FormCloudModule, ContentModule.forRoot()],
|
||||||
TranslateModule.forRoot(),
|
|
||||||
ProcessServiceCloudTestingModule,
|
|
||||||
FormCloudModule,
|
|
||||||
ContentModule.forRoot()
|
|
||||||
],
|
|
||||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||||
});
|
});
|
||||||
downloadService = TestBed.inject(DownloadService);
|
downloadService = TestBed.inject(DownloadService);
|
||||||
@ -147,15 +158,11 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
widget = fixture.componentInstance;
|
widget = fixture.componentInstance;
|
||||||
element = fixture.nativeElement;
|
element = fixture.nativeElement;
|
||||||
processCloudContentService = TestBed.inject(ProcessCloudContentService);
|
processCloudContentService = TestBed.inject(ProcessCloudContentService);
|
||||||
contentCloudNodeSelectorService = TestBed.inject(
|
contentCloudNodeSelectorService = TestBed.inject(ContentCloudNodeSelectorService);
|
||||||
ContentCloudNodeSelectorService
|
appConfigService = TestBed.inject(AppConfigService);
|
||||||
);
|
|
||||||
appConfigService = TestBed.inject(
|
|
||||||
AppConfigService
|
|
||||||
);
|
|
||||||
formService = TestBed.inject(FormService);
|
formService = TestBed.inject(FormService);
|
||||||
contentNodeSelectorPanelService = TestBed.inject(ContentNodeSelectorPanelService);
|
contentNodeSelectorPanelService = TestBed.inject(ContentNodeSelectorPanelService);
|
||||||
openUploadFileDialogSpy = spyOn(contentCloudNodeSelectorService, 'openUploadFileDialog').and.returnValue(of([fakeMinimalNode]));
|
openUploadFileDialogSpy = spyOn(contentCloudNodeSelectorService, 'openUploadFileDialog').and.returnValue(of([fakeNode]));
|
||||||
localizedDataPipe = new LocalizedDatePipe();
|
localizedDataPipe = new LocalizedDatePipe();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -234,7 +241,6 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when is required', () => {
|
describe('when is required', () => {
|
||||||
|
|
||||||
it('should be able to display label with asterisk', async () => {
|
it('should be able to display label with asterisk', async () => {
|
||||||
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
||||||
type: FormFieldTypes.UPLOAD,
|
type: FormFieldTypes.UPLOAD,
|
||||||
@ -252,7 +258,6 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Upload widget with displayable ContentModel properties', () => {
|
describe('Upload widget with displayable ContentModel properties', () => {
|
||||||
|
|
||||||
it('should display CM Properties if the file contains value', async () => {
|
it('should display CM Properties if the file contains value', async () => {
|
||||||
createUploadWidgetField(new FormModel(), 'attach-file-alfresco', [fakeLocalPngHavingCMProperties], displayableCMParams);
|
createUploadWidgetField(new FormModel(), 'attach-file-alfresco', [fakeLocalPngHavingCMProperties], displayableCMParams);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -291,7 +296,6 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('destinationFolderPath', () => {
|
describe('destinationFolderPath', () => {
|
||||||
|
|
||||||
it('should be able to fetch nodeId if destinationFolderPath is defined', async () => {
|
it('should be able to fetch nodeId if destinationFolderPath is defined', async () => {
|
||||||
const getNodeIdFromPathSpy = spyOn(contentCloudNodeSelectorService, 'getNodeIdFromPath').and.returnValue(mockNodeId);
|
const getNodeIdFromPathSpy = spyOn(contentCloudNodeSelectorService, 'getNodeIdFromPath').and.returnValue(mockNodeId);
|
||||||
|
|
||||||
@ -328,7 +332,9 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to use mapped string variable value if the destinationFolderPath set to string type variable', async () => {
|
it('should be able to use mapped string variable value if the destinationFolderPath set to string type variable', async () => {
|
||||||
const getNodeIdFromPathSpy = spyOn(contentCloudNodeSelectorService, 'getNodeIdFromPath').and.returnValue(mockNodeIdBasedOnStringVariableValue);
|
const getNodeIdFromPathSpy = spyOn(contentCloudNodeSelectorService, 'getNodeIdFromPath').and.returnValue(
|
||||||
|
mockNodeIdBasedOnStringVariableValue
|
||||||
|
);
|
||||||
|
|
||||||
const form = new FormModel({ formVariables, processVariables });
|
const form = new FormModel({ formVariables, processVariables });
|
||||||
createUploadWidgetField(form, 'attach-file-alfresco', [], mockAllFileSourceWithStringVariablePathType);
|
createUploadWidgetField(form, 'attach-file-alfresco', [], mockAllFileSourceWithStringVariablePathType);
|
||||||
@ -469,7 +475,6 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when is readonly', () => {
|
describe('when is readonly', () => {
|
||||||
|
|
||||||
it('should show empty list message when there are no file', async () => {
|
it('should show empty list message when there are no file', async () => {
|
||||||
createUploadWidgetField(new FormModel(), 'empty-test', [], onlyLocalParams, null, null, true);
|
createUploadWidgetField(new FormModel(), 'empty-test', [], onlyLocalParams, null, null, true);
|
||||||
|
|
||||||
@ -517,8 +522,8 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
|
|
||||||
describe('when a file is uploaded', () => {
|
describe('when a file is uploaded', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
apiServiceSpy = spyOn(widget['nodesApi'], 'getNode').and.returnValue(new Promise(resolve => resolve({ entry: fakeNodeWithProperties })));
|
apiServiceSpy = spyOn(widget['nodesApi'], 'getNode').and.returnValue(Promise.resolve({ entry: fakeNodeWithProperties }));
|
||||||
spyOn(contentCloudNodeSelectorService, 'getNodeIdFromPath').and.returnValue(new Promise(resolve => resolve('fake-properties')));
|
spyOn(contentCloudNodeSelectorService, 'getNodeIdFromPath').and.returnValue(Promise.resolve('fake-properties'));
|
||||||
openUploadFileDialogSpy.and.returnValue(of([fakeNodeWithProperties]));
|
openUploadFileDialogSpy.and.returnValue(of([fakeNodeWithProperties]));
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
type: FormFieldTypes.UPLOAD,
|
type: FormFieldTypes.UPLOAD,
|
||||||
@ -575,11 +580,9 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
|
|
||||||
it('should preview file when show is clicked', async () => {
|
it('should preview file when show is clicked', async () => {
|
||||||
spyOn(processCloudContentService, 'getRawContentNode').and.returnValue(of(new Blob()));
|
spyOn(processCloudContentService, 'getRawContentNode').and.returnValue(of(new Blob()));
|
||||||
await formService.formContentClicked.subscribe(
|
await formService.formContentClicked.subscribe((fileClicked: any) => {
|
||||||
(fileClicked: any) => {
|
|
||||||
expect(fileClicked.nodeId).toBe('fake-properties');
|
expect(fileClicked.nodeId).toBe('fake-properties');
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const menuButton = fixture.debugElement.query(By.css('#file-fake-properties-option-menu')).nativeElement as HTMLButtonElement;
|
const menuButton = fixture.debugElement.query(By.css('#file-fake-properties-option-menu')).nativeElement as HTMLButtonElement;
|
||||||
@ -598,7 +601,8 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
menuButton.click();
|
menuButton.click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const retrieveMetadataOption = fixture.debugElement.query(By.css('#file-fake-properties-retrieve-file-metadata')).nativeElement as HTMLButtonElement;
|
const retrieveMetadataOption = fixture.debugElement.query(By.css('#file-fake-properties-retrieve-file-metadata'))
|
||||||
|
.nativeElement as HTMLButtonElement;
|
||||||
retrieveMetadataOption.click();
|
retrieveMetadataOption.click();
|
||||||
expect(apiServiceSpy).toHaveBeenCalledWith(fakeNodeWithProperties.id);
|
expect(apiServiceSpy).toHaveBeenCalledWith(fakeNodeWithProperties.id);
|
||||||
|
|
||||||
@ -609,9 +613,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
|
|
||||||
it('should display the default menu options if no options are provided', async () => {
|
it('should display the default menu options if no options are provided', async () => {
|
||||||
widget.field.params = onlyLocalParams;
|
widget.field.params = onlyLocalParams;
|
||||||
const inputDebugElement = fixture.debugElement.query(
|
const inputDebugElement = fixture.debugElement.query(By.css('#attach-file-alfresco'));
|
||||||
By.css('#attach-file-alfresco')
|
|
||||||
);
|
|
||||||
inputDebugElement.triggerEventHandler('change', {
|
inputDebugElement.triggerEventHandler('change', {
|
||||||
target: { files: [fakeLocalPngAnswer] }
|
target: { files: [fakeLocalPngAnswer] }
|
||||||
});
|
});
|
||||||
@ -637,7 +639,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
|
|
||||||
describe('contentModelFormFileHandler', () => {
|
describe('contentModelFormFileHandler', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
apiServiceSpy = spyOn(widget['nodesApi'], 'getNode').and.returnValue(new Promise(resolve => resolve({ entry: fakeNodeWithProperties })));
|
apiServiceSpy = spyOn(widget['nodesApi'], 'getNode').and.returnValue(Promise.resolve({ entry: fakeNodeWithProperties }));
|
||||||
contentModelFormFileHandlerSpy = spyOn(widget, 'contentModelFormFileHandler').and.callThrough();
|
contentModelFormFileHandlerSpy = spyOn(widget, 'contentModelFormFileHandler').and.callThrough();
|
||||||
updateFormSpy = spyOn(formService.updateFormValuesRequested, 'next');
|
updateFormSpy = spyOn(formService.updateFormValuesRequested, 'next');
|
||||||
contentClickedSpy = spyOn(formService.formContentClicked, 'next');
|
contentClickedSpy = spyOn(formService.formContentClicked, 'next');
|
||||||
@ -673,7 +675,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not be called onInit when widget has more than one file', async () => {
|
it('should not be called onInit when widget has more than one file', async () => {
|
||||||
widget.field.value = [fakeNodeWithProperties, fakeMinimalNode];
|
widget.field.value = [fakeNodeWithProperties, fakeNode];
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
@ -681,19 +683,19 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not be called on remove node if node removed is not the selected one', async () => {
|
it('should not be called on remove node if node removed is not the selected one', async () => {
|
||||||
widget.field.value = [fakeNodeWithProperties, fakeMinimalNode];
|
widget.field.value = [fakeNodeWithProperties, fakeNode];
|
||||||
widget.selectedNode = fakeNodeWithProperties;
|
widget.selectedNode = fakeNodeWithProperties;
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
widget.onRemoveAttachFile(fakeMinimalNode);
|
widget.onRemoveAttachFile(fakeNode);
|
||||||
|
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
expect(contentModelFormFileHandlerSpy).not.toHaveBeenCalled();
|
expect(contentModelFormFileHandlerSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have been called on remove node if node removed is the selected one', async () => {
|
it('should have been called on remove node if node removed is the selected one', async () => {
|
||||||
widget.field.value = [fakeNodeWithProperties, fakeMinimalNode];
|
widget.field.value = [fakeNodeWithProperties, fakeNode];
|
||||||
widget.selectedNode = fakeNodeWithProperties;
|
widget.selectedNode = fakeNodeWithProperties;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
@ -718,7 +720,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
|
|
||||||
it('should not be called on attach file when has a file previously', async () => {
|
it('should not be called on attach file when has a file previously', async () => {
|
||||||
spyOn(contentCloudNodeSelectorService, 'getNodeIdFromPath').and.returnValue(mockNodeId);
|
spyOn(contentCloudNodeSelectorService, 'getNodeIdFromPath').and.returnValue(mockNodeId);
|
||||||
widget.field.value = [fakeMinimalNode];
|
widget.field.value = [fakeNode];
|
||||||
|
|
||||||
clickOnAttachFileWidget('attach-file-alfresco');
|
clickOnAttachFileWidget('attach-file-alfresco');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -728,7 +730,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be called when selecting a row if no previous row was selected', async () => {
|
it('should be called when selecting a row if no previous row was selected', async () => {
|
||||||
widget.field.value = [fakeNodeWithProperties, fakeMinimalNode];
|
widget.field.value = [fakeNodeWithProperties, fakeNode];
|
||||||
widget.selectedNode = null;
|
widget.selectedNode = null;
|
||||||
|
|
||||||
widget.onRowClicked(fakeNodeWithProperties);
|
widget.onRowClicked(fakeNodeWithProperties);
|
||||||
@ -743,8 +745,8 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be called when selecting a row and previous row was selected', async () => {
|
it('should be called when selecting a row and previous row was selected', async () => {
|
||||||
widget.field.value = [fakeNodeWithProperties, fakeMinimalNode];
|
widget.field.value = [fakeNodeWithProperties, fakeNode];
|
||||||
widget.selectedNode = fakeMinimalNode;
|
widget.selectedNode = fakeNode;
|
||||||
|
|
||||||
widget.onRowClicked(fakeNodeWithProperties);
|
widget.onRowClicked(fakeNodeWithProperties);
|
||||||
|
|
||||||
@ -758,7 +760,7 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be called when deselecting a row', async () => {
|
it('should be called when deselecting a row', async () => {
|
||||||
widget.field.value = [fakeNodeWithProperties, fakeMinimalNode];
|
widget.field.value = [fakeNodeWithProperties, fakeNode];
|
||||||
widget.selectedNode = fakeNodeWithProperties;
|
widget.selectedNode = fakeNodeWithProperties;
|
||||||
|
|
||||||
widget.onRowClicked(fakeNodeWithProperties);
|
widget.onRowClicked(fakeNodeWithProperties);
|
||||||
@ -850,8 +852,9 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
notificationService = TestBed.inject(NotificationService);
|
notificationService = TestBed.inject(NotificationService);
|
||||||
newVersionUploaderService = TestBed.inject(NewVersionUploaderService);
|
newVersionUploaderService = TestBed.inject(NewVersionUploaderService);
|
||||||
spyOnOpenUploadNewVersionDialog = spyOn(newVersionUploaderService, 'openUploadNewVersionDialog')
|
spyOnOpenUploadNewVersionDialog = spyOn(newVersionUploaderService, 'openUploadNewVersionDialog').and.returnValue(
|
||||||
.and.returnValue(of({ action: NewVersionUploaderDataAction.refresh }));
|
of({ action: NewVersionUploaderDataAction.refresh })
|
||||||
|
);
|
||||||
spyOnReplaceOldFileVersionWithNew = spyOn(widget, 'replaceOldFileVersionWithNew');
|
spyOnReplaceOldFileVersionWithNew = spyOn(widget, 'replaceOldFileVersionWithNew');
|
||||||
spyOnShowError = spyOn(notificationService, 'showError');
|
spyOnShowError = spyOn(notificationService, 'showError');
|
||||||
});
|
});
|
||||||
@ -876,18 +879,16 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Should show notification error if new version uploader dialog return error', async () => {
|
it('Should show notification error if new version uploader dialog return error', async () => {
|
||||||
const mockError = {value: 'Upload error'};
|
const mockError = { value: 'Upload error' };
|
||||||
spyOnOpenUploadNewVersionDialog.and.returnValue(throwError(mockError));
|
spyOnOpenUploadNewVersionDialog.and.returnValue(throwError(mockError));
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
widget.onUploadNewFileVersion(mockNodeToBeVersioned);
|
widget.onUploadNewFileVersion(mockNodeToBeVersioned);
|
||||||
expect(spyOnReplaceOldFileVersionWithNew).not.toHaveBeenCalled();
|
expect(spyOnReplaceOldFileVersionWithNew).not.toHaveBeenCalled();
|
||||||
expect(spyOnShowError).toHaveBeenCalledWith(mockError.value);
|
expect(spyOnShowError).toHaveBeenCalledWith(mockError.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when tooltip is set', () => {
|
describe('when tooltip is set', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
||||||
type: FormFieldTypes.UPLOAD,
|
type: FormFieldTypes.UPLOAD,
|
||||||
|
@ -201,29 +201,6 @@ export const allSourceWithStringTypeEmptyValue = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const allSourceWithFolderTypeEmptyValue = {
|
|
||||||
fileSource: {
|
|
||||||
name: 'all file sources',
|
|
||||||
serviceId: FileSourceTypes.ALL_FILE_SOURCES_SERVICE_ID,
|
|
||||||
destinationFolderPath: {
|
|
||||||
value: null,
|
|
||||||
name: 'folderVariableName',
|
|
||||||
type: DestinationFolderPathType.FOLDER_TYPE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const allSourceWithRootParams = {
|
|
||||||
fileSource: {
|
|
||||||
name: 'all file sources',
|
|
||||||
serviceId: FileSourceTypes.ALL_FILE_SOURCES_SERVICE_ID,
|
|
||||||
destinationFolderPath: {
|
|
||||||
value: '-root-',
|
|
||||||
type: DestinationFolderPathType.STATIC_TYPE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const allSourceWithWrongAliasParams = {
|
export const allSourceWithWrongAliasParams = {
|
||||||
fileSource: {
|
fileSource: {
|
||||||
name: 'all file sources',
|
name: 'all file sources',
|
||||||
@ -248,22 +225,7 @@ export const allSourceWithNoAliasParams = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const allSourceWithoutDestinationFolderPath = {
|
export const fakeNode = {
|
||||||
fileSource: {
|
|
||||||
name: 'all file sources',
|
|
||||||
serviceId: FileSourceTypes.ALL_FILE_SOURCES_SERVICE_ID
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const allSourceWithoutValueProperty = {
|
|
||||||
fileSource: {
|
|
||||||
name: 'all file sources',
|
|
||||||
serviceId: FileSourceTypes.ALL_FILE_SOURCES_SERVICE_ID,
|
|
||||||
destinationFolderPath: '-mockAlias-'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const fakeMinimalNode = {
|
|
||||||
id: 'fake',
|
id: 'fake',
|
||||||
name: 'fake-name',
|
name: 'fake-name',
|
||||||
content: {
|
content: {
|
||||||
@ -298,10 +260,6 @@ export const mockNodeIdBasedOnStringVariableValue = new Promise<string>((resolve
|
|||||||
resolve('mock-string-value-node-id');
|
resolve('mock-string-value-node-id');
|
||||||
});
|
});
|
||||||
|
|
||||||
export const mockNodeIdBasedOnFolderVariableValue = new Promise((resolve) => {
|
|
||||||
resolve('mock-folder-value-node-id');
|
|
||||||
});
|
|
||||||
|
|
||||||
export const fakeLocalPngAnswer = {
|
export const fakeLocalPngAnswer = {
|
||||||
id: 1155,
|
id: 1155,
|
||||||
nodeId: 1155,
|
nodeId: 1155,
|
||||||
@ -447,7 +405,7 @@ export const processVariables = [
|
|||||||
createTime: 1566989626283,
|
createTime: 1566989626283,
|
||||||
lastUpdatedTime: 1566989626283,
|
lastUpdatedTime: 1566989626283,
|
||||||
executionId: null,
|
executionId: null,
|
||||||
value: [{ id: 'mock-folder-id'}],
|
value: [{ id: 'mock-folder-id' }],
|
||||||
markedAsDeleted: false,
|
markedAsDeleted: false,
|
||||||
processInstanceId: '1be4785f-c982-11e9-bdd8-96d6903e4e44',
|
processInstanceId: '1be4785f-c982-11e9-bdd8-96d6903e4e44',
|
||||||
taskId: '1beab9f6-c982-11e9-bdd8-96d6903e4e44',
|
taskId: '1beab9f6-c982-11e9-bdd8-96d6903e4e44',
|
||||||
|
@ -18,12 +18,7 @@
|
|||||||
import { AlfrescoApiService, LogService, ExternalContent, ExternalContentLink } from '@alfresco/adf-core';
|
import { AlfrescoApiService, LogService, ExternalContent, ExternalContentLink } from '@alfresco/adf-core';
|
||||||
import { SitesService } from '@alfresco/adf-content-services';
|
import { SitesService } from '@alfresco/adf-content-services';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import {
|
import { IntegrationAlfrescoOnPremiseApi, Node, RelatedContentRepresentation, ActivitiContentApi } from '@alfresco/js-api';
|
||||||
IntegrationAlfrescoOnPremiseApi,
|
|
||||||
MinimalNode,
|
|
||||||
RelatedContentRepresentation,
|
|
||||||
ActivitiContentApi
|
|
||||||
} from '@alfresco/js-api';
|
|
||||||
import { Observable, from, throwError } from 'rxjs';
|
import { Observable, from, throwError } from 'rxjs';
|
||||||
import { map, catchError } from 'rxjs/operators';
|
import { map, catchError } from 'rxjs/operators';
|
||||||
|
|
||||||
@ -31,13 +26,13 @@ import { map, catchError } from 'rxjs/operators';
|
|||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class ActivitiContentService {
|
export class ActivitiContentService {
|
||||||
|
|
||||||
static UNKNOWN_ERROR_MESSAGE: string = 'Unknown error';
|
static UNKNOWN_ERROR_MESSAGE: string = 'Unknown error';
|
||||||
static GENERIC_ERROR_MESSAGE: string = 'Server error';
|
static GENERIC_ERROR_MESSAGE: string = 'Server error';
|
||||||
|
|
||||||
private _integrationAlfrescoOnPremiseApi: IntegrationAlfrescoOnPremiseApi;
|
private _integrationAlfrescoOnPremiseApi: IntegrationAlfrescoOnPremiseApi;
|
||||||
get integrationAlfrescoOnPremiseApi(): IntegrationAlfrescoOnPremiseApi {
|
get integrationAlfrescoOnPremiseApi(): IntegrationAlfrescoOnPremiseApi {
|
||||||
this._integrationAlfrescoOnPremiseApi = this._integrationAlfrescoOnPremiseApi ?? new IntegrationAlfrescoOnPremiseApi(this.apiService.getInstance());
|
this._integrationAlfrescoOnPremiseApi =
|
||||||
|
this._integrationAlfrescoOnPremiseApi ?? new IntegrationAlfrescoOnPremiseApi(this.apiService.getInstance());
|
||||||
return this._integrationAlfrescoOnPremiseApi;
|
return this._integrationAlfrescoOnPremiseApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,10 +42,7 @@ export class ActivitiContentService {
|
|||||||
return this._contentApi;
|
return this._contentApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private apiService: AlfrescoApiService,
|
constructor(private apiService: AlfrescoApiService, private logService: LogService, private sitesService: SitesService) {}
|
||||||
private logService: LogService,
|
|
||||||
private sitesService: SitesService) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of child nodes below the specified folder
|
* Returns a list of child nodes below the specified folder
|
||||||
@ -60,8 +52,7 @@ export class ActivitiContentService {
|
|||||||
*/
|
*/
|
||||||
getAlfrescoNodes(accountId: string, folderId: string): Observable<[ExternalContent]> {
|
getAlfrescoNodes(accountId: string, folderId: string): Observable<[ExternalContent]> {
|
||||||
const accountShortId = accountId.replace('alfresco-', '');
|
const accountShortId = accountId.replace('alfresco-', '');
|
||||||
return from(this.integrationAlfrescoOnPremiseApi.getContentInFolder(accountShortId, folderId))
|
return from(this.integrationAlfrescoOnPremiseApi.getContentInFolder(accountShortId, folderId)).pipe(
|
||||||
.pipe(
|
|
||||||
map(this.toJsonArray),
|
map(this.toJsonArray),
|
||||||
catchError((err) => this.handleError(err))
|
catchError((err) => this.handleError(err))
|
||||||
);
|
);
|
||||||
@ -78,8 +69,7 @@ export class ActivitiContentService {
|
|||||||
tenantId,
|
tenantId,
|
||||||
includeAccounts: includeAccount ? includeAccount : true
|
includeAccounts: includeAccount ? includeAccount : true
|
||||||
};
|
};
|
||||||
return from(this.integrationAlfrescoOnPremiseApi.getRepositories(opts))
|
return from(this.integrationAlfrescoOnPremiseApi.getRepositories(opts)).pipe(
|
||||||
.pipe(
|
|
||||||
map(this.toJsonArray),
|
map(this.toJsonArray),
|
||||||
catchError((err) => this.handleError(err))
|
catchError((err) => this.handleError(err))
|
||||||
);
|
);
|
||||||
@ -93,20 +83,21 @@ export class ActivitiContentService {
|
|||||||
* @param siteId
|
* @param siteId
|
||||||
*/
|
*/
|
||||||
linkAlfrescoNode(accountId: string, node: ExternalContent, siteId: string): Observable<ExternalContentLink> {
|
linkAlfrescoNode(accountId: string, node: ExternalContent, siteId: string): Observable<ExternalContentLink> {
|
||||||
return from(this.contentApi.createTemporaryRelatedContent({
|
return from(
|
||||||
|
this.contentApi.createTemporaryRelatedContent({
|
||||||
link: true,
|
link: true,
|
||||||
name: node.title,
|
name: node.title,
|
||||||
simpleType: node.simpleType,
|
simpleType: node.simpleType,
|
||||||
source: accountId,
|
source: accountId,
|
||||||
sourceId: node.id + '@' + siteId
|
sourceId: node.id + '@' + siteId
|
||||||
}))
|
})
|
||||||
.pipe(
|
).pipe(
|
||||||
map(this.toJson),
|
map(this.toJson),
|
||||||
catchError((err) => this.handleError(err))
|
catchError((err) => this.handleError(err))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
applyAlfrescoNode(node: MinimalNode, siteId: string, accountId: string) {
|
applyAlfrescoNode(node: Node, siteId: string, accountId: string) {
|
||||||
const currentSideId = siteId ? siteId : this.sitesService.getSiteNameFromNodePath(node);
|
const currentSideId = siteId ? siteId : this.sitesService.getSiteNameFromNodePath(node);
|
||||||
const params: RelatedContentRepresentation = {
|
const params: RelatedContentRepresentation = {
|
||||||
source: accountId,
|
source: accountId,
|
||||||
@ -115,8 +106,7 @@ export class ActivitiContentService {
|
|||||||
name: node.name,
|
name: node.name,
|
||||||
link: node.isLink
|
link: node.isLink
|
||||||
};
|
};
|
||||||
return from(this.contentApi.createTemporaryRelatedContent(params))
|
return from(this.contentApi.createTemporaryRelatedContent(params)).pipe(
|
||||||
.pipe(
|
|
||||||
map(this.toJson),
|
map(this.toJson),
|
||||||
catchError((err) => this.handleError(err))
|
catchError((err) => this.handleError(err))
|
||||||
);
|
);
|
||||||
@ -139,8 +129,11 @@ export class ActivitiContentService {
|
|||||||
handleError(error: any): Observable<any> {
|
handleError(error: any): Observable<any> {
|
||||||
let errMsg = ActivitiContentService.UNKNOWN_ERROR_MESSAGE;
|
let errMsg = ActivitiContentService.UNKNOWN_ERROR_MESSAGE;
|
||||||
if (error) {
|
if (error) {
|
||||||
errMsg = (error.message) ? error.message :
|
errMsg = error.message
|
||||||
error.status ? `${error.status} - ${error.statusText}` : ActivitiContentService.GENERIC_ERROR_MESSAGE;
|
? error.message
|
||||||
|
: error.status
|
||||||
|
? `${error.status} - ${error.statusText}`
|
||||||
|
: ActivitiContentService.GENERIC_ERROR_MESSAGE;
|
||||||
}
|
}
|
||||||
this.logService.error(errMsg);
|
this.logService.error(errMsg);
|
||||||
return throwError(errMsg);
|
return throwError(errMsg);
|
||||||
|
@ -18,14 +18,7 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { AttachFileWidgetComponent } from './attach-file-widget.component';
|
import { AttachFileWidgetComponent } from './attach-file-widget.component';
|
||||||
import {
|
import { FormFieldModel, FormModel, FormFieldTypes, FormService, FormFieldMetadata, DownloadService } from '@alfresco/adf-core';
|
||||||
FormFieldModel,
|
|
||||||
FormModel,
|
|
||||||
FormFieldTypes,
|
|
||||||
FormService,
|
|
||||||
FormFieldMetadata,
|
|
||||||
DownloadService
|
|
||||||
} from '@alfresco/adf-core';
|
|
||||||
import { ContentNodeDialogService, ContentModule } from '@alfresco/adf-content-services';
|
import { ContentNodeDialogService, ContentModule } from '@alfresco/adf-content-services';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { Node } from '@alfresco/js-api';
|
import { Node } from '@alfresco/js-api';
|
||||||
@ -101,7 +94,7 @@ const externalDefinedSourceParams = {
|
|||||||
}
|
}
|
||||||
} as FormFieldMetadata;
|
} as FormFieldMetadata;
|
||||||
|
|
||||||
const fakeMinimalNode: Node = {
|
const fakeNode = {
|
||||||
id: 'fake',
|
id: 'fake',
|
||||||
name: 'fake-name',
|
name: 'fake-name',
|
||||||
content: {
|
content: {
|
||||||
@ -140,7 +133,6 @@ const fakePngAnswer: any = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
describe('AttachFileWidgetComponent', () => {
|
describe('AttachFileWidgetComponent', () => {
|
||||||
|
|
||||||
let widget: AttachFileWidgetComponent;
|
let widget: AttachFileWidgetComponent;
|
||||||
let fixture: ComponentFixture<AttachFileWidgetComponent>;
|
let fixture: ComponentFixture<AttachFileWidgetComponent>;
|
||||||
let element: HTMLInputElement;
|
let element: HTMLInputElement;
|
||||||
@ -153,11 +145,7 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [TranslateModule.forRoot(), ProcessTestingModule, ContentModule.forRoot()]
|
||||||
TranslateModule.forRoot(),
|
|
||||||
ProcessTestingModule,
|
|
||||||
ContentModule.forRoot()
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
fixture = TestBed.createComponent(AttachFileWidgetComponent);
|
fixture = TestBed.createComponent(AttachFileWidgetComponent);
|
||||||
widget = fixture.componentInstance;
|
widget = fixture.componentInstance;
|
||||||
@ -218,7 +206,7 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
expect(fakeRepoOption2[0]).not.toBeNull();
|
expect(fakeRepoOption2[0]).not.toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it ('should show only remote repos when just link to files is true', async () => {
|
it('should show only remote repos when just link to files is true', async () => {
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
type: FormFieldTypes.UPLOAD,
|
type: FormFieldTypes.UPLOAD,
|
||||||
value: []
|
value: []
|
||||||
@ -252,7 +240,7 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
it('should isLink property of the selected node become true when the widget has link enabled', async () => {
|
it('should isLink property of the selected node become true when the widget has link enabled', async () => {
|
||||||
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||||
const applyAlfrescoNodeSpy = spyOn(activitiContentService, 'applyAlfrescoNode');
|
const applyAlfrescoNodeSpy = spyOn(activitiContentService, 'applyAlfrescoNode');
|
||||||
spyOn(contentNodeDialogService, 'openFileBrowseDialogByDefaultLocation').and.returnValue(of([fakeMinimalNode]));
|
spyOn(contentNodeDialogService, 'openFileBrowseDialogByDefaultLocation').and.returnValue(of([fakeNode]));
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
type: FormFieldTypes.UPLOAD,
|
type: FormFieldTypes.UPLOAD,
|
||||||
value: []
|
value: []
|
||||||
@ -271,13 +259,13 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
fixture.debugElement.query(By.css('#attach-SHAREME')).nativeElement.click();
|
fixture.debugElement.query(By.css('#attach-SHAREME')).nativeElement.click();
|
||||||
expect(applyAlfrescoNodeSpy).toHaveBeenCalledWith({ ...fakeMinimalNode, isLink: true }, undefined, 'alfresco-1000-SHAREME');
|
expect(applyAlfrescoNodeSpy).toHaveBeenCalledWith({ ...fakeNode, isLink: true }, undefined, 'alfresco-1000-SHAREME');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should isLink property of the selected node become false when the widget has link disabled', async () => {
|
it('should isLink property of the selected node become false when the widget has link disabled', async () => {
|
||||||
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||||
const applyAlfrescoNodeSpy = spyOn(activitiContentService, 'applyAlfrescoNode');
|
const applyAlfrescoNodeSpy = spyOn(activitiContentService, 'applyAlfrescoNode');
|
||||||
spyOn(contentNodeDialogService, 'openFileBrowseDialogByDefaultLocation').and.returnValue(of([fakeMinimalNode]));
|
spyOn(contentNodeDialogService, 'openFileBrowseDialogByDefaultLocation').and.returnValue(of([fakeNode]));
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
type: FormFieldTypes.UPLOAD,
|
type: FormFieldTypes.UPLOAD,
|
||||||
value: []
|
value: []
|
||||||
@ -296,13 +284,13 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
fixture.debugElement.query(By.css('#attach-SHAREME')).nativeElement.click();
|
fixture.debugElement.query(By.css('#attach-SHAREME')).nativeElement.click();
|
||||||
expect(applyAlfrescoNodeSpy).toHaveBeenCalledWith({ ...fakeMinimalNode, isLink: false }, undefined, 'alfresco-1000-SHAREME');
|
expect(applyAlfrescoNodeSpy).toHaveBeenCalledWith({ ...fakeNode, isLink: false }, undefined, 'alfresco-1000-SHAREME');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to upload files coming from content node selector', async () => {
|
it('should be able to upload files coming from content node selector', async () => {
|
||||||
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||||
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer));
|
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer));
|
||||||
spyOn(contentNodeDialogService, 'openFileBrowseDialogByDefaultLocation').and.returnValue(of([fakeMinimalNode]));
|
spyOn(contentNodeDialogService, 'openFileBrowseDialogByDefaultLocation').and.returnValue(of([fakeNode]));
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
type: FormFieldTypes.UPLOAD,
|
type: FormFieldTypes.UPLOAD,
|
||||||
value: []
|
value: []
|
||||||
@ -337,7 +325,7 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
};
|
};
|
||||||
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||||
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValues(of(fakePngAnswer), of(fakePngUpload));
|
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValues(of(fakePngAnswer), of(fakePngUpload));
|
||||||
spyOn(contentNodeDialogService, 'openFileBrowseDialogByDefaultLocation').and.returnValue(of([fakeMinimalNode]));
|
spyOn(contentNodeDialogService, 'openFileBrowseDialogByDefaultLocation').and.returnValue(of([fakeNode]));
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
type: FormFieldTypes.UPLOAD,
|
type: FormFieldTypes.UPLOAD,
|
||||||
value: []
|
value: []
|
||||||
@ -374,7 +362,7 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
widget.field.params = definedSourceParams;
|
widget.field.params = definedSourceParams;
|
||||||
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||||
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer));
|
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer));
|
||||||
spyOn(contentNodeDialogService, 'openFileBrowseDialogByFolderId').and.returnValue(of([fakeMinimalNode]));
|
spyOn(contentNodeDialogService, 'openFileBrowseDialogByFolderId').and.returnValue(of([fakeNode]));
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
@ -430,7 +418,6 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when a file is uploaded', () => {
|
describe('when a file is uploaded', () => {
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
type: FormFieldTypes.UPLOAD,
|
type: FormFieldTypes.UPLOAD,
|
||||||
@ -557,7 +544,6 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
const downloadOption = fixture.debugElement.query(By.css('#file-1155-download-file')).nativeElement as HTMLButtonElement;
|
const downloadOption = fixture.debugElement.query(By.css('#file-1155-download-file')).nativeElement as HTMLButtonElement;
|
||||||
expect(downloadOption.disabled).toBeFalsy();
|
expect(downloadOption.disabled).toBeFalsy();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not display the show button file when there is no contentAvailable', async () => {
|
it('should not display the show button file when there is no contentAvailable', async () => {
|
||||||
@ -580,7 +566,7 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
widget.field.params = externalDefinedSourceParams;
|
widget.field.params = externalDefinedSourceParams;
|
||||||
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||||
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer));
|
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer));
|
||||||
spyOn(attachFileWidgetDialogService, 'openLogin').and.returnValue(of([fakeMinimalNode]));
|
spyOn(attachFileWidgetDialogService, 'openLogin').and.returnValue(of([fakeNode]));
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
@ -605,7 +591,7 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
widget.field.params = externalDefinedSourceParams;
|
widget.field.params = externalDefinedSourceParams;
|
||||||
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||||
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer));
|
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer));
|
||||||
const openLoginSpy = spyOn(attachFileWidgetDialogService, 'openLogin').and.returnValue(of([fakeMinimalNode]));
|
const openLoginSpy = spyOn(attachFileWidgetDialogService, 'openLogin').and.returnValue(of([fakeNode]));
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
@ -25,13 +25,13 @@ import { Node } from '@alfresco/js-api';
|
|||||||
import { ProcessTestingModule } from '../../../testing/process.testing.module';
|
import { ProcessTestingModule } from '../../../testing/process.testing.module';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
|
||||||
const fakeMinimalNode: Node = {
|
const fakeNode = {
|
||||||
id: 'fake',
|
id: 'fake',
|
||||||
name: 'fake-name'
|
name: 'fake-name'
|
||||||
} as Node;
|
} as Node;
|
||||||
|
|
||||||
const definedSourceParams = {
|
const definedSourceParams = {
|
||||||
folderSource : {
|
folderSource: {
|
||||||
serviceId: 'goofy-sources',
|
serviceId: 'goofy-sources',
|
||||||
name: 'pippo-baudo',
|
name: 'pippo-baudo',
|
||||||
selectedFolder: {
|
selectedFolder: {
|
||||||
@ -42,7 +42,6 @@ const definedSourceParams = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
describe('AttachFolderWidgetComponent', () => {
|
describe('AttachFolderWidgetComponent', () => {
|
||||||
|
|
||||||
let widget: AttachFolderWidgetComponent;
|
let widget: AttachFolderWidgetComponent;
|
||||||
let fixture: ComponentFixture<AttachFolderWidgetComponent>;
|
let fixture: ComponentFixture<AttachFolderWidgetComponent>;
|
||||||
let element: HTMLInputElement;
|
let element: HTMLInputElement;
|
||||||
@ -51,10 +50,7 @@ describe('AttachFolderWidgetComponent', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [TranslateModule.forRoot(), ProcessTestingModule]
|
||||||
TranslateModule.forRoot(),
|
|
||||||
ProcessTestingModule
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
fixture = TestBed.createComponent(AttachFolderWidgetComponent);
|
fixture = TestBed.createComponent(AttachFolderWidgetComponent);
|
||||||
widget = fixture.componentInstance;
|
widget = fixture.componentInstance;
|
||||||
@ -80,7 +76,7 @@ describe('AttachFolderWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should show the folder selected by content node', async () => {
|
it('should show the folder selected by content node', async () => {
|
||||||
spyOn(contentNodeDialogService, 'openFolderBrowseDialogBySite').and.returnValue(of([fakeMinimalNode]));
|
spyOn(contentNodeDialogService, 'openFolderBrowseDialogBySite').and.returnValue(of([fakeNode]));
|
||||||
expect(widget).not.toBeNull();
|
expect(widget).not.toBeNull();
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
type: 'select-folder',
|
type: 'select-folder',
|
||||||
@ -99,7 +95,7 @@ describe('AttachFolderWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should show the folder selected by content node opening on a configured folder', async () => {
|
it('should show the folder selected by content node opening on a configured folder', async () => {
|
||||||
spyOn(contentNodeDialogService, 'openFolderBrowseDialogByFolderId').and.returnValue(of([fakeMinimalNode]));
|
spyOn(contentNodeDialogService, 'openFolderBrowseDialogByFolderId').and.returnValue(of([fakeNode]));
|
||||||
expect(widget).not.toBeNull();
|
expect(widget).not.toBeNull();
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
type: 'select-folder',
|
type: 'select-folder',
|
||||||
@ -120,7 +116,7 @@ describe('AttachFolderWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should retrieve the node information on init', async () => {
|
it('should retrieve the node information on init', async () => {
|
||||||
spyOn(nodeService, 'getNode').and.returnValue(of(fakeMinimalNode));
|
spyOn(nodeService, 'getNode').and.returnValue(of(fakeNode));
|
||||||
expect(widget).not.toBeNull();
|
expect(widget).not.toBeNull();
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
type: 'select-folder',
|
type: 'select-folder',
|
||||||
@ -136,7 +132,7 @@ describe('AttachFolderWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should remove the folder via the remove button', async () => {
|
it('should remove the folder via the remove button', async () => {
|
||||||
spyOn(nodeService, 'getNode').and.returnValue(of(fakeMinimalNode));
|
spyOn(nodeService, 'getNode').and.returnValue(of(fakeNode));
|
||||||
expect(widget).not.toBeNull();
|
expect(widget).not.toBeNull();
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
type: 'select-folder',
|
type: 'select-folder',
|
||||||
|
@ -18,28 +18,6 @@
|
|||||||
/* spell-checker: disable */
|
/* spell-checker: disable */
|
||||||
import { ProcessInstance } from '../../process-list/models/process-instance.model';
|
import { ProcessInstance } from '../../process-list/models/process-instance.model';
|
||||||
|
|
||||||
export class ProcessList {
|
|
||||||
|
|
||||||
data: ProcessInstance[];
|
|
||||||
size: number;
|
|
||||||
start: number;
|
|
||||||
total: number;
|
|
||||||
|
|
||||||
constructor(data?: ProcessInstance[]) {
|
|
||||||
this.data = data || [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class SingleProcessList extends ProcessList {
|
|
||||||
constructor(name?: string) {
|
|
||||||
const instance = new ProcessInstance({
|
|
||||||
id: '123',
|
|
||||||
name
|
|
||||||
});
|
|
||||||
super([instance]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const exampleProcess = new ProcessInstance({
|
export const exampleProcess = new ProcessInstance({
|
||||||
id: '123',
|
id: '123',
|
||||||
name: 'Process 123',
|
name: 'Process 123',
|
||||||
@ -90,86 +68,3 @@ export const exampleProcessNoName = new ProcessInstance({
|
|||||||
},
|
},
|
||||||
processDefinitionName: 'My Process'
|
processDefinitionName: 'My Process'
|
||||||
});
|
});
|
||||||
|
|
||||||
export const fakeProcessInstances = {
|
|
||||||
size: 2,
|
|
||||||
total: 2,
|
|
||||||
start: 0,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: '340124',
|
|
||||||
name: 'James Franklin EMEA Onboarding',
|
|
||||||
businessKey: null,
|
|
||||||
processDefinitionId: 'HROnboarding:60:338704',
|
|
||||||
tenantId: 'tenant_1',
|
|
||||||
started: new Date('2017-10-09T12:19:44.560+0000'),
|
|
||||||
ended: null,
|
|
||||||
startedBy: {
|
|
||||||
id: 4004,
|
|
||||||
firstName: 'Integration',
|
|
||||||
lastName: 'Test',
|
|
||||||
email: 'srintegrationtest@test.com'
|
|
||||||
},
|
|
||||||
processDefinitionName: 'HROnboarding',
|
|
||||||
processDefinitionDescription: 'HR Onboarding Workflow',
|
|
||||||
processDefinitionKey: 'fakeProcessDefinitionKey1',
|
|
||||||
processDefinitionCategory: 'http://www.activiti.org/processdef',
|
|
||||||
processDefinitionVersion: 60,
|
|
||||||
processDefinitionDeploymentId: '338695',
|
|
||||||
graphicalNotationDefined: true,
|
|
||||||
startFormDefined: false,
|
|
||||||
suspended: false,
|
|
||||||
variables: []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '340063',
|
|
||||||
name: 'Mary Franklin AMERICAS Onboarding',
|
|
||||||
businessKey: null,
|
|
||||||
processDefinitionId: 'HROnboarding:60:338704',
|
|
||||||
tenantId: 'tenant_1',
|
|
||||||
started: '2017-10-09T12:18:07.484+0000',
|
|
||||||
ended: null,
|
|
||||||
startedBy: {
|
|
||||||
id: 4004,
|
|
||||||
firstName: 'Integration',
|
|
||||||
lastName: 'Test',
|
|
||||||
email: 'srintegrationtest@test.com'
|
|
||||||
},
|
|
||||||
processDefinitionName: 'HROnboarding',
|
|
||||||
processDefinitionDescription: 'HR Onboarding Workflow',
|
|
||||||
processDefinitionKey: 'HROnboarding',
|
|
||||||
processDefinitionCategory: 'http://www.activiti.org/processdef',
|
|
||||||
processDefinitionVersion: 60,
|
|
||||||
processDefinitionDeploymentId: '338695',
|
|
||||||
graphicalNotationDefined: true,
|
|
||||||
startFormDefined: false,
|
|
||||||
suspended: false,
|
|
||||||
variables: []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '337604',
|
|
||||||
name: 'John Jacobs AMERICAS Onboarding',
|
|
||||||
businessKey: null,
|
|
||||||
processDefinitionId: 'HROnboarding:49:303243',
|
|
||||||
tenantId: 'tenant_1',
|
|
||||||
started: '2017-09-25T10:02:23.522+0000',
|
|
||||||
ended: null,
|
|
||||||
startedBy: {
|
|
||||||
id: 4004,
|
|
||||||
firstName: 'Integration',
|
|
||||||
lastName: 'Test',
|
|
||||||
email: 'srintegrationtest@test.com'
|
|
||||||
},
|
|
||||||
processDefinitionName: 'HROnboarding',
|
|
||||||
processDefinitionDescription: 'HR Onboarding Workflow',
|
|
||||||
processDefinitionKey: 'fakeProcessDefinitionKey2',
|
|
||||||
processDefinitionCategory: 'http://www.activiti.org/processdef',
|
|
||||||
processDefinitionVersion: 49,
|
|
||||||
processDefinitionDeploymentId: '303234',
|
|
||||||
graphicalNotationDefined: true,
|
|
||||||
startFormDefined: false,
|
|
||||||
suspended: false,
|
|
||||||
variables: []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AppDefinitionRepresentationModel, TaskDetailsModel } from '../../task-list';
|
import { TaskDetailsModel } from '../../task-list';
|
||||||
import { ProcessDefinitionRepresentation } from '../../process-list/models/process-definition.model';
|
import { ProcessDefinitionRepresentation } from '../../process-list/models/process-definition.model';
|
||||||
|
|
||||||
export const mockError = {
|
export const mockError = {
|
||||||
@ -23,38 +23,21 @@ export const mockError = {
|
|||||||
messageKey: 'GENERAL.ERROR.FORBIDDEN'
|
messageKey: 'GENERAL.ERROR.FORBIDDEN'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fakeApp1 = new AppDefinitionRepresentationModel({
|
|
||||||
deploymentId: 26,
|
|
||||||
name: 'HR processes',
|
|
||||||
icon: 'glyphicon-cloud',
|
|
||||||
description: null,
|
|
||||||
theme: 'theme-6',
|
|
||||||
modelId: 4,
|
|
||||||
id: 1
|
|
||||||
});
|
|
||||||
|
|
||||||
export const fakeApp2 = new AppDefinitionRepresentationModel({
|
|
||||||
deploymentId: 2501,
|
|
||||||
name: 'Sales onboarding',
|
|
||||||
icon: 'glyphicon-asterisk',
|
|
||||||
description: null,
|
|
||||||
theme: 'theme-1',
|
|
||||||
modelId: 1002,
|
|
||||||
id: 1000
|
|
||||||
});
|
|
||||||
|
|
||||||
export const fakeTasksList = {
|
export const fakeTasksList = {
|
||||||
data: [new TaskDetailsModel({
|
data: [
|
||||||
|
new TaskDetailsModel({
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Task 1',
|
name: 'Task 1',
|
||||||
processInstanceId: 1000,
|
processInstanceId: 1000,
|
||||||
created: '2016-11-10T03:37:30.010+0000'
|
created: '2016-11-10T03:37:30.010+0000'
|
||||||
}), new TaskDetailsModel({
|
}),
|
||||||
|
new TaskDetailsModel({
|
||||||
id: 2,
|
id: 2,
|
||||||
name: 'Task 2',
|
name: 'Task 2',
|
||||||
processInstanceId: 1000,
|
processInstanceId: 1000,
|
||||||
created: '2016-11-10T03:37:30.010+0000'
|
created: '2016-11-10T03:37:30.010+0000'
|
||||||
})]
|
})
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fakeProcessDef = new ProcessDefinitionRepresentation({
|
export const fakeProcessDef = new ProcessDefinitionRepresentation({
|
||||||
|
@ -21,9 +21,7 @@ export * from './process/start-process.component.mock';
|
|||||||
export * from './process/process.model.mock';
|
export * from './process/process.model.mock';
|
||||||
export * from './process/process-comments.mock';
|
export * from './process/process-comments.mock';
|
||||||
|
|
||||||
export * from './task/start-task.mock';
|
|
||||||
export * from './task/task-details.mock';
|
export * from './task/task-details.mock';
|
||||||
export * from './task/task-details.component.mock';
|
|
||||||
export * from './task/task-list.mock';
|
export * from './task/task-list.mock';
|
||||||
export * from './task/tasklist-service.mock';
|
export * from './task/tasklist-service.mock';
|
||||||
export * from './process/process-filters.mock';
|
export * from './process/process-filters.mock';
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
/*!
|
|
||||||
* @license
|
|
||||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const startTaskMock = {
|
|
||||||
name: 'fakeName',
|
|
||||||
description: 'fakeDescription',
|
|
||||||
assignee: null,
|
|
||||||
dueDate: '2017-11-03T15:25:42.749+0000',
|
|
||||||
formKey: null,
|
|
||||||
category: 'fakeAppId'
|
|
||||||
};
|
|
@ -1,20 +0,0 @@
|
|||||||
/*!
|
|
||||||
* @license
|
|
||||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const mockTaskDetailsComponent = {
|
|
||||||
noTaskDetailsTemplateComponent: null
|
|
||||||
};
|
|
@ -18,46 +18,6 @@
|
|||||||
import { UserRepresentation } from '@alfresco/js-api';
|
import { UserRepresentation } from '@alfresco/js-api';
|
||||||
import { TaskDetailsModel } from '../../task-list/models/task-details.model';
|
import { TaskDetailsModel } from '../../task-list/models/task-details.model';
|
||||||
|
|
||||||
export const standaloneTaskWithForm = new TaskDetailsModel({
|
|
||||||
id: '100',
|
|
||||||
name: 'Standalone Task With Form',
|
|
||||||
description: null,
|
|
||||||
category: null,
|
|
||||||
assignee: {
|
|
||||||
id: 1001,
|
|
||||||
firstName: 'Wilbur',
|
|
||||||
lastName: 'Adams',
|
|
||||||
email: 'wilbur@app.activiti.com'
|
|
||||||
},
|
|
||||||
created: '2016-11-03T15:25:42.749+0000',
|
|
||||||
dueDate: null,
|
|
||||||
endDate: null,
|
|
||||||
duration: null,
|
|
||||||
priority: 50,
|
|
||||||
parentTaskId: null,
|
|
||||||
parentTaskName: null,
|
|
||||||
processInstanceId: null,
|
|
||||||
processInstanceName: null,
|
|
||||||
processDefinitionId: null,
|
|
||||||
processDefinitionName: null,
|
|
||||||
processDefinitionDescription: null,
|
|
||||||
processDefinitionKey: null,
|
|
||||||
processDefinitionCategory: null,
|
|
||||||
processDefinitionVersion: null,
|
|
||||||
processDefinitionDeploymentId: null,
|
|
||||||
formKey: '222',
|
|
||||||
processInstanceStartUserId: null,
|
|
||||||
initiatorCanCompleteTask: false,
|
|
||||||
adhocTaskCanBeReassigned: false,
|
|
||||||
taskDefinitionKey: 'sid-DDECD9E4-0299-433F-9193-C3D905C3EEBE',
|
|
||||||
executionId: '86',
|
|
||||||
involvedGroups: [],
|
|
||||||
involvedPeople: [],
|
|
||||||
memberOfCandidateUsers: false,
|
|
||||||
managerOfCandidateGroup: false,
|
|
||||||
memberOfCandidateGroup: false
|
|
||||||
});
|
|
||||||
|
|
||||||
export const standaloneTaskWithoutForm = new TaskDetailsModel({
|
export const standaloneTaskWithoutForm = new TaskDetailsModel({
|
||||||
id: '200',
|
id: '200',
|
||||||
name: 'Standalone Task Without Form',
|
name: 'Standalone Task Without Form',
|
||||||
@ -546,7 +506,7 @@ export const taskDetailsWithOutFormMock = new TaskDetailsModel({
|
|||||||
name: 'Request translation',
|
name: 'Request translation',
|
||||||
description: 'fake description',
|
description: 'fake description',
|
||||||
category: null,
|
category: null,
|
||||||
assignee: {id: 1001, firstName: 'Admin', lastName: 'Paul', email: 'fake-email@gmail.com' },
|
assignee: { id: 1001, firstName: 'Admin', lastName: 'Paul', email: 'fake-email@gmail.com' },
|
||||||
created: '2016-11-03T15:25:42.749+0000',
|
created: '2016-11-03T15:25:42.749+0000',
|
||||||
dueDate: '2016-11-03T15:25:42.749+0000',
|
dueDate: '2016-11-03T15:25:42.749+0000',
|
||||||
endDate: null,
|
endDate: null,
|
||||||
@ -829,7 +789,7 @@ export const taskFormMock = {
|
|||||||
customFieldsValueInfo: {},
|
customFieldsValueInfo: {},
|
||||||
gridsterForm: false,
|
gridsterForm: false,
|
||||||
globalDateFormat: 'D-M-YYYY'
|
globalDateFormat: 'D-M-YYYY'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const tasksMock = [new TaskDetailsModel(taskDetailsMock)];
|
export const tasksMock = [new TaskDetailsModel(taskDetailsMock)];
|
||||||
|
|
||||||
|
@ -18,107 +18,76 @@
|
|||||||
import { TaskListModel } from '../../task-list/models/task-list.model';
|
import { TaskListModel } from '../../task-list/models/task-list.model';
|
||||||
import { fakeAppFilter } from './task-filters.mock';
|
import { fakeAppFilter } from './task-filters.mock';
|
||||||
|
|
||||||
export const fakeApps = {
|
|
||||||
size: 2, total: 2, start: 0,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: 1, defaultAppId: null, name: 'Sales-Fakes-App', description: 'desc-fake1', modelId: 22,
|
|
||||||
theme: 'theme-1-fake', icon: 'glyphicon-asterisk', deploymentId: '111', tenantId: null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 2, defaultAppId: null, name: 'health-care-Fake', description: 'desc-fake2', modelId: 33,
|
|
||||||
theme: 'theme-2-fake', icon: 'glyphicon-asterisk', deploymentId: '444', tenantId: null
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
export const fakeUser1 = { id: 1, email: 'fake-email@dom.com', firstName: 'firstName', lastName: 'lastName' };
|
export const fakeUser1 = { id: 1, email: 'fake-email@dom.com', firstName: 'firstName', lastName: 'lastName' };
|
||||||
|
|
||||||
export const fakeUser2 = { id: 1001, email: 'some-one@somegroup.com', firstName: 'some', lastName: 'one' };
|
export const fakeUser2 = { id: 1001, email: 'some-one@somegroup.com', firstName: 'some', lastName: 'one' };
|
||||||
|
|
||||||
export const fakeTaskList = new TaskListModel({
|
export const fakeTaskList = new TaskListModel({
|
||||||
size: 1, total: 1, start: 0,
|
size: 1,
|
||||||
|
total: 1,
|
||||||
|
start: 0,
|
||||||
data: [
|
data: [
|
||||||
{
|
{
|
||||||
id: '1', name: 'FakeNameTask', description: null, category: null,
|
id: '1',
|
||||||
|
name: 'FakeNameTask',
|
||||||
|
description: null,
|
||||||
|
category: null,
|
||||||
assignee: fakeUser1,
|
assignee: fakeUser1,
|
||||||
created: '2016-07-15T11:19:17.440+0000'
|
created: '2016-07-15T11:19:17.440+0000'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
export const fakeTaskListDifferentProcessDefinitionKey = {
|
|
||||||
size: 2, total: 1, start: 0,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: '1', name: 'FakeNameTask', description: null, category: null,
|
|
||||||
assignee: fakeUser1,
|
|
||||||
processDefinitionKey: '1',
|
|
||||||
created: '2016-07-15T11:19:17.440+0000'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '2', name: 'FakeNameTask2', description: null, category: null,
|
|
||||||
assignee: fakeUser1,
|
|
||||||
processDefinitionKey: '2',
|
|
||||||
created: '2016-07-15T11:19:17.440+0000'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
export const secondFakeTaskList = {
|
export const secondFakeTaskList = {
|
||||||
size: 1, total: 1, start: 0,
|
size: 1,
|
||||||
|
total: 1,
|
||||||
|
start: 0,
|
||||||
data: [
|
data: [
|
||||||
{
|
{
|
||||||
id: '200', name: 'FakeNameTask', description: null, category: null,
|
id: '200',
|
||||||
|
name: 'FakeNameTask',
|
||||||
|
description: null,
|
||||||
|
category: null,
|
||||||
assignee: fakeUser1,
|
assignee: fakeUser1,
|
||||||
created: '2016-07-15T11:19:17.440+0000'
|
created: '2016-07-15T11:19:17.440+0000'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
export const mockErrorTaskList = {
|
|
||||||
error: 'wrong request'
|
|
||||||
};
|
|
||||||
|
|
||||||
export const fakeTaskDetails = { id: '999', name: 'fake-task-name', formKey: '99', assignee: fakeUser1 };
|
export const fakeTaskDetails = { id: '999', name: 'fake-task-name', formKey: '99', assignee: fakeUser1 };
|
||||||
|
|
||||||
export const fakeTasksComment = {
|
|
||||||
size: 2, total: 2, start: 0,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: 1, message: 'fake-message-1', created: '', createdBy: fakeUser1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 2, message: 'fake-message-2', created: '', createdBy: fakeUser1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
export const fakeTasksChecklist = {
|
export const fakeTasksChecklist = {
|
||||||
size: 1, total: 1, start: 0,
|
size: 1,
|
||||||
|
total: 1,
|
||||||
|
start: 0,
|
||||||
data: [
|
data: [
|
||||||
{
|
{
|
||||||
id: 1, name: 'FakeCheckTask1', description: null, category: null,
|
id: 1,
|
||||||
|
name: 'FakeCheckTask1',
|
||||||
|
description: null,
|
||||||
|
category: null,
|
||||||
assignee: fakeUser1,
|
assignee: fakeUser1,
|
||||||
created: '2016-07-15T11:19:17.440+0000'
|
created: '2016-07-15T11:19:17.440+0000'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2, name: 'FakeCheckTask2', description: null, category: null,
|
id: 2,
|
||||||
|
name: 'FakeCheckTask2',
|
||||||
|
description: null,
|
||||||
|
category: null,
|
||||||
assignee: fakeUser1,
|
assignee: fakeUser1,
|
||||||
created: '2016-07-15T11:19:17.440+0000'
|
created: '2016-07-15T11:19:17.440+0000'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fakeAppPromise = new Promise((resolve) => {
|
export const fakeAppPromise = Promise.resolve(fakeAppFilter);
|
||||||
resolve(fakeAppFilter);
|
|
||||||
});
|
|
||||||
|
|
||||||
export const fakeFormList = {
|
export const fakeFormList = {
|
||||||
size: 2,
|
size: 2,
|
||||||
total: 2,
|
total: 2,
|
||||||
start: 0,
|
start: 0,
|
||||||
data: [{
|
data: [
|
||||||
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'form with all widgets',
|
name: 'form with all widgets',
|
||||||
description: '',
|
description: '',
|
||||||
@ -136,7 +105,8 @@ export const fakeFormList = {
|
|||||||
favorite: null,
|
favorite: null,
|
||||||
permission: 'write',
|
permission: 'write',
|
||||||
tenantId: null
|
tenantId: null
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
name: 'uppy',
|
name: 'uppy',
|
||||||
description: '',
|
description: '',
|
||||||
@ -154,40 +124,53 @@ export const fakeFormList = {
|
|||||||
favorite: null,
|
favorite: null,
|
||||||
permission: 'write',
|
permission: 'write',
|
||||||
tenantId: null
|
tenantId: null
|
||||||
}]
|
}
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fakeTaskOpen1 = {
|
export const fakeTaskOpen1 = {
|
||||||
id: '1', name: 'FakeOpenTask1', description: null, category: null,
|
id: '1',
|
||||||
|
name: 'FakeOpenTask1',
|
||||||
|
description: null,
|
||||||
|
category: null,
|
||||||
assignee: fakeUser1,
|
assignee: fakeUser1,
|
||||||
created: '2017-07-15T11:19:17.440+0000',
|
created: '2017-07-15T11:19:17.440+0000',
|
||||||
dueDate: null,
|
dueDate: null,
|
||||||
endDate: null
|
endDate: null
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fakeTaskOpen2 = {
|
export const fakeTaskOpen2 = {
|
||||||
id: '1', name: 'FakeOpenTask2', description: null, category: null,
|
id: '1',
|
||||||
|
name: 'FakeOpenTask2',
|
||||||
|
description: null,
|
||||||
|
category: null,
|
||||||
assignee: { id: 1, email: 'fake-open-email@dom.com', firstName: 'firstName', lastName: 'lastName' },
|
assignee: { id: 1, email: 'fake-open-email@dom.com', firstName: 'firstName', lastName: 'lastName' },
|
||||||
created: '2017-07-15T11:19:17.440+0000',
|
created: '2017-07-15T11:19:17.440+0000',
|
||||||
dueDate: null,
|
dueDate: null,
|
||||||
endDate: null
|
endDate: null
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fakeTaskCompleted1 = {
|
export const fakeTaskCompleted1 = {
|
||||||
id: '1', name: 'FakeCompletedTaskName1', description: null, category: null,
|
id: '1',
|
||||||
|
name: 'FakeCompletedTaskName1',
|
||||||
|
description: null,
|
||||||
|
category: null,
|
||||||
assignee: { id: 1, email: 'fake-completed-email@dom.com', firstName: 'firstName', lastName: 'lastName' },
|
assignee: { id: 1, email: 'fake-completed-email@dom.com', firstName: 'firstName', lastName: 'lastName' },
|
||||||
created: '2016-07-15T11:19:17.440+0000',
|
created: '2016-07-15T11:19:17.440+0000',
|
||||||
dueDate: null,
|
dueDate: null,
|
||||||
endDate: '2016-11-03T15:25:42.749+0000'
|
endDate: '2016-11-03T15:25:42.749+0000'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fakeTaskCompleted2 = {
|
export const fakeTaskCompleted2 = {
|
||||||
id: '1', name: 'FakeCompletedTaskName2', description: null, category: null,
|
id: '1',
|
||||||
|
name: 'FakeCompletedTaskName2',
|
||||||
|
description: null,
|
||||||
|
category: null,
|
||||||
assignee: fakeUser1,
|
assignee: fakeUser1,
|
||||||
created: null,
|
created: null,
|
||||||
dueDate: null,
|
dueDate: null,
|
||||||
endDate: '2016-11-03T15:25:42.749+0000'
|
endDate: '2016-11-03T15:25:42.749+0000'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fakeOpenTaskList = new TaskListModel({
|
export const fakeOpenTaskList = new TaskListModel({
|
||||||
size: 2,
|
size: 2,
|
||||||
|
@ -15,15 +15,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild, ViewEncapsulation, OnDestroy } from '@angular/core';
|
||||||
Component, EventEmitter, Input, OnChanges, OnInit,
|
import { AppConfigService, AppConfigValues, FormValues } from '@alfresco/adf-core';
|
||||||
Output, SimpleChanges, ViewChild, ViewEncapsulation, OnDestroy
|
|
||||||
} from '@angular/core';
|
|
||||||
import {
|
|
||||||
AppConfigService,
|
|
||||||
AppConfigValues,
|
|
||||||
FormValues
|
|
||||||
} from '@alfresco/adf-core';
|
|
||||||
import { AppsProcessService } from '../../app-list/services/apps-process.service';
|
import { AppsProcessService } from '../../app-list/services/apps-process.service';
|
||||||
import { ProcessInstanceVariable } from '../models/process-instance-variable.model';
|
import { ProcessInstanceVariable } from '../models/process-instance-variable.model';
|
||||||
import { ProcessDefinitionRepresentation } from './../models/process-definition.model';
|
import { ProcessDefinitionRepresentation } from './../models/process-definition.model';
|
||||||
@ -35,7 +28,7 @@ import { map, takeUntil } from 'rxjs/operators';
|
|||||||
import { MatAutocompleteTrigger } from '@angular/material/autocomplete';
|
import { MatAutocompleteTrigger } from '@angular/material/autocomplete';
|
||||||
import { MatSelectChange } from '@angular/material/select';
|
import { MatSelectChange } from '@angular/material/select';
|
||||||
import { StartFormComponent } from '../../form';
|
import { StartFormComponent } from '../../form';
|
||||||
import { MinimalNode, RelatedContentRepresentation } from '@alfresco/js-api';
|
import { Node, RelatedContentRepresentation } from '@alfresco/js-api';
|
||||||
import { AppDefinitionRepresentationModel } from '../../task-list';
|
import { AppDefinitionRepresentationModel } from '../../task-list';
|
||||||
import { ProcessNamePipe } from '../../pipes/process-name.pipe';
|
import { ProcessNamePipe } from '../../pipes/process-name.pipe';
|
||||||
import { ActivitiContentService } from '../../form/services/activiti-alfresco.service';
|
import { ActivitiContentService } from '../../form/services/activiti-alfresco.service';
|
||||||
@ -48,7 +41,6 @@ const MAX_LENGTH = 255;
|
|||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestroy {
|
export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestroy {
|
||||||
|
|
||||||
/** (optional) Limit the list of processes that can be started to those
|
/** (optional) Limit the list of processes that can be started to those
|
||||||
* contained in the specified app.
|
* contained in the specified app.
|
||||||
*/
|
*/
|
||||||
@ -130,21 +122,25 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
|||||||
movedNodeToPS: FormValues;
|
movedNodeToPS: FormValues;
|
||||||
|
|
||||||
private onDestroy$ = new Subject<boolean>();
|
private onDestroy$ = new Subject<boolean>();
|
||||||
constructor(private activitiProcess: ProcessService,
|
constructor(
|
||||||
|
private activitiProcess: ProcessService,
|
||||||
private activitiContentService: ActivitiContentService,
|
private activitiContentService: ActivitiContentService,
|
||||||
private appsProcessService: AppsProcessService,
|
private appsProcessService: AppsProcessService,
|
||||||
private appConfig: AppConfigService,
|
private appConfig: AppConfigService,
|
||||||
private processNamePipe: ProcessNamePipe) {
|
private processNamePipe: ProcessNamePipe
|
||||||
}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.processNameInput = new UntypedFormControl('', [Validators.required, Validators.maxLength(this.maxProcessNameLength), Validators.pattern('^[^\\s]+(\\s+[^\\s]+)*$')]);
|
this.processNameInput = new UntypedFormControl('', [
|
||||||
|
Validators.required,
|
||||||
|
Validators.maxLength(this.maxProcessNameLength),
|
||||||
|
Validators.pattern('^[^\\s]+(\\s+[^\\s]+)*$')
|
||||||
|
]);
|
||||||
this.processDefinitionInput = new UntypedFormControl();
|
this.processDefinitionInput = new UntypedFormControl();
|
||||||
|
|
||||||
this.load();
|
this.load();
|
||||||
|
|
||||||
this.filteredProcessesDefinitions$ = this.processDefinitionInput.valueChanges
|
this.filteredProcessesDefinitions$ = this.processDefinitionInput.valueChanges.pipe(
|
||||||
.pipe(
|
|
||||||
map((value) => this._filter(value)),
|
map((value) => this._filter(value)),
|
||||||
takeUntil(this.onDestroy$)
|
takeUntil(this.onDestroy$)
|
||||||
);
|
);
|
||||||
@ -199,7 +195,9 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
|||||||
this.isProcessDefinitionsLoading = true;
|
this.isProcessDefinitionsLoading = true;
|
||||||
this.resetSelectedProcessDefinition();
|
this.resetSelectedProcessDefinition();
|
||||||
|
|
||||||
this.activitiProcess.getProcessDefinitions(appId).pipe(
|
this.activitiProcess
|
||||||
|
.getProcessDefinitions(appId)
|
||||||
|
.pipe(
|
||||||
map((processDefinitionRepresentations: ProcessDefinitionRepresentation[]) => {
|
map((processDefinitionRepresentations: ProcessDefinitionRepresentation[]) => {
|
||||||
let currentProcessDef: ProcessDefinitionRepresentation;
|
let currentProcessDef: ProcessDefinitionRepresentation;
|
||||||
|
|
||||||
@ -208,7 +206,9 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.processDefinitionName) {
|
if (this.processDefinitionName) {
|
||||||
const filteredProcessDefinition = processDefinitionRepresentations.find((processDefinition) => processDefinition.name === this.processDefinitionName);
|
const filteredProcessDefinition = processDefinitionRepresentations.find(
|
||||||
|
(processDefinition) => processDefinition.name === this.processDefinitionName
|
||||||
|
);
|
||||||
if (filteredProcessDefinition) {
|
if (filteredProcessDefinition) {
|
||||||
currentProcessDef = filteredProcessDefinition;
|
currentProcessDef = filteredProcessDefinition;
|
||||||
}
|
}
|
||||||
@ -216,7 +216,8 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
|||||||
|
|
||||||
return { currentProcessDef, processDefinitionRepresentations };
|
return { currentProcessDef, processDefinitionRepresentations };
|
||||||
})
|
})
|
||||||
).subscribe(
|
)
|
||||||
|
.subscribe(
|
||||||
(filteredProcessDefinitions) => {
|
(filteredProcessDefinitions) => {
|
||||||
this.processDefinitions = filteredProcessDefinitions.processDefinitionRepresentations;
|
this.processDefinitions = filteredProcessDefinitions.processDefinitionRepresentations;
|
||||||
this.processDefinitionSelectionChanged(filteredProcessDefinitions.currentProcessDef);
|
this.processDefinitionSelectionChanged(filteredProcessDefinitions.currentProcessDef);
|
||||||
@ -226,7 +227,8 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
|||||||
(error) => {
|
(error) => {
|
||||||
this.isProcessDefinitionsLoading = false;
|
this.isProcessDefinitionsLoading = false;
|
||||||
this.error.emit(error);
|
this.error.emit(error);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
filterProcessDefinitionByName() {
|
filterProcessDefinitionByName() {
|
||||||
@ -244,7 +246,8 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
|||||||
this.isAppsLoading = true;
|
this.isAppsLoading = true;
|
||||||
this.appsProcessService
|
this.appsProcessService
|
||||||
.getDeployedApplications()
|
.getDeployedApplications()
|
||||||
.pipe(map((response: AppDefinitionRepresentationModel[]) => {
|
.pipe(
|
||||||
|
map((response: AppDefinitionRepresentationModel[]) => {
|
||||||
const applications = this.removeDefaultApps(response);
|
const applications = this.removeDefaultApps(response);
|
||||||
let currentApplication: AppDefinitionRepresentationModel;
|
let currentApplication: AppDefinitionRepresentationModel;
|
||||||
|
|
||||||
@ -252,7 +255,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
|||||||
currentApplication = applications[0];
|
currentApplication = applications[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
const filteredApp = applications.find( app => app.id === +this.appId );
|
const filteredApp = applications.find((app) => app.id === +this.appId);
|
||||||
|
|
||||||
if (filteredApp) {
|
if (filteredApp) {
|
||||||
currentApplication = filteredApp;
|
currentApplication = filteredApp;
|
||||||
@ -261,7 +264,8 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
|||||||
return { currentApplication, applications };
|
return { currentApplication, applications };
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.subscribe((filteredApps) => {
|
.subscribe(
|
||||||
|
(filteredApps) => {
|
||||||
this.applications = filteredApps.applications;
|
this.applications = filteredApps.applications;
|
||||||
this.selectedApplication = filteredApps.currentApplication;
|
this.selectedApplication = filteredApps.currentApplication;
|
||||||
this.applicationSelection.emit(this.selectedApplication);
|
this.applicationSelection.emit(this.selectedApplication);
|
||||||
@ -274,7 +278,6 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
|||||||
this.error.emit(err);
|
this.error.emit(err);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadProcessDefinitionsBasedOnSelectedApp() {
|
loadProcessDefinitionsBasedOnSelectedApp() {
|
||||||
@ -328,10 +331,11 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
|||||||
for (const key in this.values) {
|
for (const key in this.values) {
|
||||||
if (this.values.hasOwnProperty(key)) {
|
if (this.values.hasOwnProperty(key)) {
|
||||||
const currentValue = Array.isArray(this.values[key]) ? this.values[key] : [this.values[key]];
|
const currentValue = Array.isArray(this.values[key]) ? this.values[key] : [this.values[key]];
|
||||||
const contents = currentValue.filter((value: any) => value && value.isFile)
|
const contents = currentValue
|
||||||
.map((content: MinimalNode) => this.activitiContentService.applyAlfrescoNode(content, null, accountIdentifier));
|
.filter((value: any) => value && value.isFile)
|
||||||
|
.map((content: Node) => this.activitiContentService.applyAlfrescoNode(content, null, accountIdentifier));
|
||||||
forkJoin(contents).subscribe((res: RelatedContentRepresentation[]) => {
|
forkJoin(contents).subscribe((res: RelatedContentRepresentation[]) => {
|
||||||
this.movedNodeToPS = { [key]: [...res]};
|
this.movedNodeToPS = { [key]: [...res] };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -435,7 +439,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
|||||||
return !!(this.selectedApplication && this.selectedApplication.id);
|
return !!(this.selectedApplication && this.selectedApplication.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private removeDefaultApps(apps: AppDefinitionRepresentationModel []): AppDefinitionRepresentationModel[] {
|
private removeDefaultApps(apps: AppDefinitionRepresentationModel[]): AppDefinitionRepresentationModel[] {
|
||||||
return apps.filter((app) => app.id);
|
return apps.filter((app) => app.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,8 +470,11 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
|||||||
}
|
}
|
||||||
|
|
||||||
private isProcessDefinitionChanged(changes: SimpleChanges) {
|
private isProcessDefinitionChanged(changes: SimpleChanges) {
|
||||||
return changes['processDefinitionName'] && changes['processDefinitionName'].currentValue &&
|
return (
|
||||||
changes['processDefinitionName'].currentValue !== changes['processDefinitionName'].previousValue;
|
changes['processDefinitionName'] &&
|
||||||
|
changes['processDefinitionName'].currentValue &&
|
||||||
|
changes['processDefinitionName'].currentValue !== changes['processDefinitionName'].previousValue
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _filter(value: string): ProcessDefinitionRepresentation[] {
|
private _filter(value: string): ProcessDefinitionRepresentation[] {
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
"types": ["jasmine", "node", "jasminewd2"],
|
"types": ["jasmine", "node", "jasminewd2"],
|
||||||
"lib": ["es2018", "esnext.array", "esnext.asynciterable", "dom"],
|
"lib": ["es2018", "esnext.array", "esnext.asynciterable", "dom"],
|
||||||
"paths": {
|
"paths": {
|
||||||
"@alfresco/adf-content-services": ["lib/content-services"],
|
"@alfresco/adf-content-services": ["lib/content-services/src/public-api.ts"],
|
||||||
"@alfresco/adf-core": ["lib/core"],
|
"@alfresco/adf-core": ["lib/core/src/public-api.ts"],
|
||||||
"@alfresco/adf-core/*": ["lib/core/*/public-api.ts"],
|
"@alfresco/adf-core/*": ["lib/core/*/public-api.ts"],
|
||||||
"@alfresco/adf-core/api": ["lib/core/api/src/index.ts"],
|
"@alfresco/adf-core/api": ["lib/core/api/src/index.ts"],
|
||||||
"@alfresco/adf-core/auth": ["lib/core/auth/src/index.ts"],
|
"@alfresco/adf-core/auth": ["lib/core/auth/src/index.ts"],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user