Class: Decidim::DiffCell

Inherits:
ViewModel
  • Object
show all
Includes:
ActionView::Helpers::FormOptionsHelper, Cell::ViewModel::Partial
Defined in:
app/cells/decidim/diff_cell.rb

Overview

This cell renders the diff between :old_data and :new_data.

Instance Method Summary collapse

Instance Method Details

#attribute(data) ⇒ Object



11
12
13
# File 'app/cells/decidim/diff_cell.rb', line 11

def attribute(data)
  render locals: { data: }
end

#diff_split(data, direction, format) ⇒ Object



19
20
21
# File 'app/cells/decidim/diff_cell.rb', line 19

def diff_split(data, direction, format)
  render locals: { data:, direction:, format: }
end

#diff_split_full(data, format) ⇒ Object



23
24
25
# File 'app/cells/decidim/diff_cell.rb', line 23

def diff_split_full(data, format)
  render locals: { data:, format: }
end

#diff_unified(data, format) ⇒ Object



15
16
17
# File 'app/cells/decidim/diff_cell.rb', line 15

def diff_unified(data, format)
  render locals: { data:, format: }
end


33
34
35
# File 'app/cells/decidim/diff_cell.rb', line 33

def dropdown_options_for_select(options, value)
  options_for_select(options.map { |opt| [t("versions.dropdown.option_#{opt}"), opt] }, value)
end

#html_optionsObject



41
42
43
# File 'app/cells/decidim/diff_cell.rb', line 41

def html_options
  dropdown_options_for_select(%w(unescaped escaped), params["diff-html"])
end

#mode_optionsObject



37
38
39
# File 'app/cells/decidim/diff_cell.rb', line 37

def mode_options
  dropdown_options_for_select(%w(unified split), params["diff-mode"])
end

#path(extra_params) ⇒ Object



27
28
29
30
31
# File 'app/cells/decidim/diff_cell.rb', line 27

def path(extra_params)
  return if options[:path].blank?

  options[:path].call(extra_params)
end