-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
450 additions
and
111 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
app/controllers/decidim/action_delegator/questions_summary_controller.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,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module ActionDelegator | ||
# This controller handles user profile actions for this module | ||
class QuestionsSummaryController < ActionDelegator::ApplicationController | ||
include Decidim::Consultations::NeedsConsultation | ||
|
||
def show | ||
render partial: "decidim/consultations/question_votes/callout", locals: { consultation: current_consultation } | ||
end | ||
end | ||
end | ||
end |
2 changes: 1 addition & 1 deletion
2
...des/decidim/consultations/admin/consultations/results/add_ongoing_warning.html.erb.deface
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,3 +1,3 @@ | ||
<!-- insert_before '.table-list' --> | ||
|
||
<%= render "decidim/action_delegator/admin/consultations/ongoing_consultation_warning", consultation: current_consultation %> | ||
<%= render "decidim/action_delegator/admin/consultations/ongoing_consultation_warning", consultation: current_consultation %> |
1 change: 0 additions & 1 deletion
1
...errides/decidim/consultations/questions/_vote_button/add_modal_javascript.html.erb.deface
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,4 +1,3 @@ | ||
<!-- insert_before "erb[loud]:contains('javascript_pack_tag')" --> | ||
|
||
<%= javascript_pack_tag "decidim_action_delegator_questions" %> | ||
|
9 changes: 9 additions & 0 deletions
9
app/overrides/layouts/decidim/_consultation_header/add_consultation_callout.html.erb.deface
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,9 @@ | ||
<!-- insert_after '.consultations-home-banner' --> | ||
|
||
<% if user_signed_in? %> | ||
<div id="user-answers-summary" class="row" style="padding:0 1rem;margint-top:-1rem" data-summary-path="<%= decidim_action_delegator.questions_summary_path(current_consultation) %>"> | ||
<%= render "decidim/consultations/question_votes/callout", consultation: current_consultation %> | ||
<%= javascript_pack_tag "decidim_action_delegator_questions_summary" %> | ||
</div> | ||
<% end %> |
9 changes: 9 additions & 0 deletions
9
app/overrides/layouts/decidim/_question_header/add_consultation_callout.html.erb.deface
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,9 @@ | ||
<!-- insert_before 'h2' --> | ||
|
||
<% if user_signed_in? %> | ||
<div id="user-answers-summary" data-summary-path="<%= decidim_action_delegator.questions_summary_path(current_question.consultation) %>"> | ||
<%= render "decidim/consultations/question_votes/callout", consultation: current_question.consultation %> | ||
<%= javascript_pack_tag "decidim_action_delegator_questions_summary" %> | ||
</div> | ||
<% end %> |
1 change: 1 addition & 0 deletions
1
app/packs/entrypoints/decidim_action_delegator_questions_summary.js
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 @@ | ||
import "src/decidim/action_delegator/summary.js"; |
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,24 @@ | ||
$(() => { | ||
const $usersAnswers = $("#user-answers-summary"); | ||
const path = $usersAnswers.data("summaryPath"); | ||
let $button = $("#consultations-questions-summary-button"); | ||
let $modal = $("#consultations-questions-summary-modal"); | ||
const $div = $(".question-vote-cabin").parent(); | ||
const openModal = (evt) => { | ||
evt.preventDefault(); | ||
$modal.foundation("open"); | ||
}; | ||
|
||
$button.on("click", openModal); | ||
|
||
$div.bind("DOMSubtreeModified", function() { | ||
// console.log("tree changed", path); | ||
$usersAnswers.load(path, () => { | ||
$button = $usersAnswers.find("#consultations-questions-summary-button"); | ||
$modal = $usersAnswers.find("#consultations-questions-summary-modal"); | ||
// console.log("usersanswer loaded") | ||
$usersAnswers.foundation(); | ||
$button.on("click", openModal); | ||
}); | ||
}); | ||
}); |
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
14 changes: 9 additions & 5 deletions
14
app/views/decidim/action_delegator/consultations/questions/_link_to_delegations.html.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,11 +1,15 @@ | ||
<% if Decidim::ActionDelegator::Delegation.granted_to?(current_user, question.consultation) %> | ||
<% if has_any_delegate_vote?(question) %> | ||
<div class="delegations-notice flex--cc"> | ||
<%= link_to t("action_delegator.delegations.has_delegations", scope: "decidim"), "#", id: "delegations-button" %> | ||
<div class="delegations-notice flex--cc" style="margin-top:1rem;"> | ||
<button id="delegations-button" class="card__button hollow button small expanded text-white"> | ||
<%= t("action_delegator.delegations.has_delegations", scope: "decidim") %> | ||
</button> | ||
</div> | ||
<% else %> | ||
<div class="delegations-notice flex--cc"> | ||
<%= link_to t("action_delegator.delegations.link", scope: "decidim"), "#", id: "delegations-button" %> | ||
</div> | ||
<div class="delegations-notice flex--cc" style="margin-top:1rem; width: 100%;"> | ||
<button id="delegations-button" class="card__button button small expanded secondary hollow"> | ||
<%= t("action_delegator.delegations.link", scope: "decidim") %> | ||
</button> | ||
</div> | ||
<% end %> | ||
<% end %> |
47 changes: 47 additions & 0 deletions
47
app/views/decidim/consultations/question_votes/_callout.html.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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<% total_published_questions = consultation.questions.published.count %> | ||
<% voted_questions = consultation.questions.published.joins(:votes).where(votes: { author: current_user }).distinct.count(:id) %> | ||
<% alert_class = total_published_questions != voted_questions ? "alert" : "success" %> | ||
|
||
<div class="callout <%= alert_class %>"> | ||
<p> | ||
<%= t("action_delegator.questions.callout_text", scope: "decidim", voted: voted_questions, total: total_published_questions) %> | ||
<a href="#" class="text-primary" id="consultations-questions-summary-button"><%= t("action_delegator.questions.callout_link_text", scope: "decidim") %></a> | ||
</p> | ||
</div> | ||
|
||
<div class="reveal" id="consultations-questions-summary-modal" data-reveal> | ||
<h4><%= t("action_delegator.questions.modal.modal_votes_title", scope: "decidim", title: translated_attribute(consultation.title)) %></h4> | ||
<p class="lead"> | ||
<table class="table-list"> | ||
<thead> | ||
<tr> | ||
<th width="200"><%= t("action_delegator.questions.modal.modal_table_header_question", scope: "decidim") %></th> | ||
<th width="150"><%= t("action_delegator.questions.modal.modal_table_header_answer", scope: "decidim") %></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% consultation.questions.each do |question| %> | ||
<tr> | ||
<td><%= strip_tags(translated_attribute(question.title)).truncate(200, separator: /\s/) %></td> | ||
<td> | ||
<% if question.votes.where(author: current_user).any? %> | ||
<% user_response = question.responses.joins(:votes).find_by(votes: { author: current_user }) %> | ||
<% if user_response %> | ||
<p title="<%= translated_attribute(user_response.title) %>"><%= t("booleans.true") %></p> | ||
<% else %> | ||
<%= link_to t("action_delegator.questions.question_not_answered", scope: "decidim"), decidim_consultations.question_path(question), class: "text-primary" %> | ||
<% end %> | ||
<% else %> | ||
<%= link_to t("action_delegator.questions.question_not_answered", scope: "decidim"), decidim_consultations.question_path(question), class: "text-primary" %> | ||
<% end %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</p> | ||
<button class="close-button" data-close aria-label="Close modal" type="button"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</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.