Skip to content

Commit

Permalink
various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronpettit committed Feb 8, 2024
1 parent 3024c69 commit db13b3e
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="p-3" style="max-width: 345px">
<div class="p-3" style="width: 345px">
<!-- Header -->
<div class="row d-flex">
<div class="d-flex justify-content-between">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
<!-- Input display control value-->
<button #inputElement class="form-control border-0 text-start rounded-3" style="margin-left: 1px" type="button" data-bs-toggle="dropdown"
data-bs-auto-close="outside" [ngClass]="getInputClasses()"
[disabled]="isDisabled" style="min-height:2.25rem;" [value]="control?.value">
{{ currentDisplay || placeholder }}
[disabled]="isDisabled" style="height:2.25rem;" [value]="control?.value">
<div [ngClass]="{'text-muted': !control?.value}">
{{ currentDisplay || placeholder }}
</div>
<!-- Calendar dropdowns -->
</button>

Expand Down Expand Up @@ -45,7 +47,7 @@
</div>

<!-- Calendar template -->
<ng-template #calendarTemplate>
<ng-template #calendarTemplate style="width: 345px;">
<ngds-calendar-manager [disabled]="isDisabled" (dateChange)="handleDateChange($event)" [control]="control"
(clearDates)="handleClearDates()" (displayChange)="handleDisplayChange()" [timezone]="timezone"
[disabledDatesFn]="disabledDatesFn.bind(this)" [dateRange]="dateRange" [minDisplayDepth]="minMode"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<input inputmode="numeric" #inputElement [(ngModel)]="displayValue"
class="form-control border-0 rounded-3"
[ngClass]="getInputClasses()"
autocomplete="off"
[placeholder]="placeholder ? placeholder : ''" (focus)="onFocus()" (blur)="onLoseFocus()" [attr.id]="control?.id">

<!-- Increment/decrement buttons -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<button #inputElement class="form-select border-0 rounded-3" style="min-height: 2.25rem;"
[ngClass]="getInputClasses()" [disabled]="isDisabled"
(click)="openDropdown()">
<div class="text-muted">
{{ placeholderDisplay() }}
</div>
<!-- Input display current value -->
<!-- Multiselect display items -->
<div *ngIf="multiselect && control?.value?.length" class="m-0 d-flex justify-content-left row">
Expand All @@ -21,10 +24,10 @@
</ngds-multiselect-item>
</div>
<!-- Text input for typeahead -->
<input #typeaheadInput [hidden]="!isOpen.value" [(ngModel)]="currentDisplay" [placeholder]="placeholder ? placeholder : ''"
<input #typeaheadInput autocomplete="off" [hidden]="!isOpen.value" [(ngModel)]="currentDisplay" [placeholder]="placeholder ? placeholder : ''"
(ngModelChange)="matchControlToInput()" [typeahead]="selectionListItems" (typeaheadOnSelect)="selected()"
typeaheadOptionField="display" [optionsListTemplate]="getTemplate()" [typeaheadMinLength]="typeaheadMinLength"
[adaptivePosition]="true" [attr.disabled]="isDisabled" class="py-1 w-100 h-100 rounded border-0 multiselect-input"
[adaptivePosition]="true" [disabled]="isDisabled" class="w-100 h-100 rounded border-0 multiselect-input"
[ngClass]="{'is-invalid': isInvalid, 'shrink-input': !isOpen.value}" (focus)="onFocus()" (blur)="onBlur()" [attr.id]="control?.id">
<!-- Placeholder -->
<div class="text-muted text-start" *ngIf="multiselect && placeholder && !control.value && !isFocused">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ export class NgdsTypeaheadInput extends NgdsInput implements AfterViewInit {
this.editByModel = false;
}

placeholderDisplay() {
if (!this.isOpen.value && this.placeholder && !this.multiselect) {
return this.placeholder;
}
return '';
}

// Get the dropdown list template
getTemplate() {
if (this.selectionListTemplate) {
Expand Down
6 changes: 3 additions & 3 deletions src/app/home/demonstrator/monitor/monitor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ export class MonitorComponent {
if (this.control?.value?.length > 0 && Array.isArray(this.control.value)) {
return `[ ` + this.control.value.join(', ') + ` ]`;
}
if (isNaN(this.control?.value) && typeof this.control?.value === 'number') {
return '<NaN>';
}
if (this.control?.value === null) {
return '<null>';
}
if (isNaN(this.control?.value)) {
return '<NaN>';
}
if (this.control?.value === undefined) {
return '<undefined>';
}
Expand Down

0 comments on commit db13b3e

Please sign in to comment.