decidim-calendar 0.13.1.3 → 0.19.0

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
  SHA256:
3
- metadata.gz: f862aaa372890dc0654235d4d412f7f20b8f044edff77fe3c68f40435b4d1305
4
- data.tar.gz: bc144b74fc7dc11cd7cfe26a72f7f193c9c25de27ffee46ce41693a851f3f5fa
3
+ metadata.gz: 9c64495c829051da0ee398afc66d8e916326eeb5653d5173b84f4aaaba61fc3c
4
+ data.tar.gz: 8ca08b24948501600dabfbfc01b50f81662a93555176e4c272af83f691bce878
5
5
  SHA512:
6
- metadata.gz: 105333b516f8492f17c192e17000a3b5c6dece2d7ef2a77b5459c19eed1c9d0f63978e38681601fa20c79247f763d41fe4c8a4d5e49daf3ecf97c08691b0cde9
7
- data.tar.gz: e5e55bb6d5b95b695bbc57c855485abe907d514ef16c5aa2b830538385606473f75f383424a6bae1ee561f6cc4526ecbff986a5fda3a05fb44507ab845e4ab9f
6
+ metadata.gz: 2f1c78c53cf16dea58a3a1e4afd30360715800fa158c761ff85b081a58f8055fb5c156ceea9e5035c61e0ac690101d6d1a80360357da70456141b18b81b77284
7
+ data.tar.gz: 5bbc98be3bdf9e44c6d2c68f8f26dc48879ab0651d21924db8267e3cb317e037d9280eda29cbb9823e4d11525604b174bbf058a74bb80883d3fb8deb5ae2e1f9
data/README.md CHANGED
@@ -1,9 +1,58 @@
1
1
  # Decidim::Calendar
2
2
 
3
3
  [![Build Status](https://img.shields.io/circleci/project/github/alabs/decidim-module-calendar/master.svg)](https://circleci.com/gh/alabs/decidim-module-calendar)
4
+ [![Coverage](https://img.shields.io/codeclimate/coverage/alabs/decidim-module-calendar.svg)](https://codeclimate.com/github/alabs/decidim-module-calendar)
4
5
  [![Maintainability](https://img.shields.io/codeclimate/maintainability/alabs/decidim-module-calendar.svg)](https://codeclimate.com/github/alabs/decidim-module-calendar/maintainability)
5
6
 
7
+ This [Decidim](https://github.com/decidim/decidim) module enable a multitenant
8
+ global calendar for Consultations, Debates, External Events, Meetings and
9
+ Participatory Processes. Giving a snapshot of all current activities in a
10
+ calendar view form.
6
11
 
7
- Decidim calendar is a module to generate a global participatory space calendar.
12
+ ![decidim-calendar](docs/decidim-calendar.png)
8
13
 
9
- ## This plugin is a work in progress
14
+ ## Features
15
+
16
+ - Display past and future events in from of calendar and agenda.
17
+ - Display gantt graph of participatory processes
18
+ - Download ICAL for import
19
+
20
+ ## Instalation
21
+
22
+ Edit the Gemfile and add this lines:
23
+
24
+ ```ruby
25
+ gem "decidim-calendar", github: "alabs/decidim-module-calendar"
26
+ ```
27
+
28
+ Run this rake tasks:
29
+
30
+ ```bash
31
+ bundle install
32
+ bundle exec rake decidim_calendar:install:migrations
33
+ bundle exec rake db:migrate
34
+ ```
35
+
36
+ To keep the gem up to date, you can use the commands above to also update it.
37
+
38
+ ## Contributing
39
+
40
+ For instructions how to setup your development environment for Decidim, see
41
+ [Decidim](https://github.com/decidim/decidim). Also follow Decidim's general
42
+ instructions for development for this project as well.
43
+
44
+ ## Developing
45
+
46
+ Clone this repository or fork and run:
47
+
48
+ ```bash
49
+ bundle install
50
+ rake development_app
51
+ ```
52
+
53
+ ### Localization
54
+
55
+ If you would like to see this module in your own language, you can help with
56
+ its translation at Crowdin:
57
+
58
+ [https://crowdin.com/project/decidim-calendar](https://crowdin.com/project/decidim-calendar)
@@ -2,6 +2,12 @@
2
2
  // = require "fullcalendar/daygrid/main"
3
3
  @import "foundation";
4
4
 
5
+ $meeting: #ed1c24 !default;
6
+ $debate: #099329 !default;
7
+ $consultation: #92278f !default;
8
+ $external_event: #ed650b !default;
9
+ $participatory_step: #3A4A9F !default;
10
+
5
11
  #calendar{
6
12
  .fc-title{
7
13
  margin-left: 5px;
@@ -39,23 +45,6 @@
39
45
  }
40
46
 
41
47
  }
42
- // when "Decidim::ParticipatoryProcessStep"
43
- // "#238ff7"
44
- // when "Decidim::Meetings::Meeting"
45
- // "#fabc6c"
46
- // when "Decidim::Calendar::ExternalEvent"
47
- // "#5fbd4c"
48
- // when "Decidim::Debates::Debate"
49
- // "#d87537"
50
- // when "Decidim::Consultation"
51
- // "#A854BD"
52
- // end
53
-
54
- $meeting: #fabc6c !default;
55
- $debate: #d87537 !default;
56
- $consultation: #A854BD !default;
57
- $external_event: #5fbd4c !default;
58
- $participatory_step: #238ff7 !default;
59
48
 
60
49
  .calendar-filters{
61
50
  .meeting{
@@ -8,18 +8,19 @@ module Decidim
8
8
  layout "calendar"
9
9
  def index
10
10
  @events = Event.all(current_organization)
11
- @resources = %w(consultation debate external_event meeting participatory_step)
11
+ @resources = %w(debate external_event meeting participatory_step)
12
+ @resources = @resources << "consultation" if defined? Decidim::Consultation
12
13
  end
13
14
 
14
15
  def gantt
15
- @events = Decidim::ParticipatoryProcessStep.all.order(decidim_participatory_process_id: :asc, position: :asc, start_date: :asc).map do |p|
16
+ @events = Decidim::ParticipatoryProcessStep.where.not(start_date: nil).order(decidim_participatory_process_id: :asc, position: :asc, start_date: :asc).map do |p|
16
17
  Decidim::Calendar::EventPresenter.new(p) if p.organization == current_organization
17
18
  end
18
19
  end
19
20
 
20
21
  def ical
21
22
  filename = "#{current_organization.name.parameterize}-calendar"
22
- response.headers['Content-Disposition'] = 'attachment; filename="' + filename + '.ical"'
23
+ response.headers["Content-Disposition"] = 'attachment; filename="' + filename + '.ical"'
23
24
  render plain: GeneralCalendar.for(current_organization), content_type: "text/calendar"
24
25
  end
25
26
 
@@ -12,46 +12,33 @@ module Decidim
12
12
  "title": "#{I18n.t(name, scope: "decidim.calendar.index.filters")}"
13
13
  })
14
14
  end
15
+
16
+ def render_events(events)
17
+ events.collect { |event| calendar_event(event) }.to_json
18
+ end
19
+
15
20
  def calendar_event(event)
16
- %({
17
- "title": "#{translated_attribute event.full_title}",
18
- "start": "#{event.start.strftime("%FT%R")}",
19
- "end": "#{event.finish.strftime("%FT%R")}",
20
- "color": "#{event.color}",
21
- "url": "#{event.link}",
22
- "resourceId": "#{event.type}",
23
- "allDay": #{event.all_day?}
24
- })
21
+ {
22
+ title: translated_attribute(event.full_title),
23
+ start: (event.start.strftime("%FT%R") unless event.start.nil?),
24
+ end: (event.finish.strftime("%FT%R") unless event.finish.nil?),
25
+ color: event.color,
26
+ url: event.link,
27
+ resourceId: event.type,
28
+ allDay: event.all_day?,
29
+ subtitle: (translated_attribute(event.subtitle) unless event.subtitle.empty?)
30
+ }.compact
25
31
  end
26
32
 
27
33
  def participatory_gantt(event)
28
34
  %({
29
35
  "id": "#{event.full_id}",
30
- "name": "#{translated_attribute event.full_title}",
36
+ "name": "#{translated_attribute event.full_title} - #{translated_attribute event.subtitle}",
31
37
  "start": "#{event.start.strftime("%FT%R")}",
32
38
  "dependencies": "#{event.parent}",
33
39
  "end": "#{event.finish.strftime("%FT%R")}"
34
40
  })
35
41
  end
36
-
37
- def participatory_space_wrapper(&block)
38
- content_tag :main, class: "wrapper" do
39
- concat(capture(&block))
40
- end
41
- end
42
-
43
- def extended_navigation_bar(items, max_items: 5)
44
- return unless items.any?
45
- extra_items = []
46
- active_item = items.find { |item| item[:active] }
47
-
48
- render partial: "decidim/shared/extended_navigation_bar", locals: {
49
- items: items,
50
- extra_items: extra_items,
51
- active_item: active_item,
52
- max_items: 5
53
- }
54
- end
55
42
  end
56
43
  end
57
44
  end
@@ -3,23 +3,28 @@
3
3
  module Decidim
4
4
  module Calendar
5
5
  module Event
6
- MODELS = [
6
+ @models = [
7
7
  Decidim::Meetings::Meeting,
8
8
  Decidim::ParticipatoryProcessStep,
9
9
  Decidim::Debates::Debate,
10
- Decidim::Consultation,
11
10
  Decidim::Calendar::ExternalEvent
12
- ].freeze
11
+ ]
12
+
13
+ @models = @models << Decidim::Consultation if defined? Decidim::Consultation
13
14
 
14
15
  def self.all(current_organization)
15
16
  events = []
16
- MODELS.collect do |model|
17
+ @models.collect do |model|
17
18
  model
18
19
  .all
19
- .map { |obj| events << Decidim::Calendar::EventPresenter.new(obj) if obj.organization == current_organization }
20
+ .map { |obj| events << present(obj) if obj.organization == current_organization && present(obj).start }
20
21
  end
21
22
  events
22
23
  end
24
+
25
+ def self.present(obj)
26
+ Decidim::Calendar::EventPresenter.new(obj)
27
+ end
23
28
  end
24
29
  end
25
30
  end
@@ -12,7 +12,6 @@ module Decidim
12
12
  validates :title, :start_at, :end_at, presence: true
13
13
  validates :start_at, date: { before: :end_at, allow_blank: false, if: proc { |obj| obj.end_at.present? } }
14
14
  validates :end_at, date: { after: :start_at, allow_blank: true, if: proc { |obj| obj.start_at.present? } }
15
-
16
15
  end
17
16
  end
18
17
  end
@@ -6,15 +6,15 @@ module Decidim
6
6
  def color
7
7
  case __getobj__.class.name
8
8
  when "Decidim::ParticipatoryProcessStep"
9
- "#238ff7"
9
+ "#3A4A9F"
10
10
  when "Decidim::Meetings::Meeting"
11
- "#fabc6c"
11
+ "#ed1c24"
12
12
  when "Decidim::Calendar::ExternalEvent"
13
- "#5fbd4c"
13
+ "#ed650b"
14
14
  when "Decidim::Debates::Debate"
15
- "#d87537"
15
+ "#099329"
16
16
  when "Decidim::Consultation"
17
- "#A854BD"
17
+ "#92278f"
18
18
  end
19
19
  end
20
20
 
@@ -83,20 +83,30 @@ module Decidim
83
83
  else
84
84
  end_time
85
85
  end
86
+ @finish || start
86
87
  end
87
88
 
88
89
  def full_title
89
90
  @full_title ||= case __getobj__.class.name
90
91
  when "Decidim::ParticipatoryProcessStep"
91
- participatory_process.title.merge(title) do |_k, v, o|
92
- "#{v} - #{o}"
93
- end
92
+ participatory_process.title
94
93
  else
95
94
  title
96
95
  end
97
96
  end
98
97
 
98
+ def subtitle
99
+ @subtitle ||= case __getobj__.class.name
100
+ when "Decidim::ParticipatoryProcessStep"
101
+ title
102
+ else
103
+ ""
104
+ end
105
+ end
106
+
99
107
  def all_day?
108
+ return false if start.nil? || finish.nil?
109
+
100
110
  (start.to_date..finish.to_date).count > 1
101
111
  end
102
112
  end
@@ -16,7 +16,7 @@ module Decidim
16
16
  @ical = Icalendar::Event.new
17
17
  @ical.dtstart = Icalendar::Values::DateTime.new(@event.start)
18
18
  @ical.dtend = Icalendar::Values::DateTime.new(@event.finish)
19
- @ical.summary = translated_attribute @event.full_title
19
+ @ical.summary = "#{translated_attribute @event.full_title} - #{translated_attribute @event.subtitle}"
20
20
  @ical.url = @event.link
21
21
  @ical
22
22
  end
@@ -13,7 +13,7 @@
13
13
  <%= stylesheet_link_tag "decidim/calendar/calendar" %>
14
14
 
15
15
  <script>
16
- let filters = ["consultation", "external_event", "meeting", "debate", "participatory_step"];
16
+ let filters = <%= @resources.to_json.html_safe %>;
17
17
 
18
18
  function removeFilter(filters, filter){
19
19
  return filters.filter((element) => element !== filter)
@@ -36,14 +36,13 @@
36
36
  hour12: false,
37
37
  omitZeroMinute: false
38
38
  },
39
- events: [
40
- <% @events.each do |e| %>
41
- <%= calendar_event(e).html_safe %>
42
- <%= "," unless e == @events.last %>
43
- <% end %>
44
- ],
39
+ events: <%= render_events(@events).html_safe %>,
45
40
  eventRender: function(info) {
46
- return filters.includes(info.event.extendedProps.resourceId);
41
+ if ("subtitle" in info.event.extendedProps) {
42
+ title = "<span class=\"fc-title\"><b>" + info.event.title + "</b> - " + info.event.extendedProps.subtitle + "</span>"
43
+ info.el.firstChild.innerHTML = title
44
+ }
45
+ return filters.includes(info.event.extendedProps.resourceId);
47
46
  }
48
47
  });
49
48
  $(function() {
@@ -32,6 +32,12 @@ ca:
32
32
  url: URL
33
33
  index:
34
34
  title: Calendari global
35
+ filters:
36
+ consultation: Consultes
37
+ debate: Debats
38
+ external_event: Esdeveniments externs
39
+ meeting: Trobades
40
+ participatory_step: Processos participatius
35
41
  menu:
36
42
  calendar: Calendari
37
43
  gantt: Gràfic de Gantt
@@ -32,6 +32,12 @@ de:
32
32
  url: URL
33
33
  index:
34
34
  title: Global Calendar
35
+ filters:
36
+ consultation: Consultations
37
+ debate: Debates
38
+ external_event: External Events
39
+ meeting: Meetings
40
+ participatory_step: Participatory Process
35
41
  menu:
36
42
  calendar: Calendar
37
43
  gantt: Gantt Graph
@@ -35,14 +35,10 @@ en:
35
35
  filters:
36
36
  consultation: Consultations
37
37
  debate: Debates
38
- external_event: External Events
38
+ external_event: External events
39
39
  meeting: Meetings
40
40
  participatory_step: Participatory Process
41
41
  menu:
42
42
  calendar: Calendar
43
43
  gantt: Gantt Graph
44
44
  ical: Download ICAL
45
- shared:
46
- extended_navigation_bar:
47
- unfold: Unfold
48
- more: More
@@ -32,6 +32,12 @@ es:
32
32
  url: URL
33
33
  index:
34
34
  title: Calendario global
35
+ filters:
36
+ consultation: Consultas
37
+ debate: Debates
38
+ external_event: Eventos externos
39
+ meeting: Encuentros
40
+ participatory_step: Procesos participativos
35
41
  menu:
36
42
  calendar: Calendario
37
43
  gantt: Gráfico de Gantt
@@ -32,6 +32,12 @@ fi:
32
32
  url: URL
33
33
  index:
34
34
  title: Global Calendar
35
+ filters:
36
+ consultation: Consultations
37
+ debate: Debates
38
+ external_event: External Events
39
+ meeting: Meetings
40
+ participatory_step: Participatory Process
35
41
  menu:
36
42
  calendar: Calendar
37
43
  gantt: Gantt Graph
@@ -32,6 +32,12 @@ fr:
32
32
  url: URL
33
33
  index:
34
34
  title: Global Calendar
35
+ filters:
36
+ consultation: Consultations
37
+ debate: Debates
38
+ external_event: External Events
39
+ meeting: Meetings
40
+ participatory_step: Participatory Process
35
41
  menu:
36
42
  calendar: Calendar
37
43
  gantt: Gantt Graph
@@ -32,6 +32,12 @@ it:
32
32
  url: URL
33
33
  index:
34
34
  title: Global Calendar
35
+ filters:
36
+ consultation: Consultations
37
+ debate: Debates
38
+ external_event: External Events
39
+ meeting: Meetings
40
+ participatory_step: Participatory Process
35
41
  menu:
36
42
  calendar: Calendar
37
43
  gantt: Gantt Graph
@@ -32,6 +32,12 @@ pl:
32
32
  url: URL
33
33
  index:
34
34
  title: Global Calendar
35
+ filters:
36
+ consultation: Consultations
37
+ debate: Debates
38
+ external_event: External Events
39
+ meeting: Meetings
40
+ participatory_step: Participatory Process
35
41
  menu:
36
42
  calendar: Calendar
37
43
  gantt: Gantt Graph
@@ -32,6 +32,12 @@ pt-BR:
32
32
  url: URL
33
33
  index:
34
34
  title: Global Calendar
35
+ filters:
36
+ consultation: Consultations
37
+ debate: Debates
38
+ external_event: External events
39
+ meeting: Meetings
40
+ participatory_step: Participatory Process
35
41
  menu:
36
42
  calendar: Calendar
37
43
  gantt: Gantt Graph
@@ -32,6 +32,12 @@ ro:
32
32
  url: URL
33
33
  index:
34
34
  title: Global Calendar
35
+ filters:
36
+ consultation: Consultations
37
+ debate: Debates
38
+ external_event: External events
39
+ meeting: Meetings
40
+ participatory_step: Participatory Process
35
41
  menu:
36
42
  calendar: Calendar
37
43
  gantt: Gantt Graph
@@ -32,6 +32,12 @@ ru:
32
32
  url: URL
33
33
  index:
34
34
  title: Global Calendar
35
+ filters:
36
+ consultation: Consultations
37
+ debate: Debates
38
+ external_event: External events
39
+ meeting: Meetings
40
+ participatory_step: Participatory Process
35
41
  menu:
36
42
  calendar: Calendar
37
43
  gantt: Gantt Graph
@@ -32,6 +32,12 @@ sv:
32
32
  url: URL
33
33
  index:
34
34
  title: Global Calendar
35
+ filters:
36
+ consultation: Consultations
37
+ debate: Debates
38
+ external_event: External events
39
+ meeting: Meetings
40
+ participatory_step: Participatory Process
35
41
  menu:
36
42
  calendar: Calendar
37
43
  gantt: Gantt Graph
@@ -32,6 +32,12 @@ tr:
32
32
  url: URL
33
33
  index:
34
34
  title: Global Calendar
35
+ filters:
36
+ consultation: Consultations
37
+ debate: Debates
38
+ external_event: External events
39
+ meeting: Meetings
40
+ participatory_step: Participatory Process
35
41
  menu:
36
42
  calendar: Calendar
37
43
  gantt: Gantt Graph
@@ -32,6 +32,12 @@ uk:
32
32
  url: URL
33
33
  index:
34
34
  title: Global Calendar
35
+ filters:
36
+ consultation: Consultations
37
+ debate: Debates
38
+ external_event: External events
39
+ meeting: Meetings
40
+ participatory_step: Participatory Process
35
41
  menu:
36
42
  calendar: Calendar
37
43
  gantt: Gantt Graph
@@ -3,8 +3,10 @@
3
3
  module Decidim
4
4
  # Holds decidim-calendar version
5
5
  module Calendar
6
+ DECIDIM_VERSION = ">= 0.19.0"
7
+
6
8
  def self.version
7
- "0.13.1"
9
+ "0.19.0"
8
10
  end
9
11
  end
10
12
  end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-calendar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1.3
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mijail Rondon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-10 00:00:00.000000000 Z
11
+ date: 2020-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: decidim-admin
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.13.1
19
+ version: 0.19.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.13.1
26
+ version: 0.19.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: decidim-consultations
28
+ name: decidim-core
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.13.1
33
+ version: 0.19.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.13.1
40
+ version: 0.19.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: decidim-core
42
+ name: decidim-dev
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.13.1
48
- type: :runtime
47
+ version: 0.19.0
48
+ type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 0.13.1
54
+ version: 0.19.0
55
55
  description: A decidim module to add calendar functionalities for participatory process,
56
56
  meetings, debates, consultations and external events
57
57
  email:
@@ -88,14 +88,12 @@ files:
88
88
  - app/services/decidim/calendar/event_to_ical.rb
89
89
  - app/services/decidim/calendar/general_calendar.rb
90
90
  - app/services/decidim/calendar/meeting_to_event.rb
91
- - app/services/decidim/meetings/calendar/base_calendar.rb
92
91
  - app/views/decidim/calendar/admin/external_events/_form.html.erb
93
92
  - app/views/decidim/calendar/admin/external_events/edit.html.erb
94
93
  - app/views/decidim/calendar/admin/external_events/index.html.erb
95
94
  - app/views/decidim/calendar/admin/external_events/new.html.erb
96
95
  - app/views/decidim/calendar/calendar/gantt.html.erb
97
96
  - app/views/decidim/calendar/calendar/index.html.erb
98
- - app/views/decidim/shared/_extended_navigation_bar.html.erb
99
97
  - app/views/layouts/_calendar_navigation.html.erb
100
98
  - app/views/layouts/calendar.html.erb
101
99
  - config/locales/ca.yml
@@ -232,15 +230,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
232
230
  requirements:
233
231
  - - ">="
234
232
  - !ruby/object:Gem::Version
235
- version: 2.3.1
233
+ version: '2.5'
236
234
  required_rubygems_version: !ruby/object:Gem::Requirement
237
235
  requirements:
238
236
  - - ">="
239
237
  - !ruby/object:Gem::Version
240
238
  version: '0'
241
239
  requirements: []
242
- rubyforge_project:
243
- rubygems_version: 2.7.6
240
+ rubygems_version: 3.0.3
244
241
  signing_key:
245
242
  specification_version: 4
246
243
  summary: A decidim module to add a global calendar
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Meetings
5
- module Calendar
6
- # This class serves as a base class to render calendars. Please, inherit
7
- # from it and overwrite the `events` with whatever logic you need to do
8
- # it. After that, modify the `Decidim::Meetings::Calendar.for` method to
9
- # include your new class.
10
- class BaseCalendar
11
- # Convenience method to shorten the calls. Converts the resource
12
- # meetings to the ICalendar format.
13
- #
14
- # resource - a resource that has meetings.
15
- #
16
- # Returns a String.
17
- def self.for(resource)
18
- new(resource).calendar
19
- end
20
-
21
- # Initializes the class.
22
- #
23
- # resource - a resource that has meetings.
24
- def initialize(resource)
25
- @resource = resource
26
- end
27
-
28
- # Converts the resource meetings to the ICalendar format.
29
- #
30
- # Returns a String.
31
- def calendar
32
- return if events.blank?
33
- <<~CALENDAR.gsub("\n\n", "\n")
34
- BEGIN:VCALENDAR\r
35
- VERSION:2.0\r
36
- PRODID:icalendar-ruby\r
37
- CALSCALE:GREGORIAN\r
38
- #{events}
39
- END:VCALENDAR\r
40
- CALENDAR
41
- end
42
-
43
- # Internal: this method is supposed to be overwritten by classes
44
- # inheriting from this one. It should find the relevant meetings that
45
- # will be exported, and convert them to ICalendar events. Please use the
46
- # `MeetingToEvent` class to do so. Since this method returns a String,
47
- # you can cache its contents. Check existing implementations for an
48
- # example of how to achieve it.
49
- #
50
- # Returns a String.
51
- def events
52
- raise "Please, overwrite this method. You can use the `MeetingToEvent` class to convert a meeting to the correct ICalendar format."
53
- end
54
-
55
- private
56
-
57
- attr_reader :resource
58
- end
59
- end
60
- end
61
- end
@@ -1,51 +0,0 @@
1
- <div class="row expanded">
2
- <div class="process-nav">
3
- <div class="row">
4
- <button class="process-nav__trigger hide-for-medium" data-toggle="process-nav-content">
5
- <%= icon "caret-bottom", class: "icon--small process-nav__trigger__icon", aria_label: t(".unfold"), role: "img" %>
6
- <% default_item = active_item || items.first %>
7
- <div class="process-nav__link">
8
- <%= default_item[:name] %>
9
- </div>
10
- </button>
11
- <div class="row column process-nav__content" id="process-nav-content" data-toggler=".is-active">
12
- <ul>
13
- <% items.each_with_index do |item, index| %>
14
- <li class="<%= "is-active" if item[:active] %> <%= "hide-for-medium" if index > max_items %>">
15
- <%= link_to item[:url], class: "process-nav__link #{item[:active] ? 'active' : nil}" do %>
16
- <%= item[:name] %>
17
- <% end %>
18
- </li>
19
- <% end %>
20
- </ul>
21
-
22
- <% if extra_items.any? %>
23
- <button class="button tiny process-nav__more show-for-medium" data-toggle="process-nav__hide-content">
24
- <%= t ".more" %> <i></i><i></i><i></i>
25
- </button>
26
- <div class="dropdown-pane process-nav__hidden-content" id="process-nav__hide-content"
27
- data-dropdown
28
- data-hover="true"
29
- data-hover-pane="true"
30
- data-v-offset="-25"
31
- data-position="bottom"
32
- data-alignment="right">
33
- <div class="process-nav__hidden-content__more">
34
- <%= t ".more" %> <i></i><i></i><i></i>
35
- </div>
36
- <ul>
37
- <% extra_items.each do |item| %>
38
- <li class="<%= "is-active" if item[:active] %>">
39
- <%= link_to item[:url], class: "process-nav__link #{item[:active] ? 'active' : nil}" do %>
40
- <%= item[:name] %>
41
- <% end %>
42
- </li>
43
- <% end %>
44
- </ul>
45
- </div>
46
- <% end %>
47
- </div>
48
- </div>
49
- </div>
50
- </div>
51
-