diff --git a/ember-ui/app/components/meal-list.hbs b/ember-ui/app/components/meal-list.hbs index a677454..9bf67e6 100644 --- a/ember-ui/app/components/meal-list.hbs +++ b/ember-ui/app/components/meal-list.hbs @@ -1,5 +1,5 @@ + @models={{this.sortedItems}} as |groupHasFocus selectedIndex orderItemDown orderItemUp|> @@ -7,7 +7,9 @@ + @selectedIndex={{selectedIndex}} + @orderItemDown={{orderItemDown}} + @orderItemUp={{orderItemUp}}> - {{yield this.groupHasFocus this.selectedIndex}} + {{yield this.groupHasFocus this.selectedIndex (action 'orderItemDown') (action 'orderItemUp')}} diff --git a/ember-ui/app/components/sortable-group-accessible.js b/ember-ui/app/components/sortable-group-accessible.js index 60435f0..8a1b9fd 100644 --- a/ember-ui/app/components/sortable-group-accessible.js +++ b/ember-ui/app/components/sortable-group-accessible.js @@ -28,5 +28,29 @@ export default class SortableGroupAccessibleComponent extends Component { } } + @action + async orderItemUp(index) { + if (index - 1 < 0) return; + + let item = this.args.models.objectAt(index); + let prevItem = this.args.models.objectAt(index - 1); + + item.listOrder = index - 1; + prevItem.listOrder = index; + this.selectedIndex = index - 1; + } + + @action + async orderItemDown(index) { + if (index + 1 >= this.args.models.length) return; + + let item = this.args.models.objectAt(index); + let nextItem = this.args.models.objectAt(index + 1); + + item.listOrder = index + 1; + nextItem.listOrder = index; + this.selectedIndex = index + 1; + } + preventDefault(evt) { evt.preventDefault(); } } diff --git a/ember-ui/app/components/sortable-item-accessible.hbs b/ember-ui/app/components/sortable-item-accessible.hbs index ff85b6c..ae5964d 100644 --- a/ember-ui/app/components/sortable-item-accessible.hbs +++ b/ember-ui/app/components/sortable-item-accessible.hbs @@ -1,17 +1,19 @@ -
- {{#if (and @groupHasFocus (eq @currentIndex @selectedIndex))}} - - - {{/if}} - {{yield}} -
+{{#let (and @groupHasFocus (eq @currentIndex @selectedIndex)) as |active|}} +
+ {{#if active}} + + + {{/if}} + {{yield}} +
+{{/let}}