Fix available options in page per results in search page.

This commit is contained in:
Konstantinos Triantafyllou 2022-06-01 16:28:44 +03:00
parent fd68a2cb10
commit dd6ece97c0
5 changed files with 28 additions and 9 deletions

View File

@ -135,6 +135,7 @@ export class EntitiesSelectionComponent {
} }
this.selectedEntity = this.currentEntity; this.selectedEntity = this.currentEntity;
this.selectionChange.emit({ this.selectionChange.emit({
init: true,
entity: this.selectedEntity, entity: this.selectedEntity,
simpleUrl: this.getUrl(true), simpleUrl: this.getUrl(true),
advancedUrl: this.getUrl(false) advancedUrl: this.getUrl(false)

View File

@ -276,13 +276,14 @@
<div *ngIf="(searchUtils.status !== errorCodes.LOADING || !loadPaging)"> <div *ngIf="(searchUtils.status !== errorCodes.LOADING || !loadPaging)">
<ng-container *ngTemplateOutlet="selected_filters_pills;"></ng-container> <ng-container *ngTemplateOutlet="selected_filters_pills;"></ng-container>
</div> </div>
<div class="uk-grid uk-flex-middle uk-child-width-1-1 uk-child-width-1-2@m uk-margin-medium-top" uk-grid> <div *ngIf="availablePageOptions.length > 0 || sort || searchUtils.totalResults > searchUtils.size ||
<div (!loadPaging && oldTotalResults > searchUtils.size && searchUtils.status == errorCodes.LOADING)"
*ngIf="(results && searchUtils.totalResults > 0) || (!loadPaging && oldTotalResults > 0 && searchUtils.status == errorCodes.LOADING)"> class="uk-grid uk-flex-middle uk-child-width-1-1 uk-child-width-1-2@m uk-margin-medium-top" uk-grid>
<div>
<div class="uk-flex uk-flex-middle"> <div class="uk-flex uk-flex-middle">
<div class="uk-width-small uk-margin-right" *ngIf="searchUtils.totalResults >= 50 || disabled"> <div *ngIf="availablePageOptions.length > 0" class="uk-width-small uk-margin-right">
<div input type="select" placeholder="Results per page" inputClass="flat x-small" <div input type="select" placeholder="Results per page" inputClass="flat x-small"
[options]="['5','10','20','50']" [(value)]="searchUtils.size" [disabled]="disabled" [options]="availablePageOptions" [(value)]="searchUtils.size" [disabled]="disabled"
(valueChange)="sizeChanged($event)"></div> (valueChange)="sizeChanged($event)"></div>
</div> </div>
<search-sorting *ngIf="sort" <search-sorting *ngIf="sort"

View File

@ -119,6 +119,7 @@ export class NewSearchPageComponent {
public errorCodes: ErrorCodes = new ErrorCodes(); public errorCodes: ErrorCodes = new ErrorCodes();
url = null; url = null;
metaDescription = ""; metaDescription = "";
public pageOptions: number[] = [5, 10, 20, 50];
@Input() basicMetaDescription = []; @Input() basicMetaDescription = [];
@Input() entitiesSelection: boolean = true; @Input() entitiesSelection: boolean = true;
@ -228,7 +229,7 @@ export class NewSearchPageComponent {
} }
get disabled() { get disabled() {
return this.disableForms || this.disableRefineForms return this.disableForms || this.disableRefineForms;
} }
updateMeta(title: string) { updateMeta(title: string) {
@ -1685,4 +1686,8 @@ export class NewSearchPageComponent {
} }
return totalPages; return totalPages;
} }
get availablePageOptions() {
return this.pageOptions.filter(option => option < this.searchUtils.totalResults);
}
} }

View File

@ -62,6 +62,18 @@ export class AdvancedSearchInputComponent implements AfterContentInit, OnDestroy
ngOnDestroy() { ngOnDestroy() {
} }
focusNext(input: InputComponent | EntitiesSelectionComponent, event: any = null) {
if(!event || !event.init) {
setTimeout(() => {
if(input instanceof InputComponent) {
input.focus(true);
} else {
input.input.focus(true);
}
}, 100);
}
}
get length() { get length() {
return this.inputs.length + this.entities.length; return this.inputs.length + this.entities.length;
} }

View File

@ -245,11 +245,11 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
} }
@Input() @Input()
set options(options: (Option | string) []) { set options(options: (Option | string | number) []) {
this.optionsArray = options.map(option => { this.optionsArray = options.map(option => {
if (typeof option === 'string') { if (typeof option === 'string' || typeof option === 'number') {
return { return {
label: option, label: option.toString(),
value: option value: option
}; };
} else { } else {