Class: Matestack::Ui::VueJs::Components::Collection::CollectionConfig
- Inherits:
-
Struct
- Object
- Struct
- Matestack::Ui::VueJs::Components::Collection::CollectionConfig
- Defined in:
- lib/matestack/ui/vue_js/components/collection/helper.rb
Instance Attribute Summary collapse
-
#base_count ⇒ Object
Returns the value of attribute base_count.
-
#data ⇒ Object
Returns the value of attribute data.
-
#filter_state ⇒ Object
Returns the value of attribute filter_state.
-
#filtered_count ⇒ Object
Returns the value of attribute filtered_count.
-
#id ⇒ Object
Returns the value of attribute id.
-
#init_limit ⇒ Object
Returns the value of attribute init_limit.
-
#init_offset ⇒ Object
Returns the value of attribute init_offset.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
- #config ⇒ Object
- #from ⇒ Object
- #get_collection_limit ⇒ Object
- #get_collection_offset ⇒ Object
- #pages ⇒ Object
- #paginated_data ⇒ Object
- #to ⇒ Object
Instance Attribute Details
#base_count ⇒ Object
Returns the value of attribute base_count
66 67 68 |
# File 'lib/matestack/ui/vue_js/components/collection/helper.rb', line 66 def base_count @base_count end |
#data ⇒ Object
Returns the value of attribute data
66 67 68 |
# File 'lib/matestack/ui/vue_js/components/collection/helper.rb', line 66 def data @data end |
#filter_state ⇒ Object
Returns the value of attribute filter_state
66 67 68 |
# File 'lib/matestack/ui/vue_js/components/collection/helper.rb', line 66 def filter_state @filter_state end |
#filtered_count ⇒ Object
Returns the value of attribute filtered_count
66 67 68 |
# File 'lib/matestack/ui/vue_js/components/collection/helper.rb', line 66 def filtered_count @filtered_count end |
#id ⇒ Object
Returns the value of attribute id
66 67 68 |
# File 'lib/matestack/ui/vue_js/components/collection/helper.rb', line 66 def id @id end |
#init_limit ⇒ Object
Returns the value of attribute init_limit
66 67 68 |
# File 'lib/matestack/ui/vue_js/components/collection/helper.rb', line 66 def init_limit @init_limit end |
#init_offset ⇒ Object
Returns the value of attribute init_offset
66 67 68 |
# File 'lib/matestack/ui/vue_js/components/collection/helper.rb', line 66 def init_offset @init_offset end |
#params ⇒ Object
Returns the value of attribute params
66 67 68 |
# File 'lib/matestack/ui/vue_js/components/collection/helper.rb', line 66 def params @params end |
Instance Method Details
#config ⇒ Object
123 124 125 |
# File 'lib/matestack/ui/vue_js/components/collection/helper.rb', line 123 def config self.to_h.except(:context) end |
#from ⇒ Object
97 98 99 100 |
# File 'lib/matestack/ui/vue_js/components/collection/helper.rb', line 97 def from return get_collection_offset + 1 if to > 0 return 0 if to == 0 end |
#get_collection_limit ⇒ Object
80 81 82 |
# File 'lib/matestack/ui/vue_js/components/collection/helper.rb', line 80 def get_collection_limit (params["#{id}-limit".to_sym] ||= init_limit).to_i end |
#get_collection_offset ⇒ Object
76 77 78 |
# File 'lib/matestack/ui/vue_js/components/collection/helper.rb', line 76 def get_collection_offset (params["#{id}-offset".to_sym] ||= init_offset).to_i end |
#pages ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/matestack/ui/vue_js/components/collection/helper.rb', line 84 def pages offset = get_collection_offset limit = get_collection_limit if filtered_count.present? count = filtered_count else count = base_count end page_count = count/limit page_count += 1 if count%limit > 0 return (1..page_count).to_a end |
#paginated_data ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/matestack/ui/vue_js/components/collection/helper.rb', line 68 def paginated_data resulting_data = data resulting_data = resulting_data.offset(get_collection_offset) unless get_collection_offset == 0 resulting_data = resulting_data.limit(get_collection_limit) unless get_collection_limit == 0 return resulting_data end |
#to ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/matestack/ui/vue_js/components/collection/helper.rb', line 102 def to current_to = get_collection_offset + get_collection_limit if filtered_count.present? if current_to > filtered_count return filtered_count else return current_to end else if current_to > base_count return base_count else return current_to end end end |