From c4473f0187723167826a748e6daace75ef68e162 Mon Sep 17 00:00:00 2001 From: Adam Baker Date: Thu, 4 Apr 2019 17:54:17 -0400 Subject: [PATCH 1/2] Adding minlength --- addon/components/power-select-infinity.js | 4 ++++ .../components/power-select-infinity.hbs | 4 ++-- tests/dummy/app/templates/application.hbs | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/addon/components/power-select-infinity.js b/addon/components/power-select-infinity.js index b6b5dd4..ff281c3 100644 --- a/addon/components/power-select-infinity.js +++ b/addon/components/power-select-infinity.js @@ -20,6 +20,7 @@ export default Component.extend({ estimateHeight: 28, bufferSize: 5, staticHeight: false, + minLength: 0, fastboot: computed(function() { return getOwner(this).lookup(`service:fastboot`); }), @@ -59,6 +60,9 @@ export default Component.extend({ select.actions.choose(null); } } + }, + onInput(text) { + return text.length >= get(this, 'minLength'); } } }); diff --git a/addon/templates/components/power-select-infinity.hbs b/addon/templates/components/power-select-infinity.hbs index cfe0c03..199b9c8 100644 --- a/addon/templates/components/power-select-infinity.hbs +++ b/addon/templates/components/power-select-infinity.hbs @@ -26,7 +26,7 @@ onchange=onchange onclose=onclose onfocus=(action "handleFocus") - oninput=oninput + oninput=(action "onInput") onkeydown=(action "onKeyDown") onopen=onopen opened=opened @@ -89,7 +89,7 @@ onchange=onchange onclose=onclose onfocus=(action "handleFocus") - oninput=oninput + oninput=(action "onInput") onkeydown=(action "onKeyDown") onopen=onopen opened=opened diff --git a/tests/dummy/app/templates/application.hbs b/tests/dummy/app/templates/application.hbs index cc7e4a5..e287a20 100644 --- a/tests/dummy/app/templates/application.hbs +++ b/tests/dummy/app/templates/application.hbs @@ -52,4 +52,22 @@ {{user.name}} {{/power-select-infinity}} + + +
+
+ With min length + {{#power-select-infinity + search=(action 'search') + loadMore=(action 'loadMore') + selected=selected + onchange=(action (mut selected)) + extra=(hash labelPath="name") + inputClass="form-control" + minLength=3 + loadingComponent='loading-component' + as |user|}} + {{user.name}} + {{/power-select-infinity}} +
\ No newline at end of file From 88ef2f3182181a0263524f970836e9438e566618 Mon Sep 17 00:00:00 2001 From: Adam Baker Date: Thu, 4 Apr 2019 17:56:23 -0400 Subject: [PATCH 2/2] Rename Property --- addon/components/power-select-infinity.js | 4 ++-- tests/dummy/app/templates/application.hbs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addon/components/power-select-infinity.js b/addon/components/power-select-infinity.js index ff281c3..ec44452 100644 --- a/addon/components/power-select-infinity.js +++ b/addon/components/power-select-infinity.js @@ -20,7 +20,7 @@ export default Component.extend({ estimateHeight: 28, bufferSize: 5, staticHeight: false, - minLength: 0, + minCharacters: 0, fastboot: computed(function() { return getOwner(this).lookup(`service:fastboot`); }), @@ -62,7 +62,7 @@ export default Component.extend({ } }, onInput(text) { - return text.length >= get(this, 'minLength'); + return text.length >= get(this, 'minCharacters'); } } }); diff --git a/tests/dummy/app/templates/application.hbs b/tests/dummy/app/templates/application.hbs index e287a20..712d91b 100644 --- a/tests/dummy/app/templates/application.hbs +++ b/tests/dummy/app/templates/application.hbs @@ -64,7 +64,7 @@ onchange=(action (mut selected)) extra=(hash labelPath="name") inputClass="form-control" - minLength=3 + minCharacters=3 loadingComponent='loading-component' as |user|}} {{user.name}}