select-kit refactoring

* improve events naming/handling
* do not explicitly check for true/Fasle
* make sure header is re-computed on toggle
This commit is contained in:
Joffrey JAFFEUX 2018-01-11 09:39:51 +01:00 committed by GitHub
parent 2509bef2c0
commit 3ec2024466
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 140 additions and 153 deletions

View File

@ -85,7 +85,6 @@ export default SelectKitComponent.extend({
Ember.run.next(() => { Ember.run.next(() => {
this.mutateContent(this.get("computedContent")); this.mutateContent(this.get("computedContent"));
this.mutateValues(this.get("computedValues")); this.mutateValues(this.get("computedValues"));
applyOnSelectPluginApiCallbacks(this.get("pluginApiIdentifiers"), this.get("computedValues"), this);
this._setHeaderComputedContent(); this._setHeaderComputedContent();
}); });
}, },
@ -107,7 +106,7 @@ export default SelectKitComponent.extend({
return !computedValues.includes(get(c, "value")); return !computedValues.includes(get(c, "value"));
}); });
if (this.get("shouldFilter") === true) { if (this.get("shouldFilter")) {
computedContent = this.filterComputedContent(computedContent, computedValues, filter); computedContent = this.filterComputedContent(computedContent, computedValues, filter);
} }
@ -162,7 +161,7 @@ export default SelectKitComponent.extend({
const computedContent = this._findComputedContentItemByGuid($(el).attr("data-guid")); const computedContent = this._findComputedContentItemByGuid($(el).attr("data-guid"));
if (!Ember.isNone(computedContent)) { highlightedComputedContents.push(computedContent); } if (!Ember.isNone(computedContent)) { highlightedComputedContents.push(computedContent); }
}); });
this.send("onDeselect", highlightedComputedContents); this.send("deselect", highlightedComputedContents);
return; return;
} }
@ -208,18 +207,18 @@ export default SelectKitComponent.extend({
autoHighlight() { autoHighlight() {
Ember.run.schedule("afterRender", () => { Ember.run.schedule("afterRender", () => {
if (this.get("isExpanded") === false) { return; } if (!this.get("isExpanded")) return;
if (this.get("renderedBodyOnce") === false) { return; } if (!this.get("renderedBodyOnce")) return;
if (!isNone(this.get("highlightedValue"))) { return; } if (!isNone(this.get("highlightedValue"))) return;
if (isEmpty(this.get("filteredComputedContent"))) { if (isEmpty(this.get("filteredComputedContent"))) {
if (this.get("createRowComputedContent")) { if (this.get("createRowComputedContent")) {
this.send("onHighlight", this.get("createRowComputedContent")); this.send("highlight", this.get("createRowComputedContent"));
} else if (this.get("noneRowComputedContent") && this.get("hasSelection") === true) { } else if (this.get("noneRowComputedContent") && this.get("hasSelection")) {
this.send("onHighlight", this.get("noneRowComputedContent")); this.send("highlight", this.get("noneRowComputedContent"));
} }
} else { } else {
this.send("onHighlight", this.get("filteredComputedContent.firstObject")); this.send("highlight", this.get("filteredComputedContent.firstObject"));
} }
}); });
}, },
@ -227,6 +226,19 @@ export default SelectKitComponent.extend({
didSelect() { didSelect() {
this.focusFilterOrHeader(); this.focusFilterOrHeader();
this.autoHighlight(); this.autoHighlight();
applyOnSelectPluginApiCallbacks(
this.get("pluginApiIdentifiers"),
this.get("computedValue"),
this
);
this._boundaryActionHandler("onSelect", this.get("computedValue"));
},
willDeselect() {
this.clearFilter();
this.set("highlightedValue", null);
}, },
didDeselect() { didDeselect() {
@ -239,27 +251,29 @@ export default SelectKitComponent.extend({
}, },
actions: { actions: {
onClear() { clearSelection() {
this.get("selectedComputedContents").forEach(selectedComputedContent => { this.send("deselect", this.get("selectedComputedContents"));
this.send("onDeselect", selectedComputedContent); this._boundaryActionHandler("onClearSelection");
});
}, },
onCreate(computedContentItem) { create(computedContentItem) {
if (this.validateComputedContentItem(computedContentItem)) { if (this.validateComputedContentItem(computedContentItem)) {
this.get("computedContent").pushObject(computedContentItem); this.get("computedContent").pushObject(computedContentItem);
this.send("onSelect", computedContentItem); this._boundaryActionHandler("onCreate");
this.send("select", computedContentItem);
} else {
this._boundaryActionHandler("onCreateFailure");
} }
}, },
onSelect(computedContentItem) { select(computedContentItem) {
this.willSelect(computedContentItem); this.willSelect(computedContentItem);
this.get("computedValues").pushObject(computedContentItem.value); this.get("computedValues").pushObject(computedContentItem.value);
Ember.run.next(() => this.mutateAttributes()); Ember.run.next(() => this.mutateAttributes());
Ember.run.schedule("afterRender", () => this.didSelect(computedContentItem)); Ember.run.schedule("afterRender", () => this.didSelect(computedContentItem));
}, },
onDeselect(rowComputedContentItems) { deselect(rowComputedContentItems) {
rowComputedContentItems = Ember.makeArray(rowComputedContentItems); rowComputedContentItems = Ember.makeArray(rowComputedContentItems);
const generatedComputedContents = this._filterRemovableComputedContents(makeArray(rowComputedContentItems)); const generatedComputedContents = this._filterRemovableComputedContents(makeArray(rowComputedContentItems));
this.willDeselect(rowComputedContentItems); this.willDeselect(rowComputedContentItems);

View File

@ -5,6 +5,6 @@ export default CategoryRowComponent.extend({
classNames: "none category-row", classNames: "none category-row",
click() { click() {
this.sendAction("onClear"); this.sendAction("clearSelection");
} }
}); });

View File

@ -44,13 +44,15 @@ export default DropdownSelectBoxComponent.extend({
]); ]);
}, },
mutateValue(value) { actions: {
const topic = this.get("topic"); onSelect() {
const topic = this.get("topic");
if (value === "unpinned") { if (this.get("computedValue") === "unpinned") {
topic.clearPin(); topic.clearPin();
} else { } else {
topic.rePin(); topic.rePin();
}
} }
} }
}); });

View File

@ -6,7 +6,8 @@ import EventsMixin from "select-kit/mixins/events";
import PluginApiMixin from "select-kit/mixins/plugin-api"; import PluginApiMixin from "select-kit/mixins/plugin-api";
import { import {
applyContentPluginApiCallbacks, applyContentPluginApiCallbacks,
applyHeaderContentPluginApiCallbacks applyHeaderContentPluginApiCallbacks,
applyOnSelectPluginApiCallbacks
} from "select-kit/mixins/plugin-api"; } from "select-kit/mixins/plugin-api";
export default Ember.Component.extend(UtilsMixin, PluginApiMixin, DomHelpersMixin, EventsMixin, { export default Ember.Component.extend(UtilsMixin, PluginApiMixin, DomHelpersMixin, EventsMixin, {
@ -138,8 +139,8 @@ export default Ember.Component.extend(UtilsMixin, PluginApiMixin, DomHelpersMixi
@computed("shouldFilter", "allowAny", "filter") @computed("shouldFilter", "allowAny", "filter")
shouldDisplayFilter(shouldFilter, allowAny, filter) { shouldDisplayFilter(shouldFilter, allowAny, filter) {
if (shouldFilter === true) return true; if (shouldFilter) return true;
if (allowAny === true && filter.length > 0) return true; if (allowAny && filter.length > 0) return true;
return false; return false;
}, },
@ -150,22 +151,22 @@ export default Ember.Component.extend(UtilsMixin, PluginApiMixin, DomHelpersMixi
@computed("filter", "filterable", "autoFilterable", "renderedFilterOnce") @computed("filter", "filterable", "autoFilterable", "renderedFilterOnce")
shouldFilter(filter, filterable, autoFilterable, renderedFilterOnce) { shouldFilter(filter, filterable, autoFilterable, renderedFilterOnce) {
if (renderedFilterOnce === true && filterable === true) return true; if (renderedFilterOnce && filterable) return true;
if (filterable === true) return true; if (filterable) return true;
if (autoFilterable === true && filter.length > 0) return true; if (autoFilterable && filter.length > 0) return true;
return false; return false;
}, },
@computed("filter", "computedContent") @computed("filter", "computedContent")
shouldDisplayCreateRow(filter, computedContent) { shouldDisplayCreateRow(filter, computedContent) {
if (computedContent.map(c => c.value).includes(filter)) return false; if (computedContent.map(c => c.value).includes(filter)) return false;
if (this.get("allowAny") === true && filter.length > 0) return true; if (this.get("allowAny") && filter.length > 0) return true;
return false; return false;
}, },
@computed("filter", "shouldDisplayCreateRow") @computed("filter", "shouldDisplayCreateRow")
createRowComputedContent(filter, shouldDisplayCreateRow) { createRowComputedContent(filter, shouldDisplayCreateRow) {
if (shouldDisplayCreateRow === true) { if (shouldDisplayCreateRow) {
let content = this.createContentFromInput(filter); let content = this.createContentFromInput(filter);
return this.computeContentItem(content, { created: true }); return this.computeContentItem(content, { created: true });
} }
@ -209,15 +210,24 @@ export default Ember.Component.extend(UtilsMixin, PluginApiMixin, DomHelpersMixi
didSelect() { didSelect() {
this.collapse(); this.collapse();
this.focus(); this.focus();
applyOnSelectPluginApiCallbacks(
this.get("pluginApiIdentifiers"),
this.get("computedValue"),
this
);
this._boundaryActionHandler("onSelect", this.get("computedValue"));
}, },
willDeselect() { willDeselect() {
this.clearFilter(); this.clearFilter();
this.set("highlightedValue", null); this.set("highlightedValue", null);
}, },
didDeselect() { didDeselect(rowComputedContentItem) {
this.collapse(); this.collapse();
this.focus(); this.focus();
this._boundaryActionHandler("onDeselect", rowComputedContentItem);
}, },
clearFilter() { clearFilter() {
@ -234,28 +244,40 @@ export default Ember.Component.extend(UtilsMixin, PluginApiMixin, DomHelpersMixi
this.set("headerComputedContent", headerComputedContent); this.set("headerComputedContent", headerComputedContent);
}, },
_boundaryActionHandler(actionName, ...params) {
if (Ember.get(this.actions, actionName)) {
this.send(actionName, ...params);
} else if (this.get(actionName)) {
this.get(actionName)();
}
},
actions: { actions: {
onToggle() { toggle() {
if (this.get("onToggle")) this.sendAction("onToggle"); this._boundaryActionHandler("onToggle", this);
if (this.get("onCollapse") && this.get("isExpanded") === true) this.sendAction("onCollapse");
if (this.get("onExpand") && this.get("isExpanded") === false) this.sendAction("onExpand");
this.get("isExpanded") === true ? this.collapse() : this.expand(); if (this.get("isExpanded")) {
this._boundaryActionHandler("onCollapse", this);
this._setHeaderComputedContent(); this.collapse();
} else {
this._boundaryActionHandler("onExpand", this);
this.expand();
}
}, },
onHighlight(rowComputedContent) { highlight(rowComputedContent) {
this.set("highlightedValue", rowComputedContent.value); this.set("highlightedValue", rowComputedContent.value);
this._boundaryActionHandler("onHighlight", rowComputedContent);
}, },
onFilter(filter) { filterComputedContent(filter) {
this.setProperties({ this.setProperties({
highlightedValue: null, highlightedValue: null,
renderedFilterOnce: true, renderedFilterOnce: true,
filter filter
}); });
this.autoHighlight(); this.autoHighlight();
this._boundaryActionHandler("onFilter", filter);
} }
} }
}); });

View File

@ -2,9 +2,5 @@ import SelectKitRowComponent from "select-kit/components/select-kit/select-kit-r
export default SelectKitRowComponent.extend({ export default SelectKitRowComponent.extend({
layoutName: "select-kit/templates/components/select-kit/select-kit-row", layoutName: "select-kit/templates/components/select-kit/select-kit-row",
classNames: "create", classNames: "create"
click() {
this.sendAction("onCreate", this.get("computedContent"));
},
}); });

View File

@ -37,6 +37,6 @@ export default Ember.Component.extend({
}, },
click() { click() {
this.sendAction("onToggle"); this.sendAction("toggle");
} }
}); });

View File

@ -5,6 +5,6 @@ export default SelectKitRowComponent.extend({
classNames: "none", classNames: "none",
click() { click() {
this.sendAction("onClear"); this.sendAction("clearSelection");
} }
}); });

View File

@ -57,14 +57,14 @@ export default Ember.Component.extend(UtilsMixin, {
}, },
mouseEnter() { mouseEnter() {
this.set("hoverDebounce", run.debounce(this, this._sendOnHighlightAction, 32)); this.set("hoverDebounce", run.debounce(this, this._sendHighlightAction, 32));
}, },
click() { click() {
this.sendAction("onSelect", this.get("computedContent")); this.sendAction("select", this.get("computedContent"));
}, },
_sendOnHighlightAction() { _sendHighlightAction() {
this.sendAction("onHighlight", this.get("computedContent")); this.sendAction("highlight", this.get("computedContent"));
} }
}); });

View File

@ -2,9 +2,6 @@ import SelectKitComponent from "select-kit/components/select-kit";
import { on } from "ember-addons/ember-computed-decorators"; import { on } from "ember-addons/ember-computed-decorators";
import computed from "ember-addons/ember-computed-decorators"; import computed from "ember-addons/ember-computed-decorators";
const { get, isNone, isEmpty, isPresent, run } = Ember; const { get, isNone, isEmpty, isPresent, run } = Ember;
import {
applyOnSelectPluginApiCallbacks
} from "select-kit/mixins/plugin-api";
export default SelectKitComponent.extend({ export default SelectKitComponent.extend({
pluginApiIdentifiers: ["single-select"], pluginApiIdentifiers: ["single-select"],
@ -26,10 +23,11 @@ export default SelectKitComponent.extend({
value = this._beforeDidComputeValue(value); value = this._beforeDidComputeValue(value);
this.didComputeContent(content); this.didComputeContent(content);
this.didComputeValue(value); this.didComputeValue(value);
this._setHeaderComputedContent();
this.didComputeAttributes(); this.didComputeAttributes();
if (this.get("allowInitialValueMutation")) this.mutateAttributes(); if (this.get("allowInitialValueMutation")) this.mutateAttributes();
this._setHeaderComputedContent();
}); });
}, },
@ -39,7 +37,6 @@ export default SelectKitComponent.extend({
run.next(() => { run.next(() => {
this.mutateContent(this.get("computedContent")); this.mutateContent(this.get("computedContent"));
this.mutateValue(this.get("computedValue")); this.mutateValue(this.get("computedValue"));
applyOnSelectPluginApiCallbacks(this.get("pluginApiIdentifiers"), this.get("computedValue"), this);
this._setHeaderComputedContent(); this._setHeaderComputedContent();
}); });
}, },
@ -119,23 +116,23 @@ export default SelectKitComponent.extend({
const none = this.get("noneRowComputedContent"); const none = this.get("noneRowComputedContent");
if (this.get("hasSelection") && isEmpty(this.get("filter"))) { if (this.get("hasSelection") && isEmpty(this.get("filter"))) {
this.send("onHighlight", this.get("selectedComputedContent")); this.send("highlight", this.get("selectedComputedContent"));
return; return;
} }
if (isNone(this.get("highlightedValue")) && !isEmpty(filteredComputedContent)) { if (isNone(this.get("highlightedValue")) && !isEmpty(filteredComputedContent)) {
this.send("onHighlight", get(filteredComputedContent, "firstObject")); this.send("highlight", get(filteredComputedContent, "firstObject"));
return; return;
} }
if (displayCreateRow === true && isEmpty(filteredComputedContent)) { if (displayCreateRow === true && isEmpty(filteredComputedContent)) {
this.send("onHighlight", this.get("createRowComputedContent")); this.send("highlight", this.get("createRowComputedContent"));
} }
else if (!isEmpty(filteredComputedContent)) { else if (!isEmpty(filteredComputedContent)) {
this.send("onHighlight", get(filteredComputedContent, "firstObject")); this.send("highlight", get(filteredComputedContent, "firstObject"));
} }
else if (isEmpty(filteredComputedContent) && isPresent(none) && displayCreateRow === false) { else if (isEmpty(filteredComputedContent) && isPresent(none) && displayCreateRow === false) {
this.send("onHighlight", none); this.send("highlight", none);
} }
}); });
}, },
@ -145,25 +142,29 @@ export default SelectKitComponent.extend({
}, },
actions: { actions: {
onClear() { clearSelection() {
this.send("onDeselect", this.get("selectedComputedContent")); this.send("deselect", this.get("selectedComputedContent"));
this._boundaryActionHandler("onClearSelection");
}, },
onCreate(computedContentItem) { create(computedContentItem) {
if (this.validateComputedContentItem(computedContentItem)) { if (this.validateComputedContentItem(computedContentItem)) {
this.get("computedContent").pushObject(computedContentItem); this.get("computedContent").pushObject(computedContentItem);
this.send("onSelect", computedContentItem); this._boundaryActionHandler("onCreate");
this.send("select", computedContentItem);
} else {
this._boundaryActionHandler("onCreateFailure");
} }
}, },
onSelect(rowComputedContentItem) { select(rowComputedContentItem) {
this.willSelect(rowComputedContentItem); this.willSelect(rowComputedContentItem);
this.set("computedValue", rowComputedContentItem.value); this.set("computedValue", rowComputedContentItem.value);
this.mutateAttributes(); this.mutateAttributes();
run.schedule("afterRender", () => this.didSelect(rowComputedContentItem)); run.schedule("afterRender", () => this.didSelect(rowComputedContentItem));
}, },
onDeselect(rowComputedContentItem) { deselect(rowComputedContentItem) {
this.willDeselect(rowComputedContentItem); this.willDeselect(rowComputedContentItem);
this.set("computedValue", null); this.set("computedValue", null);
this.mutateAttributes(); this.mutateAttributes();

View File

@ -45,7 +45,7 @@ export default ComboBoxComponent.extend({
return; return;
} }
const refresh = () => this.send("onDeselect", value); const refresh = () => this.send("deselect", value);
switch(value) { switch(value) {
case "invite": case "invite":

View File

@ -80,11 +80,13 @@ export default Ember.Mixin.create({
this.setProperties({ isExpanded: true, renderedBodyOnce: true, isFocused: true }); this.setProperties({ isExpanded: true, renderedBodyOnce: true, isFocused: true });
this.focusFilterOrHeader(); this.focusFilterOrHeader();
this.autoHighlight(); this.autoHighlight();
this._setHeaderComputedContent();
}, },
collapse() { collapse() {
this.set("isExpanded", false); this.set("isExpanded", false);
Ember.run.schedule("afterRender", () => this._removeFixedPosition() ); Ember.run.schedule("afterRender", () => this._removeFixedPosition() );
this._setHeaderComputedContent();
}, },
// lose focus of the component in two steps // lose focus of the component in two steps

View File

@ -95,7 +95,7 @@ export default Ember.Mixin.create({
this.$filterInput() this.$filterInput()
.on("change.select-kit", (event) => { .on("change.select-kit", (event) => {
this.send("onFilter", $(event.target).val()); this.send("filterComputedContent", $(event.target).val());
}) })
.on("keypress.select-kit", (event) => { .on("keypress.select-kit", (event) => {
event.stopPropagation(); event.stopPropagation();

View File

@ -5,7 +5,7 @@
</span> </span>
{{#if shouldDisplayClearableButton}} {{#if shouldDisplayClearableButton}}
<button class="btn-clear" {{action onClear bubbles=false}}> <button class="btn-clear" {{action clearSelection bubbles=false}}>
{{d-icon 'times'}} {{d-icon 'times'}}
</button> </button>
{{/if}} {{/if}}

View File

@ -15,7 +15,7 @@
{{/if}} {{/if}}
{{#if shouldDisplayClearableButton}} {{#if shouldDisplayClearableButton}}
<button class="btn-clear" {{action onClear bubbles=false}}> <button class="btn-clear" {{action clearSelection bubbles=false}}>
{{d-icon 'times'}} {{d-icon 'times'}}
</button> </button>
{{/if}} {{/if}}

View File

@ -1,10 +1,12 @@
<div class="choices"> <div class="choices">
{{#each computedContent.selectedComputedContents as |selectedComputedContent|}} {{#each computedContent.selectedComputedContents as |selectedComputedContent|}}
{{component selectedNameComponent onDeselect=onDeselect computedContent=selectedComputedContent}} {{component selectedNameComponent
deselect=deselect
computedContent=selectedComputedContent}}
{{/each}} {{/each}}
<span class="filter choice" tabindex="-1"> <span class="filter choice" tabindex="-1">
{{component "select-kit/select-kit-filter" {{component "select-kit/select-kit-filter"
onFilter=onFilter filterComputedContent=filterComputedContent
shouldDisplayFilter=shouldDisplayFilter shouldDisplayFilter=shouldDisplayFilter
isFocused=isFocused isFocused=isFocused
filter=filter filter=filter

View File

@ -1,5 +1,5 @@
<span class="name"> <span class="name">
<span class="delete-icon" {{action onDeselect computedContent bubbles=false}}> <span class="delete-icon" {{action deselect computedContent bubbles=false}}>
{{d-icon "times"}} {{d-icon "times"}}
</span> </span>

View File

@ -1,7 +1,7 @@
<div class="selected-color-wrapper"> <div class="selected-color-wrapper">
<span class="name"> <span class="name">
{{#unless isLocked}} {{#unless isLocked}}
<span class="delete-icon" {{action onDeselect computedContent bubbles=false}}> <span class="delete-icon" {{action deselect computedContent bubbles=false}}>
{{d-icon "times"}} {{d-icon "times"}}
</span> </span>
{{/unless}} {{/unless}}

View File

@ -3,7 +3,7 @@
{{d-icon "lock"}} {{d-icon "lock"}}
</span> </span>
{{else}} {{else}}
<span class="locked-icon" {{action onDeselect computedContent bubbles=false}}> <span class="locked-icon" {{action deselect computedContent bubbles=false}}>
{{d-icon "times"}} {{d-icon "times"}}
</span> </span>
{{/if}} {{/if}}

View File

@ -1,24 +1,24 @@
{{component headerComponent {{component headerComponent
tabindex=tabindex tabindex=tabindex
shouldDisplayFilter=shouldDisplayFilter
isFocused=isFocused isFocused=isFocused
isExpanded=isExpanded isExpanded=isExpanded
computedContent=headerComputedContent computedContent=headerComputedContent
onDeselect=(action "onDeselect") deselect=(action "deselect")
onToggle=(action "onToggle") toggle=(action "toggle")
onFilter=(action "onFilter") filterComputedContent=(action "filterComputedContent")
onClear=(action "onClear") clearSelection=(action "clearSelection")
options=headerComponentOptions options=headerComponentOptions
shouldDisplayFilter=shouldDisplayFilter
}} }}
<div class="select-kit-body"> <div class="select-kit-body">
{{component filterComponent {{component filterComponent
onFilter=(action "onFilter") filter=filter
icon=filterIcon icon=filterIcon
shouldDisplayFilter=shouldDisplayFilter shouldDisplayFilter=shouldDisplayFilter
isFocused=isFocused
placeholder=(i18n filterPlaceholder) placeholder=(i18n filterPlaceholder)
filter=filter isFocused=isFocused
filterComputedContent=(action "filterComputedContent")
}} }}
{{#if renderedBodyOnce}} {{#if renderedBodyOnce}}
@ -34,10 +34,10 @@
templateForRow=templateForRow templateForRow=templateForRow
templateForNoneRow=templateForNoneRow templateForNoneRow=templateForNoneRow
templateForCreateRow=templateForCreateRow templateForCreateRow=templateForCreateRow
onClear=(action "onClear") clearSelection=(action "clearSelection")
onSelect=(action "onSelect") select=(action "select")
onHighlight=(action "onHighlight") highlight=(action "highlight")
onCreate=(action "onCreate") create=(action "create")
noContentLabel=noContentLabel noContentLabel=noContentLabel
highlightedValue=highlightedValue highlightedValue=highlightedValue
computedValue=computedValue computedValue=computedValue

View File

@ -10,8 +10,8 @@
computedContent=noneRowComputedContent computedContent=noneRowComputedContent
templateForRow=templateForNoneRow templateForRow=templateForNoneRow
highlightedValue=highlightedValue highlightedValue=highlightedValue
onClear=onClear clearSelection=clearSelection
onHighlight=onHighlight highlight=highlight
computedValue=computedValue computedValue=computedValue
options=rowComponentOptions options=rowComponentOptions
}} }}
@ -21,11 +21,11 @@
{{#if createRowComputedContent}} {{#if createRowComputedContent}}
{{component createRowComponent {{component createRowComponent
computedContent=createRowComputedContent computedContent=createRowComputedContent
templateForRow=templateForCreateRow
highlightedValue=highlightedValue highlightedValue=highlightedValue
onHighlight=onHighlight
onCreate=onCreate
computedValue=computedValue computedValue=computedValue
templateForRow=templateForCreateRow
highlight=highlight
select=create
options=rowComponentOptions options=rowComponentOptions
}} }}
{{/if}} {{/if}}
@ -33,11 +33,11 @@
{{#each filteredComputedContent as |computedContent|}} {{#each filteredComputedContent as |computedContent|}}
{{component rowComponent {{component rowComponent
computedContent=computedContent computedContent=computedContent
templateForRow=templateForRow
highlightedValue=highlightedValue highlightedValue=highlightedValue
onSelect=onSelect
onHighlight=onHighlight
computedValue=computedValue computedValue=computedValue
templateForRow=templateForRow
select=select
highlight=highlight
options=rowComponentOptions options=rowComponentOptions
}} }}
{{/each}} {{/each}}

View File

@ -2,7 +2,7 @@
tabindex=-1 tabindex=-1
class="filter-input" class="filter-input"
placeholder=placeholder placeholder=placeholder
key-up=onFilter key-up=filterComputedContent
autocomplete="off" autocomplete="off"
autocorrect="off" autocorrect="off"
autocapitalize="off" autocapitalize="off"

View File

@ -469,58 +469,6 @@ componentTest('with collection header', {
} }
}); });
componentTest('with onToggle', {
template: '{{single-select onToggle=onToggle}}',
beforeEach() {
this.set("onToggle", () => $(".select-kit").append("<span class='onToggleTest'></span>"));
},
test(assert) {
andThen(() => assert.notOk(exists(".onToggleTest")));
this.get('subject').expand();
andThen(() => assert.ok(exists(".onToggleTest")));
}
});
componentTest('with onExpand', {
template: '{{single-select onExpand=onExpand}}',
beforeEach() {
this.set("onExpand", () => $(".select-kit").append("<span class='onExpandTest'></span>"));
},
test(assert) {
andThen(() => assert.notOk(exists(".onExpandTest")));
this.get('subject').expand();
andThen(() => assert.ok(exists(".onExpandTest")));
}
});
componentTest('with onCollapse', {
template: '{{single-select onCollapse=onCollapse}}',
beforeEach() {
this.set("onCollapse", () => $(".select-kit").append("<span class='onCollapseTest'></span>"));
},
test(assert) {
andThen(() => assert.notOk(exists(".onCollapseTest")));
this.get('subject').expand();
andThen(() => assert.notOk(exists(".onCollapseTest")));
this.get('subject').collapse();
andThen(() => assert.ok(exists(".onCollapseTest")));
}
});
componentTest('with title', { componentTest('with title', {
template: '{{single-select title=(i18n "test.title")}}', template: '{{single-select title=(i18n "test.title")}}',

View File

@ -87,7 +87,7 @@ function selectKit(selector) { // eslint-disable-line no-unused-vars
var type = options.type || 'keydown'; var type = options.type || 'keydown';
var event = jQuery.Event(type); var event = jQuery.Event(type);
event.keyCode = keyCode; event.keyCode = keyCode;
if (options && options.metaKey === true) { event.metaKey = true; } if (options && options.metaKey) { event.metaKey = true; }
find(eventSelector).trigger(event); find(eventSelector).trigger(event);
}); });
} }