This table contains client-side logic to resort a "table" of models. This resort table will not call the actual serverside "save" function, so you will need to persist the changes to the database yourself, but it will do everything else for you (ie all you should have to do is call save, and the reorder will work). A basic usage example is the following:

<FwTableResort @items={{items}} @titleKey='name' @sortKey='sorted' />

If used in a block format instead, it is possible to fully define the title area, such as to replace it with input fields, which also adds a cheveron to expand if desired

 <FwTableResort @items={{items}} @sortKey='sorted' as |item expanded|>
     {{input item.name}}
 </FwTableResort>

Currently the only way to have a display title different from the default sort is to use the block format manually (set the titleKey to the desired default sort, and then manually display the other desired property).

Show:
reorderItems
(
  • items
)
private

Helper function to sort a list of passed items

Parameters:

  • items DS.Model[]

    Model array

_sortOrder

Array private

Sort order as defined by passed properties

activeFilter

Function public

Filter called to check if an item is active

activeKey

String public

Key used to determine if an item is active

allowExpand

Boolean public

If true, show an expand button for more fields

delete

Action public

If defined with an action, adds a delete button to delete items


Default: true

deleteIcon

String public

The icon that will be used for the delete button. Useful if you want the button to do something other than delete.


Default: fa-regular fa-trash-can

distance

Number public

Tolerance before dragging starts

items

Boolean public

Required property. This is what you pass the array of items you wish to sort with the table.

sortedItems

Array private

Sorted list of items in the table

sortKey

String public

String pointer to the model's sort key, will be used to sort the items and modify the key later

spacing

Number public

Spacing between sortable items

title

String public

Default sort for if the sort key is undefined and title to display if no block is used

viewableItems

Array private

An internal list of all items which will be shown in the table (takes into account activeKey and activeFilter)