Fix a bug with options position in modals
This commit is contained in:
parent
225285c960
commit
f19408b1a8
|
@ -41,76 +41,78 @@ declare var UIkit;
|
|||
@Component({
|
||||
selector: '[dashboard-input], [input]',
|
||||
template: `
|
||||
<div class="input-wrapper" [class.disabled]="formControl.disabled" [class.opened]="opened"
|
||||
[class.focused]="focused" [ngClass]="inputClass" [class.hint]="hint"
|
||||
[class.active]="(formAsControl?.value || formAsArray?.length > 0) && !focused"
|
||||
[class.danger]="(formControl.invalid && (formControl.touched || searchControl?.touched)) || (searchControl?.invalid && searchControl?.touched)">
|
||||
<div #inputBox class="input-box" [class.select]="type === 'select'"
|
||||
[class.static]="placeholderInfo.static">
|
||||
<div *ngIf="!placeholderInfo.static && placeholderInfo.label" class="placeholder">
|
||||
<label>{{placeholderInfo.label}} <sup *ngIf="required">*</sup></label>
|
||||
</div>
|
||||
<div class="uk-flex" [class.uk-flex-middle]="type !== 'textarea'">
|
||||
<ng-template [ngIf]="type === 'text' || type === 'URL' || type === 'logoURL'">
|
||||
<input #input class="input" [attr.placeholder]="placeholderInfo.static?placeholderInfo.label:hint"
|
||||
[formControl]="formAsControl">
|
||||
</ng-template>
|
||||
<ng-template [ngIf]="type === 'textarea'">
|
||||
<div [id]="id">
|
||||
<div class="input-wrapper" [class.disabled]="formControl.disabled" [class.opened]="opened"
|
||||
[class.focused]="focused" [ngClass]="inputClass" [class.hint]="hint"
|
||||
[class.active]="(formAsControl?.value || formAsArray?.length > 0) && !focused"
|
||||
[class.danger]="(formControl.invalid && (formControl.touched || searchControl?.touched)) || (searchControl?.invalid && searchControl?.touched)">
|
||||
<div #inputBox class="input-box" [class.select]="type === 'select'"
|
||||
[class.static]="placeholderInfo.static">
|
||||
<div *ngIf="!placeholderInfo.static && placeholderInfo.label" class="placeholder">
|
||||
<label>{{placeholderInfo.label}} <sup *ngIf="required">*</sup></label>
|
||||
</div>
|
||||
<div class="uk-flex" [class.uk-flex-middle]="type !== 'textarea'">
|
||||
<ng-template [ngIf]="type === 'text' || type === 'URL' || type === 'logoURL'">
|
||||
<input #input class="input" [attr.placeholder]="placeholderInfo.static?placeholderInfo.label:hint"
|
||||
[formControl]="formAsControl">
|
||||
</ng-template>
|
||||
<ng-template [ngIf]="type === 'textarea'">
|
||||
<textarea #textArea class="input" [attr.placeholder]="placeholderInfo.static?placeholderInfo.label:hint"
|
||||
[rows]="rows" [formControl]="formAsControl"></textarea>
|
||||
</ng-template>
|
||||
<ng-template [ngIf]="type === 'select'">
|
||||
<div *ngIf="formControl.value || !placeholderInfo.static" class="input">{{getLabel(formControl.value)}}</div>
|
||||
<div *ngIf="!formControl.value && placeholderInfo.static" class="input placeholder">{{placeholderInfo.label}}</div>
|
||||
</ng-template>
|
||||
<ng-template [ngIf]="type === 'autocomplete'">
|
||||
<div class="uk-grid uk-width-expand" uk-grid>
|
||||
<div class="uk-width-expand">
|
||||
<input [attr.placeholder]="placeholderInfo.static?placeholderInfo.label:hint"
|
||||
#searchInput class="input" [formControl]="searchControl">
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
<ng-template [ngIf]="type === 'chips'">
|
||||
<div class="uk-grid uk-grid-small uk-grid-row-collapse uk-width-expand" uk-grid>
|
||||
<div *ngFor="let chip of formAsArray.controls; let i=index" class="chip">
|
||||
<div class="uk-label uk-flex uk-flex-middle">
|
||||
<span class="uk-text-truncate uk-width-expand">{{getLabel(chip.value)}}</span>
|
||||
<icon (click)="remove(i, $event)" class="uk-link-text uk-margin-small-left clickable" [flex]="true"
|
||||
name="close" ratio="0.7"></icon>
|
||||
</ng-template>
|
||||
<ng-template [ngIf]="type === 'select'">
|
||||
<div *ngIf="formControl.value || !placeholderInfo.static" class="input">{{getLabel(formControl.value)}}</div>
|
||||
<div *ngIf="!formControl.value && placeholderInfo.static" class="input placeholder">{{placeholderInfo.label}}</div>
|
||||
</ng-template>
|
||||
<ng-template [ngIf]="type === 'autocomplete'">
|
||||
<div class="uk-grid uk-width-expand" uk-grid>
|
||||
<div class="uk-width-expand">
|
||||
<input [attr.placeholder]="placeholderInfo.static?placeholderInfo.label:hint"
|
||||
#searchInput class="input" [formControl]="searchControl">
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-width-expand uk-flex uk-flex-column uk-flex-center">
|
||||
<input #searchInput class="input" [class.search]="searchControl.value"
|
||||
[attr.placeholder]="placeholderInfo.static?placeholderInfo.label:hint"
|
||||
[formControl]="searchControl">
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
<div *ngIf="formControl.disabled || icon || (type === 'select' && selectArrow) || type === 'autocomplete'"
|
||||
class="uk-margin-small-left uk-margin-right icon">
|
||||
<icon *ngIf="formControl.disabled" [name]="'lock'" [flex]="true"></icon>
|
||||
<ng-template [ngIf]="formControl.enabled">
|
||||
<icon *ngIf="!formControl.value && icon" [name]="icon" [flex]="true"></icon>
|
||||
<icon *ngIf="!icon && type === 'select' && selectArrow" name="arrow_drop_down" [flex]="true"></icon>
|
||||
<icon *ngIf="formControl.value && type === 'autocomplete'" class="clickable" (click)="resetSearch($event)"
|
||||
[flex]="true" name="close"></icon>
|
||||
</ng-template>
|
||||
<ng-template [ngIf]="type === 'chips'">
|
||||
<div class="uk-grid uk-grid-small uk-grid-row-collapse uk-width-expand" uk-grid>
|
||||
<div *ngFor="let chip of formAsArray.controls; let i=index" class="chip">
|
||||
<div class="uk-label uk-flex uk-flex-middle">
|
||||
<span class="uk-text-truncate uk-width-expand">{{getLabel(chip.value)}}</span>
|
||||
<icon (click)="remove(i, $event)" class="uk-link-text uk-margin-small-left clickable" [flex]="true"
|
||||
name="close" ratio="0.7"></icon>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-width-expand uk-flex uk-flex-column uk-flex-center">
|
||||
<input #searchInput class="input" [class.search]="searchControl.value"
|
||||
[attr.placeholder]="placeholderInfo.static?placeholderInfo.label:hint"
|
||||
[formControl]="searchControl">
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
<div *ngIf="formControl.disabled || icon || (type === 'select' && selectArrow) || type === 'autocomplete'"
|
||||
class="uk-margin-small-left uk-margin-right icon">
|
||||
<icon *ngIf="formControl.disabled" [name]="'lock'" [flex]="true"></icon>
|
||||
<ng-template [ngIf]="formControl.enabled">
|
||||
<icon *ngIf="!formControl.value && icon" [name]="icon" [flex]="true"></icon>
|
||||
<icon *ngIf="!icon && type === 'select' && selectArrow" name="arrow_drop_down" [flex]="true"></icon>
|
||||
<icon *ngIf="formControl.value && type === 'autocomplete'" class="clickable" (click)="resetSearch($event)"
|
||||
[flex]="true" name="close"></icon>
|
||||
</ng-template>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tools">
|
||||
<ng-content select="[tools]"></ng-content>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tools">
|
||||
<ng-content select="[tools]"></ng-content>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="options uk-dropdown" *ngIf="filteredOptions && filteredOptions.length > 0 && opened" #optionBox
|
||||
uk-dropdown="pos: bottom-justify; mode: click; offset: 15;">
|
||||
<ul class="uk-nav uk-dropdown-nav">
|
||||
<li *ngFor="let option of filteredOptions" [class.uk-active]="formControl.value === option.value"
|
||||
[attr.uk-tooltip]="(tooltip)?('title: ' + option.label + ';'):null">
|
||||
<a (click)="selectOption(option, $event)">{{option.label}}</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="options uk-dropdown" *ngIf="filteredOptions && filteredOptions.length > 0 && opened" #optionBox
|
||||
uk-dropdown="pos: bottom-justify; mode: click; offset: 15; boundary-align: true;" [attr.boundary]="'#' + id">
|
||||
<ul class="uk-nav uk-dropdown-nav">
|
||||
<li *ngFor="let option of filteredOptions" [class.uk-active]="formControl.value === option.value"
|
||||
[attr.uk-tooltip]="(tooltip)?('title: ' + option.label + ';'):null">
|
||||
<a (click)="selectOption(option, $event)">{{option.label}}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<span *ngIf="formControl.invalid && formControl.touched" class="uk-text-danger">
|
||||
<span *ngIf="formControl.errors.error">{{formControl.errors.error}}</span>
|
||||
|
@ -133,6 +135,7 @@ declare var UIkit;
|
|||
`
|
||||
})
|
||||
export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChanges {
|
||||
private static INPUT_COUNTER: number = 0;
|
||||
/** Deprecated options*/
|
||||
/** @deprecated */
|
||||
@Input('label') label: string;
|
||||
|
@ -185,6 +188,7 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
|
|||
/** LogoUrl information */
|
||||
public secure: boolean = true;
|
||||
/** Internal basic information */
|
||||
public id: string;
|
||||
public placeholderInfo: Placeholder = {label: '', static: true};
|
||||
public required: boolean = false;
|
||||
public focused: boolean = false;
|
||||
|
@ -221,6 +225,8 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
|
|||
}
|
||||
|
||||
ngOnInit() {
|
||||
InputComponent.INPUT_COUNTER++;
|
||||
this.id = 'input-' + InputComponent.INPUT_COUNTER;
|
||||
if (!this.formControl) {
|
||||
if (Array.isArray(this.value)) {
|
||||
this.formControl = new FormArray([]);
|
||||
|
@ -350,7 +356,6 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
|
|||
return (this.showOptionsOnEmpty) ? options : [];
|
||||
}
|
||||
const filterValue = value.toString().toLowerCase();
|
||||
console.log(options.filter(option => option.label.toLowerCase().indexOf(filterValue) != -1));
|
||||
return options.filter(option => option.label.toLowerCase().indexOf(filterValue) != -1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue