Class: Decidim::Sortitions::SortitionMetadataCell

Inherits:
CardMetadataCell show all
Includes:
SortitionsHelper
Defined in:
decidim-sortitions/app/cells/decidim/sortitions/sortition_metadata_cell.rb

Overview

This cell renders the assembly metadata for l card

Constant Summary

Constants included from AmendmentsHelper

AmendmentsHelper::TOTAL_STEPS

Constants included from IconHelper

IconHelper::DEFAULT_RESOURCE_TYPE_ICONS

Instance Method Summary collapse

Methods included from SortitionsHelper

#component_name, #filter_sections_sortitions, #filter_state_values, #proposal_path, #sortition_category_label, #sortition_proposal_candidate_ids

Methods included from TranslationsHelper

empty_translatable, ensure_translatable, multi_translation, translated_in_current_locale?

Methods included from TranslatableAttributes

#default_locale?

Methods included from Decidim::SanitizeHelper

#decidim_html_escape, #decidim_sanitize, #decidim_sanitize_admin, #decidim_sanitize_editor, #decidim_sanitize_editor_admin, #decidim_sanitize_newsletter, #decidim_url_escape, included

Methods inherited from CardMetadataCell

#show

Methods included from ViewHooksHelper

#render_hook

Methods included from DateRangeHelper

#format_date_range

Methods included from ApplicationHelper

#cell, #edit_link, #extra_admin_link, #html_truncate, #present, #prevent_timeout_seconds, #resolve_presenter_class, #step_cta_url

Methods included from CacheHelper

#cache

Methods included from AmendmentsHelper

#accept_and_reject_buttons_for, #action_button_card_for, #allowed_to_accept_and_reject?, #allowed_to_promote?, #amend_button_for, #amendments_enabled?, #amendments_form_field_for, #amendments_form_fields_label, #amendments_form_fields_value, #can_participate_in_private_space?, #can_react_to_emendation?, #current_step, #emendation_actions_for, #emendation_announcement_for, #promote_button_for, #render_emendation_body, #total_steps, #wizard_aside_back_url, #wizard_header_title

Methods included from RichTextEditorHelper

included, #text_editor_for

Methods included from ContextualHelpHelper

#floating_help

Methods included from Decidim::ScopesHelper

#has_visible_scopes?, #scope_name_for_picker, #scopes_picker_field, #scopes_picker_filter, #scopes_select_field, #scopes_select_tag

Methods included from DecidimFormHelper

#areas_for_select, #base_error_messages, #decidim_form_for, #decidim_form_slug_url, #editor_field_tag, #form_field_has_error?, #form_required_explanation, #name_with_locale, #ordered_scopes_descendants, #ordered_scopes_descendants_for_select, #scopes_picker_field_tag, #tab_element_class_for, #translated_field_tag

Methods included from OmniauthHelper

#normalize_provider_name, #oauth_icon, #provider_name

Methods included from IconHelper

#component_icon, #manifest_icon, #resource_icon, #resource_type_icon, #resource_type_icon_key, #text_with_resource_icon

Methods included from LayoutHelper

#_icon_classes, #apple_favicon, #application_path, #current_user_unread_data, #extended_navigation_bar, #external_icon, #favicon, #icon, #legacy_favicon, #organization_colors, #role

Methods included from TooltipHelper

#with_tooltip

Methods included from ModalHelper

#decidim_modal

Methods inherited from ViewModel

#call, #current_user, #view_context

Methods included from MarkupHelper

#element_id

Methods included from ReplaceButtonsHelper

#button_to, #submit_tag

Methods included from ActionAuthorizationHelper

#action_authorized_button_to, #action_authorized_link_to, #logged_button_to, #logged_link_to

Methods included from ResourceHelper

#linked_classes_filter_values_for, #linked_classes_for, #resource_locator, #resource_title

Constructor Details

#initializeSortitionMetadataCell

Returns a new instance of SortitionMetadataCell.



11
12
13
14
15
# File 'decidim-sortitions/app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 11

def initialize(*)
  super

  @items.prepend(*sortition_items)
end

Instance Method Details

#badge_itemObject



35
36
37
38
39
# File 'decidim-sortitions/app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 35

def badge_item
  {
    text: (:span, class: "label #{state_classes}") { badge_name }
  }
end

#badge_nameObject



45
46
47
48
49
# File 'decidim-sortitions/app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 45

def badge_name
  return t("filters.cancelled", scope: "decidim.sortitions.sortitions") if model.cancelled?

  t("filters.active", scope: "decidim.sortitions.sortitions")
end

#count_itemObject



21
22
23
24
25
26
# File 'decidim-sortitions/app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 21

def count_item
  {
    text: data_with_text(proposals_count, t("decidim.sortitions.sortitions.sortition.selected_proposals", count: proposals_count)),
    icon: "chat-new-line"
  }
end

#data_with_text(data, text) ⇒ Object



51
52
53
# File 'decidim-sortitions/app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 51

def data_with_text(data, text)
  "#{(:strong) { data }}#{(:span) { text }}".html_safe
end

#has_badge?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'decidim-sortitions/app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 41

def has_badge?
  false
end

#proposals_countObject



61
62
63
# File 'decidim-sortitions/app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 61

def proposals_count
  @proposals_count = model.proposals.count
end

#seed_itemObject



28
29
30
31
32
33
# File 'decidim-sortitions/app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 28

def seed_item
  {
    text: data_with_text(model.seed, t("random_seed", scope: "decidim.sortitions.sortitions.sortition")),
    icon: "seedling-line"
  }
end

#sortition_itemsObject



17
18
19
# File 'decidim-sortitions/app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 17

def sortition_items
  [count_item, seed_item, badge_item]
end

#state_classesObject



55
56
57
58
59
# File 'decidim-sortitions/app/cells/decidim/sortitions/sortition_metadata_cell.rb', line 55

def state_classes
  return "alert" if model.cancelled?

  "success"
end