mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-8959] Introduce new takeUntilDestroyed
operator where possible (#10388)
This commit is contained in:
committed by
GitHub
parent
3f6b60760f
commit
3078387325
@@ -15,10 +15,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, DestroyRef, EventEmitter, inject, Input, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
||||
import { NodesApiService } from '../common/services/nodes-api.service';
|
||||
import { Observable, Subject, zip } from 'rxjs';
|
||||
import { concatMap, map, takeUntil, tap } from 'rxjs/operators';
|
||||
import { Observable, zip } from 'rxjs';
|
||||
import { concatMap, map, tap } from 'rxjs/operators';
|
||||
import { AspectListService } from './services/aspect-list.service';
|
||||
import { MatCheckboxChange, MatCheckboxModule } from '@angular/material/checkbox';
|
||||
import { AspectEntry } from '@alfresco/js-api';
|
||||
@@ -27,6 +27,7 @@ import { MatExpansionModule } from '@angular/material/expansion';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-aspect-list',
|
||||
@@ -36,7 +37,7 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
styleUrls: ['./aspect-list.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class AspectListComponent implements OnInit, OnDestroy {
|
||||
export class AspectListComponent implements OnInit {
|
||||
/** Node Id of the node that we want to update */
|
||||
@Input()
|
||||
nodeId: string = '';
|
||||
@@ -60,15 +61,10 @@ export class AspectListComponent implements OnInit, OnDestroy {
|
||||
notDisplayedAspects: string[] = [];
|
||||
hasEqualAspect: boolean = true;
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(private aspectListService: AspectListService, private nodeApiService: NodesApiService) {}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
let aspects$: Observable<AspectEntry[]>;
|
||||
if (this.nodeId) {
|
||||
@@ -89,10 +85,10 @@ export class AspectListComponent implements OnInit, OnDestroy {
|
||||
this.updateCounter.emit(this.nodeAspects.length);
|
||||
}),
|
||||
concatMap(() => this.aspectListService.getAspects()),
|
||||
takeUntil(this.onDestroy$)
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
);
|
||||
} else {
|
||||
aspects$ = this.aspectListService.getAspects().pipe(takeUntil(this.onDestroy$));
|
||||
aspects$ = this.aspectListService.getAspects().pipe(takeUntilDestroyed(this.destroyRef));
|
||||
}
|
||||
this.aspects$ = aspects$.pipe(map((aspects) => aspects.filter((aspect) => !this.excludedAspects.includes(aspect.entry.id))));
|
||||
}
|
||||
|
@@ -15,15 +15,25 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, ViewChild, ViewEncapsulation, OnDestroy } from '@angular/core';
|
||||
import {
|
||||
Component,
|
||||
DestroyRef,
|
||||
EventEmitter,
|
||||
inject,
|
||||
Input,
|
||||
OnChanges,
|
||||
OnInit,
|
||||
Output,
|
||||
ViewChild,
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import { MatSelect, MatSelectModule } from '@angular/material/select';
|
||||
import { Node, PathElement } from '@alfresco/js-api';
|
||||
import { DocumentListComponent } from '../document-list/components/document-list.component';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-breadcrumb',
|
||||
@@ -34,7 +44,7 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-breadcrumb' }
|
||||
})
|
||||
export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy {
|
||||
export class BreadcrumbComponent implements OnInit, OnChanges {
|
||||
/** Active node, builds UI based on folderNode.path.elements collection. */
|
||||
@Input()
|
||||
folderNode: Node = null;
|
||||
@@ -86,7 +96,7 @@ export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy {
|
||||
|
||||
route: PathElement[] = [];
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
get hasRoot(): boolean {
|
||||
return !!this.root;
|
||||
@@ -104,7 +114,7 @@ export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy {
|
||||
this.transform = this.transform ? this.transform : null;
|
||||
|
||||
if (this.target) {
|
||||
this.target.$folderNode.pipe(takeUntil(this.onDestroy$)).subscribe((folderNode: Node) => {
|
||||
this.target.$folderNode.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((folderNode: Node) => {
|
||||
this.folderNode = folderNode;
|
||||
this.recalculateNodes();
|
||||
});
|
||||
@@ -201,9 +211,4 @@ export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
}
|
||||
|
@@ -16,10 +16,22 @@
|
||||
*/
|
||||
|
||||
import { Category } from '@alfresco/js-api';
|
||||
import { Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||
import {
|
||||
Component,
|
||||
DestroyRef,
|
||||
ElementRef,
|
||||
EventEmitter,
|
||||
inject,
|
||||
Input,
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
Output,
|
||||
ViewChild,
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import { FormControl, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { EMPTY, Observable, Subject, timer } from 'rxjs';
|
||||
import { debounce, first, map, takeUntil, tap } from 'rxjs/operators';
|
||||
import { debounce, first, map, tap } from 'rxjs/operators';
|
||||
import { CategoriesManagementMode } from './categories-management-mode';
|
||||
import { CategoryService } from '../services/category.service';
|
||||
import { CommonModule } from '@angular/common';
|
||||
@@ -30,6 +42,7 @@ import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatListModule } from '@angular/material/list';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
interface CategoryNameControlErrors {
|
||||
duplicatedExistingCategory?: boolean;
|
||||
@@ -66,7 +79,6 @@ export class CategoriesManagementComponent implements OnInit, OnDestroy {
|
||||
|
||||
private existingCategoryLoaded$ = new Subject<void>();
|
||||
private cancelExistingCategoriesLoading$ = new Subject<void>();
|
||||
private onDestroy$ = new Subject<void>();
|
||||
private _categoryNameControl = new FormControl<string>(
|
||||
'',
|
||||
[this.validateIfNotAlreadyAdded.bind(this), this.validateEmptyCategory, Validators.required],
|
||||
@@ -147,6 +159,8 @@ export class CategoriesManagementComponent implements OnInit, OnDestroy {
|
||||
@ViewChild('categoryNameInput')
|
||||
private categoryNameInputElement: ElementRef;
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(private categoryService: CategoryService) {}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -162,11 +176,11 @@ export class CategoriesManagementComponent implements OnInit, OnDestroy {
|
||||
this.cancelExistingCategoriesLoading$.next();
|
||||
}),
|
||||
debounce((name: string) => (name ? timer(300) : EMPTY)),
|
||||
takeUntil(this.onDestroy$)
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
)
|
||||
.subscribe((name: string) => this.onNameControlValueChange(name));
|
||||
|
||||
this.categoryNameControl.statusChanges.pipe(takeUntil(this.onDestroy$)).subscribe(() => this.setCategoryNameControlErrorMessageKey());
|
||||
this.categoryNameControl.statusChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.setCategoryNameControlErrorMessageKey());
|
||||
|
||||
this.setCategoryNameControlErrorMessageKey();
|
||||
|
||||
@@ -178,7 +192,7 @@ export class CategoriesManagementComponent implements OnInit, OnDestroy {
|
||||
this._categoryNameControl.removeValidators(Validators.required);
|
||||
this.categories.forEach((category) => this.initialCategories.push(category));
|
||||
if (this.classifiableChanged) {
|
||||
this.classifiableChanged.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
|
||||
this.classifiableChanged.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
||||
this.categories = [];
|
||||
this.categoryNameControlVisible = false;
|
||||
this.categoryNameControlVisibleChange.emit(false);
|
||||
@@ -188,8 +202,6 @@ export class CategoriesManagementComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next();
|
||||
this.onDestroy$.complete();
|
||||
this.cancelExistingCategoriesLoading$.next();
|
||||
this.cancelExistingCategoriesLoading$.complete();
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, DestroyRef, inject, Input, OnChanges, OnInit, SimpleChanges, ViewEncapsulation } from '@angular/core';
|
||||
import { Category, CategoryEntry, CategoryLinkBody, CategoryPaging, Node, TagBody, TagEntry, TagPaging } from '@alfresco/js-api';
|
||||
import { forkJoin, Observable, of, Subject, zip } from 'rxjs';
|
||||
import {
|
||||
@@ -28,8 +28,8 @@ import {
|
||||
UpdateNotification
|
||||
} from '@alfresco/adf-core';
|
||||
import { ContentMetadataService } from '../../services/content-metadata.service';
|
||||
import { CardViewGroup, PresetConfig, ContentMetadataCustomPanel, ContentMetadataPanel } from '../../interfaces/content-metadata.interfaces';
|
||||
import { catchError, debounceTime, map, takeUntil } from 'rxjs/operators';
|
||||
import { CardViewGroup, ContentMetadataCustomPanel, ContentMetadataPanel, PresetConfig } from '../../interfaces/content-metadata.interfaces';
|
||||
import { catchError, debounceTime, map } from 'rxjs/operators';
|
||||
import { CardViewContentUpdateService } from '../../../common/services/card-view-content-update.service';
|
||||
import { NodesApiService } from '../../../common/services/nodes-api.service';
|
||||
import { TagsCreatorMode } from '../../../tag/tags-creator/tags-creator-mode';
|
||||
@@ -49,6 +49,7 @@ import { CategoriesManagementComponent } from '../../../category';
|
||||
import { DynamicExtensionComponent } from '@alfresco/adf-extensions';
|
||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||
import { TagsCreatorComponent } from '../../../tag';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
const DEFAULT_SEPARATOR = ', ';
|
||||
|
||||
@@ -80,9 +81,7 @@ enum DefaultPanels {
|
||||
host: { class: 'adf-content-metadata' },
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
||||
protected onDestroy$ = new Subject<boolean>();
|
||||
|
||||
export class ContentMetadataComponent implements OnChanges, OnInit {
|
||||
/** (required) The node entity to fetch metadata about */
|
||||
@Input()
|
||||
node: Node;
|
||||
@@ -167,6 +166,8 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
||||
panelTitle: ''
|
||||
};
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(
|
||||
private contentMetadataService: ContentMetadataService,
|
||||
private cardViewContentUpdateService: CardViewContentUpdateService,
|
||||
@@ -185,14 +186,14 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
||||
|
||||
ngOnInit() {
|
||||
this.cardViewContentUpdateService.itemUpdated$
|
||||
.pipe(debounceTime(500), takeUntil(this.onDestroy$))
|
||||
.pipe(debounceTime(500), takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((updatedNode: UpdateNotification) => {
|
||||
this.hasMetadataChanged = true;
|
||||
this.targetProperty = updatedNode.target;
|
||||
this.updateChanges(updatedNode.changed);
|
||||
});
|
||||
|
||||
this.cardViewContentUpdateService.updatedAspect$.pipe(debounceTime(500), takeUntil(this.onDestroy$)).subscribe((node) => {
|
||||
this.cardViewContentUpdateService.updatedAspect$.pipe(debounceTime(500), takeUntilDestroyed(this.destroyRef)).subscribe((node) => {
|
||||
this.node.aspectNames = node?.aspectNames;
|
||||
this.loadProperties(node);
|
||||
});
|
||||
@@ -274,11 +275,6 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
updateChanges(updatedNodeChanges) {
|
||||
Object.keys(updatedNodeChanges).map((propertyGroup: string) => {
|
||||
if (typeof updatedNodeChanges[propertyGroup] === 'object') {
|
||||
|
@@ -15,27 +15,27 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { inject, Injectable, Injector, runInInjectionContext } from '@angular/core';
|
||||
import {
|
||||
CardViewItemProperties,
|
||||
CardViewItem,
|
||||
CardViewTextItemModel,
|
||||
AppConfigService,
|
||||
CardViewBoolItemModel,
|
||||
CardViewDateItemModel,
|
||||
CardViewSelectItemModel,
|
||||
CardViewDatetimeItemModel,
|
||||
CardViewIntItemModel,
|
||||
CardViewLongItemModel,
|
||||
CardViewFloatItemModel,
|
||||
MultiValuePipe,
|
||||
AppConfigService,
|
||||
CardViewIntItemModel,
|
||||
CardViewItem,
|
||||
CardViewItemProperties,
|
||||
CardViewLongItemModel,
|
||||
CardViewSelectItemModel,
|
||||
CardViewTextItemModel,
|
||||
DecimalNumberPipe,
|
||||
LogService,
|
||||
MultiValuePipe,
|
||||
UserPreferencesService
|
||||
} from '@alfresco/adf-core';
|
||||
import { Property, CardViewGroup, OrganisedPropertyGroup } from '../interfaces/content-metadata.interfaces';
|
||||
import { CardViewGroup, OrganisedPropertyGroup, Property } from '../interfaces/content-metadata.interfaces';
|
||||
import { of } from 'rxjs';
|
||||
import { Definition, Constraint, Property as PropertyBase } from '@alfresco/js-api';
|
||||
import { Constraint, Definition, Property as PropertyBase } from '@alfresco/js-api';
|
||||
|
||||
const D_TEXT = 'd:text';
|
||||
const D_MLTEXT = 'd:mltext';
|
||||
@@ -59,6 +59,8 @@ export class PropertyGroupTranslatorService {
|
||||
|
||||
valueSeparator: string;
|
||||
|
||||
private readonly injector = inject(Injector);
|
||||
|
||||
constructor() {
|
||||
this.valueSeparator = this.appConfig.get<string>('content-metadata.multi-value-pipe-separator');
|
||||
}
|
||||
@@ -156,10 +158,7 @@ export class PropertyGroupTranslatorService {
|
||||
cardViewItemProperty = new CardViewFloatItemModel(
|
||||
Object.assign(propertyDefinition, {
|
||||
multivalued: isMultiValued,
|
||||
pipes: [
|
||||
{ pipe: new DecimalNumberPipe(this.userPreferenceService, this.appConfig) },
|
||||
{ pipe: new MultiValuePipe(), params: [this.valueSeparator] }
|
||||
]
|
||||
pipes: [{ pipe: this.getDecimalNumberPipe() }, { pipe: new MultiValuePipe(), params: [this.valueSeparator] }]
|
||||
})
|
||||
);
|
||||
break;
|
||||
@@ -218,4 +217,12 @@ export class PropertyGroupTranslatorService {
|
||||
private isEmpty(value: any): boolean {
|
||||
return value === undefined || value === null || value === '';
|
||||
}
|
||||
|
||||
private getDecimalNumberPipe(): DecimalNumberPipe {
|
||||
let decimalNumberPipe: DecimalNumberPipe;
|
||||
runInInjectionContext(this.injector, () => {
|
||||
decimalNumberPipe = new DecimalNumberPipe(this.userPreferenceService, this.appConfig);
|
||||
});
|
||||
return decimalNumberPipe;
|
||||
}
|
||||
}
|
||||
|
@@ -15,32 +15,56 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, EventEmitter, Input, OnInit, Output, ViewChild, ViewEncapsulation, OnDestroy } from '@angular/core';
|
||||
import {
|
||||
Component,
|
||||
DestroyRef,
|
||||
EventEmitter,
|
||||
inject,
|
||||
Input,
|
||||
OnInit,
|
||||
Output,
|
||||
ViewChild,
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import {
|
||||
CustomEmptyContentTemplateDirective,
|
||||
DataColumnComponent,
|
||||
DataColumnListComponent,
|
||||
DataSorting,
|
||||
HighlightDirective,
|
||||
UserPreferencesService,
|
||||
UserPreferenceValues,
|
||||
InfinitePaginationComponent,
|
||||
PaginatedComponent,
|
||||
DataSorting,
|
||||
ShowHeaderMode,
|
||||
ToolbarTitleComponent,
|
||||
ToolbarComponent,
|
||||
DataColumnListComponent,
|
||||
DataColumnComponent,
|
||||
CustomEmptyContentTemplateDirective
|
||||
ToolbarTitleComponent,
|
||||
UserPreferencesService,
|
||||
UserPreferenceValues
|
||||
} from '@alfresco/adf-core';
|
||||
import { NodesApiService, UploadService, FileUploadCompleteEvent, FileUploadDeleteEvent, SitesService } from '../../common';
|
||||
import {
|
||||
FileUploadCompleteEvent,
|
||||
FileUploadDeleteEvent,
|
||||
NodesApiService,
|
||||
SitesService,
|
||||
UploadService
|
||||
} from '../../common';
|
||||
import { ReactiveFormsModule, UntypedFormControl } from '@angular/forms';
|
||||
import { Node, NodePaging, Pagination, SiteEntry, SitePaging, NodeEntry, SearchRequest, RequestScope } from '@alfresco/js-api';
|
||||
import {
|
||||
Node,
|
||||
NodeEntry,
|
||||
NodePaging,
|
||||
Pagination,
|
||||
RequestScope,
|
||||
SearchRequest,
|
||||
SiteEntry,
|
||||
SitePaging
|
||||
} from '@alfresco/js-api';
|
||||
import { DocumentListComponent } from '../../document-list/components/document-list.component';
|
||||
import { RowFilter } from '../../document-list/data/row-filter.model';
|
||||
import { ImageResolver } from '../../document-list/data/image-resolver.model';
|
||||
import { CustomResourcesService } from '../../document-list/services/custom-resources.service';
|
||||
import { ShareDataRow } from '../../document-list/data/share-data-row.model';
|
||||
import { NodeEntryEvent } from '../../document-list/components/node.event';
|
||||
import { debounceTime, takeUntil } from 'rxjs/operators';
|
||||
import { Subject } from 'rxjs';
|
||||
import { debounceTime } from 'rxjs/operators';
|
||||
import { ContentNodeSelectorPanelService } from './content-node-selector-panel.service';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
@@ -55,6 +79,7 @@ import { NameLocationCellComponent } from '../name-location-cell/name-location-c
|
||||
import { DropdownBreadcrumbComponent } from '../../breadcrumb/dropdown-breadcrumb.component';
|
||||
import { SearchQueryBuilderService } from '../../search/services/search-query-builder.service';
|
||||
import { SearchPanelComponent } from '../../search/components/search-panel/search-panel.component';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
export type ValidationFunction = (entry: Node) => boolean;
|
||||
|
||||
@@ -92,7 +117,7 @@ export const defaultValidation = () => true;
|
||||
host: { class: 'adf-content-node-selector-panel' },
|
||||
providers: [SearchQueryBuilderService]
|
||||
})
|
||||
export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
||||
export class ContentNodeSelectorPanelComponent implements OnInit {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
DEFAULT_PAGINATION: Pagination = new Pagination({
|
||||
maxItems: 25,
|
||||
@@ -303,7 +328,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
||||
|
||||
searchPanelExpanded: boolean = false;
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(
|
||||
private customResourcesService: CustomResourcesService,
|
||||
@@ -333,13 +358,13 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.searchInput.valueChanges.pipe(debounceTime(this.debounceSearch), takeUntil(this.onDestroy$)).subscribe((searchValue: string) => {
|
||||
this.searchInput.valueChanges.pipe(debounceTime(this.debounceSearch), takeUntilDestroyed(this.destroyRef)).subscribe((searchValue: string) => {
|
||||
this.searchTerm = searchValue;
|
||||
this.queryBuilderService.userQuery = searchValue.length > 0 ? `${searchValue}*` : searchValue;
|
||||
this.queryBuilderService.update();
|
||||
});
|
||||
|
||||
this.queryBuilderService.updated.pipe(takeUntil(this.onDestroy$)).subscribe((searchRequest) => {
|
||||
this.queryBuilderService.updated.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((searchRequest) => {
|
||||
if (searchRequest) {
|
||||
this.hasValidQuery = true;
|
||||
this.prepareDialogForNewSearch(searchRequest);
|
||||
@@ -351,7 +376,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
});
|
||||
|
||||
this.queryBuilderService.executed.pipe(takeUntil(this.onDestroy$)).subscribe((results: NodePaging) => {
|
||||
this.queryBuilderService.executed.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((results: NodePaging) => {
|
||||
if (this.hasValidQuery) {
|
||||
this.showSearchResults(results);
|
||||
}
|
||||
@@ -359,7 +384,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
||||
|
||||
this.userPreferencesService
|
||||
.select(UserPreferenceValues.PaginationSize)
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((pagSize) => (this.pageSize = pagSize));
|
||||
|
||||
this.target = this.documentList;
|
||||
@@ -380,16 +405,11 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
||||
this.resetPagination();
|
||||
this.setSearchScopeToNodes();
|
||||
|
||||
this.documentList.$folderNode.pipe(takeUntil(this.onDestroy$)).subscribe((currentNode: Node) => {
|
||||
this.documentList.$folderNode.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((currentNode: Node) => {
|
||||
this.currentFolder.emit(currentNode);
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
toggleSearchPanel() {
|
||||
this.searchPanelExpanded = !this.searchPanelExpanded;
|
||||
}
|
||||
@@ -400,7 +420,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
||||
|
||||
private onFileUploadEvent() {
|
||||
this.uploadService.fileUploadComplete
|
||||
.pipe(debounceTime(500), takeUntil(this.onDestroy$))
|
||||
.pipe(debounceTime(500), takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((fileUploadEvent: FileUploadCompleteEvent) => {
|
||||
this.currentUploadBatch.push(fileUploadEvent.data);
|
||||
if (!this.uploadService.isUploading()) {
|
||||
@@ -412,7 +432,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private onFileUploadDeletedEvent() {
|
||||
this.uploadService.fileUploadDeleted.pipe(takeUntil(this.onDestroy$)).subscribe((deletedFileEvent: FileUploadDeleteEvent) => {
|
||||
this.uploadService.fileUploadDeleted.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((deletedFileEvent: FileUploadDeleteEvent) => {
|
||||
this.documentList.unselectRowFromNodeId(deletedFileEvent.file.data.entry.id);
|
||||
this.documentList.reloadWithoutResettingSelection();
|
||||
});
|
||||
|
@@ -15,9 +15,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Inject, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, DestroyRef, inject, Inject, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { TranslationService, NotificationService, ToolbarTitleComponent, ToolbarComponent, EmptyListComponent } from '@alfresco/adf-core';
|
||||
import {
|
||||
EmptyListComponent,
|
||||
NotificationService,
|
||||
ToolbarComponent,
|
||||
ToolbarTitleComponent,
|
||||
TranslationService
|
||||
} from '@alfresco/adf-core';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
import { AllowableOperationsEnum } from '../common/models/allowable-operations.enum';
|
||||
import { ContentService } from '../common/services/content.service';
|
||||
@@ -26,8 +32,6 @@ import { ContentNodeSelectorComponentData } from './content-node-selector.compon
|
||||
import { NodeEntryEvent } from '../document-list/components/node.event';
|
||||
import { NodeAction } from '../document-list/models/node-action.enum';
|
||||
import { OverlayContainer } from '@angular/cdk/overlay';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatTabsModule } from '@angular/material/tabs';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
@@ -39,6 +43,7 @@ import { FileUploadingDialogComponent } from '../upload/components/file-uploadin
|
||||
import { ContentNodeSelectorPanelComponent } from './content-node-selector-panel/content-node-selector-panel.component';
|
||||
import { UploadButtonComponent } from '../upload/components/upload-button.component';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-content-node-selector',
|
||||
@@ -64,8 +69,7 @@ import { MatButtonModule } from '@angular/material/button';
|
||||
styleUrls: ['./content-node-selector.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class ContentNodeSelectorComponent implements OnInit, OnDestroy {
|
||||
private onDestroy$ = new Subject<void>();
|
||||
export class ContentNodeSelectorComponent implements OnInit {
|
||||
|
||||
title: string;
|
||||
action: NodeAction;
|
||||
@@ -81,6 +85,8 @@ export class ContentNodeSelectorComponent implements OnInit, OnDestroy {
|
||||
emptyFolderImageUrl: string = './assets/images/empty_doc_lib.svg';
|
||||
breadcrumbFolderNode: Node;
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(
|
||||
private translation: TranslationService,
|
||||
private contentService: ContentService,
|
||||
@@ -99,7 +105,7 @@ export class ContentNodeSelectorComponent implements OnInit, OnDestroy {
|
||||
ngOnInit() {
|
||||
this.dialog
|
||||
.keydownEvents()
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((event) => {
|
||||
if (event?.key === 'Escape') {
|
||||
event.preventDefault();
|
||||
@@ -110,28 +116,22 @@ export class ContentNodeSelectorComponent implements OnInit, OnDestroy {
|
||||
|
||||
this.dialog
|
||||
.backdropClick()
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe(() => {
|
||||
this.close();
|
||||
});
|
||||
|
||||
this.dialog
|
||||
.afterOpened()
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe(() => {
|
||||
this.overlayContainer.getContainerElement().setAttribute('role', 'main');
|
||||
});
|
||||
|
||||
this.uploadService.fileUploadStarting.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
|
||||
this.uploadService.fileUploadStarting.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
||||
this.uploadStarted = true;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next();
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
close() {
|
||||
this.dialog.close();
|
||||
this.overlayContainer.getContainerElement().setAttribute('role', 'region');
|
||||
|
@@ -15,18 +15,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Inject, OnInit, ViewEncapsulation, ViewChild, OnDestroy } from '@angular/core';
|
||||
import { Component, Inject, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialog, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { MatSlideToggleChange, MatSlideToggleModule } from '@angular/material/slide-toggle';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { Subject } from 'rxjs';
|
||||
import { ContentService } from '../common/services/content.service';
|
||||
import { SharedLinksApiService } from './services/shared-links-api.service';
|
||||
import { SharedLinkBodyCreate } from '@alfresco/js-api';
|
||||
import { ClipboardDirective, ConfirmDialogComponent } from '@alfresco/adf-core';
|
||||
import { ContentNodeShareSettings } from './content-node-share.settings';
|
||||
import { RenditionService } from '../common/services/rendition.service';
|
||||
import { format, add, endOfDay, isBefore } from 'date-fns';
|
||||
import { add, endOfDay, format, isBefore } from 'date-fns';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
@@ -61,7 +60,7 @@ interface SharedDialogFormProps {
|
||||
host: { class: 'adf-share-dialog' },
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class ShareDialogComponent implements OnInit, OnDestroy {
|
||||
export class ShareDialogComponent implements OnInit {
|
||||
private minDateValidator = (control: FormControl<Date>): any =>
|
||||
isBefore(endOfDay(new Date(control.value)), this.minDate) ? { invalidDate: true } : null;
|
||||
|
||||
@@ -80,9 +79,6 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
|
||||
|
||||
@ViewChild('slideToggleExpirationDate', { static: true })
|
||||
slideToggleExpirationDate;
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(
|
||||
private sharedLinksApiService: SharedLinksApiService,
|
||||
private dialogRef: MatDialogRef<ShareDialogComponent>,
|
||||
@@ -121,12 +117,6 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
|
||||
get time(): FormControl<Date> {
|
||||
return this.form.controls['time'];
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
onSlideShareChange(event: MatSlideToggleChange) {
|
||||
if (event.checked) {
|
||||
this.createSharedLinks(this.data.node.entry.id);
|
||||
|
@@ -15,21 +15,21 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Directive, Input, HostListener, OnChanges, NgZone, OnDestroy } from '@angular/core';
|
||||
import { DestroyRef, Directive, HostListener, inject, Input, NgZone, OnChanges } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { NodeEntry, NodesApi } from '@alfresco/js-api';
|
||||
|
||||
import { ShareDialogComponent } from './content-node-share.dialog';
|
||||
import { Observable, from, Subject } from 'rxjs';
|
||||
import { from, Observable } from 'rxjs';
|
||||
import { AlfrescoApiService } from '../services/alfresco-api.service';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Directive({
|
||||
selector: '[adf-share]',
|
||||
standalone: true,
|
||||
exportAs: 'adfShare'
|
||||
})
|
||||
export class NodeSharedDirective implements OnChanges, OnDestroy {
|
||||
export class NodeSharedDirective implements OnChanges {
|
||||
isFile: boolean = false;
|
||||
isShared: boolean = false;
|
||||
|
||||
@@ -42,7 +42,6 @@ export class NodeSharedDirective implements OnChanges, OnDestroy {
|
||||
@Input()
|
||||
baseShareUrl: string;
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
_nodesApi: NodesApi;
|
||||
get nodesApi(): NodesApi {
|
||||
@@ -50,13 +49,9 @@ export class NodeSharedDirective implements OnChanges, OnDestroy {
|
||||
return this._nodesApi;
|
||||
}
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(private dialog: MatDialog, private zone: NgZone, private alfrescoApiService: AlfrescoApiService) {}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
shareNode(nodeEntry: NodeEntry) {
|
||||
if (nodeEntry?.entry?.isFile) {
|
||||
// shared and favorite
|
||||
@@ -92,7 +87,7 @@ export class NodeSharedDirective implements OnChanges, OnDestroy {
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
this.zone.onStable.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
|
||||
this.zone.onStable.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
||||
if (this.node?.entry) {
|
||||
this.isFile = this.node.entry.isFile;
|
||||
this.isShared = this.node.entry.properties ? this.node.entry.properties['qshare:sharedId'] : false;
|
||||
|
@@ -15,21 +15,21 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Observable, Subject } from 'rxjs';
|
||||
import { Component, OnInit, Output, EventEmitter, OnDestroy, ViewEncapsulation } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Component, DestroyRef, EventEmitter, inject, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
||||
import {
|
||||
UntypedFormBuilder,
|
||||
UntypedFormGroup,
|
||||
Validators,
|
||||
UntypedFormControl,
|
||||
AbstractControl,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
FormsModule
|
||||
UntypedFormBuilder,
|
||||
UntypedFormControl,
|
||||
UntypedFormGroup,
|
||||
Validators
|
||||
} from '@angular/forms';
|
||||
import { MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { QueriesApi, SiteBodyCreate, SiteEntry, SitePaging } from '@alfresco/js-api';
|
||||
import { NotificationService } from '@alfresco/adf-core';
|
||||
import { debounceTime, finalize, mergeMap, takeUntil } from 'rxjs/operators';
|
||||
import { debounceTime, finalize, mergeMap } from 'rxjs/operators';
|
||||
import { SitesService } from '../../common/services/sites.service';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
@@ -39,6 +39,7 @@ import { AutoFocusDirective } from '../../directives';
|
||||
import { MatRadioModule } from '@angular/material/radio';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { AlfrescoApiService } from '../../services';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-library-dialog',
|
||||
@@ -60,7 +61,7 @@ import { AlfrescoApiService } from '../../services';
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-library-dialog' }
|
||||
})
|
||||
export class LibraryDialogComponent implements OnInit, OnDestroy {
|
||||
export class LibraryDialogComponent implements OnInit {
|
||||
/** Emitted when an error occurs. */
|
||||
@Output()
|
||||
error: EventEmitter<any> = new EventEmitter<any>();
|
||||
@@ -73,8 +74,6 @@ export class LibraryDialogComponent implements OnInit, OnDestroy {
|
||||
@Output()
|
||||
success: EventEmitter<any> = new EventEmitter<any>();
|
||||
|
||||
onDestroy$: Subject<boolean> = new Subject<boolean>();
|
||||
|
||||
createTitle = 'LIBRARY.DIALOG.CREATE_TITLE';
|
||||
libraryTitleExists = false;
|
||||
form: UntypedFormGroup;
|
||||
@@ -96,6 +95,8 @@ export class LibraryDialogComponent implements OnInit, OnDestroy {
|
||||
return this._queriesApi;
|
||||
}
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(
|
||||
private alfrescoApiService: AlfrescoApiService,
|
||||
private sitesService: SitesService,
|
||||
@@ -126,7 +127,7 @@ export class LibraryDialogComponent implements OnInit, OnDestroy {
|
||||
(title) => this.checkLibraryNameExists(title),
|
||||
(title) => title
|
||||
),
|
||||
takeUntil(this.onDestroy$)
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
)
|
||||
.subscribe((title: string) => {
|
||||
if (!this.form.controls['id'].dirty && this.canGenerateId(title)) {
|
||||
@@ -136,11 +137,6 @@ export class LibraryDialogComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
get title(): string {
|
||||
const { title } = this.form.value;
|
||||
|
||||
|
@@ -30,7 +30,16 @@ import {
|
||||
import { FavoritePaging, FavoritePagingList, Node, NodeEntry, NodePaging } from '@alfresco/js-api';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { Component, CUSTOM_ELEMENTS_SCHEMA, QueryList, SimpleChange, SimpleChanges, ViewChild } from '@angular/core';
|
||||
import {
|
||||
Component,
|
||||
CUSTOM_ELEMENTS_SCHEMA,
|
||||
Injector,
|
||||
QueryList,
|
||||
runInInjectionContext,
|
||||
SimpleChange,
|
||||
SimpleChanges,
|
||||
ViewChild
|
||||
} from '@angular/core';
|
||||
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||
import { MatProgressSpinnerHarness } from '@angular/material/progress-spinner/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
@@ -84,6 +93,7 @@ describe('DocumentList', () => {
|
||||
let spyFolder: any;
|
||||
let spyFolderNode: any;
|
||||
let authenticationService: AuthenticationService;
|
||||
let injector: Injector;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
@@ -106,6 +116,7 @@ describe('DocumentList', () => {
|
||||
contentService = TestBed.inject(ContentService);
|
||||
appConfigService = TestBed.inject(AppConfigService);
|
||||
authenticationService = TestBed.inject(AuthenticationService);
|
||||
injector = TestBed.inject(Injector);
|
||||
|
||||
spyFolder = spyOn(documentListService, 'getFolder').and.returnValue(of({ list: {} }));
|
||||
spyFolderNode = spyOn(documentListService, 'getFolderNode').and.returnValue(of(new NodeEntry({ entry: new Node() })));
|
||||
@@ -140,7 +151,7 @@ describe('DocumentList', () => {
|
||||
spyOn(documentList, 'resetSelection').and.callThrough();
|
||||
spyOn(documentList, 'reload').and.callThrough();
|
||||
|
||||
documentList.ngOnDestroy();
|
||||
fixture.destroy();
|
||||
documentListService.reload();
|
||||
|
||||
expect(documentList.resetSelection).not.toHaveBeenCalled();
|
||||
@@ -158,7 +169,7 @@ describe('DocumentList', () => {
|
||||
it('should not reset selection after component is destroyed', () => {
|
||||
spyOn(documentList, 'resetSelection').and.callThrough();
|
||||
|
||||
documentList.ngOnDestroy();
|
||||
fixture.destroy();
|
||||
documentListService.resetSelection();
|
||||
|
||||
expect(documentList.resetSelection).not.toHaveBeenCalled();
|
||||
@@ -1126,7 +1137,9 @@ describe('DocumentList', () => {
|
||||
|
||||
it('should display [empty folder] template ', () => {
|
||||
fixture.detectChanges();
|
||||
documentList.dataTable = new DataTableComponent(null, null, matIconRegistryMock, domSanitizerMock);
|
||||
runInInjectionContext(injector, () => {
|
||||
documentList.dataTable = new DataTableComponent(null, null, matIconRegistryMock, domSanitizerMock);
|
||||
})
|
||||
expect(documentList.dataTable).toBeDefined();
|
||||
expect(fixture.debugElement.query(By.css('adf-empty-list'))).not.toBeNull();
|
||||
});
|
||||
@@ -1145,7 +1158,9 @@ describe('DocumentList', () => {
|
||||
});
|
||||
|
||||
it('should empty folder NOT show the pagination', () => {
|
||||
documentList.dataTable = new DataTableComponent(null, null, matIconRegistryMock, domSanitizerMock);
|
||||
runInInjectionContext(injector, () => {
|
||||
documentList.dataTable = new DataTableComponent(null, null, matIconRegistryMock, domSanitizerMock);
|
||||
})
|
||||
|
||||
expect(documentList.isEmpty()).toBeTruthy();
|
||||
expect(element.querySelector('alfresco-pagination')).toBe(null);
|
||||
|
@@ -51,12 +51,13 @@ import {
|
||||
AfterContentInit,
|
||||
Component,
|
||||
ContentChild,
|
||||
DestroyRef,
|
||||
ElementRef,
|
||||
EventEmitter,
|
||||
HostListener,
|
||||
inject,
|
||||
Input,
|
||||
OnChanges,
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
Output,
|
||||
SimpleChanges,
|
||||
@@ -65,7 +66,6 @@ import {
|
||||
} from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { BehaviorSubject, of, Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { ContentService, NodesApiService } from '../../common';
|
||||
import { FilterSearch } from '../../search';
|
||||
import { RowFilter } from '../data/row-filter.model';
|
||||
@@ -86,6 +86,7 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { AlfrescoApiService } from '../../services/alfresco-api.service';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
const BYTES_TO_MB_CONVERSION_VALUE = 1048576;
|
||||
|
||||
@@ -118,7 +119,7 @@ const BYTES_TO_MB_CONVERSION_VALUE = 1048576;
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-document-list' }
|
||||
})
|
||||
export class DocumentListComponent extends DataTableSchema implements OnInit, OnChanges, OnDestroy, AfterContentInit, PaginatedComponent {
|
||||
export class DocumentListComponent extends DataTableSchema implements OnInit, OnChanges, AfterContentInit, PaginatedComponent {
|
||||
static SINGLE_CLICK_NAVIGATION: string = 'click';
|
||||
static DOUBLE_CLICK_NAVIGATION: string = 'dblclick';
|
||||
|
||||
@@ -444,7 +445,8 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On
|
||||
|
||||
private rowMenuCache: { [key: string]: ContentActionModel[] } = {};
|
||||
private loadingTimeout: any;
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
private _nodesApi: NodesApi;
|
||||
get nodesApi(): NodesApi {
|
||||
@@ -466,13 +468,13 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On
|
||||
private dialog: MatDialog
|
||||
) {
|
||||
super(appConfig, 'default', presetsDefaultModel);
|
||||
this.nodeService.nodeUpdated.pipe(takeUntil(this.onDestroy$)).subscribe((node) => {
|
||||
this.nodeService.nodeUpdated.pipe(takeUntilDestroyed()).subscribe((node) => {
|
||||
this.dataTableService.rowUpdate.next({ id: node.id, obj: { entry: node } });
|
||||
});
|
||||
|
||||
this.userPreferencesService
|
||||
.select(UserPreferenceValues.PaginationSize)
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.pipe(takeUntilDestroyed())
|
||||
.subscribe((pagSize) => {
|
||||
this.maxItems = this._pagination.maxItems = pagSize;
|
||||
});
|
||||
@@ -534,7 +536,7 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On
|
||||
this.data.setImageResolver(this.imageResolver);
|
||||
}
|
||||
|
||||
this.contextActionHandler.pipe(takeUntil(this.onDestroy$)).subscribe((val) => this.contextActionCallback(val));
|
||||
this.contextActionHandler.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((val) => this.contextActionCallback(val));
|
||||
|
||||
this.enforceSingleClickNavigationForMobile();
|
||||
if (this.filterValue && Object.keys(this.filterValue).length > 0) {
|
||||
@@ -544,19 +546,19 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On
|
||||
this.setPresetKey(this.columnsPresetKey);
|
||||
}
|
||||
|
||||
this.documentListService.reload$.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
|
||||
this.documentListService.reload$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
||||
this.resetSelection();
|
||||
this.reload();
|
||||
});
|
||||
|
||||
this.documentListService.resetSelection$.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
|
||||
this.documentListService.resetSelection$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
||||
this.resetSelection();
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterContentInit() {
|
||||
if (this.columnList) {
|
||||
this.columnList.columns.changes.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
|
||||
this.columnList.columns.changes.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
||||
this.createColumns();
|
||||
this.data.setColumns(this.columns);
|
||||
});
|
||||
@@ -751,7 +753,7 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On
|
||||
const handlerSub = typeof action.handler === 'function' ? action.handler(node, this, action.permission) : of(true);
|
||||
|
||||
if (typeof action.execute === 'function' && handlerSub) {
|
||||
handlerSub.pipe(takeUntil(this.onDestroy$)).subscribe(() => action.execute(node));
|
||||
handlerSub.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => action.execute(node));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1038,11 +1040,6 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On
|
||||
this._pagination.maxItems = this.maxItems;
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
private handleError(err: any) {
|
||||
if (err.message) {
|
||||
try {
|
||||
|
@@ -15,15 +15,27 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Inject, OnInit, OnChanges, SimpleChanges, Input, Output, EventEmitter, OnDestroy } from '@angular/core';
|
||||
import { PaginationModel, DataSorting, HeaderFilterTemplateDirective } from '@alfresco/adf-core';
|
||||
import {
|
||||
Component,
|
||||
DestroyRef,
|
||||
EventEmitter,
|
||||
Inject,
|
||||
inject,
|
||||
Input,
|
||||
OnChanges,
|
||||
OnInit,
|
||||
Output,
|
||||
SimpleChanges
|
||||
} from '@angular/core';
|
||||
import { DataSorting, HeaderFilterTemplateDirective, PaginationModel } from '@alfresco/adf-core';
|
||||
import { SearchHeaderQueryBuilderService } from '../../../search/services/search-header-query-builder.service';
|
||||
import { FilterSearch } from './../../../search/models/filter-search.interface';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { ADF_DOCUMENT_PARENT_COMPONENT } from '../document-list.token';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { SearchFilterContainerComponent } from '../../../search/components/search-filter-container/search-filter-container.component';
|
||||
import {
|
||||
SearchFilterContainerComponent
|
||||
} from '../../../search/components/search-filter-container/search-filter-container.component';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-filter-header',
|
||||
@@ -31,7 +43,7 @@ import { SearchFilterContainerComponent } from '../../../search/components/searc
|
||||
imports: [CommonModule, HeaderFilterTemplateDirective, SearchFilterContainerComponent],
|
||||
templateUrl: './filter-header.component.html'
|
||||
})
|
||||
export class FilterHeaderComponent implements OnInit, OnChanges, OnDestroy {
|
||||
export class FilterHeaderComponent implements OnInit, OnChanges {
|
||||
/** (optional) Initial filter value to sort . */
|
||||
@Input()
|
||||
value: any = {};
|
||||
@@ -45,14 +57,15 @@ export class FilterHeaderComponent implements OnInit, OnChanges, OnDestroy {
|
||||
filterSelection: EventEmitter<FilterSearch[]> = new EventEmitter();
|
||||
|
||||
isFilterServiceActive: boolean;
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(@Inject(ADF_DOCUMENT_PARENT_COMPONENT) private documentList: any, private searchFilterQueryBuilder: SearchHeaderQueryBuilderService) {
|
||||
this.isFilterServiceActive = this.searchFilterQueryBuilder.isFilterServiceActive();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.searchFilterQueryBuilder.executed.pipe(takeUntil(this.onDestroy$)).subscribe((newNodePaging) => {
|
||||
this.searchFilterQueryBuilder.executed.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((newNodePaging) => {
|
||||
this.documentList.node = newNodePaging;
|
||||
this.documentList.reload();
|
||||
});
|
||||
@@ -81,13 +94,13 @@ export class FilterHeaderComponent implements OnInit, OnChanges, OnDestroy {
|
||||
}
|
||||
|
||||
initDataPagination() {
|
||||
this.documentList.pagination.pipe(takeUntil(this.onDestroy$)).subscribe((newPagination: PaginationModel) => {
|
||||
this.documentList.pagination.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((newPagination: PaginationModel) => {
|
||||
this.searchFilterQueryBuilder.setupCurrentPagination(newPagination.maxItems, newPagination.skipCount);
|
||||
});
|
||||
}
|
||||
|
||||
initDataSorting() {
|
||||
this.documentList.sortingSubject.pipe(takeUntil(this.onDestroy$)).subscribe((sorting: DataSorting[]) => {
|
||||
this.documentList.sortingSubject.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((sorting: DataSorting[]) => {
|
||||
this.searchFilterQueryBuilder.setSorting(sorting);
|
||||
});
|
||||
}
|
||||
@@ -110,9 +123,4 @@ export class FilterHeaderComponent implements OnInit, OnChanges, OnDestroy {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
}
|
||||
|
@@ -15,15 +15,24 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, ChangeDetectionStrategy, ViewEncapsulation, OnInit, Input, ElementRef, OnDestroy } from '@angular/core';
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
DestroyRef,
|
||||
ElementRef,
|
||||
inject,
|
||||
Input,
|
||||
OnInit,
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import { NodeEntry, Site } from '@alfresco/js-api';
|
||||
import { ShareDataRow } from '../../data/share-data-row.model';
|
||||
import { NodesApiService } from '../../../common/services/nodes-api.service';
|
||||
|
||||
import { BehaviorSubject, Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-library-name-column',
|
||||
@@ -54,7 +63,7 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
class: 'adf-datatable-content-cell adf-datatable-link adf-library-name-column'
|
||||
}
|
||||
})
|
||||
export class LibraryNameColumnComponent implements OnInit, OnDestroy {
|
||||
export class LibraryNameColumnComponent implements OnInit {
|
||||
@Input()
|
||||
context: any;
|
||||
|
||||
@@ -62,14 +71,14 @@ export class LibraryNameColumnComponent implements OnInit, OnDestroy {
|
||||
displayText$ = new BehaviorSubject<string>('');
|
||||
node: NodeEntry;
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(private element: ElementRef, private nodesApiService: NodesApiService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.updateValue();
|
||||
|
||||
this.nodesApiService.nodeUpdated.pipe(takeUntil(this.onDestroy$)).subscribe((node) => {
|
||||
this.nodesApiService.nodeUpdated.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((node) => {
|
||||
const row: ShareDataRow = this.context.row;
|
||||
if (row) {
|
||||
const { entry } = row.node;
|
||||
@@ -121,8 +130,4 @@ export class LibraryNameColumnComponent implements OnInit, OnDestroy {
|
||||
return isDuplicate ? `${title} (${id})` : `${title}`;
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
}
|
||||
|
@@ -15,14 +15,22 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, OnInit, Input, ChangeDetectionStrategy, ViewEncapsulation, OnDestroy } from '@angular/core';
|
||||
import { BehaviorSubject, Subject } from 'rxjs';
|
||||
import { SiteEntry, Site } from '@alfresco/js-api';
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
DestroyRef,
|
||||
inject,
|
||||
Input,
|
||||
OnInit,
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { Site, SiteEntry } from '@alfresco/js-api';
|
||||
import { ShareDataRow } from '../../data/share-data-row.model';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { NodesApiService } from '../../../common/services/nodes-api.service';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-library-role-column',
|
||||
@@ -37,20 +45,20 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-library-role-column adf-datatable-content-cell' }
|
||||
})
|
||||
export class LibraryRoleColumnComponent implements OnInit, OnDestroy {
|
||||
export class LibraryRoleColumnComponent implements OnInit {
|
||||
@Input()
|
||||
context: any;
|
||||
|
||||
displayText$ = new BehaviorSubject<string>('');
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(private nodesApiService: NodesApiService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.updateValue();
|
||||
|
||||
this.nodesApiService.nodeUpdated.pipe(takeUntil(this.onDestroy$)).subscribe((node) => {
|
||||
this.nodesApiService.nodeUpdated.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((node) => {
|
||||
const row: ShareDataRow = this.context.row;
|
||||
if (row) {
|
||||
const { entry } = row.node;
|
||||
@@ -86,9 +94,4 @@ export class LibraryRoleColumnComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
}
|
||||
|
@@ -15,14 +15,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Input, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Component, DestroyRef, inject, Input, OnInit } from '@angular/core';
|
||||
import { NodesApiService } from '../../../common/services/nodes-api.service';
|
||||
import { BehaviorSubject, Subject } from 'rxjs';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { Site, SiteEntry } from '@alfresco/js-api';
|
||||
import { ShareDataRow } from '../../data/share-data-row.model';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-library-status-column',
|
||||
@@ -35,20 +35,20 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
`,
|
||||
host: { class: 'adf-library-status-column adf-datatable-content-cell' }
|
||||
})
|
||||
export class LibraryStatusColumnComponent implements OnInit, OnDestroy {
|
||||
export class LibraryStatusColumnComponent implements OnInit {
|
||||
@Input()
|
||||
context: any;
|
||||
|
||||
displayText$ = new BehaviorSubject<string>('');
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(private nodesApiService: NodesApiService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.updateValue();
|
||||
|
||||
this.nodesApiService.nodeUpdated.pipe(takeUntil(this.onDestroy$)).subscribe((node) => {
|
||||
this.nodesApiService.nodeUpdated.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((node) => {
|
||||
const row: ShareDataRow = this.context.row;
|
||||
if (row) {
|
||||
const { entry } = row.node;
|
||||
@@ -83,8 +83,4 @@ export class LibraryStatusColumnComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
}
|
||||
|
@@ -15,15 +15,24 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Input, OnInit, ChangeDetectionStrategy, ViewEncapsulation, ElementRef, OnDestroy } from '@angular/core';
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
DestroyRef,
|
||||
ElementRef,
|
||||
inject,
|
||||
Input,
|
||||
OnInit,
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
import { BehaviorSubject, Subject } from 'rxjs';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { NodesApiService } from '../../../common/services/nodes-api.service';
|
||||
import { ShareDataRow } from '../../data/share-data-row.model';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { NodeNameTooltipPipe } from '../../../pipes/node-name-tooltip.pipe';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-name-column',
|
||||
@@ -52,7 +61,7 @@ import { NodeNameTooltipPipe } from '../../../pipes/node-name-tooltip.pipe';
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-datatable-content-cell adf-datatable-link adf-name-column' }
|
||||
})
|
||||
export class NameColumnComponent implements OnInit, OnDestroy {
|
||||
export class NameColumnComponent implements OnInit {
|
||||
@Input()
|
||||
context: any;
|
||||
|
||||
@@ -62,14 +71,14 @@ export class NameColumnComponent implements OnInit, OnDestroy {
|
||||
displayText$ = new BehaviorSubject<string>('');
|
||||
node: NodeEntry;
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(private element: ElementRef, private nodesApiService: NodesApiService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.updateValue();
|
||||
|
||||
this.nodesApiService.nodeUpdated.pipe(takeUntil(this.onDestroy$)).subscribe((node) => {
|
||||
this.nodesApiService.nodeUpdated.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((node) => {
|
||||
const row: ShareDataRow = this.context.row;
|
||||
if (row) {
|
||||
const { entry } = row.node;
|
||||
@@ -102,8 +111,4 @@ export class NameColumnComponent implements OnInit, OnDestroy {
|
||||
);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
}
|
||||
|
@@ -15,12 +15,23 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AfterViewInit, Directive, ElementRef, HostListener, Input, OnDestroy, OnInit, TemplateRef, ViewContainerRef } from '@angular/core';
|
||||
import {
|
||||
AfterViewInit,
|
||||
DestroyRef,
|
||||
Directive,
|
||||
ElementRef,
|
||||
HostListener,
|
||||
inject,
|
||||
Input,
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
TemplateRef,
|
||||
ViewContainerRef
|
||||
} from '@angular/core';
|
||||
import { ConnectionPositionPair, Overlay, OverlayRef } from '@angular/cdk/overlay';
|
||||
import { TemplatePortal } from '@angular/cdk/portal';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { Subject } from 'rxjs';
|
||||
import { ConfigurableFocusTrap, ConfigurableFocusTrapFactory } from '@angular/cdk/a11y';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Directive({
|
||||
selector: '[adf-pop-over]',
|
||||
@@ -38,11 +49,11 @@ export class PopOverDirective implements OnInit, OnDestroy, AfterViewInit {
|
||||
@Input() autofocusedElementSelector: string;
|
||||
|
||||
private _open = false;
|
||||
private destroy$ = new Subject();
|
||||
private overlayRef!: OverlayRef;
|
||||
|
||||
private focusTrap: ConfigurableFocusTrap;
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(
|
||||
private element: ElementRef,
|
||||
private overlay: Overlay,
|
||||
@@ -62,8 +73,6 @@ export class PopOverDirective implements OnInit, OnDestroy, AfterViewInit {
|
||||
ngOnDestroy(): void {
|
||||
this.element.nativeElement.removeEventListener('keydown', this.preventDefaultForEnter);
|
||||
this.detachOverlay();
|
||||
this.destroy$.next(undefined);
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
private createOverlay(): void {
|
||||
@@ -87,7 +96,7 @@ export class PopOverDirective implements OnInit, OnDestroy, AfterViewInit {
|
||||
|
||||
this.overlayRef
|
||||
.backdropClick()
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe(() => {
|
||||
this.detachOverlay();
|
||||
});
|
||||
|
@@ -15,19 +15,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, DestroyRef, inject, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { MatCheckboxChange, MatCheckboxModule } from '@angular/material/checkbox';
|
||||
import { SearchWidget } from '../../models/search-widget.interface';
|
||||
import { SearchWidgetSettings } from '../../models/search-widget-settings.interface';
|
||||
import { SearchQueryBuilderService } from '../../services/search-query-builder.service';
|
||||
import { SearchFilterList } from '../../models/search-filter-list.model';
|
||||
import { TranslationService } from '@alfresco/adf-core';
|
||||
import { ReplaySubject, Subject } from 'rxjs';
|
||||
import { map, takeUntil } from 'rxjs/operators';
|
||||
import { ReplaySubject } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
export interface SearchListOption {
|
||||
name: string;
|
||||
@@ -44,7 +45,7 @@ export interface SearchListOption {
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-search-check-list' }
|
||||
})
|
||||
export class SearchCheckListComponent implements SearchWidget, OnInit, OnDestroy {
|
||||
export class SearchCheckListComponent implements SearchWidget, OnInit {
|
||||
id: string;
|
||||
settings?: SearchWidgetSettings;
|
||||
context?: SearchQueryBuilderService;
|
||||
@@ -56,7 +57,7 @@ export class SearchCheckListComponent implements SearchWidget, OnInit, OnDestroy
|
||||
enableChangeUpdate = true;
|
||||
displayValue$ = new ReplaySubject<string>(1);
|
||||
|
||||
private readonly destroy$ = new Subject<void>();
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(private translationService: TranslationService) {
|
||||
this.options = new SearchFilterList<SearchListOption>();
|
||||
@@ -84,7 +85,7 @@ export class SearchCheckListComponent implements SearchWidget, OnInit, OnDestroy
|
||||
.asObservable()
|
||||
.pipe(
|
||||
map((filtersQueries) => filtersQueries[this.id]),
|
||||
takeUntil(this.destroy$)
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
)
|
||||
.subscribe((filterQuery) => {
|
||||
if (filterQuery) {
|
||||
@@ -102,11 +103,6 @@ export class SearchCheckListComponent implements SearchWidget, OnInit, OnDestroy
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.isActive = false;
|
||||
this.clearOptions();
|
||||
|
@@ -17,28 +17,30 @@
|
||||
|
||||
import {
|
||||
Component,
|
||||
ViewEncapsulation,
|
||||
DestroyRef,
|
||||
ElementRef,
|
||||
ViewChild,
|
||||
OnInit,
|
||||
OnDestroy,
|
||||
Input,
|
||||
Output,
|
||||
EventEmitter,
|
||||
inject,
|
||||
Input,
|
||||
OnChanges,
|
||||
OnInit,
|
||||
Output,
|
||||
SimpleChanges,
|
||||
OnChanges
|
||||
ViewChild,
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import { ENTER } from '@angular/cdk/keycodes';
|
||||
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatAutocompleteModule, MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
||||
import { MatChipInputEvent, MatChipsModule } from '@angular/material/chips';
|
||||
import { EMPTY, Observable, Subject, timer } from 'rxjs';
|
||||
import { debounce, startWith, takeUntil, tap } from 'rxjs/operators';
|
||||
import { EMPTY, Observable, timer } from 'rxjs';
|
||||
import { debounce, startWith, tap } from 'rxjs/operators';
|
||||
import { AutocompleteOption } from '../../models/autocomplete-option.interface';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-search-chip-autocomplete-input',
|
||||
@@ -48,7 +50,7 @@ import { MatIconModule } from '@angular/material/icon';
|
||||
styleUrls: ['./search-chip-autocomplete-input.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class SearchChipAutocompleteInputComponent implements OnInit, OnDestroy, OnChanges {
|
||||
export class SearchChipAutocompleteInputComponent implements OnInit, OnChanges {
|
||||
@ViewChild('optionInput')
|
||||
optionInput: ElementRef<HTMLInputElement>;
|
||||
|
||||
@@ -89,9 +91,11 @@ export class SearchChipAutocompleteInputComponent implements OnInit, OnDestroy,
|
||||
formCtrl = new FormControl('');
|
||||
filteredOptions: AutocompleteOption[] = [];
|
||||
selectedOptions: AutocompleteOption[] = [];
|
||||
private onDestroy$ = new Subject<void>();
|
||||
|
||||
private _activeAnyOption = false;
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
set activeAnyOption(active: boolean) {
|
||||
this._activeAnyOption = active;
|
||||
}
|
||||
@@ -102,13 +106,13 @@ export class SearchChipAutocompleteInputComponent implements OnInit, OnDestroy,
|
||||
startWith(''),
|
||||
tap(() => (this.activeAnyOption = false)),
|
||||
debounce((value: string) => (value ? timer(300) : EMPTY)),
|
||||
takeUntil(this.onDestroy$)
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
)
|
||||
.subscribe((value: string) => {
|
||||
this.filteredOptions = value ? this.filter(this.autocompleteOptions, value) : [];
|
||||
this.inputChanged.emit(value);
|
||||
});
|
||||
this.onReset$?.pipe(takeUntil(this.onDestroy$)).subscribe(() => this.reset());
|
||||
this.onReset$?.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.reset());
|
||||
this.selectedOptions = this.preselectedOptions ?? [];
|
||||
}
|
||||
|
||||
@@ -121,11 +125,6 @@ export class SearchChipAutocompleteInputComponent implements OnInit, OnDestroy,
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next();
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
add(event: MatChipInputEvent) {
|
||||
if (!this._activeAnyOption) {
|
||||
let value = (event.value || '').trim();
|
||||
|
@@ -15,19 +15,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AuthenticationService, ThumbnailService, SearchTextInputComponent, HighlightPipe } from '@alfresco/adf-core';
|
||||
import { AuthenticationService, HighlightPipe, SearchTextInputComponent, ThumbnailService } from '@alfresco/adf-core';
|
||||
import {
|
||||
Component,
|
||||
ContentChild,
|
||||
EventEmitter,
|
||||
Input,
|
||||
OnDestroy,
|
||||
Output,
|
||||
QueryList,
|
||||
ViewEncapsulation,
|
||||
TemplateRef,
|
||||
ViewChild,
|
||||
ViewChildren,
|
||||
TemplateRef,
|
||||
ContentChild
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
import { Subject } from 'rxjs';
|
||||
@@ -47,7 +46,7 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-search-control' }
|
||||
})
|
||||
export class SearchControlComponent implements OnDestroy {
|
||||
export class SearchControlComponent {
|
||||
/** Toggles highlighting of the search term in the results. */
|
||||
@Input()
|
||||
highlight: boolean = false;
|
||||
@@ -111,19 +110,11 @@ export class SearchControlComponent implements OnDestroy {
|
||||
noSearchResultTemplate: TemplateRef<any> = null;
|
||||
searchTerm: string = '';
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(public authService: AuthenticationService, private thumbnailService: ThumbnailService) {}
|
||||
|
||||
isNoSearchTemplatePresent(): boolean {
|
||||
return !!this.emptySearchTemplate;
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
isLoggedIn(): boolean {
|
||||
return this.authService.isEcmLoggedIn();
|
||||
}
|
||||
|
@@ -15,9 +15,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { ReplaySubject, Subject } from 'rxjs';
|
||||
import { map, takeUntil } from 'rxjs/operators';
|
||||
import { Component, DestroyRef, inject, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { ReplaySubject } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { DateRangeType } from './search-date-range/date-range-type';
|
||||
import { SearchDateRange } from './search-date-range/search-date-range';
|
||||
import { SearchWidget } from '../../models/search-widget.interface';
|
||||
@@ -30,6 +30,7 @@ import { CommonModule } from '@angular/common';
|
||||
import { SearchFilterTabbedComponent } from '../search-filter-tabbed/search-filter-tabbed.component';
|
||||
import { SearchDateRangeComponent } from './search-date-range/search-date-range.component';
|
||||
import { SearchFilterTabDirective } from '../search-filter-tabbed/search-filter-tab.directive';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
const DEFAULT_DATE_DISPLAY_FORMAT = 'dd-MMM-yy';
|
||||
|
||||
@@ -41,7 +42,7 @@ const DEFAULT_DATE_DISPLAY_FORMAT = 'dd-MMM-yy';
|
||||
styleUrls: ['./search-date-range-tabbed.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class SearchDateRangeTabbedComponent implements SearchWidget, OnInit, OnDestroy {
|
||||
export class SearchDateRangeTabbedComponent implements SearchWidget, OnInit {
|
||||
displayValue$ = new ReplaySubject<string>(1);
|
||||
id: string;
|
||||
startValue: SearchDateRange = {
|
||||
@@ -62,7 +63,8 @@ export class SearchDateRangeTabbedComponent implements SearchWidget, OnInit, OnD
|
||||
private value: { [key: string]: Partial<SearchDateRange> } = {};
|
||||
private queryMapByField: Map<string, string> = new Map<string, string>();
|
||||
private displayValueMapByField: Map<string, string> = new Map<string, string>();
|
||||
private readonly destroy$ = new Subject<void>();
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(private translateService: TranslationService) {}
|
||||
|
||||
@@ -73,7 +75,7 @@ export class SearchDateRangeTabbedComponent implements SearchWidget, OnInit, OnD
|
||||
.asObservable()
|
||||
.pipe(
|
||||
map((filtersQueries) => filtersQueries[this.id]),
|
||||
takeUntil(this.destroy$)
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
)
|
||||
.subscribe((filterQuery) => {
|
||||
if (filterQuery) {
|
||||
@@ -94,12 +96,6 @@ export class SearchDateRangeTabbedComponent implements SearchWidget, OnInit, OnD
|
||||
this.context.filterLoaded.next();
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
private setDefaultDateFormatSettings() {
|
||||
if (this.settings && !this.settings.dateFormat) {
|
||||
this.settings.dateFormat = DEFAULT_DATE_DISPLAY_FORMAT;
|
||||
|
@@ -15,17 +15,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, EventEmitter, Inject, Input, OnDestroy, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
import { endOfDay, parse, isValid, isBefore, isAfter } from 'date-fns';
|
||||
import { Component, DestroyRef, EventEmitter, inject, Inject, Input, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
||||
import { endOfDay, isAfter, isBefore, isValid, parse } from 'date-fns';
|
||||
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE, MatDateFormats } from '@angular/material/core';
|
||||
import { DateFnsAdapter, MAT_DATE_FNS_FORMATS } from '@angular/material-date-fns-adapter';
|
||||
import { InLastDateType } from './in-last-date-type';
|
||||
import { DateRangeType } from './date-range-type';
|
||||
import { SearchDateRange } from './search-date-range';
|
||||
import { FormBuilder, ReactiveFormsModule, UntypedFormControl, Validators } from '@angular/forms';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { UserPreferencesService, UserPreferenceValues, DateFnsUtils } from '@alfresco/adf-core';
|
||||
import { DateFnsUtils, UserPreferencesService, UserPreferenceValues } from '@alfresco/adf-core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatRadioModule } from '@angular/material/radio';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
@@ -33,6 +31,7 @@ import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatDatepickerModule } from '@angular/material/datepicker';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
const DEFAULT_DATE_DISPLAY_FORMAT = 'dd-MMM-yy';
|
||||
|
||||
@@ -58,7 +57,7 @@ const DEFAULT_DATE_DISPLAY_FORMAT = 'dd-MMM-yy';
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-search-date-range' }
|
||||
})
|
||||
export class SearchDateRangeComponent implements OnInit, OnDestroy {
|
||||
export class SearchDateRangeComponent implements OnInit {
|
||||
@Input()
|
||||
dateFormat = DEFAULT_DATE_DISPLAY_FORMAT;
|
||||
@Input()
|
||||
@@ -87,11 +86,12 @@ export class SearchDateRangeComponent implements OnInit, OnDestroy {
|
||||
betweenStartDateFormControl = this.form.controls.betweenStartDate;
|
||||
betweenEndDateFormControl = this.form.controls.betweenEndDate;
|
||||
convertedMaxDate: Date;
|
||||
private readonly destroy$ = new Subject<void>();
|
||||
|
||||
readonly DateRangeType = DateRangeType;
|
||||
readonly InLastDateType = InLastDateType;
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(
|
||||
private formBuilder: FormBuilder,
|
||||
private userPreferencesService: UserPreferencesService,
|
||||
@@ -113,19 +113,13 @@ export class SearchDateRangeComponent implements OnInit, OnDestroy {
|
||||
this.convertedMaxDate = endOfDay(this.maxDate && this.maxDate !== 'today' ? parse(this.maxDate, this.dateFormat, new Date()) : new Date());
|
||||
this.userPreferencesService
|
||||
.select(UserPreferenceValues.Locale)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((locale) => this.dateAdapter.setLocale(DateFnsUtils.getLocaleFromString(locale)));
|
||||
this.form.controls.dateRangeType.valueChanges
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((dateRangeType) => this.updateValidators(dateRangeType));
|
||||
this.form.valueChanges.pipe(takeUntil(this.destroy$)).subscribe(() => this.onChange());
|
||||
this.form.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.onChange());
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
private updateValidators(dateRangeType: DateRangeType) {
|
||||
switch (dateRangeType) {
|
||||
case DateRangeType.BETWEEN:
|
||||
|
@@ -15,22 +15,34 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, DestroyRef, inject, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { ADF_DATE_FORMATS, ADF_DATETIME_FORMATS, AdfDateFnsAdapter, AdfDateTimeFnsAdapter, DateFnsUtils } from '@alfresco/adf-core';
|
||||
import {
|
||||
ADF_DATE_FORMATS,
|
||||
ADF_DATETIME_FORMATS,
|
||||
AdfDateFnsAdapter,
|
||||
AdfDateTimeFnsAdapter,
|
||||
DateFnsUtils
|
||||
} from '@alfresco/adf-core';
|
||||
import { SearchWidget } from '../../models/search-widget.interface';
|
||||
import { SearchWidgetSettings } from '../../models/search-widget-settings.interface';
|
||||
import { SearchQueryBuilderService } from '../../services/search-query-builder.service';
|
||||
import { LiveErrorStateMatcher } from '../../forms/live-error-state-matcher';
|
||||
import { ReplaySubject, Subject } from 'rxjs';
|
||||
import { map, takeUntil } from 'rxjs/operators';
|
||||
import { DatetimeAdapter, MAT_DATETIME_FORMATS, MatDatetimepickerInputEvent, MatDatetimepickerModule } from '@mat-datetimepicker/core';
|
||||
import { ReplaySubject } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import {
|
||||
DatetimeAdapter,
|
||||
MAT_DATETIME_FORMATS,
|
||||
MatDatetimepickerInputEvent,
|
||||
MatDatetimepickerModule
|
||||
} from '@mat-datetimepicker/core';
|
||||
import { DateAdapter, MAT_DATE_FORMATS } from '@angular/material/core';
|
||||
import { isValid, isBefore, startOfMinute, endOfMinute, parseISO } from 'date-fns';
|
||||
import { endOfMinute, isBefore, isValid, parseISO, startOfMinute } from 'date-fns';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
export interface DatetimeRangeValue {
|
||||
from: string;
|
||||
@@ -59,7 +71,7 @@ export const DEFAULT_DATETIME_FORMAT: string = 'dd/MM/yyyy HH:mm';
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-search-date-range' }
|
||||
})
|
||||
export class SearchDatetimeRangeComponent implements SearchWidget, OnInit, OnDestroy {
|
||||
export class SearchDatetimeRangeComponent implements SearchWidget, OnInit {
|
||||
from: FormControl<Date>;
|
||||
to: FormControl<Date>;
|
||||
|
||||
@@ -77,7 +89,7 @@ export class SearchDatetimeRangeComponent implements SearchWidget, OnInit, OnDes
|
||||
enableChangeUpdate: boolean;
|
||||
displayValue$ = new ReplaySubject<string>(1);
|
||||
|
||||
private readonly destroy$ = new Subject<void>();
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(private dateAdapter: DateAdapter<Date>, private dateTimeAdapter: DatetimeAdapter<Date>) {}
|
||||
|
||||
@@ -140,7 +152,7 @@ export class SearchDatetimeRangeComponent implements SearchWidget, OnInit, OnDes
|
||||
.asObservable()
|
||||
.pipe(
|
||||
map((filtersQueries) => filtersQueries[this.id]),
|
||||
takeUntil(this.destroy$)
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
)
|
||||
.subscribe((filterQuery) => {
|
||||
if (filterQuery) {
|
||||
@@ -156,11 +168,6 @@ export class SearchDatetimeRangeComponent implements SearchWidget, OnInit, OnDes
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
apply(model: Partial<{ from: Date; to: Date }>, isValidValue: boolean, updateContext = true) {
|
||||
if (isValidValue && this.id && this.context && this.settings && this.settings.field) {
|
||||
this.isActive = true;
|
||||
|
@@ -15,9 +15,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, ViewEncapsulation, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Component, DestroyRef, inject, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { BehaviorSubject, Observable, ReplaySubject, Subject } from 'rxjs';
|
||||
import { map, takeUntil } from 'rxjs/operators';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { SearchWidget } from '../../models/search-widget.interface';
|
||||
import { SearchWidgetSettings } from '../../models/search-widget-settings.interface';
|
||||
import { SearchQueryBuilderService } from '../../services/search-query-builder.service';
|
||||
@@ -29,6 +29,7 @@ import { CommonModule } from '@angular/common';
|
||||
import { SearchChipAutocompleteInputComponent } from '../search-chip-autocomplete-input';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-search-filter-autocomplete-chips',
|
||||
@@ -37,7 +38,7 @@ import { MatButtonModule } from '@angular/material/button';
|
||||
templateUrl: './search-filter-autocomplete-chips.component.html',
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class SearchFilterAutocompleteChipsComponent implements SearchWidget, OnInit, OnDestroy {
|
||||
export class SearchFilterAutocompleteChipsComponent implements SearchWidget, OnInit {
|
||||
id: string;
|
||||
settings?: SearchWidgetSettings;
|
||||
context?: SearchQueryBuilderService;
|
||||
@@ -51,7 +52,8 @@ export class SearchFilterAutocompleteChipsComponent implements SearchWidget, OnI
|
||||
reset$: Observable<void> = this.resetSubject$.asObservable();
|
||||
private autocompleteOptionsSubject$ = new BehaviorSubject<AutocompleteOption[]>([]);
|
||||
autocompleteOptions$: Observable<AutocompleteOption[]> = this.autocompleteOptionsSubject$.asObservable();
|
||||
private readonly destroy$ = new Subject<void>();
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(private tagService: TagService, private categoryService: CategoryService) {
|
||||
this.options = new SearchFilterList<AutocompleteOption[]>();
|
||||
@@ -69,7 +71,7 @@ export class SearchFilterAutocompleteChipsComponent implements SearchWidget, OnI
|
||||
.asObservable()
|
||||
.pipe(
|
||||
map((filterQueries) => filterQueries[this.id]),
|
||||
takeUntil(this.destroy$)
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
)
|
||||
.subscribe((filterQuery) => {
|
||||
if (filterQuery) {
|
||||
@@ -82,11 +84,6 @@ export class SearchFilterAutocompleteChipsComponent implements SearchWidget, OnI
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
reset(updateContext = true) {
|
||||
this.selectedOptions = [];
|
||||
this.context.filterRawParams[this.id] = undefined;
|
||||
|
@@ -15,19 +15,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, EventEmitter, inject, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, DestroyRef, EventEmitter, inject, Input, OnChanges, OnInit, Output, SimpleChanges, ViewEncapsulation } from '@angular/core';
|
||||
import { Observable, Subject } from 'rxjs';
|
||||
import { SearchQueryBuilderService } from '../../../services/search-query-builder.service';
|
||||
import { FacetWidget } from '../../../models/facet-widget.interface';
|
||||
import { TranslationService } from '@alfresco/adf-core';
|
||||
import { AutocompleteOption } from '../../../models/autocomplete-option.interface';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { TabbedFacetField } from '../../../models/tabbed-facet-field.interface';
|
||||
import { SearchFacetFiltersService } from '../../../services/search-facet-filters.service';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { SearchChipAutocompleteInputComponent } from '../../search-chip-autocomplete-input';
|
||||
import { SearchFilterTabbedComponent } from '../../search-filter-tabbed/search-filter-tabbed.component';
|
||||
import { SearchFilterTabDirective } from '../../search-filter-tabbed';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-search-facet-tabbed-content',
|
||||
@@ -36,7 +36,7 @@ import { SearchFilterTabDirective } from '../../search-filter-tabbed';
|
||||
templateUrl: './search-facet-tabbed-content.component.html',
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class SearchFacetTabbedContentComponent implements OnInit, OnDestroy, OnChanges, FacetWidget {
|
||||
export class SearchFacetTabbedContentComponent implements OnInit, OnChanges, FacetWidget {
|
||||
private queryBuilder = inject(SearchQueryBuilderService);
|
||||
private translationService = inject(TranslationService);
|
||||
private searchFacetFiltersService = inject(SearchFacetFiltersService);
|
||||
@@ -57,13 +57,14 @@ export class SearchFacetTabbedContentComponent implements OnInit, OnDestroy, OnC
|
||||
displayValue$ = new EventEmitter<string>();
|
||||
|
||||
private resetSubject$ = new Subject<void>();
|
||||
private onDestroy$ = new Subject<void>();
|
||||
|
||||
reset$ = this.resetSubject$.asObservable();
|
||||
chipIcon = 'keyboard_arrow_down';
|
||||
autocompleteOptions = {};
|
||||
selectedOptions = {};
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
ngOnInit() {
|
||||
this.tabbedFacet.fields.forEach((field) => {
|
||||
Object.defineProperty(this.selectedOptions, field, {
|
||||
@@ -72,13 +73,8 @@ export class SearchFacetTabbedContentComponent implements OnInit, OnDestroy, OnC
|
||||
});
|
||||
});
|
||||
|
||||
this.onReset$?.pipe(takeUntil(this.onDestroy$)).subscribe(() => this.reset());
|
||||
this.onApply$?.pipe(takeUntil(this.onDestroy$)).subscribe(() => this.submitValues());
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next();
|
||||
this.onDestroy$.complete();
|
||||
this.onReset$?.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.reset());
|
||||
this.onApply$?.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.submitValues());
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
|
@@ -15,11 +15,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, inject, Input, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, DestroyRef, inject, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { SearchFacetFiltersService } from '../../services/search-facet-filters.service';
|
||||
import { SearchQueryBuilderService } from '../../services/search-query-builder.service';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { FacetField, SearchCategory, TabbedFacetField } from '../../models';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatChipsModule } from '@angular/material/chips';
|
||||
@@ -27,6 +25,7 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
import { SearchFacetChipTabbedComponent } from './search-facet-chip-tabbed/search-facet-chip-tabbed.component';
|
||||
import { SearchFacetChipComponent } from './search-facet-chip/search-facet-chip.component';
|
||||
import { SearchWidgetChipComponent } from './search-widget-chip/search-widget-chip.component';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-search-filter-chips',
|
||||
@@ -36,11 +35,11 @@ import { SearchWidgetChipComponent } from './search-widget-chip/search-widget-ch
|
||||
styleUrls: ['./search-filter-chips.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class SearchFilterChipsComponent implements OnInit, OnDestroy {
|
||||
export class SearchFilterChipsComponent implements OnInit {
|
||||
private queryBuilder = inject(SearchQueryBuilderService);
|
||||
private facetFiltersService = inject(SearchFacetFiltersService);
|
||||
|
||||
private onDestroy$ = new Subject<void>();
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
/** Toggles whether to show or not the context facet filters. */
|
||||
@Input()
|
||||
@@ -63,12 +62,7 @@ export class SearchFilterChipsComponent implements OnInit, OnDestroy {
|
||||
ngOnInit() {
|
||||
this.queryBuilder.executed
|
||||
.asObservable()
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe(() => (this.facetChipTabbedId = 'search-fact-chip-tabbed-' + this.facetFiltersService.tabbedFacet?.fields.join('-')));
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next();
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
}
|
||||
|
@@ -15,13 +15,21 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Input, Output, OnInit, EventEmitter, ViewEncapsulation, ViewChild, OnDestroy, ElementRef } from '@angular/core';
|
||||
import { ConfigurableFocusTrapFactory, ConfigurableFocusTrap } from '@angular/cdk/a11y';
|
||||
import {
|
||||
Component,
|
||||
ElementRef,
|
||||
EventEmitter,
|
||||
Input,
|
||||
OnInit,
|
||||
Output,
|
||||
ViewChild,
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import { ConfigurableFocusTrap, ConfigurableFocusTrapFactory } from '@angular/cdk/a11y';
|
||||
import { DataColumn, IconComponent, TranslationService } from '@alfresco/adf-core';
|
||||
import { SearchWidgetContainerComponent } from '../search-widget-container/search-widget-container.component';
|
||||
import { SearchHeaderQueryBuilderService } from '../../services/search-header-query-builder.service';
|
||||
import { SearchCategory } from '../../models/search-category.interface';
|
||||
import { Subject } from 'rxjs';
|
||||
import { MatMenuModule, MatMenuTrigger } from '@angular/material/menu';
|
||||
import { FilterSearch } from '../../models/filter-search.interface';
|
||||
import { CommonModule } from '@angular/common';
|
||||
@@ -47,7 +55,7 @@ import { MatDialogModule } from '@angular/material/dialog';
|
||||
styleUrls: ['./search-filter-container.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class SearchFilterContainerComponent implements OnInit, OnDestroy {
|
||||
export class SearchFilterContainerComponent implements OnInit {
|
||||
/** The column the filter will be applied on. */
|
||||
@Input()
|
||||
col: DataColumn;
|
||||
@@ -70,8 +78,6 @@ export class SearchFilterContainerComponent implements OnInit, OnDestroy {
|
||||
focusTrap: ConfigurableFocusTrap;
|
||||
initialValue: any;
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(
|
||||
private searchFilterQueryBuilder: SearchHeaderQueryBuilderService,
|
||||
private translationService: TranslationService,
|
||||
@@ -83,11 +89,6 @@ export class SearchFilterContainerComponent implements OnInit, OnDestroy {
|
||||
this.initialValue = this.value?.[this.col.key] ? this.value[this.col.key] : undefined;
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
onKeyPressed(event: KeyboardEvent, menuTrigger: MatMenuTrigger) {
|
||||
if (event.key === 'Enter' && this.widgetContainer.selector !== 'check-list') {
|
||||
this.onApply();
|
||||
|
@@ -15,17 +15,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, DestroyRef, inject, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { SearchWidget } from '../../models/search-widget.interface';
|
||||
import { SearchWidgetSettings } from '../../models/search-widget-settings.interface';
|
||||
import { SearchQueryBuilderService } from '../../services/search-query-builder.service';
|
||||
import { ReplaySubject, Subject } from 'rxjs';
|
||||
import { map, takeUntil } from 'rxjs/operators';
|
||||
import { ReplaySubject } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { TranslationService } from '@alfresco/adf-core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
export enum LogicalSearchFields {
|
||||
MATCH_ALL = 'matchAll',
|
||||
@@ -46,7 +47,7 @@ export interface LogicalSearchCondition extends LogicalSearchConditionEnumValued
|
||||
styleUrls: ['./search-logical-filter.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class SearchLogicalFilterComponent implements SearchWidget, OnInit, OnDestroy {
|
||||
export class SearchLogicalFilterComponent implements SearchWidget, OnInit {
|
||||
id: string;
|
||||
settings?: SearchWidgetSettings;
|
||||
context?: SearchQueryBuilderService;
|
||||
@@ -56,7 +57,7 @@ export class SearchLogicalFilterComponent implements SearchWidget, OnInit, OnDes
|
||||
LogicalSearchFields = LogicalSearchFields;
|
||||
displayValue$ = new ReplaySubject<string>(1);
|
||||
|
||||
private readonly destroy$ = new Subject<void>();
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(private translationService: TranslationService) {}
|
||||
|
||||
@@ -66,7 +67,7 @@ export class SearchLogicalFilterComponent implements SearchWidget, OnInit, OnDes
|
||||
.asObservable()
|
||||
.pipe(
|
||||
map((filtersQueries) => filtersQueries[this.id]),
|
||||
takeUntil(this.destroy$)
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
)
|
||||
.subscribe((filterQuery) => {
|
||||
if (filterQuery) {
|
||||
@@ -79,11 +80,6 @@ export class SearchLogicalFilterComponent implements SearchWidget, OnInit, OnDes
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
submitValues(updateContext = true) {
|
||||
if (this.hasValidValue() && this.id && this.context && this.settings && this.settings.field) {
|
||||
this.updateDisplayValue();
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AfterViewChecked, Component, ElementRef, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||
import { AfterViewChecked, Component, DestroyRef, ElementRef, inject, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
|
||||
import { FileSizeCondition } from './file-size-condition';
|
||||
import { FileSizeOperator } from './file-size-operator.enum';
|
||||
@@ -31,7 +31,8 @@ import { CommonModule } from '@angular/common';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { SearchChipAutocompleteInputComponent } from '../search-chip-autocomplete-input';
|
||||
import { map, takeUntil } from 'rxjs/operators';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-search-properties',
|
||||
@@ -41,7 +42,7 @@ import { map, takeUntil } from 'rxjs/operators';
|
||||
styleUrls: ['./search-properties.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class SearchPropertiesComponent implements OnInit, AfterViewChecked, OnDestroy, SearchWidget {
|
||||
export class SearchPropertiesComponent implements OnInit, AfterViewChecked, SearchWidget {
|
||||
id: string;
|
||||
settings?: SearchWidgetSettings;
|
||||
context?: SearchQueryBuilderService;
|
||||
@@ -95,7 +96,7 @@ export class SearchPropertiesComponent implements OnInit, AfterViewChecked, OnDe
|
||||
this._selectedExtensions = this.parseFromAutocompleteOptions(extensions);
|
||||
}
|
||||
|
||||
private readonly destroy$ = new Subject<void>();
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(private formBuilder: FormBuilder, private translateService: TranslateService) {}
|
||||
|
||||
@@ -114,7 +115,7 @@ export class SearchPropertiesComponent implements OnInit, AfterViewChecked, OnDe
|
||||
.asObservable()
|
||||
.pipe(
|
||||
map((filtersQueries) => filtersQueries[this.id]),
|
||||
takeUntil(this.destroy$)
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
)
|
||||
.subscribe((filterQuery) => {
|
||||
if (filterQuery) {
|
||||
@@ -149,11 +150,6 @@ export class SearchPropertiesComponent implements OnInit, AfterViewChecked, OnDe
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
narrowDownAllowedCharacters(event: Event) {
|
||||
const value = (event.target as HTMLInputElement).value;
|
||||
if (!(event.target as HTMLInputElement).value) {
|
||||
|
@@ -15,17 +15,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Input, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, DestroyRef, inject, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { SearchWidget } from '../../models/search-widget.interface';
|
||||
import { SearchWidgetSettings } from '../../models/search-widget-settings.interface';
|
||||
import { SearchQueryBuilderService } from '../../services/search-query-builder.service';
|
||||
import { ReplaySubject, Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { ReplaySubject } from 'rxjs';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatSliderModule } from '@angular/material/slider';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-search-slider',
|
||||
@@ -36,7 +36,7 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-search-slider' }
|
||||
})
|
||||
export class SearchSliderComponent implements SearchWidget, OnInit, OnDestroy {
|
||||
export class SearchSliderComponent implements SearchWidget, OnInit {
|
||||
/** The numeric value represented by the slider. */
|
||||
@Input()
|
||||
value: number | null;
|
||||
@@ -54,7 +54,7 @@ export class SearchSliderComponent implements SearchWidget, OnInit, OnDestroy {
|
||||
enableChangeUpdate: boolean;
|
||||
displayValue$ = new ReplaySubject<string>(1);
|
||||
|
||||
private readonly destroy$ = new Subject<void>();
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
ngOnInit() {
|
||||
if (this.settings) {
|
||||
@@ -79,7 +79,7 @@ export class SearchSliderComponent implements SearchWidget, OnInit, OnDestroy {
|
||||
}
|
||||
this.context.populateFilters
|
||||
.asObservable()
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((filtersQueries) => {
|
||||
if (filtersQueries[this.id]) {
|
||||
this.value = filtersQueries[this.id];
|
||||
@@ -91,11 +91,6 @@ export class SearchSliderComponent implements SearchWidget, OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.value = this.min || 0;
|
||||
if (this.enableChangeUpdate) {
|
||||
|
@@ -15,12 +15,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Input, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, DestroyRef, inject, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { SearchWidget } from '../../models/search-widget.interface';
|
||||
import { SearchWidgetSettings } from '../../models/search-widget-settings.interface';
|
||||
import { SearchQueryBuilderService } from '../../services/search-query-builder.service';
|
||||
import { ReplaySubject, Subject } from 'rxjs';
|
||||
import { map, takeUntil } from 'rxjs/operators';
|
||||
import { ReplaySubject } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
@@ -28,6 +28,7 @@ import { MatInputModule } from '@angular/material/input';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-search-text',
|
||||
@@ -38,7 +39,7 @@ import { MatIconModule } from '@angular/material/icon';
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-search-text' }
|
||||
})
|
||||
export class SearchTextComponent implements SearchWidget, OnInit, OnDestroy {
|
||||
export class SearchTextComponent implements SearchWidget, OnInit {
|
||||
/** The content of the text box. */
|
||||
@Input()
|
||||
value = '';
|
||||
@@ -51,7 +52,7 @@ export class SearchTextComponent implements SearchWidget, OnInit, OnDestroy {
|
||||
enableChangeUpdate = true;
|
||||
displayValue$ = new ReplaySubject<string>(1);
|
||||
|
||||
private readonly destroy$ = new Subject<void>();
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
ngOnInit() {
|
||||
if (this.context && this.settings && this.settings.pattern) {
|
||||
@@ -77,7 +78,7 @@ export class SearchTextComponent implements SearchWidget, OnInit, OnDestroy {
|
||||
.asObservable()
|
||||
.pipe(
|
||||
map((filtersQueries) => filtersQueries[this.id]),
|
||||
takeUntil(this.destroy$)
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
)
|
||||
.subscribe((filterQuery) => {
|
||||
if (filterQuery) {
|
||||
@@ -89,12 +90,6 @@ export class SearchTextComponent implements SearchWidget, OnInit, OnDestroy {
|
||||
this.context.filterLoaded.next();
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.isActive = false;
|
||||
this.value = '';
|
||||
|
@@ -25,18 +25,18 @@ import {
|
||||
Input,
|
||||
OnChanges,
|
||||
Output,
|
||||
SimpleChanges,
|
||||
TemplateRef,
|
||||
ViewChild,
|
||||
ViewEncapsulation,
|
||||
OnDestroy,
|
||||
SimpleChanges
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import { NodePaging, ResultSetPaging } from '@alfresco/js-api';
|
||||
import { Subject } from 'rxjs';
|
||||
import { debounceTime, takeUntil } from 'rxjs/operators';
|
||||
import { debounceTime } from 'rxjs/operators';
|
||||
import { SearchComponentInterface } from '@alfresco/adf-core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-search',
|
||||
@@ -49,7 +49,7 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
exportAs: 'searchAutocomplete',
|
||||
host: { class: 'adf-search' }
|
||||
})
|
||||
export class SearchComponent implements SearchComponentInterface, AfterContentInit, OnChanges, OnDestroy {
|
||||
export class SearchComponent implements SearchComponentInterface, AfterContentInit, OnChanges {
|
||||
@ViewChild('panel', { static: true })
|
||||
panel: ElementRef;
|
||||
|
||||
@@ -107,14 +107,12 @@ export class SearchComponent implements SearchComponentInterface, AfterContentIn
|
||||
_isOpen: boolean = false;
|
||||
keyPressedStream = new Subject<string>();
|
||||
_classList: { [key: string]: boolean } = {};
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(private searchService: SearchService, private _elementRef: ElementRef) {
|
||||
this.keyPressedStream.pipe(debounceTime(200), takeUntil(this.onDestroy$)).subscribe((searchedWord) => {
|
||||
this.keyPressedStream.pipe(debounceTime(200), takeUntilDestroyed()).subscribe((searchedWord) => {
|
||||
this.loadSearchResults(searchedWord);
|
||||
});
|
||||
|
||||
searchService.dataLoaded.pipe(takeUntil(this.onDestroy$)).subscribe(
|
||||
searchService.dataLoaded.pipe(takeUntilDestroyed()).subscribe(
|
||||
(nodePaging) => this.onSearchDataLoaded(nodePaging),
|
||||
(error) => this.onSearchDataError(error)
|
||||
);
|
||||
@@ -129,12 +127,6 @@ export class SearchComponent implements SearchComponentInterface, AfterContentIn
|
||||
this.loadSearchResults(changes.searchTerm.currentValue);
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
resetResults() {
|
||||
this.cleanResults();
|
||||
this.setVisibility();
|
||||
|
@@ -15,18 +15,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Injectable, OnDestroy } from '@angular/core';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { FacetBucketSortBy, FacetBucketSortDirection, FacetField } from '../models/facet-field.interface';
|
||||
import { Subject, throwError } from 'rxjs';
|
||||
import { throwError } from 'rxjs';
|
||||
import { SearchQueryBuilderService } from './search-query-builder.service';
|
||||
import { TranslationService } from '@alfresco/adf-core';
|
||||
import { SearchService } from './search.service';
|
||||
import { catchError, takeUntil } from 'rxjs/operators';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { GenericBucket, GenericFacetResponse, ResultSetContext, ResultSetPaging } from '@alfresco/js-api';
|
||||
import { SearchFilterList } from '../models/search-filter-list.model';
|
||||
import { FacetFieldBucket } from '../models/facet-field-bucket.interface';
|
||||
import { CategoryService } from '../../category/services/category.service';
|
||||
import { TabbedFacetField } from '../models/tabbed-facet-field.interface';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
export interface SelectedBucket {
|
||||
field: FacetField;
|
||||
@@ -38,7 +39,7 @@ const DEFAULT_PAGE_SIZE: number = 5;
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class SearchFacetFiltersService implements OnDestroy {
|
||||
export class SearchFacetFiltersService {
|
||||
/**
|
||||
* All facet field items to be displayed in the component. These are updated according to the response.
|
||||
* When a new search is performed, the already existing items are updated with the new bucket count values and
|
||||
@@ -52,8 +53,6 @@ export class SearchFacetFiltersService implements OnDestroy {
|
||||
selectedBuckets: SelectedBucket[] = [];
|
||||
|
||||
private readonly facetQueriesPageSize = DEFAULT_PAGE_SIZE;
|
||||
private readonly onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(
|
||||
private queryBuilder: SearchQueryBuilderService,
|
||||
private searchService: SearchService,
|
||||
@@ -64,14 +63,14 @@ export class SearchFacetFiltersService implements OnDestroy {
|
||||
this.facetQueriesPageSize = queryBuilder.config.facetQueries.pageSize || DEFAULT_PAGE_SIZE;
|
||||
}
|
||||
|
||||
this.queryBuilder.configUpdated.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
|
||||
this.queryBuilder.configUpdated.pipe(takeUntilDestroyed()).subscribe(() => {
|
||||
this.selectedBuckets = [];
|
||||
this.responseFacets = null;
|
||||
});
|
||||
|
||||
this.queryBuilder.updated.pipe(takeUntil(this.onDestroy$)).subscribe((query) => this.queryBuilder.execute(true, query));
|
||||
this.queryBuilder.updated.pipe(takeUntilDestroyed()).subscribe((query) => this.queryBuilder.execute(true, query));
|
||||
|
||||
this.queryBuilder.executed.pipe(takeUntil(this.onDestroy$)).subscribe((resultSetPaging: ResultSetPaging) => {
|
||||
this.queryBuilder.executed.pipe(takeUntilDestroyed()).subscribe((resultSetPaging: ResultSetPaging) => {
|
||||
this.onDataLoaded(resultSetPaging);
|
||||
this.searchService.dataLoaded.next(resultSetPaging);
|
||||
});
|
||||
@@ -420,11 +419,6 @@ export class SearchFacetFiltersService implements OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.onDestroy$.next(undefined);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
resetAllSelectedBuckets() {
|
||||
this.responseFacets.forEach((facetField) => {
|
||||
if (facetField?.buckets) {
|
||||
|
@@ -16,11 +16,19 @@
|
||||
*/
|
||||
|
||||
import { TranslationService } from '@alfresco/adf-core';
|
||||
import { Component, EventEmitter, Input, OnChanges, Output, ViewEncapsulation, OnDestroy, OnInit } from '@angular/core';
|
||||
import {
|
||||
Component,
|
||||
DestroyRef,
|
||||
EventEmitter,
|
||||
inject,
|
||||
Input,
|
||||
OnChanges,
|
||||
OnInit,
|
||||
Output,
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import { TagService } from '../services/tag.service';
|
||||
import { Subject } from 'rxjs';
|
||||
import { TagPaging } from '@alfresco/js-api';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatListModule } from '@angular/material/list';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
@@ -29,6 +37,7 @@ import { MatInputModule } from '@angular/material/input';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -44,7 +53,7 @@ import { MatButtonModule } from '@angular/material/button';
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-tag-node-actions-list' }
|
||||
})
|
||||
export class TagActionsComponent implements OnChanges, OnInit, OnDestroy {
|
||||
export class TagActionsComponent implements OnChanges, OnInit {
|
||||
/** The identifier of a node. */
|
||||
@Input()
|
||||
nodeId: string;
|
||||
@@ -66,23 +75,18 @@ export class TagActionsComponent implements OnChanges, OnInit, OnDestroy {
|
||||
errorMsg: string;
|
||||
disableAddTag: boolean = true;
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(private tagService: TagService, private translateService: TranslationService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.tagService.refresh.pipe(takeUntil(this.onDestroy$)).subscribe(() => this.refreshTag());
|
||||
this.tagService.refresh.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.refreshTag());
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
return this.refreshTag();
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
refreshTag() {
|
||||
if (this.nodeId) {
|
||||
this.tagService.getTagsByNodeId(this.nodeId).subscribe(
|
||||
|
@@ -15,16 +15,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, EventEmitter, OnInit, Output, ViewEncapsulation, OnDestroy } from '@angular/core';
|
||||
import { Component, EventEmitter, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
||||
import { TagService } from '../services/tag.service';
|
||||
import { PaginationModel } from '@alfresco/adf-core';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { TagEntry } from '@alfresco/js-api';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatChipsModule } from '@angular/material/chips';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
/**
|
||||
* This component provide a list of all the tag inside the ECM
|
||||
@@ -38,7 +37,7 @@ import { MatIconModule } from '@angular/material/icon';
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-tag-list' }
|
||||
})
|
||||
export class TagListComponent implements OnInit, OnDestroy {
|
||||
export class TagListComponent implements OnInit {
|
||||
/** Emitted when a tag is selected. */
|
||||
@Output()
|
||||
result = new EventEmitter();
|
||||
@@ -59,8 +58,6 @@ export class TagListComponent implements OnInit, OnDestroy {
|
||||
isLoading = false;
|
||||
isSizeMinimum = true;
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(private tagService: TagService) {
|
||||
this.defaultPagination = {
|
||||
skipCount: 0,
|
||||
@@ -70,7 +67,7 @@ export class TagListComponent implements OnInit, OnDestroy {
|
||||
|
||||
this.pagination = this.defaultPagination;
|
||||
|
||||
this.tagService.refresh.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
|
||||
this.tagService.refresh.pipe(takeUntilDestroyed()).subscribe(() => {
|
||||
this.tagsEntries = [];
|
||||
this.refreshTag(this.defaultPagination);
|
||||
});
|
||||
@@ -79,12 +76,6 @@ export class TagListComponent implements OnInit, OnDestroy {
|
||||
ngOnInit() {
|
||||
this.refreshTag(this.defaultPagination);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
refreshTag(opts?: any) {
|
||||
this.tagService.getAllTheTags(opts).subscribe((tags) => {
|
||||
this.tagsEntries = this.tagsEntries.concat(tags.list.entries);
|
||||
|
@@ -15,12 +15,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, DestroyRef, EventEmitter, inject, Input, OnChanges, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
||||
import { TagService } from '../services/tag.service';
|
||||
import { TagEntry } from '@alfresco/js-api';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { Chip, DynamicChipListComponent } from '@alfresco/adf-core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -34,7 +33,7 @@ import { Chip, DynamicChipListComponent } from '@alfresco/adf-core';
|
||||
templateUrl: './tag-node-list.component.html',
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class TagNodeListComponent implements OnChanges, OnDestroy, OnInit {
|
||||
export class TagNodeListComponent implements OnChanges, OnInit {
|
||||
/** The identifier of a node. */
|
||||
@Input()
|
||||
nodeId: string;
|
||||
@@ -51,13 +50,14 @@ export class TagNodeListComponent implements OnChanges, OnDestroy, OnInit {
|
||||
@Output()
|
||||
results = new EventEmitter<TagEntry[]>();
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
private _tagChips: Chip[] = [];
|
||||
|
||||
get tagChips(): Chip[] {
|
||||
return this._tagChips;
|
||||
}
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(private tagService: TagService) {}
|
||||
|
||||
ngOnChanges(): void {
|
||||
@@ -65,12 +65,7 @@ export class TagNodeListComponent implements OnChanges, OnDestroy, OnInit {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.tagService.refresh.pipe(takeUntil(this.onDestroy$)).subscribe(() => this.refreshTag());
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
this.tagService.refresh.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.refreshTag());
|
||||
}
|
||||
|
||||
refreshTag(): void {
|
||||
|
@@ -16,7 +16,20 @@
|
||||
*/
|
||||
|
||||
import { TagEntry, TagPaging } from '@alfresco/js-api';
|
||||
import { Component, ElementRef, EventEmitter, HostBinding, Input, OnDestroy, OnInit, Output, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||
import {
|
||||
Component,
|
||||
DestroyRef,
|
||||
ElementRef,
|
||||
EventEmitter,
|
||||
HostBinding,
|
||||
inject,
|
||||
Input,
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
Output,
|
||||
ViewChild,
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import { FormControl, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { debounce, distinctUntilChanged, finalize, first, map, takeUntil, tap } from 'rxjs/operators';
|
||||
import { EMPTY, forkJoin, Observable, Subject, timer } from 'rxjs';
|
||||
@@ -32,6 +45,7 @@ import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatListModule } from '@angular/material/list';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
interface TagNameControlErrors {
|
||||
duplicatedExistingTag?: boolean;
|
||||
@@ -162,7 +176,6 @@ export class TagsCreatorComponent implements OnInit, OnDestroy {
|
||||
private _tagNameControlVisible = false;
|
||||
private _existingTags: TagEntry[];
|
||||
private _initialExistingTags: TagEntry[];
|
||||
private onDestroy$ = new Subject<void>();
|
||||
private _tagNameErrorMessageKey = '';
|
||||
private _spinnerVisible = false;
|
||||
private _typing = false;
|
||||
@@ -176,6 +189,8 @@ export class TagsCreatorComponent implements OnInit, OnDestroy {
|
||||
@ViewChild('tagNameInput')
|
||||
private tagNameInputElement: ElementRef;
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(private tagService: TagService, private notificationService: NotificationService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -201,18 +216,16 @@ export class TagsCreatorComponent implements OnInit, OnDestroy {
|
||||
this._existingTags = null;
|
||||
}),
|
||||
debounce((name: string) => (name ? timer(300) : EMPTY)),
|
||||
takeUntil(this.onDestroy$)
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
)
|
||||
.subscribe((name: string) => this.onTagNameControlValueChange(name));
|
||||
|
||||
this.tagNameControl.statusChanges.pipe(takeUntil(this.onDestroy$)).subscribe(() => this.setTagNameControlErrorMessageKey());
|
||||
this.tagNameControl.statusChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.setTagNameControlErrorMessageKey());
|
||||
|
||||
this.setTagNameControlErrorMessageKey();
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.onDestroy$.next();
|
||||
this.onDestroy$.complete();
|
||||
this.cancelExistingTagsLoading$.next();
|
||||
this.cancelExistingTagsLoading$.complete();
|
||||
}
|
||||
|
@@ -19,14 +19,13 @@ import { FileInfo, TranslationService } from '@alfresco/adf-core';
|
||||
import { FileUploadErrorEvent } from '../../../common/events/file.event';
|
||||
import { FileModel } from '../../../common/models/file.model';
|
||||
import { UploadService } from '../../../common/services/upload.service';
|
||||
import { EventEmitter, Input, Output, OnInit, OnDestroy, NgZone, Directive, inject } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
import { DestroyRef, Directive, EventEmitter, inject, Input, NgZone, OnInit, Output } from '@angular/core';
|
||||
import { UploadFilesEvent } from '../upload-files.event';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Directive()
|
||||
// eslint-disable-next-line @angular-eslint/directive-class-suffix
|
||||
export abstract class UploadBase implements OnInit, OnDestroy {
|
||||
export abstract class UploadBase implements OnInit {
|
||||
protected uploadService = inject(UploadService);
|
||||
protected translationService = inject(TranslationService);
|
||||
protected ngZone = inject(NgZone);
|
||||
@@ -85,19 +84,14 @@ export abstract class UploadBase implements OnInit, OnDestroy {
|
||||
@Output()
|
||||
updateFileVersion = new EventEmitter<CustomEvent>();
|
||||
|
||||
protected onDestroy$ = new Subject<boolean>();
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
ngOnInit() {
|
||||
this.uploadService.fileUploadError
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe(error => this.error.emit(error));
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload a list of file in the specified path
|
||||
*
|
||||
|
@@ -19,29 +19,32 @@ import { UserPreferencesService } from '@alfresco/adf-core';
|
||||
import {
|
||||
ChangeDetectorRef,
|
||||
Component,
|
||||
Input,
|
||||
Output,
|
||||
DestroyRef,
|
||||
ElementRef,
|
||||
EventEmitter,
|
||||
HostBinding,
|
||||
inject,
|
||||
Input,
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
Output,
|
||||
ViewChild,
|
||||
HostBinding,
|
||||
ElementRef,
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import { Subscription, merge, Subject } from 'rxjs';
|
||||
import { merge, Subject } from 'rxjs';
|
||||
import { FileUploadingListComponent } from './file-uploading-list.component';
|
||||
import { Direction } from '@angular/cdk/bidi';
|
||||
import { takeUntil, delay } from 'rxjs/operators';
|
||||
import { delay } from 'rxjs/operators';
|
||||
import { UploadService } from '../../common/services/upload.service';
|
||||
import { FileModel, FileUploadStatus } from '../../common/models/file.model';
|
||||
import { FileUploadDeleteEvent, FileUploadCompleteEvent } from '../../common/events/file.event';
|
||||
import { FileUploadCompleteEvent, FileUploadDeleteEvent } from '../../common/events/file.event';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { FileUploadingListRowComponent } from './file-uploading-list-row.component';
|
||||
import { A11yModule } from '@angular/cdk/a11y';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-file-uploading-dialog',
|
||||
@@ -54,7 +57,6 @@ import { A11yModule } from '@angular/cdk/a11y';
|
||||
export class FileUploadingDialogComponent implements OnInit, OnDestroy {
|
||||
/** Dialog direction. Can be 'ltr' or 'rtl. */
|
||||
private direction: Direction = 'ltr';
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
@ViewChild('uploadList')
|
||||
uploadList: FileUploadingListComponent;
|
||||
@@ -87,12 +89,10 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy {
|
||||
isDialogMinimized: boolean = false;
|
||||
isConfirmation: boolean = false;
|
||||
|
||||
private listSubscription: Subscription;
|
||||
private counterSubscription: Subscription;
|
||||
private fileUploadSubscription: Subscription;
|
||||
private errorSubscription: Subscription;
|
||||
private dialogActive = new Subject<boolean>();
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(
|
||||
private uploadService: UploadService,
|
||||
private changeDetector: ChangeDetectorRef,
|
||||
@@ -101,14 +101,14 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy {
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.dialogActive.pipe(delay(100), takeUntil(this.onDestroy$)).subscribe(() => {
|
||||
this.dialogActive.pipe(delay(100), takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
||||
const element: any = this.elementRef.nativeElement.querySelector('#upload-dialog');
|
||||
if (element) {
|
||||
element.focus();
|
||||
}
|
||||
});
|
||||
|
||||
this.listSubscription = this.uploadService.queueChanged.pipe(takeUntil(this.onDestroy$)).subscribe((fileList) => {
|
||||
this.uploadService.queueChanged.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((fileList) => {
|
||||
this.filesUploadingList = fileList;
|
||||
|
||||
if (this.filesUploadingList.length && !this.isDialogActive) {
|
||||
@@ -119,23 +119,23 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
});
|
||||
|
||||
this.counterSubscription = merge(this.uploadService.fileUploadComplete, this.uploadService.fileUploadDeleted)
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
merge(this.uploadService.fileUploadComplete, this.uploadService.fileUploadDeleted)
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((event: FileUploadCompleteEvent | FileUploadDeleteEvent) => {
|
||||
this.totalCompleted = event.totalComplete;
|
||||
this.changeDetector.detectChanges();
|
||||
});
|
||||
|
||||
this.errorSubscription = this.uploadService.fileUploadError.pipe(takeUntil(this.onDestroy$)).subscribe((event) => {
|
||||
this.uploadService.fileUploadError.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((event) => {
|
||||
this.totalErrors = event.totalError;
|
||||
this.changeDetector.detectChanges();
|
||||
});
|
||||
|
||||
this.fileUploadSubscription = this.uploadService.fileUpload.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
|
||||
this.uploadService.fileUpload.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
||||
this.changeDetector.detectChanges();
|
||||
});
|
||||
|
||||
this.uploadService.fileDeleted.pipe(takeUntil(this.onDestroy$)).subscribe((objId) => {
|
||||
this.uploadService.fileDeleted.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((objId) => {
|
||||
if (this.filesUploadingList) {
|
||||
const uploadedFile = this.filesUploadingList.find((file) => (file.data ? file.data.entry.id === objId : false));
|
||||
if (uploadedFile) {
|
||||
@@ -147,7 +147,7 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy {
|
||||
|
||||
this.userPreferencesService
|
||||
.select('textOrientation')
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((textOrientation: Direction) => {
|
||||
this.direction = textOrientation;
|
||||
});
|
||||
@@ -201,12 +201,6 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy {
|
||||
|
||||
ngOnDestroy() {
|
||||
this.uploadService.clearQueue();
|
||||
this.listSubscription.unsubscribe();
|
||||
this.counterSubscription.unsubscribe();
|
||||
this.fileUploadSubscription.unsubscribe();
|
||||
this.errorSubscription.unsubscribe();
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
canShowDialog(): boolean {
|
||||
|
@@ -17,14 +17,25 @@
|
||||
|
||||
import { ConfirmDialogComponent } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService } from '../services/alfresco-api.service';
|
||||
import { Component, Input, OnChanges, ViewEncapsulation, EventEmitter, Output, OnInit, OnDestroy, ViewChild } from '@angular/core';
|
||||
import { VersionsApi, Node, VersionEntry, NodesApi, NodeEntry, ContentApi, ContentPagingQuery } from '@alfresco/js-api';
|
||||
import {
|
||||
Component,
|
||||
DestroyRef,
|
||||
EventEmitter,
|
||||
inject,
|
||||
Input,
|
||||
OnChanges,
|
||||
OnInit,
|
||||
Output,
|
||||
ViewChild,
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import { ContentApi, ContentPagingQuery, Node, NodeEntry, NodesApi, VersionEntry, VersionsApi } from '@alfresco/js-api';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ContentVersionService } from './content-version.service';
|
||||
import { ContentService } from '../common';
|
||||
import { InfiniteScrollDatasource } from '../infinite-scroll-datasource';
|
||||
import { from, Observable, Subject } from 'rxjs';
|
||||
import { map, take, takeUntil } from 'rxjs/operators';
|
||||
import { from, Observable } from 'rxjs';
|
||||
import { map, take } from 'rxjs/operators';
|
||||
import { CdkFixedSizeVirtualScroll, CdkVirtualForOf, CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||
@@ -34,6 +45,7 @@ import { MatMenuModule } from '@angular/material/menu';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { VersionCompatibilityDirective } from '../version-compatibility';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
export class VersionListDataSource extends InfiniteScrollDatasource<VersionEntry> {
|
||||
constructor(private versionsApi: VersionsApi, private node: Node) {
|
||||
@@ -69,8 +81,7 @@ export class VersionListDataSource extends InfiniteScrollDatasource<VersionEntry
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-version-list' }
|
||||
})
|
||||
export class VersionListComponent implements OnChanges, OnInit, OnDestroy {
|
||||
private onDestroy$ = new Subject<void>();
|
||||
export class VersionListComponent implements OnChanges, OnInit {
|
||||
private _contentApi: ContentApi;
|
||||
get contentApi(): ContentApi {
|
||||
this._contentApi = this._contentApi ?? new ContentApi(this.alfrescoApi.getInstance());
|
||||
@@ -132,6 +143,8 @@ export class VersionListComponent implements OnChanges, OnInit, OnDestroy {
|
||||
@ViewChild('viewport')
|
||||
viewport: CdkVirtualScrollViewport;
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(
|
||||
private alfrescoApi: AlfrescoApiService,
|
||||
private contentService: ContentService,
|
||||
@@ -141,7 +154,7 @@ export class VersionListComponent implements OnChanges, OnInit, OnDestroy {
|
||||
|
||||
ngOnInit() {
|
||||
this.versionsDataSource = new VersionListDataSource(this.versionsApi, this.node);
|
||||
this.versionsDataSource.isLoading.pipe(takeUntil(this.onDestroy$)).subscribe((isLoading) => {
|
||||
this.versionsDataSource.isLoading.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((isLoading) => {
|
||||
this.isLoading = isLoading;
|
||||
this.latestVersion = this.versionsDataSource.firstItem;
|
||||
});
|
||||
@@ -153,10 +166,6 @@ export class VersionListComponent implements OnChanges, OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next();
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
canUpdate(): boolean {
|
||||
return this.contentService.hasAllowableOperations(this.node, 'update') && this.versionsDataSource.itemsCount > 1;
|
||||
@@ -188,7 +197,7 @@ export class VersionListComponent implements OnChanges, OnInit, OnDestroy {
|
||||
if (this.allowDownload) {
|
||||
this.contentVersionService
|
||||
.getVersionContentUrl(this.node.id, versionId, true)
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((versionDownloadUrl) => this.downloadContent(versionDownloadUrl));
|
||||
}
|
||||
}
|
||||
@@ -207,7 +216,7 @@ export class VersionListComponent implements OnChanges, OnInit, OnDestroy {
|
||||
|
||||
dialogRef
|
||||
.afterClosed()
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((result) => {
|
||||
if (result) {
|
||||
this.versionsApi.deleteVersion(this.node.id, versionId).then(() => this.onVersionDeleted(this.node));
|
||||
|
@@ -15,10 +15,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, DestroyRef, EventEmitter, inject, Input, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
||||
import { Node, Version } from '@alfresco/js-api';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { ContentService } from '../common/services/content.service';
|
||||
import { UploadService } from '../common/services/upload.service';
|
||||
import { FileUploadErrorEvent, FileUploadEvent } from '../common/events/file.event';
|
||||
@@ -30,6 +28,7 @@ import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { UploadVersionButtonComponent } from '../upload';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-version-upload',
|
||||
@@ -49,12 +48,11 @@ import { UploadVersionButtonComponent } from '../upload';
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-version-upload' }
|
||||
})
|
||||
export class VersionUploadComponent implements OnInit, OnDestroy {
|
||||
export class VersionUploadComponent implements OnInit {
|
||||
semanticVersion: string = 'minor';
|
||||
comment: string;
|
||||
uploadVersion: boolean = false;
|
||||
disabled: boolean = false;
|
||||
onDestroy$ = new Subject<void>();
|
||||
majorVersion = '2.0';
|
||||
minorVersion = '1.1';
|
||||
|
||||
@@ -107,10 +105,12 @@ export class VersionUploadComponent implements OnInit, OnDestroy {
|
||||
@Output()
|
||||
uploadStarted = new EventEmitter<FileUploadEvent>();
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(private contentService: ContentService, private uploadService: UploadService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.uploadService.fileUploadStarting.pipe(takeUntil(this.onDestroy$)).subscribe((event: FileUploadEvent) => {
|
||||
this.uploadService.fileUploadStarting.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((event: FileUploadEvent) => {
|
||||
this.disabled = true;
|
||||
this.uploadStarted.emit(event);
|
||||
});
|
||||
@@ -146,11 +146,6 @@ export class VersionUploadComponent implements OnInit, OnDestroy {
|
||||
this.error.emit(event);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(undefined);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
getNextMinorVersion(version: string): string {
|
||||
const { major, minor } = this.getParsedVersion(version);
|
||||
return `${major}.${minor + 1}`;
|
||||
|
@@ -19,10 +19,11 @@ import {
|
||||
ChangeDetectorRef,
|
||||
Component,
|
||||
ContentChild,
|
||||
DestroyRef,
|
||||
EventEmitter,
|
||||
inject,
|
||||
Input,
|
||||
OnChanges,
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
Output,
|
||||
SimpleChanges,
|
||||
@@ -33,8 +34,8 @@ import {
|
||||
import {
|
||||
CloseButtonPosition,
|
||||
Track,
|
||||
ViewerComponent,
|
||||
VIEWER_DIRECTIVES,
|
||||
ViewerComponent,
|
||||
ViewerMoreActionsComponent,
|
||||
ViewerOpenWithComponent,
|
||||
ViewerSidebarComponent,
|
||||
@@ -43,11 +44,10 @@ import {
|
||||
ViewUtilService
|
||||
} from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService } from '../../services/alfresco-api.service';
|
||||
import { Subject } from 'rxjs';
|
||||
import { ContentApi, Node, NodeEntry, NodesApi, RenditionEntry, SharedlinksApi, Version, VersionEntry, VersionsApi } from '@alfresco/js-api';
|
||||
import { RenditionService } from '../../common/services/rendition.service';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { filter, takeUntil } from 'rxjs/operators';
|
||||
import { filter } from 'rxjs/operators';
|
||||
import { ContentService } from '../../common/services/content.service';
|
||||
import { NodesApiService } from '../../common/services/nodes-api.service';
|
||||
import { UploadService } from '../../common/services/upload.service';
|
||||
@@ -58,6 +58,7 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { NodeDownloadDirective } from '../../directives';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-alfresco-viewer',
|
||||
@@ -69,7 +70,7 @@ import { NodeDownloadDirective } from '../../directives';
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
providers: [ViewUtilService]
|
||||
})
|
||||
export class AlfrescoViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
export class AlfrescoViewerComponent implements OnChanges, OnInit {
|
||||
@ViewChild('adfViewer')
|
||||
adfViewer: ViewerComponent<{ node: Node }>;
|
||||
|
||||
@@ -204,8 +205,6 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
@Output()
|
||||
showViewerChange = new EventEmitter<boolean>();
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
private cacheBusterNumber: number;
|
||||
|
||||
versionEntry: VersionEntry;
|
||||
@@ -247,6 +246,8 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
return this._contentApi;
|
||||
}
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(
|
||||
private apiService: AlfrescoApiService,
|
||||
private nodesApiService: NodesApiService,
|
||||
@@ -268,7 +269,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
(node) =>
|
||||
node && node.id === this.nodeId && this.getNodeVersionProperty(this.nodeEntry.entry) !== this.getNodeVersionProperty(node)
|
||||
),
|
||||
takeUntil(this.onDestroy$)
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
)
|
||||
.subscribe((node) => this.onNodeUpdated(node));
|
||||
}
|
||||
@@ -458,11 +459,6 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
onDownloadFile() {
|
||||
this.nodeActionsService.downloadNode(this.nodeEntry);
|
||||
}
|
||||
|
Reference in New Issue
Block a user