forked from decidim-ice/decidim-module-decidim_awesome
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add modal window with instructions (#20)
* change basic copies * namespace css * introduce modal pre-voting * handle localstorage * refactor namespaces for copies * fix copy * copies * add finger * add svg icons * add margin * fix margins in modal * abstain style * fix tests * prevent voting abstain if not allowed * fix footer * normalize i18n * add additional specs * add conf var for sorting * fix cache proposal_m * proposal conf fixes
- Loading branch information
1 parent
ef5770a
commit 5768ddd
Showing
32 changed files
with
1,165 additions
and
334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
app/cells/concerns/decidim/decidim_awesome/proposal_m_cell_override.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module DecidimAwesome | ||
module ProposalMCellOverride | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
# rubocop:disable Metrics/CyclomaticComplexity | ||
def cache_hash | ||
hash = [] | ||
hash << I18n.locale.to_s | ||
hash << model.cache_key_with_version | ||
hash << model.proposal_votes_count | ||
hash << model.weight_cache&.totals | ||
hash << model.endorsements_count | ||
hash << model.comments_count | ||
hash << Digest::MD5.hexdigest(model.component.cache_key_with_version) | ||
hash << Digest::MD5.hexdigest(resource_image_path) if resource_image_path | ||
hash << render_space? ? 1 : 0 | ||
if current_user | ||
hash << current_user.cache_key_with_version | ||
hash << current_user.follows?(model) ? 1 : 0 | ||
end | ||
hash << model.follows_count | ||
hash << Digest::MD5.hexdigest(model.authors.map(&:cache_key_with_version).to_s) | ||
hash << (model.must_render_translation?(model.organization) ? 1 : 0) if model.respond_to?(:must_render_translation?) | ||
hash << model.component.participatory_space.active_step.id if model.component.participatory_space.try(:active_step) | ||
hash << has_footer? | ||
hash << has_actions? | ||
|
||
hash.join(Decidim.cache_key_separator) | ||
end | ||
# rubocop:enable Metrics/CyclomaticComplexity | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 15 additions & 8 deletions
23
app/cells/decidim/decidim_awesome/voting/three_flags_counter/show.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
<span class="votes_counter"> | ||
<span id="green-votes-<%= model.id %>" data-weight="3" class="text-success">G: <%= model.weight_count(3) %></span> | | ||
<span id="yellow-votes-<%= model.id %>" data-weight="2" class="text-warning">Y: <%= model.weight_count(2) %></span> | | ||
<span id="red-votes-<%= model.id %>" data-weight="1" class="text-alert">R: <%= model.weight_count(1) %></span> | ||
</span> | ||
<div id="proposal-<%= model.id %>-vote-button"> | ||
<%= render "vote_button" %> | ||
</div> | ||
<% unless proposal.rejected? || proposal.withdrawn? %> | ||
<% unless current_settings.votes_hidden? %> | ||
<span class="votes_counter"> | ||
<span data-weight="3" title="<%= proposal.manifest.label_for(3) %>" class="text-success"><%= t("decidim.decidim_awesome.voting.three_flags.weights.g") %>: <%= model.weight_count(3) %></span> | | ||
<span data-weight="2" title="<%= proposal.manifest.label_for(2) %>" class="text-warning"><%= t("decidim.decidim_awesome.voting.three_flags.weights.y") %>: <%= model.weight_count(2) %></span> | | ||
<span data-weight="1" title="<%= proposal.manifest.label_for(1) %>" class="text-alert"><%= t("decidim.decidim_awesome.voting.three_flags.weights.r") %>: <%= model.weight_count(1) %></span> | ||
<% if current_component.settings.three_flags_show_abstain %> | ||
| <span title="<%= proposal.manifest.label_for(0) %>" data-weight="0"><%= t("decidim.decidim_awesome.voting.three_flags.weights.a") %>: <%= model.weight_count(0) %></span> | ||
<% end %> | ||
</span> | ||
<% end %> | ||
<div id="proposal-<%= model.id %>-vote-button"> | ||
<%= render "vote_button" %> | ||
</div> | ||
<% end %> |
15 changes: 10 additions & 5 deletions
15
app/cells/decidim/decidim_awesome/voting/three_flags_counter/vote_button.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
<%= link_to resource_path, | ||
class: "button #{vote_btn_class} button--sc", | ||
title: t("decidim.decidim_awesome.proposal_m.vote_button"), | ||
style: "cursor: pointer; padding-top: 0.6rem; padding-bottom: 0.6rem; margin-bottom: 0" do %> | ||
class: "button #{vote_btn_class} small button--sc#{" disabled" if current_settings.votes_blocked?}", | ||
title: t("decidim.decidim_awesome.voting.three_flags.vote_button") do %> | ||
<% if user_voted_weight %> | ||
<%= icon "actions", class: "icon" %><span><%= t("decidim.decidim_awesome.proposal_m.voted") %></span> | ||
<%= icon "actions", class: "icon" %> <%= t("decidim.decidim_awesome.voting.three_flags.voted") %> | ||
<% elsif proposal.maximum_votes_reached? && !proposal.can_accumulate_supports_beyond_threshold && current_component.participatory_space.can_participate?(current_user) %> | ||
<%= t("decidim.proposals.proposals.vote_button.maximum_votes_reached") %> | ||
<% elsif vote_limit_enabled? && remaining_votes_count_for(current_user) <= 0 %> | ||
<%= t("decidim.proposals.proposals.vote_button.no_votes_remaining") %> | ||
<% elsif current_settings.votes_blocked? || !current_component.participatory_space.can_participate?(current_user) %> | ||
<%= t("decidim.proposals.proposals.vote_button.votes_blocked") %> | ||
<% else %> | ||
<%= t("decidim.decidim_awesome.proposal_m.vote_button") %> | ||
<%= t("decidim.decidim_awesome.voting.three_flags.vote_button") %> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 28 additions & 21 deletions
49
app/cells/decidim/decidim_awesome/voting/three_flags_proposal/show.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,35 @@ | ||
<h4 class="heading4 vote-title"><%= t("decidim.decidim_awesome.proposal_m.modal.title") %></h4> | ||
<% if voted_for_any? %> | ||
<h4 class="heading4 vote-title"><%= title %></h4> | ||
|
||
<div class="flex--sbc"> | ||
<%= vote_block_for(proposal, 3) %> | ||
<%= vote_block_for(proposal, 2) %> | ||
<%= vote_block_for(proposal, 1) %> | ||
</div> | ||
|
||
<% if component_settings.three_flags_show_abstain? %> | ||
<%= action_authorized_link_to :vote, | ||
voted_for?(0) ? t("decidim.decidim_awesome.voting.three_flags.abstained") : proposal.manifest.label_for(0), | ||
proposal_vote_path(0), | ||
link_options(0).merge({ | ||
title: t("decidim.decidim_awesome.voting.three_flags.voting_for", type: proposal.manifest.label_for(0)), | ||
class: "button secondary hollow expanded vote-action abstain-button small #{classes_for(0)}" | ||
}) %> | ||
<% end %> | ||
|
||
<% if voted_for_any? && !current_settings.votes_blocked? %> | ||
<p class="text-center"> | ||
<%= action_authorized_link_to :unvote, | ||
"👉 #{t('decidim.decidim_awesome.proposal_m.change_vote')}", | ||
t("decidim.decidim_awesome.voting.three_flags.change_vote"), | ||
proposal_vote_path(current_vote&.weight), | ||
resource: proposal, | ||
remote: true, | ||
method: :delete, | ||
id: "change-vote", | ||
class: "change-vote-button" %> | ||
<% end %> | ||
</p> | ||
|
||
<div class="flex--sbc"> | ||
<%= vote_block_for(proposal, 3, "green") %> | ||
<%= vote_block_for(proposal, 2, "yellow") %> | ||
<%= vote_block_for(proposal, 1, "red") %> | ||
</div> | ||
<% if current_component.settings.proposal_vote_abstain %> | ||
<%= action_authorized_link_to :vote, | ||
t("decidim.decidim_awesome.proposal_m.abstain"), | ||
proposal_vote_path(0), | ||
resource: proposal, | ||
remote: true, | ||
method: :post, | ||
class: "button expanded abstain-button small #{opacity_class_for(0)}" %> | ||
class: "change-vote-button vote-action" %> | ||
</p> | ||
<% elsif proposal.maximum_votes_reached? && !proposal.can_accumulate_supports_beyond_threshold && current_component.participatory_space.can_participate?(current_user) %> | ||
<p class="text-center"><%= t("decidim.proposals.proposals.vote_button.maximum_votes_reached") %></p> | ||
<% elsif vote_limit_enabled? && remaining_votes_count_for(current_user) <= 0 %> | ||
<p class="text-center"><%= t("decidim.proposals.proposals.vote_button.no_votes_remaining") %></p> | ||
<% elsif current_settings.votes_blocked? || !current_component.participatory_space.can_participate?(current_user) %> | ||
<p class="text-center"><%= t("decidim.proposals.proposals.vote_button.votes_blocked") %></p> | ||
<% end %> |
18 changes: 10 additions & 8 deletions
18
app/cells/decidim/decidim_awesome/voting/three_flags_proposal/vote_block_for.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
<div id="vote-container" data-proposal-id="<%= proposal.id %>"> | ||
<div class="vote-block modal" data-modal-id="voteProposalModal<%= proposal.id %>" id="vote-proposal-<%= proposal.id %>-<%= weight %>"> | ||
<p class="vote-count" data-id="<%= proposal.id %>" data-weight="<%= weight %>"><%= proposal_votes(weight) %></p> | ||
<p class="vote-label <%= color %>"><%= color.capitalize %></p> | ||
<div class="vote-block"> | ||
<% unless current_settings.votes_hidden? %> | ||
<p class="vote-count" data-weight="<%= weight %>"><%= proposal_votes(weight) %></p> | ||
<% end %> | ||
<%= action_authorized_link_to :vote, | ||
proposal_vote_path(weight), | ||
resource: proposal, | ||
remote: true, | ||
method: :post, | ||
class: "rectangle voting-block #{color} #{opacity_class_for(weight)} #{'voted' if voted_for?(weight)}" do %> | ||
<%= icon "thumb-up" %> | ||
**link_options(weight) do %> | ||
<span class="vote-label"><%= proposal.manifest.label_for(weight) %></span> | ||
<%= content_tag :svg, role: "img" do | ||
content_tag(:title, t("decidim.decidim_awesome.voting.three_flags.voting_for", type: proposal.manifest.label_for(weight))) + | ||
content_tag(:use, "", "href" => svg_path(weight)) | ||
end %> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 11 additions & 13 deletions
24
app/cells/decidim/decidim_awesome/voting/three_flags_proposal_modal/show.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
<!--the modal window will be used in another pr--> | ||
<div class="reveal vote_proposal_modal voting-three-flag" id="<%= modal_id %>" data-reveal role="dialog" aria-modal="true" aria-labelledby="<%#= modal_id %>-label"> | ||
<div class="reveal vote_proposal_modal voting-three-flag" id="threeFlagsModalHelp" data-reveal role="dialog" aria-modal="true" aria-labelledby="threeFlagsModalHelp-label"> | ||
<div class="reveal__content"> | ||
<p><%= vote_instructions %></p> | ||
<div> | ||
<%= check_box_tag "#{modal_id}-no_more_messages", true, false, id: "#{modal_id}-no-more-messages" %> | ||
<%= label_tag "#{modal_id}-no-more-messages", "Check here to not receive these messages in the future" %> | ||
<div class="instructions"><%= vote_instructions %></div> | ||
<div class="current-choice voting-three-flags"><div class="vote-card"></div></div> | ||
<div class="future-dismiss"> | ||
<%= check_box_tag "three_flag-skip_help", current_component.id, false %> | ||
<%= label_tag "three_flag-skip_help", t("decidim.decidim_awesome.voting.three_flags.modal.skip") %> | ||
</div> | ||
|
||
<div class="text-center"> | ||
<button class="button vote-action"><%= t("decidim.decidim_awesome.voting.three_flags.modal.proceed") %></button> | ||
<button class="button cancel-action hollow secondary" data-close><%= t("decidim.decidim_awesome.voting.three_flags.modal.cancel") %></button> | ||
</div> | ||
</div> | ||
<%= action_authorized_link_to :vote, | ||
proposal_vote_path(weight), | ||
resource: proposal, | ||
remote: true, | ||
method: :post, | ||
class: "button" do %> | ||
Proceed | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.