Skip to content

Commit

Permalink
Open initiative print page in new tab
Browse files Browse the repository at this point in the history
  • Loading branch information
andreslucena committed May 2, 2022
1 parent ce70c09 commit fad049c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

require "active_support/concern"

module Decidim
module Initiatives
# Common methods for elements that need specific behaviour when there is only one initiative type.
module NeedsInitiativeType
extend ActiveSupport::Concern

included do
before_action :verify_initiative_type

private

def any_initiative_type?
Decidim::InitiativesType.where(organization: current_organization).any?
end

def verify_initiative_type
unless any_initiative_type?
flash[:error] = "There needs to be an initiative type created by an administrator for initiatives to work"
redirect_to decidim.root_path
end
end
end
end
end
end

Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
<%= icon_link_to "print",
decidim_initiatives.print_initiative_path(initiative),
t(".print",),
class: "action-icon--print" %>
class: "action-icon--print",
target: :blank %>
<% else %>
<span class="action-space icon"></span>
<% end %>
Expand Down

0 comments on commit fad049c

Please sign in to comment.