From 8fb8f70efd5bb6b21a953305100b74e1e9a1eaeb Mon Sep 17 00:00:00 2001 From: Julian Herrero Date: Thu, 13 Dec 2018 10:03:30 +0100 Subject: [PATCH] cleanup (due to new CRUD for budget groups and headings) --- app/helpers/admin_helper.rb | 4 -- app/views/admin/budget_groups/create.js.erb | 2 - app/views/admin/budget_groups/update.js.erb | 7 --- .../admin/budget_headings/_errors.html.erb | 7 --- app/views/admin/budget_headings/create.js.erb | 2 - app/views/admin/budget_headings/edit.js.erb | 1 - app/views/admin/budget_headings/update.js.erb | 1 - app/views/admin/budgets/_group.html.erb | 48 --------------- app/views/admin/budgets/_group_form.html.erb | 28 --------- app/views/admin/budgets/_groups.html.erb | 21 ------- app/views/admin/budgets/_heading.html.erb | 27 --------- .../admin/budgets/_heading_form.html.erb | 58 ------------------- .../budgets/_max_headings_label.html.erb | 2 - 13 files changed, 208 deletions(-) delete mode 100644 app/views/admin/budget_groups/create.js.erb delete mode 100644 app/views/admin/budget_groups/update.js.erb delete mode 100644 app/views/admin/budget_headings/_errors.html.erb delete mode 100644 app/views/admin/budget_headings/create.js.erb delete mode 100644 app/views/admin/budget_headings/edit.js.erb delete mode 100644 app/views/admin/budget_headings/update.js.erb delete mode 100644 app/views/admin/budgets/_group.html.erb delete mode 100644 app/views/admin/budgets/_group_form.html.erb delete mode 100644 app/views/admin/budgets/_groups.html.erb delete mode 100644 app/views/admin/budgets/_heading.html.erb delete mode 100644 app/views/admin/budgets/_heading_form.html.erb delete mode 100644 app/views/admin/budgets/_max_headings_label.html.erb diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index afce592a9..903a1e0a3 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -89,10 +89,6 @@ module AdminHelper user_roles(user).join(", ") end - def display_budget_goup_form(group) - group.errors.messages.size > 0 ? "" : "display:none" - end - private def namespace diff --git a/app/views/admin/budget_groups/create.js.erb b/app/views/admin/budget_groups/create.js.erb deleted file mode 100644 index cb926a7c6..000000000 --- a/app/views/admin/budget_groups/create.js.erb +++ /dev/null @@ -1,2 +0,0 @@ -$("#<%= dom_id(@budget) %>_groups").html('<%= j render("admin/budgets/groups", groups: @groups) %>'); -App.Forms.toggleLink(); \ No newline at end of file diff --git a/app/views/admin/budget_groups/update.js.erb b/app/views/admin/budget_groups/update.js.erb deleted file mode 100644 index c4f9774ba..000000000 --- a/app/views/admin/budget_groups/update.js.erb +++ /dev/null @@ -1,7 +0,0 @@ -<% if @group.errors.any? %> - $("#group-form-<%= @group.id %>").html('<%= j render("admin/budgets/group_form", group: @group, budget: @group.budget, button_title: t("admin.budgets.form.submit"), id: "group-form-#{@group.id}", css_class: "group-toggle-#{@group.id}" ) %>'); -<% else %> - $("#group-name-<%= @group.id %>").html('<%= @group.name %>') - $("#max-heading-label-<%=@group.id%>").html('<%= j render("admin/budgets/max_headings_label", current: @group.max_votable_headings, max: @group.headings.count, group: @group) %>') - $(".group-toggle-<%= @group.id %>").toggle() -<% end %> diff --git a/app/views/admin/budget_headings/_errors.html.erb b/app/views/admin/budget_headings/_errors.html.erb deleted file mode 100644 index bb3e5482e..000000000 --- a/app/views/admin/budget_headings/_errors.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -
- -
diff --git a/app/views/admin/budget_headings/create.js.erb b/app/views/admin/budget_headings/create.js.erb deleted file mode 100644 index 5d8eefb2d..000000000 --- a/app/views/admin/budget_headings/create.js.erb +++ /dev/null @@ -1,2 +0,0 @@ -$("#<%= dom_id(@budget_group) %>").html('<%= j render("admin/budgets/group", group: @budget_group, headings: @headings) %>'); -App.Forms.toggleLink(); \ No newline at end of file diff --git a/app/views/admin/budget_headings/edit.js.erb b/app/views/admin/budget_headings/edit.js.erb deleted file mode 100644 index 5f9ac48f8..000000000 --- a/app/views/admin/budget_headings/edit.js.erb +++ /dev/null @@ -1 +0,0 @@ -$("#heading-<%=@heading.id%>").html("<%= j render("admin/budgets/heading_form", group: @budget_group, budget: @budget, heading: @heading) %>"); diff --git a/app/views/admin/budget_headings/update.js.erb b/app/views/admin/budget_headings/update.js.erb deleted file mode 100644 index 6466959cd..000000000 --- a/app/views/admin/budget_headings/update.js.erb +++ /dev/null @@ -1 +0,0 @@ -$("#<%= dom_id(@budget_group) %>").html('<%= j render("admin/budgets/group", group: @budget_group, headings: @budget_group.headings) %>'); diff --git a/app/views/admin/budgets/_group.html.erb b/app/views/admin/budgets/_group.html.erb deleted file mode 100644 index e4b313207..000000000 --- a/app/views/admin/budgets/_group.html.erb +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - <% if headings.present? %> - - - - - - - - <% end %> - - - - - <% if headings.blank? %> - - - - <% end %> - - - - - - <% headings.each do |heading| %> - <%= render "admin/budgets/heading", group: group, budget: @budget, heading: heading %> - <% end %> - -
- <%= content_tag(:span, group.name, class:"group-toggle-#{group.id}", id:"group-name-#{group.id}") %> - - <%= content_tag(:span, (render 'admin/budgets/max_headings_label', current: group.max_votable_headings, max: group.headings.count, group: group if group.max_votable_headings), class:"small group-toggle-#{group.id}", id:"max-heading-label-#{group.id}") %> - - <%= render 'admin/budgets/group_form', budget: @budget, group: group, id: "group-form-#{group.id}", button_title: t("admin.budgets.form.submit"), css_class: "group-toggle-#{group.id}" %> - <%= link_to t("admin.budgets.form.edit_group"), "#", class: "button float-right js-toggle-link hollow", data: { "toggle-selector" => ".group-toggle-#{group.id}" } %> - <%= link_to t("admin.budgets.form.add_heading"), "#", class: "button float-right js-toggle-link", data: { "toggle-selector" => "#group-#{group.id}-new-heading-form" } %> -
<%= t("admin.budgets.form.table_heading") %><%= t("admin.budgets.form.table_amount") %><%= t("admin.budgets.form.table_population") %><%= t("admin.budgets.form.table_allow_custom_contents") %><%= t("admin.actions.actions") %>
-
- <%= t("admin.budgets.form.no_heading") %> -
-
diff --git a/app/views/admin/budgets/_group_form.html.erb b/app/views/admin/budgets/_group_form.html.erb deleted file mode 100644 index 0bb83b1b7..000000000 --- a/app/views/admin/budgets/_group_form.html.erb +++ /dev/null @@ -1,28 +0,0 @@ -<%= form_for [:admin, budget, group], html: {id: id, style: display_budget_goup_form(group), class: css_class}, remote: true do |f| %> - - <%= f.label :name, t("admin.budgets.form.group") %> - -
- <%= f.text_field :name, - label: false, - maxlength: 50, - placeholder: t("admin.budgets.form.group"), - class: "input-group-field" %> - - <% if group.persisted? %> -
- <%= f.label :name, t("admin.budgets.form.max_votable_headings") %> - - <%= f.select :max_votable_headings, - (1..group.headings.count), - label: false, - placeholder: t("admin.budgets.form.max_votable_headings"), - class: "input-group-field" %> -
- <% end %> - -
- <%= f.submit button_title, class: "button success" %> -
-
-<% end %> diff --git a/app/views/admin/budgets/_groups.html.erb b/app/views/admin/budgets/_groups.html.erb deleted file mode 100644 index dbee9576c..000000000 --- a/app/views/admin/budgets/_groups.html.erb +++ /dev/null @@ -1,21 +0,0 @@ -

<%= t('admin.budgets.show.groups', count: groups.count) %>

-<%= link_to t("admin.budgets.form.add_group"), "#", class: "button float-right js-toggle-link", data: { "toggle-selector" => "#new-group-form" } %> - -<% if groups.blank? %> -
- <%= t("admin.budgets.form.no_groups") %> -
-<% end %> - -<%= render 'admin/budgets/group_form', - budget: @budget, - group: Budget::Group.new, - id: "new-group-form", - button_title: t("admin.budgets.form.create_group"), - css_class: '' %> - -<% groups.each do |group| %> -
- <%= render "admin/budgets/group", group: group, headings: group.headings.order(:id) %> -
-<% end %> diff --git a/app/views/admin/budgets/_heading.html.erb b/app/views/admin/budgets/_heading.html.erb deleted file mode 100644 index e06bb96d1..000000000 --- a/app/views/admin/budgets/_heading.html.erb +++ /dev/null @@ -1,27 +0,0 @@ - - - <%= heading.name %> - - - <%= heading.budget.formatted_heading_price(heading) %> - - - <%= heading.population %> - - - <%= heading.allow_custom_content ? t("true_value") : t("false_value") %> - - - <%= link_to t("admin.actions.edit"), - edit_admin_budget_budget_group_budget_heading_path(budget_id: group.budget.id, budget_group_id: group.id, id: heading.id), - class: "button hollow", - remote: true %> - <% if heading.can_be_deleted? %> - <%= link_to t('admin.administrators.administrator.delete'), - #admin_budget_budget_group_budget_headings_path(group.budget.id, group.id), - [:admin, group.budget, group, heading], - method: :delete, - class: "button hollow alert" %> - <% end %> - - diff --git a/app/views/admin/budgets/_heading_form.html.erb b/app/views/admin/budgets/_heading_form.html.erb deleted file mode 100644 index a102b421a..000000000 --- a/app/views/admin/budgets/_heading_form.html.erb +++ /dev/null @@ -1,58 +0,0 @@ -<%= form_for [:admin, budget, group, heading], remote: true do |f| %> - <%= render 'shared/errors', resource: heading %> - <%= f.text_field :name, - label: t("admin.budgets.form.heading"), - maxlength: 50, - placeholder: t("admin.budgets.form.heading") %> - -
-
- <%= f.text_field :price, - label: t("admin.budgets.form.amount"), - maxlength: 8, - placeholder: t("admin.budgets.form.amount") %> -
-
-
-
-

- <%= t("admin.budgets.form.population_help_text") %> -

- <%= f.text_field :population, - label: t("admin.budgets.form.population"), - maxlength: 8, - placeholder: t("admin.budgets.form.population"), - data: {toggle_focus: "population-info"}, - aria: {describedby: "budgets-population-help-text"} %> -
-
- -
-
-
-
- <%= f.text_field :latitude, - label: t("admin.budgets.form.latitude"), - maxlength: 22, - placeholder: "latitude" %> -
-
-
-
- <%= f.text_field :longitude, - label: t("admin.budgets.form.longitude"), - maxlength: 22, - placeholder: "longitude" %> -
-
- -
-
- <%= f.check_box :allow_custom_content, label: t('admin.budgets.form.allow_content_block') %> -
-
- - <%= f.submit t("admin.budgets.form.save_heading"), class: "button success" %> -<% end %> diff --git a/app/views/admin/budgets/_max_headings_label.html.erb b/app/views/admin/budgets/_max_headings_label.html.erb deleted file mode 100644 index f2c438d4f..000000000 --- a/app/views/admin/budgets/_max_headings_label.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -<%= t("admin.budgets.form.max_votable_headings")%> -<%= t("admin.budgets.form.current_of_max_headings", current: current, max: max) %>