Skip to content

Commit

Permalink
refactor(lookup): allow for custom default captions
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximBalaganskiy committed Dec 6, 2019
1 parent aa9d800 commit 9bb09df
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/config-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export class ConfigBuilder {
noWavesAttach: boolean = false;
autoButtonWaves: boolean = false;
useGlobalResources: boolean = true;
lookupSearchingText: string = "Searching...";
lookupNoMatchesText: string = "No Matches";

useAll(): ConfigBuilder {
return this
Expand Down
7 changes: 3 additions & 4 deletions src/lookup/lookup.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@

<div style="position: relative">
<div class="input-field">
<input id="${controlId}" type="text" value.bind="filter & debounce: debounce" ref="input" readonly.bind="readonly" blur.trigger="blur()"
focus.trigger="focus()" class="${validationClass}"/>
<input id="${controlId}" type="text" value.bind="filter & debounce: debounce" ref="input" readonly.bind="readonly" blur.trigger="blur()" focus.trigger="focus()" class="${validationClass}" />
<label for="${controlId}" ref="labelElement">${label}</label>
<span repeat.for="r of validateResults" class="helper-text" data-error.bind="r.message"></span>
<div ref="dropdown" if.bind="isOpen" class="dropdown-div z-depth-1">
<ul ref="dropdownUl" class="collection">
<li if.bind="state === LookupState.searching" class="disabled collection-item" md-wait-cursor.bind="true">
<template replaceable part="searching-template">
Searching...
${configBuilder.lookupSearchingText}
</template>
</li>
<li if.bind="state === LookupState.noMatches" class="disabled collection-item">
<template replaceable part="no-matches-template">
No Matches
${configBuilder.lookupNoMatchesText}
</template>
</li>
<li if.bind="state === LookupState.error" class="disabled collection-item">
Expand Down
3 changes: 2 additions & 1 deletion src/lookup/lookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
import { LookupState } from "./lookup-state";
import { ILookupOptionsFunctionParameter } from "./i-lookup-options-function-parameter";
import { DiscardablePromise, discard } from "../common/discardable-promise";
import { ConfigBuilder } from "../config-builder";

export type BlurAction = "Nothing" | "ClearOnNoMatch" | "SetOnMatch" | "Both";

@au.customElement("md-lookup")
@au.autoinject
export class MdLookup {
constructor(private element: Element, private taskQueue: au.TaskQueue) {
constructor(private element: Element, private taskQueue: au.TaskQueue, private configBuilder: ConfigBuilder) {
this.logger = au.getLogger("MdLookup");
this.controlId = `md-lookup-${MdLookup.id++}`;
}
Expand Down

0 comments on commit 9bb09df

Please sign in to comment.