|
|
|
@ -49,7 +49,8 @@ export interface Option {
|
|
|
|
|
|
|
|
|
|
export interface Placeholder {
|
|
|
|
|
label: string,
|
|
|
|
|
static?: boolean
|
|
|
|
|
static?: boolean,
|
|
|
|
|
tooltip?: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface YearRange {
|
|
|
|
@ -80,50 +81,72 @@ declare var UIkit;
|
|
|
|
|
<div #inputBox class="input-box" [class.select]="selectable || type ==='date'" click-outside-or-esc
|
|
|
|
|
[class.static]="placeholderInfo?.static" (clickOutside)="click($event)">
|
|
|
|
|
<div *ngIf="!placeholderInfo?.static && placeholderInfo?.label" class="placeholder">
|
|
|
|
|
<label>{{placeholderInfo.label}} <sup *ngIf="required">*</sup></label>
|
|
|
|
|
<label>{{ placeholderInfo.label }} <sup *ngIf="required">*</sup></label>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="uk-flex" [class.uk-flex-middle]="type !== 'textarea'"
|
|
|
|
|
[attr.uk-tooltip]="(tooltip && !focused && type !== 'chips' && type !== 'textarea' && (formControl.value || hint || placeholderInfo?.label))?('title: ' + (formControl.value ?getTooltip(formControl.value):(hint?hint:placeholderInfo?.label)) + '; delay: 500; pos: bottom-left'):null">
|
|
|
|
|
[attr.uk-tooltip]="placeholderInfo.tooltip?('title: ' + placeholderInfo.tooltip + '; delay: 500; pos: bottom-left'):
|
|
|
|
|
((tooltip && !focused && type !== 'chips' && type !== 'textarea' && (formControl.value || hint || placeholderInfo?.label))?
|
|
|
|
|
('title: ' + (formControl.value ?getTooltip(formControl.value):(hint?hint:placeholderInfo?.label)) + '; delay: 500; pos: bottom-left'):null)">
|
|
|
|
|
<ng-template [ngIf]="type === 'text' || type === 'URL' || type === 'logoURL'">
|
|
|
|
|
<input #input class="input" [attr.placeholder]="placeholderInfo?.static?placeholderInfo.label:hint"
|
|
|
|
|
<input #input class="input"
|
|
|
|
|
[attr.placeholder]="placeholderInfo?.static?placeholderInfo.label:hint"
|
|
|
|
|
[type]="password?'password':'text'" [formControl]="formAsControl"
|
|
|
|
|
[class.uk-text-truncate]="!focused">
|
|
|
|
|
</ng-template>
|
|
|
|
|
<ng-template [ngIf]="type === 'textarea'">
|
|
|
|
|
<textarea #textArea class="input" [attr.placeholder]="placeholderInfo?.static?placeholderInfo.label:hint"
|
|
|
|
|
<textarea #textArea class="input"
|
|
|
|
|
[attr.placeholder]="placeholderInfo?.static?placeholderInfo.label:hint"
|
|
|
|
|
[rows]="rows" [formControl]="formAsControl"></textarea>
|
|
|
|
|
</ng-template>
|
|
|
|
|
<ng-template [ngIf]="type === 'select'">
|
|
|
|
|
<ng-container *ngIf="placeholderInfo?.static">
|
|
|
|
|
<div *ngIf="!getLabel(formControl.value)"
|
|
|
|
|
class="input placeholder uk-width-expand uk-text-truncate" [class.uk-disabled]="formControl.disabled">{{placeholderInfo.label}}</div>
|
|
|
|
|
class="input placeholder uk-width-expand uk-text-truncate"
|
|
|
|
|
[class.uk-disabled]="formControl.disabled">{{ placeholderInfo.label }}
|
|
|
|
|
</div>
|
|
|
|
|
<div *ngIf="getLabel(formControl.value)"
|
|
|
|
|
class="input uk-width-expand uk-text-truncate" [class.uk-disabled]="formControl.disabled">{{getLabel(formControl.value)}}</div>
|
|
|
|
|
class="input uk-width-expand uk-text-truncate"
|
|
|
|
|
[class.uk-disabled]="formControl.disabled">{{ getLabel(formControl.value) }}
|
|
|
|
|
</div>
|
|
|
|
|
</ng-container>
|
|
|
|
|
<ng-container *ngIf="!placeholderInfo?.static">
|
|
|
|
|
<div *ngIf="!getLabel(formControl.value)"
|
|
|
|
|
class="input uk-width-expand uk-text-truncate" [class.uk-disabled]="formControl.disabled">{{noValueSelected}}</div>
|
|
|
|
|
class="input uk-width-expand uk-text-truncate"
|
|
|
|
|
[class.uk-disabled]="formControl.disabled">{{ noValueSelected }}
|
|
|
|
|
</div>
|
|
|
|
|
<div *ngIf="getLabel(formControl.value)"
|
|
|
|
|
class="input uk-width-expand uk-text-truncate" [class.uk-disabled]="formControl.disabled">{{getLabel(formControl.value)}}</div>
|
|
|
|
|
class="input uk-width-expand uk-text-truncate"
|
|
|
|
|
[class.uk-disabled]="formControl.disabled">{{ getLabel(formControl.value) }}
|
|
|
|
|
</div>
|
|
|
|
|
</ng-container>
|
|
|
|
|
</ng-template>
|
|
|
|
|
<ng-template [ngIf]="type === 'autocomplete'">
|
|
|
|
|
<input *ngIf="focused" [attr.placeholder]="placeholderInfo?.static?placeholderInfo.label:hint"
|
|
|
|
|
#searchInput class="input" [formControl]="searchControl" [class.uk-text-truncate]="!focused">
|
|
|
|
|
#searchInput class="input" [formControl]="searchControl"
|
|
|
|
|
[class.uk-text-truncate]="!focused">
|
|
|
|
|
<ng-container *ngIf="!focused && !selectable">
|
|
|
|
|
<div *ngIf="!getLabel(formControl.value)"
|
|
|
|
|
class="input placeholder uk-text-truncate" [class.uk-disabled]="formControl.disabled">{{placeholderInfo?.static ? placeholderInfo.label : getLabel(formAsControl.value)}}</div>
|
|
|
|
|
class="input placeholder uk-text-truncate"
|
|
|
|
|
[class.uk-disabled]="formControl.disabled">{{ placeholderInfo?.static ? placeholderInfo.label : getLabel(formAsControl.value) }}
|
|
|
|
|
</div>
|
|
|
|
|
<div *ngIf="getLabel(formControl.value)"
|
|
|
|
|
class="input uk-text-truncate" [class.uk-disabled]="formControl.disabled">{{getLabel(formAsControl.value)}}</div>
|
|
|
|
|
class="input uk-text-truncate"
|
|
|
|
|
[class.uk-disabled]="formControl.disabled">{{ getLabel(formAsControl.value) }}
|
|
|
|
|
</div>
|
|
|
|
|
</ng-container>
|
|
|
|
|
<ng-container *ngIf="!focused && selectable">
|
|
|
|
|
<div *ngIf="!getLabel(formControl.value)" class="input uk-text-truncate" [class.uk-disabled]="formControl.disabled">{{noValueSelected}}</div>
|
|
|
|
|
<div *ngIf="!getLabel(formControl.value)" class="input uk-text-truncate"
|
|
|
|
|
[class.uk-disabled]="formControl.disabled">{{ noValueSelected }}
|
|
|
|
|
</div>
|
|
|
|
|
<div *ngIf="getLabel(formControl.value)"
|
|
|
|
|
class="input uk-text-truncate" [class.uk-disabled]="formControl.disabled">{{getLabel(formControl.value)}}</div>
|
|
|
|
|
class="input uk-text-truncate"
|
|
|
|
|
[class.uk-disabled]="formControl.disabled">{{ getLabel(formControl.value) }}
|
|
|
|
|
</div>
|
|
|
|
|
</ng-container>
|
|
|
|
|
</ng-template>
|
|
|
|
|
<ng-template [ngIf]="type === 'autocomplete_soft'">
|
|
|
|
|
<input #input class="input" [attr.placeholder]="placeholderInfo?.static?placeholderInfo.label:hint"
|
|
|
|
|
<input #input class="input"
|
|
|
|
|
[attr.placeholder]="placeholderInfo?.static?placeholderInfo.label:hint"
|
|
|
|
|
[formControl]="formAsControl" [class.uk-text-truncate]="!focused">
|
|
|
|
|
</ng-template>
|
|
|
|
|
<ng-template [ngIf]="type === 'chips'">
|
|
|
|
@ -134,7 +157,7 @@ declare var UIkit;
|
|
|
|
|
class="chip">
|
|
|
|
|
<div class="uk-label uk-label-small uk-text-transform-none uk-flex uk-flex-middle"
|
|
|
|
|
[attr.uk-tooltip]="(tooltip)?('title: ' + getLabel(chip.value) + '; delay: 500; pos: bottom-left'):null">
|
|
|
|
|
<span class="uk-text-truncate uk-width-expand">{{getLabel(chip.value)}}</span>
|
|
|
|
|
<span class="uk-text-truncate uk-width-expand">{{ getLabel(chip.value) }}</span>
|
|
|
|
|
<icon *ngIf="focused" (click)="remove(i, $event)"
|
|
|
|
|
class="uk-link-text uk-margin-small-left clickable" [flex]="true"
|
|
|
|
|
name="close" ratio="0.7"></icon>
|
|
|
|
@ -148,32 +171,42 @@ declare var UIkit;
|
|
|
|
|
</div>
|
|
|
|
|
<div *ngIf="!focused && formAsArray.length > visibleChips"
|
|
|
|
|
class="uk-width-expand uk-flex uk-flex-column uk-flex-center more">
|
|
|
|
|
+ {{(formAsArray.length - visibleChips)}} more
|
|
|
|
|
+ {{ (formAsArray.length - visibleChips) }} more
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</ng-template>
|
|
|
|
|
<ng-template [ngIf]="type === 'year-range' && yearRange && formAsGroup">
|
|
|
|
|
<div class="uk-width-2-5">
|
|
|
|
|
<input #input class="input uk-text-center uk-text-truncate" [attr.placeholder]="yearRange.from.placeholder"
|
|
|
|
|
maxlength="4" (click)="activeIndex = 0;$event.preventDefault()" [formControl]="getFormByName(yearRange.from.control)">
|
|
|
|
|
<input #input class="input uk-text-center uk-text-truncate"
|
|
|
|
|
[attr.placeholder]="yearRange.from.placeholder"
|
|
|
|
|
maxlength="4" (click)="activeIndex = 0;$event.preventDefault()"
|
|
|
|
|
[formControl]="getFormByName(yearRange.from.control)">
|
|
|
|
|
</div>
|
|
|
|
|
<div class="uk-width-1-5 uk-text-center">-</div>
|
|
|
|
|
<div class="uk-width-2-5">
|
|
|
|
|
<input #input class="input uk-text-center uk-text-truncate" [attr.placeholder]="yearRange.to.placeholder"
|
|
|
|
|
maxlength="4" (click)="activeIndex = 1;$event.preventDefault()" [formControl]="getFormByName(yearRange.to.control)">
|
|
|
|
|
<input #input class="input uk-text-center uk-text-truncate"
|
|
|
|
|
[attr.placeholder]="yearRange.to.placeholder"
|
|
|
|
|
maxlength="4" (click)="activeIndex = 1;$event.preventDefault()"
|
|
|
|
|
[formControl]="getFormByName(yearRange.to.control)">
|
|
|
|
|
</div>
|
|
|
|
|
</ng-template>
|
|
|
|
|
<ng-template [ngIf]="type === 'date'">
|
|
|
|
|
<div *ngIf="!formAsControl.getRawValue()" class="input uk-text-truncate" [class.uk-disabled]="formControl.disabled">{{selectADate}}</div>
|
|
|
|
|
<div *ngIf="formAsControl.getRawValue()" class="input uk-text-truncate" [class.uk-disabled]="formControl.disabled">{{formAsControl.getRawValue() | date: 'dd-MM-yyyy'}}</div>
|
|
|
|
|
<div *ngIf="!formAsControl.getRawValue()" class="input uk-text-truncate"
|
|
|
|
|
[class.uk-disabled]="formControl.disabled">{{ selectADate }}
|
|
|
|
|
</div>
|
|
|
|
|
<div *ngIf="formAsControl.getRawValue()" class="input uk-text-truncate"
|
|
|
|
|
[class.uk-disabled]="formControl.disabled">{{ formAsControl.getRawValue() | date: 'dd-MM-yyyy' }}
|
|
|
|
|
</div>
|
|
|
|
|
</ng-template>
|
|
|
|
|
<div *ngIf="(formControl.disabled && disabledIcon) || icon || (selectable && selectArrow) || type === 'autocomplete' || searchable || type === 'date'"
|
|
|
|
|
class="uk-margin-small-left icon">
|
|
|
|
|
class="uk-margin-small-left icon">
|
|
|
|
|
<icon *ngIf="formControl.disabled && disabledIcon" [name]="disabledIcon" [flex]="true"></icon>
|
|
|
|
|
<ng-template [ngIf]="formControl.enabled">
|
|
|
|
|
<icon *ngIf="!searchControl?.value && icon" [name]="icon" [flex]="true"></icon>
|
|
|
|
|
<icon *ngIf="!icon && selectable && selectArrow" [name]="selectArrow" [flex]="true"></icon>
|
|
|
|
|
<button *ngIf="focused && type === 'autocomplete' && (!selectable || searchControl.value)" class="uk-close uk-icon"
|
|
|
|
|
<icon *ngIf="!icon && selectable && selectArrow" [name]="selectArrow"
|
|
|
|
|
[flex]="true"></icon>
|
|
|
|
|
<button *ngIf="focused && type === 'autocomplete' && (!selectable || searchControl.value)"
|
|
|
|
|
class="uk-close uk-icon"
|
|
|
|
|
(click)="resetSearch($event)">
|
|
|
|
|
<icon [flex]="true" name="close"></icon>
|
|
|
|
|
</button>
|
|
|
|
@ -193,28 +226,34 @@ declare var UIkit;
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div *ngIf="!mobile && type === 'date' && opened" class="uk-dropdown" #calendarBox
|
|
|
|
|
uk-dropdown="pos: bottom-left; mode: none; flip: false ; shift: false" [attr.target]="'#' + id" [attr.boundary]="'#' + id" (click)="$event.stopPropagation()">
|
|
|
|
|
<mat-calendar [selected]="selectedDate" [startAt]="selectedDate" (selectedChange)="dateChanged($event)"></mat-calendar>
|
|
|
|
|
<div *ngIf="!mobile && type === 'date' && opened" class="uk-dropdown" #calendarBox
|
|
|
|
|
uk-dropdown="pos: bottom-left; mode: none; flip: false ; shift: false" [attr.target]="'#' + id"
|
|
|
|
|
[attr.boundary]="'#' + id" (click)="$event.stopPropagation()">
|
|
|
|
|
<mat-calendar [selected]="selectedDate" [startAt]="selectedDate"
|
|
|
|
|
(selectedChange)="dateChanged($event)"></mat-calendar>
|
|
|
|
|
</div>
|
|
|
|
|
<mobile-dropdown *ngIf="mobile && type === 'date' && opened" (onClose)="focus(false)" #mobileDropdown>
|
|
|
|
|
<mat-calendar [selected]="selectedDate" [startAt]="selectedDate" (selectedChange)="dateChanged($event)"></mat-calendar>
|
|
|
|
|
<mat-calendar [selected]="selectedDate" [startAt]="selectedDate"
|
|
|
|
|
(selectedChange)="dateChanged($event)"></mat-calendar>
|
|
|
|
|
</mobile-dropdown>
|
|
|
|
|
<div *ngIf="!mobile && filteredOptions && filteredOptions.length > 0 && opened" class="options uk-dropdown" #optionBox
|
|
|
|
|
<div *ngIf="!mobile && filteredOptions && filteredOptions.length > 0 && opened" class="options uk-dropdown"
|
|
|
|
|
#optionBox
|
|
|
|
|
uk-dropdown="mode: none; stretch: true; flip: false; shift: false" [attr.boundary]="'#' + id">
|
|
|
|
|
<ul class="uk-nav uk-dropdown-nav">
|
|
|
|
|
<li *ngFor="let option of filteredOptions; let i=index" [class.uk-hidden]="option.hidden"
|
|
|
|
|
[class.uk-active]="(formControl.value === option.value) || selectedIndex === i">
|
|
|
|
|
<a (click)="selectOption(option, $event)"
|
|
|
|
|
[class]="option.disabled ? 'uk-disabled uk-text-muted' : ''">
|
|
|
|
|
<span [attr.uk-tooltip]="(tooltip)?('title: ' + (option.tooltip ? option.tooltip : option.label) + '; delay: 500; pos:bottom-left'):null">{{option.label}}</span>
|
|
|
|
|
<span [attr.uk-tooltip]="(tooltip)?('title: ' + (option.tooltip ? option.tooltip : option.label) + '; delay: 500; pos:bottom-left'):null">{{ option.label }}</span>
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
<mobile-dropdown *ngIf="mobile && filteredOptions && filteredOptions.length > 0 && opened" (onClose)="focus(false)" #mobileDropdown>
|
|
|
|
|
<div *ngIf="placeholderInfo" class="uk-text-emphasis uk-text-bolder uk-text-center uk-padding-small uk-padding-remove-vertical uk-text-uppercase">
|
|
|
|
|
{{placeholderInfo.label}}
|
|
|
|
|
<mobile-dropdown *ngIf="mobile && filteredOptions && filteredOptions.length > 0 && opened"
|
|
|
|
|
(onClose)="focus(false)" #mobileDropdown>
|
|
|
|
|
<div *ngIf="placeholderInfo"
|
|
|
|
|
class="uk-text-emphasis uk-text-bolder uk-text-center uk-padding-small uk-padding-remove-vertical uk-text-uppercase">
|
|
|
|
|
{{ placeholderInfo.label }}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="uk-padding uk-padding-remove-horizontal">
|
|
|
|
|
<ul class="uk-nav uk-nav-default">
|
|
|
|
@ -222,7 +261,7 @@ declare var UIkit;
|
|
|
|
|
[class.uk-active]="formControl.value === option.value">
|
|
|
|
|
<a (click)="selectOption(option, $event)"
|
|
|
|
|
[class]="option.disabled ? 'uk-disabled uk-text-muted' : ''">
|
|
|
|
|
<span>{{option.label}}</span>
|
|
|
|
|
<span>{{ option.label }}</span>
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
@ -230,7 +269,7 @@ declare var UIkit;
|
|
|
|
|
</mobile-dropdown>
|
|
|
|
|
</div>
|
|
|
|
|
<span *ngIf="formControl?.invalid && formControl?.touched" class="uk-text-small uk-text-danger">
|
|
|
|
|
<span *ngIf="errors?.error">{{errors?.error}}</span>
|
|
|
|
|
<span *ngIf="errors?.error">{{ errors?.error }}</span>
|
|
|
|
|
<span *ngIf="type === 'URL' || type === 'logoURL'">Please provide a valid URL (e.g. https://example.com)</span>
|
|
|
|
|
</span>
|
|
|
|
|
<span class="uk-text-small uk-text-danger">
|
|
|
|
@ -320,7 +359,7 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
|
|
|
|
|
|
|
|
|
|
@Input()
|
|
|
|
|
set placeholder(placeholder: string | Placeholder) {
|
|
|
|
|
if(this.type === 'year-range') {
|
|
|
|
|
if (this.type === 'year-range') {
|
|
|
|
|
this.placeholderInfo = null;
|
|
|
|
|
} else if (typeof placeholder === 'string') {
|
|
|
|
|
this.placeholderInfo = {label: placeholder, static: false};
|
|
|
|
@ -336,7 +375,7 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
|
|
|
|
|
@Input()
|
|
|
|
|
set options(options: (Option | string | number) []) {
|
|
|
|
|
this.optionsArray = options.map(option => {
|
|
|
|
|
if(option === null) {
|
|
|
|
|
if (option === null) {
|
|
|
|
|
return {
|
|
|
|
|
label: this.noValueSelected,
|
|
|
|
|
value: ''
|
|
|
|
@ -537,20 +576,20 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get yearRangeActive(): boolean {
|
|
|
|
|
if(this.yearRange) {
|
|
|
|
|
if (this.yearRange) {
|
|
|
|
|
return this.formAsGroup && (this.getFormByName(this.yearRange.from.control)?.value || this.getFormByName(this.yearRange.to.control)?.value);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get errors(): any {
|
|
|
|
|
if(this.formAsGroup) {
|
|
|
|
|
if (this.formAsGroup) {
|
|
|
|
|
return (this.formAsGroup.errors
|
|
|
|
|
?this.formAsGroup.errors:(this.getFormByName(this.yearRange.from.control).errors
|
|
|
|
|
?this.getFormByName(this.yearRange.from.control).errors:this.getFormByName(this.yearRange.to.control).errors));
|
|
|
|
|
} else if(this.formAsControl) {
|
|
|
|
|
? this.formAsGroup.errors : (this.getFormByName(this.yearRange.from.control).errors
|
|
|
|
|
? this.getFormByName(this.yearRange.from.control).errors : this.getFormByName(this.yearRange.to.control).errors));
|
|
|
|
|
} else if (this.formAsControl) {
|
|
|
|
|
return this.formAsControl.errors;
|
|
|
|
|
} else if(this.searchControl) {
|
|
|
|
|
} else if (this.searchControl) {
|
|
|
|
|
return this.searchControl.errors;
|
|
|
|
|
} else {
|
|
|
|
|
return null;
|
|
|
|
@ -578,7 +617,7 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
|
|
|
|
|
if (this.focused) {
|
|
|
|
|
this.open(true);
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
if(this.searchInput) {
|
|
|
|
|
if (this.searchInput) {
|
|
|
|
|
this.searchInput.nativeElement.focus();
|
|
|
|
|
this.searchInput.nativeElement.value = value;
|
|
|
|
|
}
|
|
|
|
@ -590,12 +629,12 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
|
|
|
|
|
let validator = this.formControl.validator({} as AbstractControl);
|
|
|
|
|
this.required = (validator && validator.required);
|
|
|
|
|
}
|
|
|
|
|
if(this.type === 'date') {
|
|
|
|
|
this.selectedDate = this.formAsControl.getRawValue()?new Date(this.formAsControl.getRawValue()):null;
|
|
|
|
|
if (this.type === 'date') {
|
|
|
|
|
this.selectedDate = this.formAsControl.getRawValue() ? new Date(this.formAsControl.getRawValue()) : null;
|
|
|
|
|
}
|
|
|
|
|
this.subscriptions.push(this.formControl.valueChanges.subscribe(value => {
|
|
|
|
|
if (this.formControl.enabled) {
|
|
|
|
|
if(this.type !== 'year-range') {
|
|
|
|
|
if (this.type !== 'year-range') {
|
|
|
|
|
value = (value === '') ? null : value;
|
|
|
|
|
if (this.type === 'logoURL') {
|
|
|
|
|
this.secure = (!value || value.includes('https://'));
|
|
|
|
@ -613,7 +652,7 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (this.type === 'date') {
|
|
|
|
|
this.selectedDate = value?new Date(value):null;
|
|
|
|
|
this.selectedDate = value ? new Date(value) : null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ((this.value && value && this.value !== value) || (!this.value && value) || this.value && !value) {
|
|
|
|
@ -621,7 +660,7 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
if(this.formAsGroup) {
|
|
|
|
|
if (this.formAsGroup) {
|
|
|
|
|
let fromControl = this.formAsGroup.get(this.yearRange.from.control);
|
|
|
|
|
this.subscriptions.push(fromControl.valueChanges.subscribe(value => {
|
|
|
|
|
let from = this.initValue[this.yearRange.from.control];
|
|
|
|
@ -630,8 +669,8 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
|
|
|
|
|
} else {
|
|
|
|
|
fromControl.markAsDirty();
|
|
|
|
|
}
|
|
|
|
|
if(fromControl.valid) {
|
|
|
|
|
if(this.activeIndex === 0 && value) {
|
|
|
|
|
if (fromControl.valid) {
|
|
|
|
|
if (this.activeIndex === 0 && value) {
|
|
|
|
|
this.activeIndex = 1;
|
|
|
|
|
this.input.get(this.activeIndex).nativeElement.focus();
|
|
|
|
|
}
|
|
|
|
@ -745,13 +784,13 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
focus(value: boolean, event = null) {
|
|
|
|
|
if(!this.activeIndex) {
|
|
|
|
|
if (!this.activeIndex) {
|
|
|
|
|
this.activeIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
if (this.focused) {
|
|
|
|
|
this.formControl.markAsTouched();
|
|
|
|
|
}
|
|
|
|
|
if(this.formControl.enabled) {
|
|
|
|
|
if (this.formControl.enabled) {
|
|
|
|
|
this.focused = value;
|
|
|
|
|
this.cdr.detectChanges();
|
|
|
|
|
if (this.focused) {
|
|
|
|
@ -791,7 +830,7 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
|
|
|
|
|
open(value: boolean) {
|
|
|
|
|
this.opened = value && this.formControl.enabled;
|
|
|
|
|
this.cdr.detectChanges();
|
|
|
|
|
if(this.optionBox) {
|
|
|
|
|
if (this.optionBox) {
|
|
|
|
|
if (this.opened) {
|
|
|
|
|
this.selectedIndex = this.filteredOptions.findIndex(option => option.value === this.formControl.value);
|
|
|
|
|
if (this.selectedIndex === -1 && this.type !== 'autocomplete_soft') {
|
|
|
|
@ -802,17 +841,17 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
|
|
|
|
|
UIkit.dropdown(this.optionBox.nativeElement).hide();
|
|
|
|
|
this.focused = false;
|
|
|
|
|
}
|
|
|
|
|
} else if(this.calendarBox) {
|
|
|
|
|
} else if (this.calendarBox) {
|
|
|
|
|
if (this.opened) {
|
|
|
|
|
UIkit.dropdown(this.calendarBox.nativeElement).show();
|
|
|
|
|
} else {
|
|
|
|
|
UIkit.dropdown(this.calendarBox.nativeElement).hide();
|
|
|
|
|
this.focused = false;
|
|
|
|
|
}
|
|
|
|
|
} else if(this.mobileDropdown) {
|
|
|
|
|
if(this.opened) {
|
|
|
|
|
} else if (this.mobileDropdown) {
|
|
|
|
|
if (this.opened) {
|
|
|
|
|
this.mobileDropdown.open();
|
|
|
|
|
if(this.searchInput) {
|
|
|
|
|
if (this.searchInput) {
|
|
|
|
|
this.searchInput.nativeElement.blur();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
@ -845,7 +884,7 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
|
|
|
|
|
this.searchControl.setValue('');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(this.mobileDropdown) {
|
|
|
|
|
if (this.mobileDropdown) {
|
|
|
|
|
this.mobileDropdown.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|