From a97c007150fb901ca9202cf45474875c0e4ebf95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Thu, 18 Jan 2018 21:33:22 +0100 Subject: [PATCH] Added admin budget phases views --- app/assets/stylesheets/admin.scss | 35 ++++++++++ app/views/admin/budget_phases/_form.html.erb | 67 ++++++++++++++++++++ app/views/admin/budget_phases/edit.html.erb | 5 ++ app/views/admin/budgets/_form.html.erb | 60 +++++++++++++++--- app/views/admin/budgets/edit.html.erb | 4 +- 5 files changed, 158 insertions(+), 13 deletions(-) create mode 100644 app/views/admin/budget_phases/_form.html.erb create mode 100644 app/views/admin/budget_phases/edit.html.erb diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss index a2e3e0e7f..615e7ac43 100644 --- a/app/assets/stylesheets/admin.scss +++ b/app/assets/stylesheets/admin.scss @@ -9,6 +9,7 @@ // 07. Legislation // 08. CMS // 09. Map +// 10. Budget phases // // 01. Global styles @@ -1032,3 +1033,37 @@ table { visibility: hidden; height: 0; } + +// 10. Budget phases +// ----------------- +.budget-phase-enabled { + font-weight: bold; + padding-left: rem-calc(20); + position: relative; + text-decoration: none; + + &.enabled::before, + &.disabled::before { + font-family: 'icons'; + left: 0; + position: absolute; + } + + &.enabled { + color: $check; + + &::before { + color: $check; + content: '\6c'; + } + } + + &.disabled { + color: #000; + + &::before { + color: #000; + content: '\76'; + } + } +} diff --git a/app/views/admin/budget_phases/_form.html.erb b/app/views/admin/budget_phases/_form.html.erb new file mode 100644 index 000000000..9595907ac --- /dev/null +++ b/app/views/admin/budget_phases/_form.html.erb @@ -0,0 +1,67 @@ +<%= form_for [:admin, @phase.budget, @phase] do |f| %> + +
+
+
+ <%= f.label :starts_at, t("admin.budget_phases.edit.start_date") %> + <%= f.text_field :starts_at, + value: format_date_for_calendar_form(@phase.starts_at), + class: "js-calendar-full", + id: "start_date", + label: false %> +
+
+ <%= f.label :ends_at, t("admin.budget_phases.edit.end_date") %> + <%= f.text_field :ends_at, + value: format_date_for_calendar_form(@phase.ends_at), + class: "js-calendar-full", + id: "end_date", + label: false %> +
+
+ +
+
+ <%= f.label :summary, t("admin.budget_phases.edit.summary") %> + +

+ <%= t("admin.budget_phases.edit.summary_help_text") %> +

+ + <%= f.cktext_area :summary, + maxlength: Budget::Phase::SUMMARY_MAX_LENGTH, + ckeditor: { language: I18n.locale }, + label: false %> +
+
+ +
+
+ <%= f.label :description, t("admin.budget_phases.edit.description") %> + +

+ <%= t("admin.budget_phases.edit.description_help_text") %> +

+ + <%= f.cktext_area :description, + maxlength: Budget::Phase::DESCRIPTION_MAX_LENGTH, + ckeditor: { language: I18n.locale }, + label: false %> +
+
+ +
+
+ <%= f.check_box :enabled, label: t("admin.budget_phases.edit.enabled") %> + +

+ <%= t("admin.budget_phases.edit.enabled_help_text") %> +

+
+
+ +
+ <%= f.submit t("admin.budget_phases.edit.save_changes"), class: "button success" %> +
+
+<% end %> diff --git a/app/views/admin/budget_phases/edit.html.erb b/app/views/admin/budget_phases/edit.html.erb new file mode 100644 index 000000000..2d9659c7b --- /dev/null +++ b/app/views/admin/budget_phases/edit.html.erb @@ -0,0 +1,5 @@ +<%= back_link_to edit_admin_budget_path(@phase.budget) %> + +

<%= t("admin.budgets.edit.title") %> - <%= t("budgets.phase.#{@phase.kind}") %>

+ +<%= render '/admin/budget_phases/form' %> diff --git a/app/views/admin/budgets/_form.html.erb b/app/views/admin/budgets/_form.html.erb index 48a52079e..9b96107ac 100644 --- a/app/views/admin/budgets/_form.html.erb +++ b/app/views/admin/budgets/_form.html.erb @@ -2,12 +2,6 @@ <%= f.text_field :name, maxlength: Budget.title_max_length %> - <% Budget::Phase::PHASE_KINDS.each do |phase| %> -
- <%= f.cktext_area "description_#{phase}", maxlength: Budget::Phase::DESCRIPTION_MAX_LENGTH, ckeditor: { language: I18n.locale } %> -
- <% end %> -
<%= f.select :phase, budget_phases_select_options %> @@ -16,15 +10,61 @@ <%= f.select :currency_symbol, budget_currency_symbol_select_options %>
+ + <% if @budget.phases.present? %> + + + + + + + + + + + <% @budget.phases.each do |phase| %> + + + + + + + <% end %> +
<%= t("admin.budgets.edit.phase") %><%= t("admin.budgets.edit.dates") %><%= t("admin.budgets.edit.enabled") %><%= t("admin.budgets.edit.actions") %>
+ <%= t("budgets.phase.#{phase.kind}") %> + <% if @budget.current_phase == phase %> + <%= t("admin.budgets.edit.active") %> + <% end %> + + <% if phase.starts_at.present? && phase.ends_at.present? %> + <%= l phase.starts_at.to_date %> - <%= l phase.ends_at.to_date %> + <% else %> + <%= t("admin.budgets.edit.blank_dates") %> + <% end %> + + + + <%= link_to t("admin.budgets.edit.edit_phase"), + edit_admin_budget_budget_phase_path(@budget, phase), + method: :get, class: "button hollow" %> +
+ <% end %> +
<%= f.submit nil, class: "button success" %> - <% if @budget.balloting_process? %> -
+ +
+ <% if @budget.balloting_process? %> <%= link_to t("admin.budgets.winners.calculate"), calculate_winners_admin_budget_path(@budget), method: :put, class: "button hollow" %> -
- <% end %> + <% end %> + + <% if @budget.persisted? %> + <%= button_to t("admin.budgets.edit.delete"), admin_budget_path(@budget), method: :delete, class: "button hollow alert float-right" %> + <% end %> +
+
<% end %> diff --git a/app/views/admin/budgets/edit.html.erb b/app/views/admin/budgets/edit.html.erb index 16a39d3dc..6c54cc75b 100644 --- a/app/views/admin/budgets/edit.html.erb +++ b/app/views/admin/budgets/edit.html.erb @@ -1,7 +1,5 @@ <%= back_link_to admin_budgets_path %> -<%= button_to t("admin.budgets.edit.delete"), admin_budget_path(@budget), method: :delete, class: "button hollow alert float-right small" %> - -

<%= t("admin.budgets.edit.title") %>

+

<%= t("admin.budgets.edit.title") %>

<%= render '/admin/budgets/form' %>