From 25ef8ac45130b81a4115e2c692c99321a9e8ef28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Sch=C3=B6nburg?= Date: Wed, 15 Feb 2017 11:47:04 +0100 Subject: [PATCH 1/7] initial failing test --- .../components/power-select/multiple-test.js | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/integration/components/power-select/multiple-test.js b/tests/integration/components/power-select/multiple-test.js index 0c71fa1f0..955f6bbdd 100644 --- a/tests/integration/components/power-select/multiple-test.js +++ b/tests/integration/components/power-select/multiple-test.js @@ -809,4 +809,27 @@ test('If the options of a multiple select implement `isEqual`, that option is us assert.equal($('.ember-power-select-option:eq(0)').attr('aria-selected'), 'true', 'The item in the list is marked as selected'); nativeMouseUp('.ember-power-select-option:eq(0)'); // select the same user again should remove it assert.equal(this.$('.ember-power-select-multiple-option').length, 0); -}); \ No newline at end of file +}); + +test('placeholder can be customized using placeholderComponent', function(assert) { + assert.expect(2); + + this.countries = countries; + + this.render(hbs` + {{#power-select-multiple + options=countries + placeholder="test" + placeholderComponent="custom-placeholder" + onchange=(action (mut foo)) as |country|}} + {{country.name}} + {{/power-select-multiple}} + `); + + assert.equal($('.ember-power-select-placeholder').length, 1, 'The placeholder appears.'); + assert.equal( + $('.ember-power-select-placeholder').text().trim(), + 'This is a very bold placeholder', + 'The placeholder content is equal.' + ); +}); From fcfc3095a208a740661724bdba52c19753fd166c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Sch=C3=B6nburg?= Date: Wed, 15 Feb 2017 13:47:47 +0100 Subject: [PATCH 2/7] render placeholderComponent in multiple-trigger --- addon/templates/components/power-select-multiple.hbs | 2 ++ addon/templates/components/power-select-multiple/trigger.hbs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addon/templates/components/power-select-multiple.hbs b/addon/templates/components/power-select-multiple.hbs index adccfe66d..94118e01e 100644 --- a/addon/templates/components/power-select-multiple.hbs +++ b/addon/templates/components/power-select-multiple.hbs @@ -32,6 +32,7 @@ options=options optionsComponent=optionsComponent placeholder=placeholder + placeholderComponent=placeholderComponent registerAPI=(readonly registerAPI) renderInPlace=renderInPlace required=required @@ -86,6 +87,7 @@ options=options optionsComponent=optionsComponent placeholder=placeholder + placeholderComponent=placeholderComponent registerAPI=(readonly registerAPI) renderInPlace=renderInPlace required=required diff --git a/addon/templates/components/power-select-multiple/trigger.hbs b/addon/templates/components/power-select-multiple/trigger.hbs index 83db5d03b..64b9b3cca 100644 --- a/addon/templates/components/power-select-multiple/trigger.hbs +++ b/addon/templates/components/power-select-multiple/trigger.hbs @@ -16,8 +16,8 @@ {{/if}} {{else}} - {{#if (and placeholder (not searchEnabled))}} - {{placeholder}} + {{#if placeholder}} + {{component placeholderComponent placeholder=placeholder}} {{/if}} {{/each}} {{#if searchEnabled}} From 6e5129f89e8bc8859e12e011c649e1f362ab72a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Sch=C3=B6nburg?= Date: Wed, 15 Feb 2017 13:49:20 +0100 Subject: [PATCH 3/7] don't render two placeholders --- addon/components/power-select-multiple/trigger.js | 5 ++++- addon/templates/components/power-select-multiple/trigger.hbs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/addon/components/power-select-multiple/trigger.js b/addon/components/power-select-multiple/trigger.js index 953220d85..52cf0422f 100644 --- a/addon/components/power-select-multiple/trigger.js +++ b/addon/components/power-select-multiple/trigger.js @@ -70,7 +70,10 @@ export default Component.extend({ }), maybePlaceholder: computed('placeholder', 'select.selected.length', function() { - if (isIE) { + const component = this.get('placeholderComponent'); + const hasCustomPlaceholder = component !== 'power-select/placeholder'; + + if (isIE || hasCustomPlaceholder) { return null; } let select = this.get('select'); diff --git a/addon/templates/components/power-select-multiple/trigger.hbs b/addon/templates/components/power-select-multiple/trigger.hbs index 64b9b3cca..d2e32867e 100644 --- a/addon/templates/components/power-select-multiple/trigger.hbs +++ b/addon/templates/components/power-select-multiple/trigger.hbs @@ -16,7 +16,7 @@ {{/if}} {{else}} - {{#if placeholder}} + {{#if (not-eq placeholder maybePlaceholder)}} {{component placeholderComponent placeholder=placeholder}} {{/if}} {{/each}} From 828580621c92c28e65e10825030f38e14e586b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Sch=C3=B6nburg?= Date: Wed, 15 Feb 2017 14:16:38 +0100 Subject: [PATCH 4/7] fix jscs --- addon/components/power-select-multiple/trigger.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/components/power-select-multiple/trigger.js b/addon/components/power-select-multiple/trigger.js index 52cf0422f..2ec640acc 100644 --- a/addon/components/power-select-multiple/trigger.js +++ b/addon/components/power-select-multiple/trigger.js @@ -70,8 +70,8 @@ export default Component.extend({ }), maybePlaceholder: computed('placeholder', 'select.selected.length', function() { - const component = this.get('placeholderComponent'); - const hasCustomPlaceholder = component !== 'power-select/placeholder'; + let component = this.get('placeholderComponent'); + let hasCustomPlaceholder = component !== 'power-select/placeholder'; if (isIE || hasCustomPlaceholder) { return null; From a150e255c96ab9d7d00491ba71f31771d3e8faf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Sch=C3=B6nburg?= Date: Wed, 15 Feb 2017 14:48:08 +0100 Subject: [PATCH 5/7] don't show placeholder when searchEnabled --- addon/templates/components/power-select-multiple/trigger.hbs | 2 +- tests/integration/components/power-select/multiple-test.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/addon/templates/components/power-select-multiple/trigger.hbs b/addon/templates/components/power-select-multiple/trigger.hbs index d2e32867e..99648cc25 100644 --- a/addon/templates/components/power-select-multiple/trigger.hbs +++ b/addon/templates/components/power-select-multiple/trigger.hbs @@ -16,7 +16,7 @@ {{/if}} {{else}} - {{#if (not-eq placeholder maybePlaceholder)}} + {{#if (and placeholder (not searchEnabled))}} {{component placeholderComponent placeholder=placeholder}} {{/if}} {{/each}} diff --git a/tests/integration/components/power-select/multiple-test.js b/tests/integration/components/power-select/multiple-test.js index 955f6bbdd..059e39743 100644 --- a/tests/integration/components/power-select/multiple-test.js +++ b/tests/integration/components/power-select/multiple-test.js @@ -820,6 +820,7 @@ test('placeholder can be customized using placeholderComponent', function(assert {{#power-select-multiple options=countries placeholder="test" + searchEnabled=false placeholderComponent="custom-placeholder" onchange=(action (mut foo)) as |country|}} {{country.name}} From c021e61df1ac290b2ad27a7843ee88dba74e070a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Sch=C3=B6nburg?= Date: Wed, 15 Feb 2017 16:04:53 +0100 Subject: [PATCH 6/7] add change to changelog.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d203d36b..7eeb3c3c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ there before. EPS doens't rely on those attributes and it's unlikely that this will break for anyone, but just in case I'll bump a minor version number and keep it in beta for some days. +- [ENHANCEMENT] Providing a custom `placeholderComponent` is available for + `power-select-multiple` too now. # 1.4.3 - [ENHANCEMENT] `typeInSearch` integration test helper now accepts an options scope to From 13ad5b5b8eda5faedb109f7cfbb195e8d8ad424e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Sch=C3=B6nburg?= Date: Wed, 15 Feb 2017 16:05:05 +0100 Subject: [PATCH 7/7] refactoring --- CHANGELOG.md | 4 ++-- addon/components/power-select-multiple/trigger.js | 5 +---- addon/templates/components/power-select-multiple/trigger.hbs | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7eeb3c3c4..5e48ebe15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ # Master +- [ENHANCEMENT] Providing a custom `placeholderComponent` is available for + `power-select-multiple` too now. # 1.5.0-beta.0 - [ENHANCEMENT/BREAKING-ISH] `ember-basic-dropdown` has improved the experience with A11y @@ -6,8 +8,6 @@ there before. EPS doens't rely on those attributes and it's unlikely that this will break for anyone, but just in case I'll bump a minor version number and keep it in beta for some days. -- [ENHANCEMENT] Providing a custom `placeholderComponent` is available for - `power-select-multiple` too now. # 1.4.3 - [ENHANCEMENT] `typeInSearch` integration test helper now accepts an options scope to diff --git a/addon/components/power-select-multiple/trigger.js b/addon/components/power-select-multiple/trigger.js index 2ec640acc..953220d85 100644 --- a/addon/components/power-select-multiple/trigger.js +++ b/addon/components/power-select-multiple/trigger.js @@ -70,10 +70,7 @@ export default Component.extend({ }), maybePlaceholder: computed('placeholder', 'select.selected.length', function() { - let component = this.get('placeholderComponent'); - let hasCustomPlaceholder = component !== 'power-select/placeholder'; - - if (isIE || hasCustomPlaceholder) { + if (isIE) { return null; } let select = this.get('select'); diff --git a/addon/templates/components/power-select-multiple/trigger.hbs b/addon/templates/components/power-select-multiple/trigger.hbs index 99648cc25..8f8f142db 100644 --- a/addon/templates/components/power-select-multiple/trigger.hbs +++ b/addon/templates/components/power-select-multiple/trigger.hbs @@ -16,7 +16,7 @@ {{/if}} {{else}} - {{#if (and placeholder (not searchEnabled))}} + {{#if (not searchEnabled)}} {{component placeholderComponent placeholder=placeholder}} {{/if}} {{/each}}