Class: Decidim::ViewModel

Inherits:
Cell::ViewModel
  • Object
show all
Includes:
ActionController::Helpers, ActionView::Helpers::TranslationHelper, Cell::Caching::Notifications, Cell::Translation, ActionAuthorization, ActionAuthorizationHelper, LayoutHelper, MarkupHelper, ReplaceButtonsHelper, ResourceHelper, ScopesHelper
Defined in:
decidim-core/lib/decidim/view_model.rb

Direct Known Subclasses

Accountability::HighlightedResultsCell, Accountability::HighlightedResultsForComponentCell, Accountability::ProjectCell, Accountability::ResultCardCell, Accountability::ResultCell, Accountability::ResultsCell, Accountability::StatusCell, ActivitiesCell, ActivityCell, AddressCell, Admin::AttachmentsPrivacyWarningCell, Admin::ContentBlockCell, Admin::ResultsPerPageCell, Amendable::AmendButtonCardCell, Amendable::AmendmentsCell, Amendable::AnnouncementCell, Amendable::EmendationActionsCell, Amendable::PromoteButtonCardCell, Amendable::WizardStepFormCell, AnnouncementCell, Assemblies::AssembliesCell, Assemblies::AssemblyCell, Assemblies::AssemblyMemberCell, Assemblies::ContentBlocks::HighlightedAssembliesSettingsFormCell, AuthorCell, AuthorizationModalCell, BadgeCell, BadgesCell, Blogs::PostCell, Budgets::BaseCell, Budgets::BudgetCell, Budgets::ProjectCell, Budgets::ProjectSelectedStatusCell, Budgets::ProjectVoteButtonCell, Budgets::ProjectVotesCountCell, ButtonCell, CardCell, CardGCell, CardLCell, CardMetadataCell, CardSCell, CoauthorshipsCell, CollapsibleAuthorsCell, Comments::CommentCardCell, Comments::CommentCell, Comments::CommentFormCell, Comments::CommentThreadCell, Comments::CommentsCell, Comments::EditCommentModalFormCell, Conferences::ConferenceCell, Conferences::LinkedParticipatorySpacesCell, Conferences::MediaLinkCell, Conferences::PartnerCell, Conferences::RegistrationTypeCell, ContentBlocks::BaseCell, ContentBlocks::CtaCell, ContentBlocks::CtaSettingsFormCell, ContentBlocks::FooterSubHeroCell, ContentBlocks::GlobalMenuCell, ContentBlocks::HeroCell, ContentBlocks::HeroSettingsFormCell, ContentBlocks::HighlightedContentBannerCell, ContentBlocks::HighlightedElementsSettingsFormCell, ContentBlocks::HowToParticipateCell, ContentBlocks::HtmlCell, ContentBlocks::HtmlSettingsFormCell, ContentBlocks::LastActivityCell, ContentBlocks::LastActivitySettingsFormCell, ContentBlocks::StaticPage::SectionCell, ContentBlocks::StaticPage::SectionSettingsFormCell, ContentBlocks::StaticPage::SummaryCell, ContentBlocks::StaticPage::SummarySettingsFormCell, ContentBlocks::StaticPage::TwoPaneSectionCell, ContentBlocks::StaticPage::TwoPaneSectionSettingsFormCell, ContentBlocks::StatsCell, ContentBlocks::SubHeroCell, DataConsentCell, DateRangeCell, Debates::DebateCell, DiffCell, DocumentsPanelCell, Elections::ElectionCell, Elections::ElectionPreviewCell, Elections::ElectionResultsCell, Elections::ElectionVoteCtaCell, Elections::HighlightedElectionsForComponentCell, Elections::RemainingTimeCalloutCell, Elections::VotingStepNavigationCell, EndorsementBlockCell, EndorsementButtonsCell, EndorsersListCell, FlagModalCell, FollowersCell, FollowingCell, FooterPagesCell, Forms::AnswerReadonlyCell, Forms::MatrixReadonlyCell, Forms::QuestionReadonlyCell, Forms::StepNavigationCell, GroupsCell, HighlightedParticipatoryProcessCell, ImagesPanelCell, Initiatives::ContentBlocks::HighlightedInitiativesSettingsFormCell, Initiatives::InitiativeCell, InitiativesVotes::VoteCell, LinkedResourcesForCell, Meetings::DatesAndMapCell, Meetings::HighlightedMeetingsCell, Meetings::HighlightedMeetingsForComponentCell, Meetings::JoinMeetingButtonCell, Meetings::MeetingCell, Meetings::MeetingMonthCell, Meetings::OnlineMeetingCell, Meetings::PublicParticipantsListCell, Meetings::QuestionResponsesCell, MembersCell, NavLinksCell, NavbarAdminLinkCell, NewsletterTemplates::BaseCell, NewsletterTemplates::BaseSettingsFormCell, NotificationCell, NotificationsCell, PadIframeCell, ParticipatoryProcesses::ContentBlocks::HighlightedProcessesSettingsFormCell, ParticipatoryProcesses::ContentBlocks::ProcessesSettingsFormCell, ParticipatoryProcesses::FilteredParticipatoryProcessesCell, ParticipatoryProcesses::ProcessCell, ParticipatoryProcesses::ProcessFiltersCell, ParticipatoryProcesses::ProcessGroupCell, ParticipatoryProcesses::ProcessStepCell, ParticipatoryProcesses::ProcessesCell, ParticipatorySpaceDropdownMetadataCell, PhotoCell, PhotosListCell, ProfileCell, ProgressBarCell, Proposals::CollaborativeDraftCell, Proposals::CollaborativeDraftLinkToProposalCell, Proposals::CostReportCell, Proposals::HighlightedProposalsCell, Proposals::HighlightedProposalsForComponentCell, Proposals::IrreversibleActionModalCell, Proposals::ParticipatoryTextProposalCell, Proposals::ProposalCell, Proposals::ProposalLinkedResourcesCell, Proposals::ProposalsPickerCell, PublicParticipationCell, ReportedContentCell, RepresentUserGroupCell, ResourceTypesFilterCell, ScopesPickerCell, SearchResultsCell, SearchResultsSectionCell, Sortitions::SortitionCell, StatisticCell, StatisticsCell, TabPanelsCell, TagsCell, TosPageCell, TranslationBarCell, UploadModalCell, UserActivityCell, UserConversationCell, UserConversationsCell, UserGroupPendingInvitationsListCell, UserGroupPendingRequestsListCell, UserTimelineCell, Decidim::Verifications::AuthorizationMetadataCell, Decidim::Verifications::RevocationsCell, VersionCell, VersionsListCell, VersionsListItemCell, Decidim::Votings::ContentBlocks::HeroSettingsFormCell, Decidim::Votings::ContentBlocks::HighlightedVotingsSettingsFormCell, Decidim::Votings::ContentBlocks::PollingStationsCell, Decidim::Votings::PollingOfficers::PollingOfficersPickerCell, Decidim::Votings::PollingStationClosureCertificateCell, Decidim::Votings::PollingStationClosureRecountCell, Decidim::Votings::VotingCell, WizardStepFormCell

Instance Method Summary collapse

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 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 ScopesHelper

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

Methods included from TranslatableAttributes

#default_locale?

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 ResourceHelper

#linked_classes_filter_values_for, #linked_classes_for, #resource_locator, #resource_title

Instance Method Details

#callObject



30
31
32
33
34
35
# File 'decidim-core/lib/decidim/view_model.rb', line 30

def call(*)
  identifier = self.class.name.sub(/Cell$/, "").underscore
  instrument(:cell, identifier:) do |_payload|
    super
  end
end

#current_userObject



26
27
28
# File 'decidim-core/lib/decidim/view_model.rb', line 26

def current_user
  context&.dig(:current_user) || controller&.current_user
end

#view_contextObject



58
59
60
# File 'decidim-core/lib/decidim/view_model.rb', line 58

def view_context
  context&.dig(:view_context) || ::ActionController::Base.helpers
end