Class: Spark::Checklist

Inherits:
Spark::Component::Base show all
Defined in:
app/components/spark/checklist.rb,
app/components/spark/checklist/item.rb,
app/components/spark/checklist/trigger.rb,
app/components/spark/checklist/container.rb

Defined Under Namespace

Classes: Container, Item, Trigger

Instance Method Summary collapse

Methods inherited from Spark::Component::Base

#selector, #to_s, #unique_id

Constructor Details

#initializeChecklist

Returns a new instance of Checklist.



10
11
12
13
14
15
# File 'app/components/spark/checklist.rb', line 10

def initialize(*)
  super
  data.add checklist_id: unique_id

  classname.base = 'spark-checklist-container'
end

Instance Method Details

#sort_itemsObject



17
18
19
20
21
# File 'app/components/spark/checklist.rb', line 17

def sort_items
  items.sort_by! { |item| item.attribute_completed ? 1 : 0 }
  add_collapse_item_class if @collapse_after
  items
end