Skip to content

Commit

Permalink
Refactor concerns, add deface (#121)
Browse files Browse the repository at this point in the history
* reorder concerns & initializers

* move to deface

* add locales
  • Loading branch information
microstudi committed Mar 23, 2023
1 parent ffe1fba commit 141092b
Show file tree
Hide file tree
Showing 35 changed files with 122 additions and 767 deletions.
10 changes: 9 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
PATH
remote: .
specs:
decidim-action_delegator (0.6.1)
decidim-action_delegator (0.7.0)
decidim-admin (>= 0.26.0, < 0.27)
decidim-consultations (>= 0.26.0, < 0.27)
decidim-core (>= 0.26.0, < 0.27)
deface (>= 1.9)
savon
twilio-ruby

Expand Down Expand Up @@ -334,6 +335,12 @@ GEM
declarative-builder (0.1.0)
declarative-option (< 0.2.0)
declarative-option (0.1.0)
deface (1.9.0)
actionview (>= 5.2)
nokogiri (>= 1.6)
polyglot
railties (>= 5.2)
rainbow (>= 2.1.0)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
devise (4.8.1)
Expand Down Expand Up @@ -543,6 +550,7 @@ GEM
pg_search (2.3.6)
activerecord (>= 5.2)
activesupport (>= 5.2)
polyglot (0.3.5)
premailer (1.18.0)
addressable
css_parser (>= 1.12.0)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Depending on your Decidim version, choose the corresponding version to ensure co

| Version | Compatible Decidim versions |
|---|---|
| 0.7.x | 0.26.x |
| 0.6.x | 0.26.x |
| 0.5 | 0.25.x |
| 0.4 | 0.24.x |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module ActionDelegator
module Consultations
module ConsultationsControllerOverride
extend ActiveSupport::Concern
include ::Decidim::ActionDelegator::NeedsConsultationSnippets

included do
helper ::Decidim::ActionDelegator::DelegationHelper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module ActionDelegator
module Consultations
module QuestionsControllerOverride
extend ActiveSupport::Concern
include ::Decidim::ActionDelegator::NeedsConsultationSnippets

included do
helper ::Decidim::ActionDelegator::DelegationHelper
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

module Decidim
module ActionDelegator
module NeedsConsultationSnippets
extend ActiveSupport::Concern

included do
helper_method :snippets
end

def snippets
@snippets ||= Decidim::Snippets.new

unless @snippets.any?(:action_delegator_consultation_questions)
@snippets.add(:action_delegator_consultation_questions, ActionController::Base.helpers.stylesheet_pack_tag("decidim_action_delegator_questions"))
@snippets.add(:action_delegator_consultation_questions, ActionController::Base.helpers.javascript_pack_tag("decidim_action_delegator_questions_js"))
@snippets.add(:head, @snippets.for(:action_delegator_consultation_questions))
end

@snippets
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- insert_after "erb[loud]:contains('display_take_part_button_for(question)')" -->

<%= render partial: "decidim/action_delegator/link_to_question", locals: { question: question } %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- insert_before ".card__content.multiple_votes_form" -->

<% if delegation %>
<div class="delegation-callout callout warning">
<p><%= t "action_delegator.delegations_modal.callout", scope: "decidim" %> <strong><%= delegation.granter.name %></strong></p>
</div>
<%= hidden_field_tag :decidim_consultations_delegation_id, delegation.id %>
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- insert_before "erb[silent]:contains('elsif question.consultation.active?')" -->

<%= render partial: "decidim/action_delegator/link_to_delegations", locals: { question: question } %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- insert_before "erb[loud]:contains('javascript_pack_tag')" -->

<%= render partial: "decidim/action_delegator/delegations_modal", locals: { question: question } %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- replace_contents "erb[silent]:contains('if question.multiple?')"
closing_selector "erb[silent]:contains('else')" -->

<%= link_to decidim_consultations.question_question_multiple_votes_path(question, delegation: 0),
class: "card__button button expanded",
id: "multivote_button" do %>
<div class="vote-button-caption"><%= t "questions.vote_button.vote", scope: "decidim" %></div>
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- insert_after ".reveal__header" -->

<%= render partial: "decidim/action_delegator/callout", locals: { consultation: question.consultation } %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- insert_after ".reveal__header" -->

<%= render partial: "decidim/action_delegator/callout", locals: { consultation: question.consultation } %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- insert_after "erb[loud]:contains('form.hidden_field :decidim_consultations_response_id')" -->

<%= hidden_field_tag :decidim_consultations_delegation_id, nil, id: "decidim_consultations_delegation_id" %>
10 changes: 10 additions & 0 deletions app/overrides/layouts/decidim/admin/remove_deprecation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

Deface::Override.new(virtual_path: "layouts/decidim/admin/consultations",
name: "remove_deprecation_warning",
remove: ".callout.warning",
disabled: !Decidim::ActionDelegator.remove_consultation_deprecation_warning)
Deface::Override.new(virtual_path: "layouts/decidim/admin/consultation",
name: "remove_deprecation_warning",
remove: ".callout.warning",
disabled: !Decidim::ActionDelegator.remove_consultation_deprecation_warning)
41 changes: 0 additions & 41 deletions app/views/decidim/consultations/consultations/_question.html.erb

This file was deleted.

14 changes: 0 additions & 14 deletions app/views/decidim/consultations/consultations/show.html.erb

This file was deleted.

This file was deleted.

106 changes: 0 additions & 106 deletions app/views/decidim/consultations/questions/_vote_button.html.erb

This file was deleted.

30 changes: 0 additions & 30 deletions app/views/decidim/consultations/questions/_vote_modal.html.erb

This file was deleted.

This file was deleted.

Loading

0 comments on commit 141092b

Please sign in to comment.