1
0
Fork 0

Refactored how actions were passed

This commit is contained in:
Ava Wroten 2020-03-05 10:21:52 -06:00
parent 450d8b4036
commit d30bf89db3
3 changed files with 16 additions and 6 deletions

View file

@ -1,4 +1,5 @@
<LinkTo
{{on 'focus' @handleFocus}}
{{on 'blur' @handleBlur}}
@route="meal"
@model={{@meal}}

View file

@ -1,6 +1,6 @@
<SortableGroupAccessible
@models={{this.sortedItems}}
as |groupHasFocus selectedIndex orderItemDown orderItemUp handleBlur|>
as |groupHasFocus selectedIndex groupActions|>
<SortableGroup
@onChange={{action this.reorderMeals}}
as |group|>
@ -9,16 +9,17 @@
@groupHasFocus={{groupHasFocus}}
@currentIndex={{index}}
@selectedIndex={{selectedIndex}}
@orderItemDown={{orderItemDown}}
@orderItemUp={{orderItemUp}}
@handleBlur={{handleBlur}}>
@orderItemDown={{groupActions.orderItemDown}}
@orderItemUp={{groupActions.orderItemUp}}
@handleBlur={{groupActions.handleBlur}}>
<SortableItem
@model={{meal}}
@group={{group}}
data-test-id="meal-item">
<MealItem
@meal={{meal}}
@handleBlur={{handleBlur}}
@handleFocus={{groupActions.handleFocus}}
@handleBlur={{groupActions.handleBlur}}
/>
</SortableItem>
</SortableItemAccessible>

View file

@ -8,5 +8,13 @@
{{key-down this.preventDefault key='ArrowDown'}}
tabindex="0"
class="shadow-md bg-gray-200 outline-none border border-gray-400 focus:border-teal-400 focus:shadow-lg">
{{yield this.groupHasFocus this.selectedIndex (action 'orderItemDown') (action 'orderItemUp') (action 'handleBlur')}}
{{yield
this.groupHasFocus
this.selectedIndex
(hash
orderItemDown=(action 'orderItemDown')
orderItemUp=(action 'orderItemUp')
handleFocus=(action 'handleFocus')
handleBlur=(action 'handleBlur')
)}}
</div>