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 +4 -4
- data/lib/index_as_calendar/dsl.rb +11 -8
- data/lib/index_as_calendar/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66f68b875a2e11365cd5715a77aa5e2d69262d79
|
4
|
+
data.tar.gz: 6267bf19f8a95dd9e8c4b3c881c23e8eef699b39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 =>
|
10
|
-
:model => nil, #
|
11
|
-
:includes =>
|
12
|
-
:
|
13
|
-
:
|
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[:
|
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[:
|
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
|