Skip to content

Commit

Permalink
fix: JS incompatibility between budgets-category & budget-booth (#540)
Browse files Browse the repository at this point in the history
* fix: Add JS compatibility

* fix: Override budgets booth update_budget.js

* fix: Merge budget category & budget booth

* chore: Change PTP's module branch
  • Loading branch information
Quentinchampenois authored and moustachu committed Jun 14, 2024
1 parent 3f84e32 commit 7be6655
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ GIT

GIT
remote: https://github.com/OpenSourcePolitics/decidim-module-ptp.git
revision: 025a22755afc4ca3cec4c6fef65adebe1b26110c
revision: 347e46f850ea47772d2c9fe7fd7a10405b38011b
specs:
decidim-budgets_booth (0.27.0)
decidim-budgets (~> 0.27.0)
Expand Down
45 changes: 45 additions & 0 deletions app/views/decidim/budgets/line_items/update_budget.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
var $orderTotalBudget = $('#order-total-budget');
var $orderSelectedProjects = $('#order-selected-projects');
var $orderProgress = $('#order-progress');
var $projectItem = $('#project-<%= project.id %>-item');
var $projectBudgetButton = $('#project-<%= project.id %>-budget-button');
var $budgetConfirm = $('#budget-confirm');
var $projectModal = $('#project-modal-<%= project.id %>');

morphdom($orderTotalBudget[0], '<%= j(render partial: "decidim/budgets/projects/order_total_budget").strip.html_safe %>');
morphdom($orderSelectedProjects[0], '<%= j(render partial: "decidim/budgets/projects/order_selected_projects").strip.html_safe %>');
morphdom($orderProgress[0], '<%= j(render partial: "decidim/budgets/projects/order_progress").strip.html_safe %>');
morphdom($budgetConfirm[0], '<%= j(render partial: "decidim/budgets/projects/budget_confirm").strip.html_safe %>');

<% current_order.categories.each do |category| %>
var $votingSummary = $(`.vote_by_category[data-category-id=<%= category.id %>]`);
morphdom($votingSummary[0], '<%= j(cell(category.card_class, category)).strip.html_safe %>');
<% end %>

$("#order-progress").foundation();
$(".budget-summary__selected").foundation();

if ($projectItem.length > 0) {
morphdom($projectItem[0], '<%= j(render partial: "decidim/budgets/projects/project", locals: { project: project }).strip.html_safe %>');
}

if ($projectBudgetButton.length > 0) {
morphdom($projectBudgetButton[0], '<%= j(render partial: "decidim/budgets/projects/project_budget_button", locals: { project: project }).strip.html_safe %>');
}

if ($projectModal.length > 0) {
var $projectModalButtonForm = $(".project-vote-button", $projectModal).parent();
morphdom($projectModalButtonForm[0], '<%= j(cell("decidim/budgets/project_vote_button", project, scale_up: true)).strip.html_safe %>');
}

if ($projectModal.length > 0 && $projectModal.attr("aria-hidden") === "false") {
$(".project-vote-button", $projectModal).focus();
} else {
$(".project-vote-button", $projectItem).focus();
}

<% if @show_help_modal %>
$("#voting-help").foundation("open");
<% end %>

window.DecidimBudgets.checkProgressPosition();

0 comments on commit 7be6655

Please sign in to comment.