forked from decidim/decidim
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from AjuntamentdeBarcelona/fix/budget-modal-de…
…tail Fix modal pop up when project exceeds budget amount
- Loading branch information
Showing
6 changed files
with
38 additions
and
75 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
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
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
File renamed without changes.
10 changes: 10 additions & 0 deletions
10
decidim-budgets/app/cells/decidim/budgets/project_vote_button_cell.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,10 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Budgets | ||
# This cell renders an authorized_action button | ||
# to vote a given instance of a Project in a budget list | ||
class ProjectVoteButtonCell < ProjectListItemCell | ||
end | ||
end | ||
end |
63 changes: 12 additions & 51 deletions
63
decidim-budgets/app/views/decidim/budgets/projects/_project_budget_button.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,54 +1,15 @@ | ||
<div id="project-<%= project.id %>-budget-button"> | ||
<% if voted_for?(project) %> | ||
<%= action_authorized_button_to( | ||
"vote", | ||
budget_order_line_item_path(budget, project_id: project), | ||
method: :delete, | ||
remote: true, | ||
data: { | ||
disable: true, | ||
budget: project.budget_amount, | ||
"redirect-url": budget_project_path(budget, project) | ||
}, | ||
disabled: !can_have_order? || current_order_checked_out?, | ||
class: "button expanded button--sc budget-vote-button added", | ||
"aria-label": t(".added_descriptive", resource_name: translated_attribute(project.title)) | ||
) do %> | ||
|
||
<span> | ||
<%= t(".added") %> | ||
</span> | ||
<span class="icon-wrapper"> | ||
<%= icon "x", class: "icon--small", role: "img" %> | ||
</span> | ||
<% end %> | ||
<% elsif current_user.present? %> | ||
<%= action_authorized_button_to( | ||
"vote", | ||
budget_order_line_item_path(budget, project_id: project), | ||
method: :post, | ||
remote: true, | ||
data: { | ||
disable: true, | ||
budget: project.budget_amount, | ||
add: true, | ||
"redirect-url": budget_project_path(budget, project) | ||
}, | ||
disabled: !can_have_order? || current_order_checked_out?, | ||
class: "button expanded button--sc budget-vote-button hollow", | ||
"aria-label": t(".add_descriptive", resource_name: translated_attribute(project.title)) | ||
) do %> | ||
|
||
<span> | ||
<%= t(".add") %> | ||
</span> | ||
<span class="icon-wrapper"> | ||
<%= icon "check", class: "icon--small", role: "img" %> | ||
</span> | ||
<% end %> | ||
<% else %> | ||
<% if current_user.blank? %> | ||
<div id="project-<%= project.id %>-budget-button"> | ||
<button class="button expanded button--sc" data-toggle="loginModal"> | ||
<%= t(".add") %> | ||
</button> | ||
<% end %> | ||
</div> | ||
</div> | ||
<% else %> | ||
<div id="project-<%= project.id %>-budget-button" class="<%= "added" if voted_for?(project) %> button expanded button--sc budget-vote-button budget-list__data"> | ||
<span> | ||
<%= t(voted_for?(project) ? ".added" : ".add") %> | ||
</span> | ||
|
||
<%= cell("decidim/budgets/project_vote_button", project) %> | ||
</div> | ||
<% end %> |