mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
[ACS-5088] Replaced function calls in templates with variable references (#3227)
* [ACS-5088] Replaced method calls in templates with variables * [ACS-5088] Replaced method calls in templates with variables * [ACS-5088] Replaced method calls for *ngIf and *ngFor with variables - Batch 1 (WIP) * [ACS-5088] Replaced method calls for *ngIf and *ngFor with variables - Batch 2 (WIP) * [ACS-5088] Replaced instances of $any with cast pipe. Replaced other instances of method calls in templates with variables * [ACS-5088] Resolved test cases * [ACS-5088] Resolved test cases in aca-content library * [ACS-5088] Resolved test cases in aca-shared library * [ACS-5088] Resolved test cases in aca-folder-rules library * [ACS-5088] Reverted usage of cast pipe to $any() * [ACS-5088] Fixed incorrect revert * [ACS-5088] Resolved code review findings - shortened expressions and made onDestroy subjects use void instead of boolean * [ACS-5088] Resolved code review findings - changed parameter name in sort function * [ACS-5088] Resolved code review findings - added 'void' type to onDestroy subjects * [ACS-5088] Upgraded eslint version to 8.41.0. Added "@angular-eslint/template/no-call-expression" rule to prevent function calls in templates unless needed (reports warnings) * [ACS-5088] Resolved typo in ToggleFavoriteComponent
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
(searchChange)="onSearchChange($event)"
|
||||
>
|
||||
</app-search-input-control>
|
||||
<mat-hint *ngIf="hasLibraryConstraint()" class="app-search-hint">{{ 'SEARCH.INPUT.HINT' | translate }}</mat-hint>
|
||||
<mat-hint *ngIf="hasLibrariesConstraint" class="app-search-hint">{{ 'SEARCH.INPUT.HINT' | translate }}</mat-hint>
|
||||
|
||||
<div id="search-options">
|
||||
<mat-checkbox
|
||||
|
@@ -91,7 +91,7 @@ describe('SearchInputComponent', () => {
|
||||
});
|
||||
|
||||
it('should have no library constraint by default', () => {
|
||||
expect(component.hasLibraryConstraint()).toBe(false);
|
||||
expect(component.evaluateLibrariesConstraint()).toBe(false);
|
||||
});
|
||||
|
||||
it('should have library constraint on 400 error received', async () => {
|
||||
@@ -103,7 +103,7 @@ describe('SearchInputComponent', () => {
|
||||
|
||||
appHookService.library400Error.next();
|
||||
|
||||
expect(component.hasLibraryConstraint()).toBe(true);
|
||||
expect(component.evaluateLibrariesConstraint()).toBe(true);
|
||||
});
|
||||
|
||||
describe('onSearchSubmit()', () => {
|
||||
|
@@ -49,6 +49,7 @@ export class SearchInputComponent implements OnInit, OnDestroy {
|
||||
hasNewChange = false;
|
||||
navigationTimer: any;
|
||||
has400LibraryError = false;
|
||||
hasLibrariesConstraint = false;
|
||||
searchOnChange: boolean;
|
||||
|
||||
searchedWord: string = null;
|
||||
@@ -106,6 +107,7 @@ export class SearchInputComponent implements OnInit, OnDestroy {
|
||||
|
||||
this.appHookService.library400Error.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
|
||||
this.has400LibraryError = true;
|
||||
this.hasLibrariesConstraint = this.evaluateLibrariesConstraint();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -116,6 +118,7 @@ export class SearchInputComponent implements OnInit, OnDestroy {
|
||||
showInputValue() {
|
||||
this.appService.appNavNarMode$.next('collapsed');
|
||||
this.has400LibraryError = false;
|
||||
this.hasLibrariesConstraint = this.evaluateLibrariesConstraint();
|
||||
this.searchedWord = this.getUrlSearchTerm();
|
||||
|
||||
if (this.searchInputControl) {
|
||||
@@ -162,6 +165,7 @@ export class SearchInputComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
this.has400LibraryError = false;
|
||||
this.hasLibrariesConstraint = this.evaluateLibrariesConstraint();
|
||||
this.searchedWord = searchTerm;
|
||||
|
||||
if (this.hasOneChange) {
|
||||
@@ -187,6 +191,7 @@ export class SearchInputComponent implements OnInit, OnDestroy {
|
||||
this.syncInputValues();
|
||||
this.has400LibraryError = false;
|
||||
if (this.isLibrariesChecked()) {
|
||||
this.hasLibrariesConstraint = this.evaluateLibrariesConstraint();
|
||||
if (this.onLibrariesSearchResults && this.isSameSearchTerm()) {
|
||||
this.queryLibrariesBuilder.update();
|
||||
} else if (this.searchedWord) {
|
||||
@@ -238,7 +243,7 @@ export class SearchInputComponent implements OnInit, OnDestroy {
|
||||
return this.isFilesChecked() || this.isFoldersChecked();
|
||||
}
|
||||
|
||||
hasLibraryConstraint(): boolean {
|
||||
evaluateLibrariesConstraint(): boolean {
|
||||
if (this.isLibrariesChecked()) {
|
||||
return this.has400LibraryError || this.searchInputControl.isTermTooShort();
|
||||
}
|
||||
|
@@ -79,7 +79,7 @@
|
||||
</adf-custom-empty-content-template>
|
||||
</adf-document-list>
|
||||
|
||||
<adf-pagination *ngIf="!documentList.isEmpty()" acaPagination [target]="documentList" (change)="onPaginationChanged($event)">
|
||||
<adf-pagination *ngIf="totalResults > 0" acaPagination [target]="documentList" (change)="onPaginationChanged($event)">
|
||||
</adf-pagination>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -50,6 +50,8 @@ export class SearchResultsRowComponent implements OnInit, OnDestroy {
|
||||
name$ = new BehaviorSubject<string>('');
|
||||
title$ = new BehaviorSubject<string>('');
|
||||
|
||||
isFile = false;
|
||||
|
||||
constructor(
|
||||
private store: Store<any>,
|
||||
private nodesApiService: NodesApiService,
|
||||
@@ -77,6 +79,7 @@ export class SearchResultsRowComponent implements OnInit, OnDestroy {
|
||||
|
||||
private updateValues() {
|
||||
this.node = this.context.row.node;
|
||||
this.isFile = this.node.entry.isFile;
|
||||
|
||||
const { name, properties } = this.node.entry;
|
||||
const title = properties ? properties['cm:title'] : '';
|
||||
@@ -93,10 +96,6 @@ export class SearchResultsRowComponent implements OnInit, OnDestroy {
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
get isFile(): boolean {
|
||||
return this.node.entry.isFile;
|
||||
}
|
||||
|
||||
showPreview(event: Event) {
|
||||
event.stopPropagation();
|
||||
if (this.fileAutoDownloadService.shouldFileAutoDownload(this.node.entry.content.sizeInBytes)) {
|
||||
|
@@ -95,7 +95,7 @@
|
||||
</adf-custom-empty-content-template>
|
||||
</adf-document-list>
|
||||
|
||||
<adf-pagination *ngIf="!documentList.isEmpty()" acaPagination [target]="documentList" (change)="onPaginationChanged($event)">
|
||||
<adf-pagination *ngIf="totalResults > 0" acaPagination [target]="documentList" (change)="onPaginationChanged($event)">
|
||||
</adf-pagination>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -56,6 +56,7 @@ export class SearchResultsComponent extends PageComponent implements OnInit {
|
||||
data: ResultSetPaging;
|
||||
sorting = ['name', 'asc'];
|
||||
isLoading = false;
|
||||
totalResults: number;
|
||||
|
||||
constructor(private queryBuilder: SearchQueryBuilderService, private route: ActivatedRoute, private translationService: TranslationService) {
|
||||
super();
|
||||
@@ -191,6 +192,14 @@ export class SearchResultsComponent extends PageComponent implements OnInit {
|
||||
|
||||
onSearchResultLoaded(nodePaging: ResultSetPaging) {
|
||||
this.data = nodePaging;
|
||||
this.totalResults = this.getNumberOfResults();
|
||||
}
|
||||
|
||||
getNumberOfResults() {
|
||||
if (this.data?.list?.pagination) {
|
||||
return this.data.list.pagination.totalItems;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
onPaginationChanged(pagination: Pagination) {
|
||||
|
Reference in New Issue
Block a user