decidim-budgets 0.30.3 → 0.31.0.rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/app/cells/decidim/budgets/budget_list_item/show.erb +19 -9
 - data/app/cells/decidim/budgets/budget_list_item/vote_action.erb +2 -2
 - data/app/cells/decidim/budgets/budget_list_item_cell.rb +44 -10
 - data/app/cells/decidim/budgets/budgets_list/card_list.erb +0 -2
 - data/app/cells/decidim/budgets/budgets_list/main_list.erb +2 -2
 - data/app/cells/decidim/budgets/budgets_list/show.erb +3 -3
 - data/app/cells/decidim/budgets/budgets_list/voted.erb +12 -10
 - data/app/cells/decidim/budgets/budgets_list_cell.rb +22 -0
 - data/app/cells/decidim/budgets/project_budget_amount_cell.rb +14 -0
 - data/app/cells/decidim/budgets/project_l/extra_data.erb +8 -2
 - data/app/cells/decidim/budgets/project_l/metadata.erb +1 -1
 - data/app/cells/decidim/budgets/project_l_cell.rb +2 -4
 - data/app/cells/decidim/budgets/project_metadata_cell.rb +15 -19
 - data/app/cells/decidim/budgets/project_selected_status_cell.rb +1 -11
 - data/app/cells/decidim/budgets/project_vote_button/show.erb +5 -5
 - data/app/cells/decidim/budgets/project_vote_button_cell.rb +14 -9
 - data/app/cells/decidim/budgets/project_votes_count_cell.rb +8 -14
 - data/app/commands/decidim/budgets/cancel_order.rb +5 -0
 - data/app/controllers/decidim/budgets/admin/budgets_controller.rb +2 -2
 - data/app/controllers/decidim/budgets/admin/projects_controller.rb +2 -2
 - data/app/controllers/decidim/budgets/admin/proposals_imports_controller.rb +1 -1
 - data/app/controllers/decidim/budgets/application_controller.rb +13 -1
 - data/app/controllers/decidim/budgets/budgets_controller.rb +1 -3
 - data/app/controllers/decidim/budgets/line_items_controller.rb +19 -0
 - data/app/controllers/decidim/budgets/orders_controller.rb +20 -0
 - data/app/controllers/decidim/budgets/projects_controller.rb +3 -1
 - data/app/forms/decidim/budgets/admin/component_form.rb +4 -30
 - data/app/helpers/decidim/budgets/application_helper.rb +1 -0
 - data/app/helpers/decidim/budgets/projects_helper.rb +11 -7
 - data/app/models/decidim/budgets/order.rb +2 -2
 - data/app/packs/entrypoints/decidim_budgets.js +1 -0
 - data/app/packs/src/decidim/budgets/admin/projects.js +2 -2
 - data/app/packs/src/decidim/budgets/budgetSummaryBackdrop.js +41 -0
 - data/app/packs/src/decidim/budgets/exit_handler.js +7 -2
 - data/app/packs/src/decidim/budgets/progressFixed.js +1 -1
 - data/app/packs/src/decidim/budgets/projects.js +1 -1
 - data/app/packs/stylesheets/budgets.scss +57 -37
 - data/app/permissions/decidim/budgets/permissions.rb +17 -13
 - data/app/presenters/decidim/budgets/project_presenter.rb +2 -4
 - data/app/views/decidim/budgets/admin/budgets/_actions.html.erb +65 -18
 - data/app/views/decidim/budgets/admin/budgets/_budget-tr.html.erb +4 -4
 - data/app/views/decidim/budgets/admin/budgets/_form.html.erb +1 -1
 - data/app/views/decidim/budgets/admin/budgets/index.html.erb +14 -11
 - data/app/views/decidim/budgets/admin/budgets/manage_trash.html.erb +2 -1
 - data/app/views/decidim/budgets/admin/projects/_actions.html.erb +66 -22
 - data/app/views/decidim/budgets/admin/projects/_bulk-actions.html.erb +15 -17
 - data/app/views/decidim/budgets/admin/projects/_form.html.erb +1 -1
 - data/app/views/decidim/budgets/admin/projects/_project-tr.html.erb +7 -7
 - data/app/views/decidim/budgets/admin/projects/bulk_actions/_dropdown.html.erb +23 -30
 - data/app/views/decidim/budgets/admin/projects/index.html.erb +2 -2
 - data/app/views/decidim/budgets/admin/projects/manage_trash.html.erb +2 -1
 - data/app/views/decidim/budgets/line_items/update_budget.js.erb +6 -5
 - data/app/views/decidim/budgets/orders/status.html.erb +30 -30
 - data/app/views/decidim/budgets/projects/_addition_selector.html.erb +1 -1
 - data/app/views/decidim/budgets/projects/_budget_summary.html.erb +5 -1
 - data/app/views/decidim/budgets/projects/_exit_modal.html.erb +1 -1
 - data/app/views/decidim/budgets/projects/_project.html.erb +5 -1
 - data/app/views/decidim/budgets/projects/_project_budget_button.html.erb +1 -9
 - data/app/views/decidim/budgets/projects/_projects.html.erb +3 -1
 - data/app/views/decidim/budgets/projects/index.html.erb +28 -6
 - data/app/views/decidim/budgets/projects/order_progress_summary/_content.html.erb +30 -0
 - data/app/views/decidim/budgets/projects/order_progress_summary/_content_responsive.html.erb +56 -0
 - data/app/views/decidim/budgets/projects/order_progress_summary/_progress_box.html.erb +43 -0
 - data/app/views/decidim/budgets/projects/order_progress_summary/_progress_box_buttons.html.erb +12 -0
 - data/app/views/decidim/budgets/projects/order_progress_summary/_progress_box_sticky.html.erb +25 -0
 - data/app/views/decidim/budgets/projects/show.html.erb +30 -17
 - data/config/assets.rb +2 -2
 - data/config/locales/ar.yml +0 -8
 - data/config/locales/bg.yml +2 -18
 - data/config/locales/ca-IT.yml +26 -14
 - data/config/locales/ca.yml +26 -14
 - data/config/locales/cs.yml +21 -18
 - data/config/locales/de.yml +26 -14
 - data/config/locales/el.yml +0 -7
 - data/config/locales/en.yml +26 -14
 - data/config/locales/es-MX.yml +26 -14
 - data/config/locales/es-PY.yml +26 -14
 - data/config/locales/es.yml +25 -13
 - data/config/locales/eu.yml +26 -14
 - data/config/locales/fi-plain.yml +26 -14
 - data/config/locales/fi.yml +26 -14
 - data/config/locales/fr-CA.yml +26 -14
 - data/config/locales/fr.yml +26 -14
 - data/config/locales/ga-IE.yml +0 -5
 - data/config/locales/gl.yml +0 -7
 - data/config/locales/hu.yml +2 -18
 - data/config/locales/id-ID.yml +0 -7
 - data/config/locales/is-IS.yml +0 -6
 - data/config/locales/it.yml +0 -7
 - data/config/locales/ja.yml +26 -14
 - data/config/locales/kaa.yml +0 -1
 - data/config/locales/ko.yml +0 -5
 - data/config/locales/lb.yml +0 -7
 - data/config/locales/lt.yml +2 -18
 - data/config/locales/lv.yml +0 -7
 - data/config/locales/nl.yml +0 -7
 - data/config/locales/no.yml +0 -7
 - data/config/locales/pl.yml +2 -18
 - data/config/locales/pt-BR.yml +2 -18
 - data/config/locales/pt.yml +0 -7
 - data/config/locales/ro-RO.yml +7 -7
 - data/config/locales/ru.yml +0 -7
 - data/config/locales/sk.yml +0 -7
 - data/config/locales/sq-AL.yml +0 -3
 - data/config/locales/sv.yml +25 -13
 - data/config/locales/tr-TR.yml +0 -8
 - data/config/locales/uk.yml +0 -7
 - data/config/locales/zh-CN.yml +0 -8
 - data/config/locales/zh-TW.yml +0 -7
 - data/db/migrate/20250912110212_move_voting_rules_to_radio_buttons.rb +22 -0
 - data/lib/decidim/api/budget_type.rb +7 -0
 - data/lib/decidim/api/project_type.rb +29 -1
 - data/lib/decidim/budgets/budget_order_pdf.rb +73 -0
 - data/lib/decidim/budgets/component.rb +26 -13
 - data/lib/decidim/budgets/engine.rb +3 -11
 - data/lib/decidim/budgets/seeds.rb +16 -5
 - data/lib/decidim/budgets/test/factories.rb +3 -18
 - data/lib/decidim/budgets/version.rb +1 -1
 - data/lib/decidim/budgets/workflows/base.rb +0 -14
 - data/lib/decidim/budgets.rb +1 -5
 - metadata +21 -15
 - data/app/queries/decidim/budgets/metrics/budget_followers_metric_measure.rb +0 -32
 - data/app/queries/decidim/budgets/metrics/budget_participants_metric_measure.rb +0 -27
 - data/app/views/decidim/budgets/projects/_order_progress_summary_content.html.erb +0 -122
 - /data/app/views/decidim/budgets/projects/{_order_progress_progressbar_marks_right.html.erb → order_progress_summary/_progressbar_marks_right.html.erb} +0 -0
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 20d4fb24b4a1f49b2ca49af36c7f003191fc9d52d41fae007572fe19c91a7806
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: edf7bd92c9b86e551d90f20ba1899d85bbf935feba50a8aeb6b3a1e6b6820bcb
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 90a2d923c01553686d6476819c54cff399ac1b37dbea289eb7c4ed4152af3b7d075f7aa47099277f548c77cbc716e2b6bb0bf0c89ea81c4bc5d583df6d94ff82
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 76364a19e54acc61d46055c7223ee442dcf2a0611b7b34f1a1cb50918cc8919d0f4f0d90c708ec9731d4c5acc92c1d80252c8809a1ae262a8b01ad63fd13c3d5
         
     | 
| 
         @@ -5,7 +5,16 @@ 
     | 
|
| 
       5 
5 
     | 
    
         
             
                    <%= decidim_escape_translated(title) %>
         
     | 
| 
       6 
6 
     | 
    
         
             
                  </h3>
         
     | 
| 
       7 
7 
     | 
    
         
             
                  <% if voted? %>
         
     | 
| 
       8 
     | 
    
         
            -
                     
     | 
| 
      
 8 
     | 
    
         
            +
                    <div class="float-right">
         
     | 
| 
      
 9 
     | 
    
         
            +
                      <%= icon "check-double-line", class: "inline-block align-middle fill-success ml-2 h-[1.5em] w-[1.5em]" %>
         
     | 
| 
      
 10 
     | 
    
         
            +
                      <span class="text-success font-bold"><%= t("completed", scope: "decidim.budgets.budgets_list") %></span>
         
     | 
| 
      
 11 
     | 
    
         
            +
                    </div>
         
     | 
| 
      
 12 
     | 
    
         
            +
                  <% end %>
         
     | 
| 
      
 13 
     | 
    
         
            +
                  <% if progress? %>
         
     | 
| 
      
 14 
     | 
    
         
            +
                    <div class="float-right">
         
     | 
| 
      
 15 
     | 
    
         
            +
                      <%= icon "progress-2-line", class: "inline-block align-middle fill-warning ml-2 h-[1.5em] w-[1.5em]" %>
         
     | 
| 
      
 16 
     | 
    
         
            +
                      <span class="text-warning font-bold"><%= t("incomplete", scope: "decidim.budgets.budgets_list") %></span>
         
     | 
| 
      
 17 
     | 
    
         
            +
                    </div>
         
     | 
| 
       9 
18 
     | 
    
         
             
                  <% end %>
         
     | 
| 
       10 
19 
     | 
    
         
             
                  <div class="my-2">
         
     | 
| 
       11 
20 
     | 
    
         
             
                    <%= decidim_sanitize html_truncate(translated_attribute(description), length: 70) %>
         
     | 
| 
         @@ -24,20 +33,21 @@ 
     | 
|
| 
       24 
33 
     | 
    
         
             
                  </div>
         
     | 
| 
       25 
34 
     | 
    
         
             
                <% end %>
         
     | 
| 
       26 
35 
     | 
    
         
             
              </div>
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
       27 
37 
     | 
    
         
             
              <% if voting_context? %>
         
     | 
| 
       28 
     | 
    
         
            -
                <%=  
     | 
| 
      
 38 
     | 
    
         
            +
                <%= link_to_resource_or_vote("budget__card__highlight-vote") do %>
         
     | 
| 
       29 
39 
     | 
    
         
             
                  <div class="budget__card__highlight-vote__header">
         
     | 
| 
       30 
     | 
    
         
            -
                    <span class="budget__card__highlight-vote__text">
         
     | 
| 
       31 
     | 
    
         
            -
                      <%= t("name", scope: "decidim.budgets.admin.models.budget") %>
         
     | 
| 
       32 
     | 
    
         
            -
                    </span>
         
     | 
| 
       33 
40 
     | 
    
         
             
                    <span class="budget__card__highlight-vote__number">
         
     | 
| 
       34 
41 
     | 
    
         
             
                      <%= budget_to_currency(total_budget) %>
         
     | 
| 
       35 
42 
     | 
    
         
             
                    </span>
         
     | 
| 
       36 
43 
     | 
    
         
             
                  </div>
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
                    <%=  
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                  <div class="w-2/3 px-4">
         
     | 
| 
      
 46 
     | 
    
         
            +
                    <%= button_tag class: button_class do %>
         
     | 
| 
      
 47 
     | 
    
         
            +
                      <span><%= button_text %></span>
         
     | 
| 
      
 48 
     | 
    
         
            +
                      <%= icon "arrow-right-line" %>
         
     | 
| 
      
 49 
     | 
    
         
            +
                    <% end %>
         
     | 
| 
      
 50 
     | 
    
         
            +
                  </div>
         
     | 
| 
       41 
51 
     | 
    
         
             
                <% end %>
         
     | 
| 
       42 
52 
     | 
    
         
             
              <% end %>
         
     | 
| 
       43 
53 
     | 
    
         
             
            </div>
         
     | 
| 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <% if voted? %>
         
     | 
| 
      
 1 
     | 
    
         
            +
            <% if voted? && voting_open? %>
         
     | 
| 
       2 
2 
     | 
    
         
             
              <%= link_to(
         
     | 
| 
       3 
3 
     | 
    
         
             
                    budget_order_path(budget),
         
     | 
| 
       4 
4 
     | 
    
         
             
                    method: :delete,
         
     | 
| 
         @@ -6,7 +6,7 @@ 
     | 
|
| 
       6 
6 
     | 
    
         
             
                    data: { confirm: t(:are_you_sure, scope: "decidim.budgets.projects.budget_summary") }
         
     | 
| 
       7 
7 
     | 
    
         
             
                  ) do %>
         
     | 
| 
       8 
8 
     | 
    
         
             
                  <%= icon "delete-bin-line", class: "inline-block align-middle text-gray fill-secondary" %>
         
     | 
| 
       9 
     | 
    
         
            -
                  <span class="inline-block align-middle  
     | 
| 
      
 9 
     | 
    
         
            +
                  <span class="inline-block align-middle text-secondary font-semibold">
         
     | 
| 
       10 
10 
     | 
    
         
             
                    <%= t("cancel_order", scope: "decidim.budgets.projects.budget_summary") %>
         
     | 
| 
       11 
11 
     | 
    
         
             
                  </span>
         
     | 
| 
       12 
12 
     | 
    
         
             
              <% end %>
         
     | 
| 
         @@ -7,6 +7,7 @@ module Decidim 
     | 
|
| 
       7 
7 
     | 
    
         
             
                  include Decidim::Budgets::ProjectsHelper
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                  delegate :highlighted, to: :current_workflow
         
     | 
| 
      
 10 
     | 
    
         
            +
                  delegate :voting_finished?, to: :controller
         
     | 
| 
       10 
11 
     | 
    
         | 
| 
       11 
12 
     | 
    
         
             
                  property :title, :description, :total_budget
         
     | 
| 
       12 
13 
     | 
    
         
             
                  alias budget model
         
     | 
| 
         @@ -14,13 +15,12 @@ module Decidim 
     | 
|
| 
       14 
15 
     | 
    
         
             
                  private
         
     | 
| 
       15 
16 
     | 
    
         | 
| 
       16 
17 
     | 
    
         
             
                  def card_class
         
     | 
| 
       17 
     | 
    
         
            -
                     
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
                    end.join(" ")
         
     | 
| 
      
 18 
     | 
    
         
            +
                    css_classes = "card--list__item"
         
     | 
| 
      
 19 
     | 
    
         
            +
                    css_classes += " budget__card__list-budget--highlighted" if highlighted?
         
     | 
| 
      
 20 
     | 
    
         
            +
                    css_classes += " budget__card__list-budget--progress" if progress?
         
     | 
| 
      
 21 
     | 
    
         
            +
                    css_classes += " budget__card__list-budget--voted" if voted?
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                    css_classes
         
     | 
| 
       24 
24 
     | 
    
         
             
                  end
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
                  def link_class
         
     | 
| 
         @@ -32,7 +32,7 @@ module Decidim 
     | 
|
| 
       32 
32 
     | 
    
         
             
                  end
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
                  def progress?
         
     | 
| 
       35 
     | 
    
         
            -
                    current_user && status == :progress
         
     | 
| 
      
 35 
     | 
    
         
            +
                    current_user && status == :progress && voting_open?
         
     | 
| 
       36 
36 
     | 
    
         
             
                  end
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
38 
     | 
    
         
             
                  def highlighted?
         
     | 
| 
         @@ -43,12 +43,38 @@ module Decidim 
     | 
|
| 
       43 
43 
     | 
    
         
             
                    @status ||= current_workflow.status(budget)
         
     | 
| 
       44 
44 
     | 
    
         
             
                  end
         
     | 
| 
       45 
45 
     | 
    
         | 
| 
      
 46 
     | 
    
         
            +
                  # If the voting is open, then do the link for the authorized focus mode
         
     | 
| 
      
 47 
     | 
    
         
            +
                  # If not (i.e. voting is disabled or finished), then link to the resource itself
         
     | 
| 
      
 48 
     | 
    
         
            +
                  def link_to_resource_or_vote(css_class)
         
     | 
| 
      
 49 
     | 
    
         
            +
                    if voting_open?
         
     | 
| 
      
 50 
     | 
    
         
            +
                      action_authorized_link_to "vote",
         
     | 
| 
      
 51 
     | 
    
         
            +
                                                budget_projects_path(budget, start_voting: true),
         
     | 
| 
      
 52 
     | 
    
         
            +
                                                resource: budget,
         
     | 
| 
      
 53 
     | 
    
         
            +
                                                data: { "redirect-url": budget_projects_path(budget) },
         
     | 
| 
      
 54 
     | 
    
         
            +
                                                class: css_class do
         
     | 
| 
      
 55 
     | 
    
         
            +
                        yield
         
     | 
| 
      
 56 
     | 
    
         
            +
                      end
         
     | 
| 
      
 57 
     | 
    
         
            +
                    else
         
     | 
| 
      
 58 
     | 
    
         
            +
                      link_to resource_path, class: css_class do
         
     | 
| 
      
 59 
     | 
    
         
            +
                        yield
         
     | 
| 
      
 60 
     | 
    
         
            +
                      end
         
     | 
| 
      
 61 
     | 
    
         
            +
                    end
         
     | 
| 
      
 62 
     | 
    
         
            +
                  end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
       46 
64 
     | 
    
         
             
                  def button_class
         
     | 
| 
       47 
     | 
    
         
            -
                    " 
     | 
| 
      
 65 
     | 
    
         
            +
                    css_classes = "button button__sm w-full budget__card__highlight-vote__button "
         
     | 
| 
      
 66 
     | 
    
         
            +
                    css_classes += voted? ? "button__transparent-secondary" : "button__secondary"
         
     | 
| 
      
 67 
     | 
    
         
            +
                    css_classes += " hollow" if voted? || !highlighted?
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                    css_classes
         
     | 
| 
       48 
70 
     | 
    
         
             
                  end
         
     | 
| 
       49 
71 
     | 
    
         | 
| 
       50 
72 
     | 
    
         
             
                  def button_text
         
     | 
| 
       51 
     | 
    
         
            -
                    key = if  
     | 
| 
      
 73 
     | 
    
         
            +
                    key = if voting_disabled?
         
     | 
| 
      
 74 
     | 
    
         
            +
                            :see_projects
         
     | 
| 
      
 75 
     | 
    
         
            +
                          elsif voting_finished?
         
     | 
| 
      
 76 
     | 
    
         
            +
                            :see_results
         
     | 
| 
      
 77 
     | 
    
         
            +
                          elsif voting_allowed? && !voted?
         
     | 
| 
       52 
78 
     | 
    
         
             
                            progress? ? :progress : :vote
         
     | 
| 
       53 
79 
     | 
    
         
             
                          else
         
     | 
| 
       54 
80 
     | 
    
         
             
                            :show
         
     | 
| 
         @@ -75,6 +101,14 @@ module Decidim 
     | 
|
| 
       75 
101 
     | 
    
         
             
                    @component ||= controller.try(:current_component) || budget.component
         
     | 
| 
       76 
102 
     | 
    
         
             
                  end
         
     | 
| 
       77 
103 
     | 
    
         | 
| 
      
 104 
     | 
    
         
            +
                  def voting_disabled?
         
     | 
| 
      
 105 
     | 
    
         
            +
                    current_settings.votes == "disabled"
         
     | 
| 
      
 106 
     | 
    
         
            +
                  end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                  def voting_allowed?
         
     | 
| 
      
 109 
     | 
    
         
            +
                    current_workflow.vote_allowed?(budget)
         
     | 
| 
      
 110 
     | 
    
         
            +
                  end
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
       78 
112 
     | 
    
         
             
                  def voting_context?
         
     | 
| 
       79 
113 
     | 
    
         
             
                    controller.respond_to?(:voting_finished?)
         
     | 
| 
       80 
114 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -1,5 +1,5 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <h2 class="h5 md:h3 decorator"><%= t(:count, scope: i18n_scope, count:  
     | 
| 
      
 1 
     | 
    
         
            +
            <h2 class="h5 md:h3 decorator"><%= t(:count, scope: i18n_scope, count: (highlighted + non_highlighted).length) %></h2>
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
            <%= render partial: "decidim/shared/orders", formats: [:html], locals: { orders: AVAILABLE_ORDERS, i18n_scope: "decidim.budgets.budgets_list.orders", css_class: "items-start ml-6", b_css_class: "!justify-start pb-0 pl-0" } %>
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            <%= render :card_list %>
         
     | 
| 
         @@ -1,12 +1,12 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <% if  
     | 
| 
       2 
     | 
    
         
            -
              <h2 class="h5 md:h3 decorator 
     | 
| 
      
 1 
     | 
    
         
            +
            <% if voted? || progress? %>
         
     | 
| 
      
 2 
     | 
    
         
            +
              <h2 class="h5 md:h3 decorator">
         
     | 
| 
       3 
3 
     | 
    
         
             
                <%= t("voted_budgets", scope: "decidim.budgets.budgets_list") %>
         
     | 
| 
       4 
4 
     | 
    
         
             
              </h2>
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
              <%= render :voted %>
         
     | 
| 
       7 
7 
     | 
    
         
             
            <% end %>
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
            <% if  
     | 
| 
      
 9 
     | 
    
         
            +
            <% if non_voted_budgets.any? %>
         
     | 
| 
       10 
10 
     | 
    
         
             
              <div id="budgets" class="card__list-list !space-y-5 w-full">
         
     | 
| 
       11 
11 
     | 
    
         
             
                <%= main_list %>
         
     | 
| 
       12 
12 
     | 
    
         
             
              </div>
         
     | 
| 
         @@ -1,13 +1,15 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
              <p><%= t(:voted_on, scope: i18n_scope, links: budgets_link_list(voted)) %></p>
         
     | 
| 
      
 1 
     | 
    
         
            +
            <p><%= t(:voted_on, scope: i18n_scope, links: budgets_link_list(voted)) %></p>
         
     | 
| 
       3 
2 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
                <% end %>
         
     | 
| 
       8 
     | 
    
         
            -
              </div>
         
     | 
| 
      
 3 
     | 
    
         
            +
            <% if finished? %>
         
     | 
| 
      
 4 
     | 
    
         
            +
              <%= cell("decidim/announcement", { body: t(:finished_message, scope: i18n_scope) }, callout_class: "success w-full") %>
         
     | 
| 
      
 5 
     | 
    
         
            +
            <% end %>
         
     | 
| 
       9 
6 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
            <div id="voted-budgets" class="card__list-list w-full">
         
     | 
| 
      
 8 
     | 
    
         
            +
              <% voted.each do |budget| %>
         
     | 
| 
      
 9 
     | 
    
         
            +
                <%= cell("decidim/budgets/budget_list_item", budget) %>
         
     | 
| 
       12 
10 
     | 
    
         
             
              <% end %>
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              <% progress_budgets.each do |budget| %>
         
     | 
| 
      
 13 
     | 
    
         
            +
                <%= cell("decidim/budgets/budget_list_item", budget) %>
         
     | 
| 
      
 14 
     | 
    
         
            +
              <% end %>
         
     | 
| 
      
 15 
     | 
    
         
            +
            </div>
         
     | 
| 
         @@ -26,6 +26,18 @@ module Decidim 
     | 
|
| 
       26 
26 
     | 
    
         | 
| 
       27 
27 
     | 
    
         
             
                  private
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
      
 29 
     | 
    
         
            +
                  def progress?
         
     | 
| 
      
 30 
     | 
    
         
            +
                    current_user && voting_open? && progress_budgets.any?
         
     | 
| 
      
 31 
     | 
    
         
            +
                  end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                  def progress_budgets
         
     | 
| 
      
 34 
     | 
    
         
            +
                    budgets.select { |budget| current_workflow.status(budget) == :progress }
         
     | 
| 
      
 35 
     | 
    
         
            +
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  def non_voted_budgets
         
     | 
| 
      
 38 
     | 
    
         
            +
                    budgets.where.not(id: voted.map(&:id))
         
     | 
| 
      
 39 
     | 
    
         
            +
                  end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
       29 
41 
     | 
    
         
             
                  def highlighted?
         
     | 
| 
       30 
42 
     | 
    
         
             
                    current_user && highlighted.any?
         
     | 
| 
       31 
43 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -34,6 +46,16 @@ module Decidim 
     | 
|
| 
       34 
46 
     | 
    
         
             
                    current_user && voted.any?
         
     | 
| 
       35 
47 
     | 
    
         
             
                  end
         
     | 
| 
       36 
48 
     | 
    
         | 
| 
      
 49 
     | 
    
         
            +
                  def non_highlighted
         
     | 
| 
      
 50 
     | 
    
         
            +
                    budgets_to_exclude = if voting_finished?
         
     | 
| 
      
 51 
     | 
    
         
            +
                                           highlighted + voted
         
     | 
| 
      
 52 
     | 
    
         
            +
                                         else
         
     | 
| 
      
 53 
     | 
    
         
            +
                                           highlighted + voted + progress_budgets
         
     | 
| 
      
 54 
     | 
    
         
            +
                                         end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                    reorder(budgets).where.not(id: budgets_to_exclude.map(&:id))
         
     | 
| 
      
 57 
     | 
    
         
            +
                  end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
       37 
59 
     | 
    
         
             
                  def finished?
         
     | 
| 
       38 
60 
     | 
    
         
             
                    return unless budgets.any?
         
     | 
| 
       39 
61 
     | 
    
         | 
| 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Decidim
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Budgets
         
     | 
| 
      
 5 
     | 
    
         
            +
                # This cell renders the project budget amount
         
     | 
| 
      
 6 
     | 
    
         
            +
                class ProjectBudgetAmountCell < Decidim::ViewModel
         
     | 
| 
      
 7 
     | 
    
         
            +
                  delegate :voting_finished?, to: :controller
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  def show
         
     | 
| 
      
 10 
     | 
    
         
            +
                    budget_to_currency(model.budget_amount)
         
     | 
| 
      
 11 
     | 
    
         
            +
                  end
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,6 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            <div class="budget__card__list-project">
         
     | 
| 
       2 
2 
     | 
    
         
             
              <span class="budget__card__list-project__amount">
         
     | 
| 
       3 
     | 
    
         
            -
                 
     | 
| 
      
 3 
     | 
    
         
            +
                <% if show_votes_count? %>
         
     | 
| 
      
 4 
     | 
    
         
            +
                  <%= cell "decidim/budgets/project_votes_count", project, layout: :with_count_label %>
         
     | 
| 
      
 5 
     | 
    
         
            +
                <% else %>
         
     | 
| 
      
 6 
     | 
    
         
            +
                  <%= budget_to_currency_with_html(project.budget_amount) %>
         
     | 
| 
      
 7 
     | 
    
         
            +
                <% end %>
         
     | 
| 
       4 
8 
     | 
    
         
             
              </span>
         
     | 
| 
       5 
     | 
    
         
            -
               
     | 
| 
      
 9 
     | 
    
         
            +
              <% if voting_open? %>
         
     | 
| 
      
 10 
     | 
    
         
            +
                <%= cell("decidim/budgets/project_vote_button", project, show_only_added:) %>
         
     | 
| 
      
 11 
     | 
    
         
            +
              <% end %>
         
     | 
| 
       6 
12 
     | 
    
         
             
            </div>
         
     | 
| 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            <div class="card__list-metadata">
         
     | 
| 
       2 
2 
     | 
    
         
             
              <%= cell metadata_cell, project %>
         
     | 
| 
       3 
3 
     | 
    
         
             
            </div>
         
     | 
| 
       4 
     | 
    
         
            -
            <%= cell("decidim/budgets/project_voted_hint", project, class: "margin-left-1") if current_order_checked_out? && resource_added? %>
         
     | 
| 
      
 4 
     | 
    
         
            +
            <%= cell("decidim/budgets/project_voted_hint", project, class: "margin-left-1") if current_order_checked_out? && resource_added?(project) %>
         
     | 
| 
         @@ -9,6 +9,8 @@ module Decidim 
     | 
|
| 
       9 
9 
     | 
    
         
             
                class ProjectLCell < Decidim::CardLCell
         
     | 
| 
       10 
10 
     | 
    
         
             
                  include Decidim::Budgets::ProjectsHelper
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
      
 12 
     | 
    
         
            +
                  delegate :voting_open?, :resource_added?, to: :controller
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
       12 
14 
     | 
    
         
             
                  alias project model
         
     | 
| 
       13 
15 
     | 
    
         | 
| 
       14 
16 
     | 
    
         
             
                  private
         
     | 
| 
         @@ -17,10 +19,6 @@ module Decidim 
     | 
|
| 
       17 
19 
     | 
    
         
             
                    resource_locator([project.budget, project]).path(url_extra_params)
         
     | 
| 
       18 
20 
     | 
    
         
             
                  end
         
     | 
| 
       19 
21 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
                  def resource_added?
         
     | 
| 
       21 
     | 
    
         
            -
                    current_order && current_order.projects.include?(model)
         
     | 
| 
       22 
     | 
    
         
            -
                  end
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
22 
     | 
    
         
             
                  def current_order
         
     | 
| 
       25 
23 
     | 
    
         
             
                    @current_order ||= controller.try(:current_order)
         
     | 
| 
       26 
24 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -7,6 +7,7 @@ module Decidim 
     | 
|
| 
       7 
7 
     | 
    
         
             
                  include Decidim::Budgets::ProjectsHelper
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                  delegate :selected?, to: :model
         
     | 
| 
      
 10 
     | 
    
         
            +
                  delegate :resource_added?, to: :controller
         
     | 
| 
       10 
11 
     | 
    
         | 
| 
       11 
12 
     | 
    
         
             
                  alias project model
         
     | 
| 
       12 
13 
     | 
    
         | 
| 
         @@ -18,8 +19,12 @@ module Decidim 
     | 
|
| 
       18 
19 
     | 
    
         | 
| 
       19 
20 
     | 
    
         
             
                  private
         
     | 
| 
       20 
21 
     | 
    
         | 
| 
      
 22 
     | 
    
         
            +
                  def show_votes_count?
         
     | 
| 
      
 23 
     | 
    
         
            +
                    model.component.current_settings.show_votes?
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
       21 
26 
     | 
    
         
             
                  def project_items
         
     | 
| 
       22 
     | 
    
         
            -
                    [ 
     | 
| 
      
 27 
     | 
    
         
            +
                    [status_item] + taxonomy_items + [budget_amount]
         
     | 
| 
       23 
28 
     | 
    
         
             
                  end
         
     | 
| 
       24 
29 
     | 
    
         | 
| 
       25 
30 
     | 
    
         
             
                  def items_for_map
         
     | 
| 
         @@ -34,31 +39,26 @@ module Decidim 
     | 
|
| 
       34 
39 
     | 
    
         
             
                  def voted_item_for_map
         
     | 
| 
       35 
40 
     | 
    
         
             
                    {
         
     | 
| 
       36 
41 
     | 
    
         
             
                      text: "#{model.confirmed_orders_count} #{t("decidim.budgets.projects.project.votes", count: model.confirmed_orders_count)}",
         
     | 
| 
       37 
     | 
    
         
            -
                      icon: current_order_checked_out? && resource_added? ? "check-double-line" : "check-line"
         
     | 
| 
      
 42 
     | 
    
         
            +
                      icon: current_order_checked_out? && resource_added?(model) ? "check-double-line" : "check-line"
         
     | 
| 
       38 
43 
     | 
    
         
             
                    }
         
     | 
| 
       39 
44 
     | 
    
         
             
                  end
         
     | 
| 
       40 
45 
     | 
    
         | 
| 
       41 
     | 
    
         
            -
                  def  
     | 
| 
       42 
     | 
    
         
            -
                     
     | 
| 
       43 
     | 
    
         
            -
                  end
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
                  def voted_item
         
     | 
| 
       46 
     | 
    
         
            -
                    return unless show_votes_count? && model.confirmed_orders_count.positive?
         
     | 
| 
      
 46 
     | 
    
         
            +
                  def status_item
         
     | 
| 
      
 47 
     | 
    
         
            +
                    return unless controller.try(:voting_finished?) && selected?
         
     | 
| 
       47 
48 
     | 
    
         | 
| 
       48 
49 
     | 
    
         
             
                    {
         
     | 
| 
       49 
     | 
    
         
            -
                      cell: "decidim/budgets/ 
     | 
| 
       50 
     | 
    
         
            -
                      args:  
     | 
| 
       51 
     | 
    
         
            -
                      icon: current_order_checked_out? && resource_added? ? "check-double-line" : "check-line"
         
     | 
| 
      
 50 
     | 
    
         
            +
                      cell: "decidim/budgets/project_selected_status",
         
     | 
| 
      
 51 
     | 
    
         
            +
                      args: model
         
     | 
| 
       52 
52 
     | 
    
         
             
                    }
         
     | 
| 
       53 
53 
     | 
    
         
             
                  end
         
     | 
| 
       54 
54 
     | 
    
         | 
| 
       55 
     | 
    
         
            -
                  def  
     | 
| 
       56 
     | 
    
         
            -
                    return unless  
     | 
| 
      
 55 
     | 
    
         
            +
                  def budget_amount
         
     | 
| 
      
 56 
     | 
    
         
            +
                    return unless show_votes_count?
         
     | 
| 
       57 
57 
     | 
    
         | 
| 
       58 
58 
     | 
    
         
             
                    {
         
     | 
| 
       59 
     | 
    
         
            -
                      cell: "decidim/budgets/ 
     | 
| 
      
 59 
     | 
    
         
            +
                      cell: "decidim/budgets/project_budget_amount",
         
     | 
| 
       60 
60 
     | 
    
         
             
                      args: model,
         
     | 
| 
       61 
     | 
    
         
            -
                      icon: " 
     | 
| 
      
 61 
     | 
    
         
            +
                      icon: "coin-line"
         
     | 
| 
       62 
62 
     | 
    
         
             
                    }
         
     | 
| 
       63 
63 
     | 
    
         
             
                  end
         
     | 
| 
       64 
64 
     | 
    
         | 
| 
         @@ -66,10 +66,6 @@ module Decidim 
     | 
|
| 
       66 
66 
     | 
    
         
             
                    @current_order ||= controller.try(:current_order)
         
     | 
| 
       67 
67 
     | 
    
         
             
                  end
         
     | 
| 
       68 
68 
     | 
    
         | 
| 
       69 
     | 
    
         
            -
                  def resource_added?
         
     | 
| 
       70 
     | 
    
         
            -
                    current_order && current_order.projects.include?(model)
         
     | 
| 
       71 
     | 
    
         
            -
                  end
         
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
69 
     | 
    
         
             
                  def current_order_checked_out?
         
     | 
| 
       74 
70 
     | 
    
         
             
                    current_order&.checked_out?
         
     | 
| 
       75 
71 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -8,21 +8,11 @@ module Decidim 
     | 
|
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                  def show
         
     | 
| 
       10 
10 
     | 
    
         
             
                    if voting_finished? && model.selected?
         
     | 
| 
       11 
     | 
    
         
            -
                      content_tag :span, class:  
     | 
| 
      
 11 
     | 
    
         
            +
                      content_tag :span, class: "label success" do
         
     | 
| 
       12 
12 
     | 
    
         
             
                        t("decidim.budgets.projects.project.selected")
         
     | 
| 
       13 
13 
     | 
    
         
             
                      end
         
     | 
| 
       14 
14 
     | 
    
         
             
                    end
         
     | 
| 
       15 
15 
     | 
    
         
             
                  end
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                  private
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                  def css_class
         
     | 
| 
       20 
     | 
    
         
            -
                    if options[:as_label] == true
         
     | 
| 
       21 
     | 
    
         
            -
                      "success label project-status"
         
     | 
| 
       22 
     | 
    
         
            -
                    else
         
     | 
| 
       23 
     | 
    
         
            -
                      "success card__text--status"
         
     | 
| 
       24 
     | 
    
         
            -
                    end
         
     | 
| 
       25 
     | 
    
         
            -
                  end
         
     | 
| 
       26 
16 
     | 
    
         
             
                end
         
     | 
| 
       27 
17 
     | 
    
         
             
              end
         
     | 
| 
       28 
18 
     | 
    
         
             
            end
         
     | 
| 
         @@ -2,20 +2,20 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
                                            budget_order_line_item_path(model.budget, project_id: model, show_only_added: options[:show_only_added]),
         
     | 
| 
       3 
3 
     | 
    
         
             
                                            method: vote_button_method,
         
     | 
| 
       4 
4 
     | 
    
         
             
                                            remote: true,
         
     | 
| 
       5 
     | 
    
         
            -
                                            resource: model,
         
     | 
| 
      
 5 
     | 
    
         
            +
                                            resource: model.budget,
         
     | 
| 
       6 
6 
     | 
    
         
             
                                            class: "button #{vote_button_classes}",
         
     | 
| 
       7 
7 
     | 
    
         
             
                                            id: "project-vote-button-#{model.id}",
         
     | 
| 
       8 
8 
     | 
    
         
             
                                            data: {
         
     | 
| 
       9 
     | 
    
         
            -
                                              add: !resource_added 
     | 
| 
      
 9 
     | 
    
         
            +
                                              add: !resource_added?(model),
         
     | 
| 
       10 
10 
     | 
    
         
             
                                              disable: true,
         
     | 
| 
       11 
11 
     | 
    
         
             
                                              budget: model.budget_amount,
         
     | 
| 
       12 
12 
     | 
    
         
             
                                              allocation: resource_allocation,
         
     | 
| 
       13 
     | 
    
         
            -
                                              "redirect-url":  
     | 
| 
       14 
     | 
    
         
            -
                                              onboarding_redirect_path:  
     | 
| 
      
 13 
     | 
    
         
            +
                                              "redirect-url": authorization_redirect_path,
         
     | 
| 
      
 14 
     | 
    
         
            +
                                              onboarding_redirect_path: authorization_redirect_path
         
     | 
| 
       15 
15 
     | 
    
         
             
                                            },
         
     | 
| 
       16 
16 
     | 
    
         
             
                                            disabled: vote_button_disabled?,
         
     | 
| 
       17 
17 
     | 
    
         
             
                                            title: vote_button_label do %>
         
     | 
| 
       18 
     | 
    
         
            -
              <% if resource_added? %>
         
     | 
| 
      
 18 
     | 
    
         
            +
              <% if resource_added?(model) %>
         
     | 
| 
       19 
19 
     | 
    
         
             
                 <%= t("added", scope: "decidim.budgets.projects.project_budget_button") %>
         
     | 
| 
       20 
20 
     | 
    
         
             
                 <%= icon "checkbox-circle-line", class: "inline-block" %>
         
     | 
| 
       21 
21 
     | 
    
         
             
              <% else %>
         
     | 
| 
         @@ -8,7 +8,7 @@ module Decidim 
     | 
|
| 
       8 
8 
     | 
    
         
             
                  include Decidim::Budgets::ProjectsHelper
         
     | 
| 
       9 
9 
     | 
    
         
             
                  include Decidim::Budgets::Engine.routes.url_helpers
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
                  delegate :current_user, :current_order, :current_component, :can_have_order?, to: :parent_controller
         
     | 
| 
      
 11 
     | 
    
         
            +
                  delegate :current_user, :current_order, :current_component, :can_have_order?, :resource_added?, to: :parent_controller
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
                  private
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
         @@ -16,6 +16,10 @@ module Decidim 
     | 
|
| 
       16 
16 
     | 
    
         
             
                    options[:project_item]
         
     | 
| 
       17 
17 
     | 
    
         
             
                  end
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
      
 19 
     | 
    
         
            +
                  def button_extra_classes
         
     | 
| 
      
 20 
     | 
    
         
            +
                    options[:button_extra_classes] || []
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
       19 
23 
     | 
    
         
             
                  def resource_path
         
     | 
| 
       20 
24 
     | 
    
         
             
                    resource_locator([model.budget, model]).path
         
     | 
| 
       21 
25 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -28,10 +32,6 @@ module Decidim 
     | 
|
| 
       28 
32 
     | 
    
         
             
                    translated_attribute model.title
         
     | 
| 
       29 
33 
     | 
    
         
             
                  end
         
     | 
| 
       30 
34 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
                  def resource_added?
         
     | 
| 
       32 
     | 
    
         
            -
                    current_order && current_order.projects.include?(model)
         
     | 
| 
       33 
     | 
    
         
            -
                  end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
35 
     | 
    
         
             
                  def resource_allocation
         
     | 
| 
       36 
36 
     | 
    
         
             
                    current_order.allocation_for(model)
         
     | 
| 
       37 
37 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -41,9 +41,9 @@ module Decidim 
     | 
|
| 
       41 
41 
     | 
    
         
             
                  end
         
     | 
| 
       42 
42 
     | 
    
         | 
| 
       43 
43 
     | 
    
         
             
                  def vote_button_classes
         
     | 
| 
       44 
     | 
    
         
            -
                    classes = []
         
     | 
| 
      
 44 
     | 
    
         
            +
                    classes = ["xl:w-40"]
         
     | 
| 
       45 
45 
     | 
    
         | 
| 
       46 
     | 
    
         
            -
                    classes << if resource_added?
         
     | 
| 
      
 46 
     | 
    
         
            +
                    classes << if resource_added?(model)
         
     | 
| 
       47 
47 
     | 
    
         
             
                                 "success button__secondary budget-list__data--added"
         
     | 
| 
       48 
48 
     | 
    
         
             
                               else
         
     | 
| 
       49 
49 
     | 
    
         
             
                                 "hollow button__transparent-secondary"
         
     | 
| 
         @@ -56,18 +56,23 @@ module Decidim 
     | 
|
| 
       56 
56 
     | 
    
         
             
                               end
         
     | 
| 
       57 
57 
     | 
    
         | 
| 
       58 
58 
     | 
    
         
             
                    classes << "budget-list__action" unless vote_button_disabled?
         
     | 
| 
      
 59 
     | 
    
         
            +
                    classes << button_extra_classes
         
     | 
| 
       59 
60 
     | 
    
         | 
| 
       60 
61 
     | 
    
         
             
                    classes.join(" ")
         
     | 
| 
       61 
62 
     | 
    
         
             
                  end
         
     | 
| 
       62 
63 
     | 
    
         | 
| 
       63 
64 
     | 
    
         
             
                  def vote_button_method
         
     | 
| 
       64 
     | 
    
         
            -
                    return :delete if resource_added?
         
     | 
| 
      
 65 
     | 
    
         
            +
                    return :delete if resource_added?(model)
         
     | 
| 
       65 
66 
     | 
    
         | 
| 
       66 
67 
     | 
    
         
             
                    :post
         
     | 
| 
       67 
68 
     | 
    
         
             
                  end
         
     | 
| 
       68 
69 
     | 
    
         | 
| 
      
 70 
     | 
    
         
            +
                  def authorization_redirect_path
         
     | 
| 
      
 71 
     | 
    
         
            +
                    budget_projects_path(budget, start_voting: true)
         
     | 
| 
      
 72 
     | 
    
         
            +
                  end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
       69 
74 
     | 
    
         
             
                  def vote_button_label
         
     | 
| 
       70 
     | 
    
         
            -
                    if resource_added?
         
     | 
| 
      
 75 
     | 
    
         
            +
                    if resource_added?(model)
         
     | 
| 
       71 
76 
     | 
    
         
             
                      return t(
         
     | 
| 
       72 
77 
     | 
    
         
             
                        "decidim.budgets.projects.project.remove",
         
     | 
| 
       73 
78 
     | 
    
         
             
                        resource_name: resource_title
         
     | 
| 
         @@ -3,25 +3,25 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module Decidim
         
     | 
| 
       4 
4 
     | 
    
         
             
              module Budgets
         
     | 
| 
       5 
5 
     | 
    
         
             
                # This cell renders the vote count.
         
     | 
| 
       6 
     | 
    
         
            -
                # Two possible layouts: 
     | 
| 
      
 6 
     | 
    
         
            +
                # Two possible layouts:
         
     | 
| 
      
 7 
     | 
    
         
            +
                # - with the count label ("0 votes", "1 vote", "999 votes")
         
     | 
| 
      
 8 
     | 
    
         
            +
                # - without the count label ("0", "1", "999")
         
     | 
| 
       7 
9 
     | 
    
         
             
                class ProjectVotesCountCell < Decidim::ViewModel
         
     | 
| 
      
 10 
     | 
    
         
            +
                  delegate :show_votes_count?, to: :controller
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       8 
12 
     | 
    
         
             
                  def show
         
     | 
| 
       9 
13 
     | 
    
         
             
                    return unless show_votes_count?
         
     | 
| 
       10 
14 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
                     
     | 
| 
      
 15 
     | 
    
         
            +
                    content
         
     | 
| 
       12 
16 
     | 
    
         
             
                  end
         
     | 
| 
       13 
17 
     | 
    
         | 
| 
       14 
18 
     | 
    
         
             
                  private
         
     | 
| 
       15 
19 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
                  def show_votes_count?
         
     | 
| 
       17 
     | 
    
         
            -
                    model.component.current_settings.show_votes?
         
     | 
| 
       18 
     | 
    
         
            -
                  end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
20 
     | 
    
         
             
                  def content
         
     | 
| 
       21 
     | 
    
         
            -
                    if options[:layout] == : 
     | 
| 
      
 21 
     | 
    
         
            +
                    if options[:layout] == :with_count_label
         
     | 
| 
       22 
22 
     | 
    
         
             
                      safe_join([model.confirmed_orders_count, " ", count_label])
         
     | 
| 
       23 
23 
     | 
    
         
             
                    else
         
     | 
| 
       24 
     | 
    
         
            -
                       
     | 
| 
      
 24 
     | 
    
         
            +
                      number
         
     | 
| 
       25 
25 
     | 
    
         
             
                    end
         
     | 
| 
       26 
26 
     | 
    
         
             
                  end
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
         @@ -32,12 +32,6 @@ module Decidim 
     | 
|
| 
       32 
32 
     | 
    
         
             
                  def count_label
         
     | 
| 
       33 
33 
     | 
    
         
             
                    content_tag(:span, t("decidim.budgets.projects.project.votes", count: model.confirmed_orders_count))
         
     | 
| 
       34 
34 
     | 
    
         
             
                  end
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
                  def css_class
         
     | 
| 
       37 
     | 
    
         
            -
                    css = ["project-votes"]
         
     | 
| 
       38 
     | 
    
         
            -
                    css << options[:class] if options[:class]
         
     | 
| 
       39 
     | 
    
         
            -
                    css.join(" ")
         
     | 
| 
       40 
     | 
    
         
            -
                  end
         
     | 
| 
       41 
35 
     | 
    
         
             
                end
         
     | 
| 
       42 
36 
     | 
    
         
             
              end
         
     | 
| 
       43 
37 
     | 
    
         
             
            end
         
     | 
| 
         @@ -19,6 +19,7 @@ module Decidim 
     | 
|
| 
       19 
19 
     | 
    
         
             
                  # Returns nothing.
         
     | 
| 
       20 
20 
     | 
    
         
             
                  def call
         
     | 
| 
       21 
21 
     | 
    
         
             
                    return broadcast(:invalid) if invalid_order?
         
     | 
| 
      
 22 
     | 
    
         
            +
                    return broadcast(:invalid) unless voting_open?
         
     | 
| 
       22 
23 
     | 
    
         | 
| 
       23 
24 
     | 
    
         
             
                    cancel_order!
         
     | 
| 
       24 
25 
     | 
    
         
             
                    broadcast(:ok, @order)
         
     | 
| 
         @@ -33,6 +34,10 @@ module Decidim 
     | 
|
| 
       33 
34 
     | 
    
         
             
                  def cancel_order!
         
     | 
| 
       34 
35 
     | 
    
         
             
                    @order.destroy!
         
     | 
| 
       35 
36 
     | 
    
         
             
                  end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                  def voting_open?
         
     | 
| 
      
 39 
     | 
    
         
            +
                    @order.budget.component.current_settings.votes == "enabled"
         
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
       36 
41 
     | 
    
         
             
                end
         
     | 
| 
       37 
42 
     | 
    
         
             
              end
         
     | 
| 
       38 
43 
     | 
    
         
             
            end
         
     | 
| 
         @@ -26,7 +26,7 @@ module Decidim 
     | 
|
| 
       26 
26 
     | 
    
         | 
| 
       27 
27 
     | 
    
         
             
                        on(:invalid) do
         
     | 
| 
       28 
28 
     | 
    
         
             
                          flash.now[:alert] = I18n.t("budgets.create.invalid", scope: "decidim.budgets.admin")
         
     | 
| 
       29 
     | 
    
         
            -
                          render action: "new"
         
     | 
| 
      
 29 
     | 
    
         
            +
                          render action: "new", status: :unprocessable_entity
         
     | 
| 
       30 
30 
     | 
    
         
             
                        end
         
     | 
| 
       31 
31 
     | 
    
         
             
                      end
         
     | 
| 
       32 
32 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -48,7 +48,7 @@ module Decidim 
     | 
|
| 
       48 
48 
     | 
    
         | 
| 
       49 
49 
     | 
    
         
             
                        on(:invalid) do
         
     | 
| 
       50 
50 
     | 
    
         
             
                          flash.now[:alert] = I18n.t("budgets.update.invalid", scope: "decidim.budgets.admin")
         
     | 
| 
       51 
     | 
    
         
            -
                          render action: "edit"
         
     | 
| 
      
 51 
     | 
    
         
            +
                          render action: "edit", status: :unprocessable_entity
         
     | 
| 
       52 
52 
     | 
    
         
             
                        end
         
     | 
| 
       53 
53 
     | 
    
         
             
                      end
         
     | 
| 
       54 
54 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -39,7 +39,7 @@ module Decidim 
     | 
|
| 
       39 
39 
     | 
    
         | 
| 
       40 
40 
     | 
    
         
             
                        on(:invalid) do
         
     | 
| 
       41 
41 
     | 
    
         
             
                          flash.now[:alert] = I18n.t("projects.create.invalid", scope: "decidim.budgets.admin")
         
     | 
| 
       42 
     | 
    
         
            -
                          render action: "new"
         
     | 
| 
      
 42 
     | 
    
         
            +
                          render action: "new", status: :unprocessable_entity
         
     | 
| 
       43 
43 
     | 
    
         
             
                        end
         
     | 
| 
       44 
44 
     | 
    
         
             
                      end
         
     | 
| 
       45 
45 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -62,7 +62,7 @@ module Decidim 
     | 
|
| 
       62 
62 
     | 
    
         | 
| 
       63 
63 
     | 
    
         
             
                        on(:invalid) do
         
     | 
| 
       64 
64 
     | 
    
         
             
                          flash.now[:alert] = I18n.t("projects.update.invalid", scope: "decidim.budgets.admin")
         
     | 
| 
       65 
     | 
    
         
            -
                          render action: "edit"
         
     | 
| 
      
 65 
     | 
    
         
            +
                          render action: "edit", status: :unprocessable_entity
         
     | 
| 
       66 
66 
     | 
    
         
             
                        end
         
     | 
| 
       67 
67 
     | 
    
         
             
                      end
         
     | 
| 
       68 
68 
     | 
    
         
             
                    end
         
     |