Added admin budget phases views

This commit is contained in:
María Checa
2018-01-18 21:33:22 +01:00
parent 1abb7f0310
commit a97c007150
5 changed files with 158 additions and 13 deletions

View File

@@ -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';
}
}
}

View File

@@ -0,0 +1,67 @@
<%= form_for [:admin, @phase.budget, @phase] do |f| %>
<div class="row">
<div class="row">
<div class="small-12 medium-6 column">
<%= 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 %>
</div>
<div class="small-12 medium-6 column">
<%= 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 %>
</div>
</div>
<div class="row margin-top">
<div class="small-12 medium-12 column">
<%= f.label :summary, t("admin.budget_phases.edit.summary") %>
<p class="help-text" id="phase-summary-help-text">
<%= t("admin.budget_phases.edit.summary_help_text") %>
</p>
<%= f.cktext_area :summary,
maxlength: Budget::Phase::SUMMARY_MAX_LENGTH,
ckeditor: { language: I18n.locale },
label: false %>
</div>
</div>
<div class="row margin-top">
<div class="small-12 medium-12 column">
<%= f.label :description, t("admin.budget_phases.edit.description") %>
<p class="help-text" id="phase-description-help-text">
<%= t("admin.budget_phases.edit.description_help_text") %>
</p>
<%= f.cktext_area :description,
maxlength: Budget::Phase::DESCRIPTION_MAX_LENGTH,
ckeditor: { language: I18n.locale },
label: false %>
</div>
</div>
<div class="row margin-top">
<div class="small-12 medium-12 column">
<%= f.check_box :enabled, label: t("admin.budget_phases.edit.enabled") %>
<p class="help-text" id="phase-summary-help-text">
<%= t("admin.budget_phases.edit.enabled_help_text") %>
</p>
</div>
</div>
<div class="margin-top">
<%= f.submit t("admin.budget_phases.edit.save_changes"), class: "button success" %>
</div>
</div>
<% end %>

View File

@@ -0,0 +1,5 @@
<%= back_link_to edit_admin_budget_path(@phase.budget) %>
<h2><%= t("admin.budgets.edit.title") %> - <%= t("budgets.phase.#{@phase.kind}") %></h2>
<%= render '/admin/budget_phases/form' %>

View File

@@ -2,12 +2,6 @@
<%= f.text_field :name, maxlength: Budget.title_max_length %>
<% Budget::Phase::PHASE_KINDS.each do |phase| %>
<div class="margin-top">
<%= f.cktext_area "description_#{phase}", maxlength: Budget::Phase::DESCRIPTION_MAX_LENGTH, ckeditor: { language: I18n.locale } %>
</div>
<% end %>
<div class="row margin-top">
<div class="small-12 medium-9 column">
<%= f.select :phase, budget_phases_select_options %>
@@ -16,15 +10,61 @@
<%= f.select :currency_symbol, budget_currency_symbol_select_options %>
</div>
</div>
<% if @budget.phases.present? %>
<table id='budget-phases-table' class="table-for-mobile">
<thead>
<tr>
<th><%= t("admin.budgets.edit.phase") %></th>
<th><%= t("admin.budgets.edit.dates") %></th>
<th class="text-center"><%= t("admin.budgets.edit.enabled") %></th>
<th><%= t("admin.budgets.edit.actions") %></th>
</tr>
</thead>
<% @budget.phases.each do |phase| %>
<tr id="<%= dom_id(phase) %>" class="phase">
<td>
<%= t("budgets.phase.#{phase.kind}") %>
<% if @budget.current_phase == phase %>
<span class="label success"><strong><%= t("admin.budgets.edit.active") %></strong></span>
<% end %>
</td>
<td>
<% if phase.starts_at.present? && phase.ends_at.present? %>
<%= l phase.starts_at.to_date %> - <%= l phase.ends_at.to_date %>
<% else %>
<em><%= t("admin.budgets.edit.blank_dates") %></em>
<% end %>
</td>
<td class="text-center">
<span class="budget-phase-enabled <%= phase.enabled? ? 'enabled' : 'disabled' %>"></span>
</td>
<td>
<%= link_to t("admin.budgets.edit.edit_phase"),
edit_admin_budget_budget_phase_path(@budget, phase),
method: :get, class: "button hollow" %>
</td>
</tr>
<% end %>
</table>
<% end %>
<div class="margin-top">
<%= f.submit nil, class: "button success" %>
<% if @budget.balloting_process? %>
<div class="float-right">
<div class="float-right">
<% if @budget.balloting_process? %>
<%= link_to t("admin.budgets.winners.calculate"),
calculate_winners_admin_budget_path(@budget),
method: :put,
class: "button hollow" %>
</div>
<% 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 %>
</div>
</div>
<% end %>

View File

@@ -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" %>
<h2 class="inline-block"><%= t("admin.budgets.edit.title") %></h2>
<h2><%= t("admin.budgets.edit.title") %></h2>
<%= render '/admin/budgets/form' %>