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 items collection #1637

Closed
tomgreenfield opened this issue Jul 6, 2017 · 0 comments
Closed

Add items collection #1637

tomgreenfield opened this issue Jul 6, 2017 · 0 comments
Assignees

Comments

@tomgreenfield
Copy link
Contributor

Proposal: use a true Backbone collection for items in a component model.

Benefits include built-in change events and helper functions, and it also works to align with Adapt's existing parent > collection of children architecture.

Building on the excellent foundation from @lc-thomasberger, the functions have been whittled down to the below:

Component level itemsComponentModel.js

  • init(): custom initialise function to set up items and event listeners
  • setUpItems(): create a collection of ItemModels
  • getItem(index): get the item at specified index
  • getVisitedItems(): return all items where _isVisited: true
  • getActiveItems(): return all items where _isActive: true
  • getActiveItem(): return first item where _isActive: true
  • areAllItemsCompleted(): does what it says on the tin
  • checkCompletionStatus(): set component to complete if all items are completed (easily overriden)
  • reset(): resets all items and then component
  • resetActiveItems: set all items to _isActive: false

Item level itemModel.js

  • reset(): shortcut to set _isActive: false and _isVisited: false
  • toggleActive(isActive): shortcut to this.set('_isActive', ...);
  • toggleVisited(isVisited): shortcut to this.set('_isVisited', ...);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant