Class: Decidim::DecidimAwesome::ContentBlocks::AwesomeProcessesFormCell

Inherits:
ViewModel
  • Object
show all
Defined in:
app/cells/decidim/decidim_awesome/content_blocks/awesome_processes_form_cell.rb

Instance Method Summary collapse

Instance Method Details

#content_blockObject



9
10
11
# File 'app/cells/decidim/decidim_awesome/content_blocks/awesome_processes_form_cell.rb', line 9

def content_block
  options[:content_block]
end

#i18n_scopeObject



13
14
15
# File 'app/cells/decidim/decidim_awesome/content_blocks/awesome_processes_form_cell.rb', line 13

def i18n_scope
  "decidim.decidim_awesome.content_blocks.awesome_processes"
end

#process_group_optionsObject



25
26
27
28
29
30
31
32
# File 'app/cells/decidim/decidim_awesome/content_blocks/awesome_processes_form_cell.rb', line 25

def process_group_options
  groups = Decidim::ParticipatoryProcessGroup.where(organization: current_organization)
  opts = [[t("any_group", scope: i18n_scope), 0]]
  groups.find_each do |group|
    opts << [translated_attribute(group.title), group.id]
  end
  opts
end

#process_status_optionsObject



34
35
36
37
38
39
40
41
# File 'app/cells/decidim/decidim_awesome/content_blocks/awesome_processes_form_cell.rb', line 34

def process_status_options
  [
    [t("process_statuses.active", scope: i18n_scope), "active"],
    [t("process_statuses.all", scope: i18n_scope), "all"],
    [t("process_statuses.upcoming", scope: i18n_scope), "upcoming"],
    [t("process_statuses.past", scope: i18n_scope), "past"]
  ]
end

#process_type_optionsObject



17
18
19
20
21
22
23
# File 'app/cells/decidim/decidim_awesome/content_blocks/awesome_processes_form_cell.rb', line 17

def process_type_options
  [
    [t("process_types.all", scope: i18n_scope), "all"],
    [t("process_types.processes", scope: i18n_scope), "processes"],
    [t("process_types.groups", scope: i18n_scope), "groups"]
  ]
end

#processes_for_selectObject



50
51
52
53
54
55
56
57
58
59
60
# File 'app/cells/decidim/decidim_awesome/content_blocks/awesome_processes_form_cell.rb', line 50

def processes_for_select
  processes = published_processes.map do |process|
    ["##{process.id} - #{translated_attribute(process.title)}", "process_#{process.id}"]
  end

  groups = Decidim::ParticipatoryProcessGroup.where(organization: current_organization).map do |group|
    ["[#{t("group_label", scope: i18n_scope)}] #{translated_attribute(group.title)}", "group_#{group.id}"]
  end

  processes + groups
end

#selection_criteria_optionsObject



43
44
45
46
47
48
# File 'app/cells/decidim/decidim_awesome/content_blocks/awesome_processes_form_cell.rb', line 43

def selection_criteria_options
  [
    [t("selection_criteria_options.automatic", scope: i18n_scope), "automatic"],
    [t("selection_criteria_options.manual", scope: i18n_scope), "manual"]
  ]
end