Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for full ember-power-select API #18

Merged
merged 2 commits into from
Dec 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 7 additions & 39 deletions addon/components/model-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,6 @@ export default Component.extend({
*/
searchKey: null,

/**
* Whether or not search is enabled.
*
* @argument searchEnabled
* @type Boolean
* @default true
*/
searchEnabled: fallbackIfUndefined(true),

/**
* Whether or not the list is populated by default.
*
Expand Down Expand Up @@ -104,24 +95,6 @@ export default Component.extend({
*/
query: fallbackIfUndefined(null),

/**
* Whether or not the model-search-box is disabled.
*
* @argument disabled
* @type Boolean
* @default false
*/
disabled: fallbackIfUndefined(false),

/**
* Whether or not the select can be cleared.
*
* @argument allowClear
* @type Boolean
* @default true
*/
allowClear: fallbackIfUndefined(true),

/**
* Debounce duration in ms used when searching.
*
Expand All @@ -131,19 +104,11 @@ export default Component.extend({
*/
debounceDuration: fallbackIfUndefined(250),

/**
* Whether or not the dropdown is rendered in place (or in a wormhole).
*
* @argument renderInPlace
* @type Boolean
* @default false
*/
renderInPlace: fallbackIfUndefined(false),

//TODO: global config?
perPageParam: fallbackIfUndefined('page[size]'),
pageParam: fallbackIfUndefined('page[number]'),
totalPagesParam: fallbackIfUndefined('meta.total'),
// ember-infinity options
perPageParam: fallbackIfUndefined('page[size]'),
pageParam: fallbackIfUndefined('page[number]'),
totalPagesParam: fallbackIfUndefined('meta.total'),

/**
* Hook called when a model is selected.
Expand All @@ -153,6 +118,9 @@ export default Component.extend({
*/
onChange(){},

// NOTE: apart from the arguments above, ember-model-select supports the full
// ember-power-select API which can be found: https://ember-power-select.com/docs/api-reference

/**
* @private
*/
Expand Down
62 changes: 50 additions & 12 deletions addon/templates/components/model-select.hbs
Original file line number Diff line number Diff line change
@@ -1,20 +1,58 @@
{{#power-select
search=(perform searchModels)
searchEnabled=searchEnabled
selected=_selectedModel
options=_options
onopen=(action "loadDefaultOptions")
oninput=(action "onInput")
onclose=(cancel-all searchModels)
onchange=(action "change")
afterOptionsComponent=(component "model-select/loading-mask")
allowClear=allowClear
animationEnabled=animationEnabled
ariaDescribedBy=ariaDescribedBy
ariaInvalid=ariaInvalid
ariaLabel=ariaLabel
ariaLabelledBy=ariaLabelledBy
beforeOptionsComponent=beforeOptionsComponent
buildSelection=buildSelection
calculatePosition=calculatePosition
closeOnSelect=closeOnSelect
defaultHighlighted=defaultHighlighted
destination=destination
disabled=disabled
optionsComponent=(component "model-select/options" infiniteScroll=infiniteScroll infiniteModel=model)
afterOptionsComponent=(component "model-select/loading-mask")
loadingMessage=false
dropdownClass="ember-model-select__dropdown"
extra=extra
groupComponent=groupComponent
highlightOnHover=highlightOnHover
horizontalPosition=horizontalPosition
initiallyOpened=initiallyOpened
loadingMessage=false
eventType=eventType
matcher=matcher
matchTriggerWidth=matchTriggerWidth
noMatchesMessage=noMatchesMessage
onblur=onblur
onchange=(action "change")
onclose=(cancel-all searchModels)
onfocus=onfocus
oninput=(action "onInput")
onkeydown=onkeydown
onopen=(action "loadDefaultOptions")
options=_options
optionsComponent=(component "model-select/options" infiniteScroll=infiniteScroll infiniteModel=model)
placeholder=placeholder
placeholderComponent=placeholderComponent
preventScroll=preventScroll
renderInPlace=renderInPlace
scrollTo=scrollTo
search=(perform searchModels)
searchEnabled=searchEnabled
searchField=searchField
searchMessage=searchMessage
searchPlaceholder=searchPlaceholder
selected=_selectedModel
selectedItemComponent=selectedItemComponent
tabindex=tabindex
triggerClass=triggerClass
triggerComponent=triggerComponent
triggerId=triggerId
triggerRole=triggerRole
typeAheadMatcher=typeAheadMatcher
verticalPosition=verticalPosition
as |model|
}}
{{get model labelProperty}}
{{/power-select}}
{{/power-select}}