mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-5426] Remove compatibility layer from Lib (#7110)
* remove compatibility step 1 * remove compatibility step 2 * remove compatibility step 3 * remove compatibility step 4 * remove compatibility step 5
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
/* tslint:disable:no-input-rename */
|
||||
|
||||
import { Directive, EventEmitter, HostListener, Input, OnChanges, Output } from '@angular/core';
|
||||
import { FavoriteBody, NodeEntry, SharedLinkEntry, Node, SharedLink } from '@alfresco/js-api';
|
||||
import { FavoriteBody, NodeEntry, SharedLinkEntry, Node, SharedLink, FavoritesApi } from '@alfresco/js-api';
|
||||
import { Observable, from, forkJoin, of } from 'rxjs';
|
||||
import { AlfrescoApiService } from '../services/alfresco-api.service';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
@@ -30,6 +30,8 @@ import { catchError, map } from 'rxjs/operators';
|
||||
export class NodeFavoriteDirective implements OnChanges {
|
||||
favorites: any[] = [];
|
||||
|
||||
private favoritesApi: FavoritesApi;
|
||||
|
||||
/** Array of nodes to toggle as favorites. */
|
||||
@Input('adf-node-favorite')
|
||||
selection: NodeEntry[] = [];
|
||||
@@ -46,6 +48,7 @@ export class NodeFavoriteDirective implements OnChanges {
|
||||
}
|
||||
|
||||
constructor(private alfrescoApiService: AlfrescoApiService) {
|
||||
this.favoritesApi = new FavoritesApi(this.alfrescoApiService.getInstance());
|
||||
}
|
||||
|
||||
ngOnChanges(changes) {
|
||||
@@ -70,7 +73,7 @@ export class NodeFavoriteDirective implements OnChanges {
|
||||
// shared files have nodeId
|
||||
const id = (<SharedLinkEntry> selected).entry.nodeId || selected.entry.id;
|
||||
|
||||
return from(this.alfrescoApiService.favoritesApi.removeFavoriteSite('-me-', id));
|
||||
return from(this.favoritesApi.deleteFavorite('-me-', id));
|
||||
});
|
||||
|
||||
forkJoin(batch).subscribe(
|
||||
@@ -86,7 +89,7 @@ export class NodeFavoriteDirective implements OnChanges {
|
||||
const notFavorite = this.favorites.filter((node) => !node.entry.isFavorite);
|
||||
const body: FavoriteBody[] = notFavorite.map((node) => this.createFavoriteBody(node));
|
||||
|
||||
from(this.alfrescoApiService.favoritesApi.addFavorite('-me-', <any> body))
|
||||
from(this.favoritesApi.createFavorite('-me-', <any> body))
|
||||
.subscribe(
|
||||
() => {
|
||||
notFavorite.map((selected) => selected.entry.isFavorite = true);
|
||||
@@ -133,9 +136,9 @@ export class NodeFavoriteDirective implements OnChanges {
|
||||
|
||||
// ACS 5.x and 6.x without 'isFavorite' include
|
||||
const { name, isFile, isFolder } = <Node> node;
|
||||
const id = (<SharedLink> node).nodeId || node.id;
|
||||
const id = (<SharedLink> node).nodeId || node.id;
|
||||
|
||||
const promise = this.alfrescoApiService.favoritesApi.getFavorite('-me-', id);
|
||||
const promise = this.favoritesApi.getFavorite('-me-', id);
|
||||
|
||||
return from(promise).pipe(
|
||||
map(() => ({
|
||||
|
Reference in New Issue
Block a user