activeadmin-index_as_calendar 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dfe4e99ae55c82ac3607db4185506ea1e0d060ed
4
- data.tar.gz: 0e22453dd7c9f49886edcc2e4141687ae7297aee
3
+ metadata.gz: 66f68b875a2e11365cd5715a77aa5e2d69262d79
4
+ data.tar.gz: 6267bf19f8a95dd9e8c4b3c881c23e8eef699b39
5
5
  SHA512:
6
- metadata.gz: a7197efc034ac26d4cec3467f6941fbf224012970d3b6cc69452fd169da0d64a5301402341654dddd7dea188e4fa05ae658f72d0c501e7ffbd46f89cba5e9c10
7
- data.tar.gz: 9331019eaed2c8f1ac267d71c60d2dc8c03c0305162552895ee3d81f0e6c589e2e7e3f734aea8a06d8deaea24d940b2ef889c0da4c4da60174312530b5f03553
6
+ metadata.gz: f3b170a182fbf534ebed394333547a265005702ebc14105bf4a815c772671c0da467d44bba19b306a110d393bea2ab6a345117164e7bd7c78854d6453a974ba1
7
+ data.tar.gz: 7908d7a61f5b803ede8a2ae37aa16fcb626ff967ba57bfd724f892378d17a1be573b0aa43ea834eaf7f4379ae16ae8a8014e875b7e031f5b7a20db9030e12de2
@@ -6,12 +6,13 @@ module ActiveAdminIndexAsCalendar
6
6
  #
7
7
  def index_as_calendar( options={}, &block )
8
8
  default_options = {
9
- :ajax => nil,
10
- :model => nil, # Needed only for AJAX
11
- :includes => nil, # Eager loading of related models
12
- :start_field => :created_at, # Default
13
- :end_field => nil,
14
- :block => block
9
+ :ajax => true, # Use AJAX to fetch events. Set to false to send data during render.
10
+ :model => nil, # Model to be used to fetch events. Defaults to ActiveAdmin resource model.
11
+ :includes => [], # Eager loading of related models
12
+ :start_date => :created_at, # Field to be used as start date for events
13
+ :end_date => nil, # Field to be used as end date for events
14
+ :block => block, # Block with the model<->event field mappings
15
+ :fullCalendarOptions => nil # fullCalendar options to be sent upon initialization
15
16
  }
16
17
  options = default_options.deep_merge(options)
17
18
 
@@ -25,7 +26,7 @@ module ActiveAdminIndexAsCalendar
25
26
  {
26
27
  :id => item.id,
27
28
  :title => item.to_s,
28
- :start => (options[:start_field].blank? or item.send(options[:start_field]).blank?) ? Date.today.to_s : item.send(options[:start_field])
29
+ :start => (options[:start_date].blank? or item.send(options[:start_date]).blank?) ? Date.today.to_s : item.send(options[:start_date])
29
30
  }
30
31
  end
31
32
  end
@@ -37,6 +38,7 @@ module ActiveAdminIndexAsCalendar
37
38
 
38
39
  # Setup fullCalendar to use AJAX calls to retrieve event data
39
40
  index as: :calendar do |context|
41
+ context[:fullCalendarOptions] = options[:fullCalendarOptions]
40
42
  events = {
41
43
  url: "#{collection_path()}/index_as_events.json",
42
44
  type: 'GET',
@@ -49,7 +51,7 @@ module ActiveAdminIndexAsCalendar
49
51
  items = options[:model] || end_of_association_chain
50
52
  items = items.send(params[:scope]) if params[:scope].present?
51
53
  items = items.includes(options[:includes]) unless options[:includes].blank?
52
- items = items.where(options[:start_field] => params[:start].to_date...params[:end].to_date).search(params[:q]).result
54
+ items = items.where(options[:start_date] => params[:start].to_date...params[:end].to_date).search(params[:q]).result
53
55
 
54
56
  events = event_mapping(items, options)
55
57
 
@@ -61,6 +63,7 @@ module ActiveAdminIndexAsCalendar
61
63
  # Return events to be used during partial render
62
64
  else
63
65
  index as: :calendar do |context|
66
+ context[:fullCalendarOptions] = options[:fullCalendarOptions]
64
67
  events = self.controller.event_mapping(context[:collection], options)
65
68
  end
66
69
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveAdminIndexAsCalendar
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin-index_as_calendar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - ByS Sistemas de Control