Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store credit admin UI fixes #2426

Merged
merged 9 commits into from
Dec 22, 2017
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ fieldset {

&.no-border-bottom {
border-bottom: none;
}

&.no-margin-bottom {
margin-bottom: 0;
}

Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/images/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<%= render 'new', product: @product, image: Spree::Image.new(viewable: @product) %>
</div>

<fieldset>
<fieldset class="no-border-bottom">
<legend align="center"><%= t(".upload_images") %></legend>

<div id="upload-zone">
Expand Down
4 changes: 2 additions & 2 deletions backend/app/views/spree/admin/store_credits/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<div data-hook="admin_store_credit_form_fields" class="row">
<div class="col-12">
<%= f.field_container :amount do %>
<%= f.label :amount, class: 'required' %><br />
<%= f.label :amount, class: 'required' %>
<%= render "spree/admin/shared/number_with_currency", f: f, amount_attr: :amount, currency_attr: :currency, required: true %>
<%= f.error_message_on :amount %>
<%= f.error_message_on :currency %>
<% end %>
</div>
<div class="col-12">
<%= f.field_container :category_id do %>
<%= f.label :category_id, class: 'required' %><br />
<%= f.label :category_id, class: 'required' %>
<%= f.select :category_id, options_from_collection_for_select(@credit_categories, :id, :name, f.object.category.try(:id)),
{ include_blank: true }, { class: 'custom-select fullwidth', placeholder: t('spree.admin.store_credits.select_reason') } %>
<%= f.error_message_on :category_id %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<div class="col-12">
<%= f.field_container :reason do %>
<%= f.label :reason, t('spree.reason'), class: 'required' %><br />
<%= select_tag :update_reason_id, options_from_collection_for_select(@update_reasons, :id, :name),
{ include_blank: true , class: 'custom-select fullwidth', placeholder: t('spree.admin.store_credits.select_amount_update_reason') } %>
<%= f.error_message_on :reason %>
<% end %>
</div>
<%= f.field_container :reason do %>
<%= f.label :reason, t('spree.reason'), class: 'required' %>
<%= select_tag :update_reason_id, options_from_collection_for_select(@update_reasons, :id, :name),
include_blank: t('spree.choose_reason'), class: 'custom-select fullwidth',
placeholder: t('spree.admin.store_credits.select_amount_update_reason') %>
<%= f.error_message_on :reason %>
<% end %>
12 changes: 8 additions & 4 deletions backend/app/views/spree/admin/store_credits/edit_amount.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@
<fieldset>
<legend align="center"><%= t('spree.admin.store_credits.edit_amount') %></legend>
<div data-hook="admin_store_credit_form_fields" class="row">
<div class="col-9">
<div class="col-6">
<%= f.field_container :amount do %>
<%= f.label :amount, class: 'required' %><br />
<%= f.number_field :amount, min: 0.00, step: :any %>
<%= render "spree/admin/shared/number_with_currency", f: f,
amount_attr: :amount, currency: @store_credit.currency, required: true %>
<%= f.error_message_on :amount %>
<% end %>
</div>
<%= render partial: 'update_reason_field', locals: { f: f } %>
<div class="col-6">
<%= render 'update_reason_field', f: f %>
</div>
</div>
<%= render partial: 'spree/admin/shared/edit_resource_links', locals: { collection_url: admin_user_store_credits_path(@user, @store_credit) } %>
<%= render 'spree/admin/shared/edit_resource_links',
collection_url: admin_user_store_credits_path(@user, @store_credit) %>
</fieldset>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
<fieldset>
<legend align="center"><%= t('spree.admin.store_credits.invalidate_store_credit') %></legend>
<div data-hook="admin_store_credit_form_fields" class="row">
<%= render partial: 'update_reason_field', locals: { f: f } %>
<div class="col-12">
<%= render partial: 'update_reason_field', locals: { f: f } %>
</div>
</div>
<div class="form-buttons filter-actions actions" data-hook="buttons">
<%= button t('spree.store_credit.actions.invalidate') %>
Expand Down
20 changes: 10 additions & 10 deletions backend/app/views/spree/admin/store_credits/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@

<% if @store_credits.any? %>
<% @store_credits.group_by(&:currency).each do |currency, credits| %>
<fieldset class="sc-current-balance">
<fieldset class="sc-current-balance no-border-bottom">
<legend>
<%= currency %> <%= t('spree.admin.store_credits.current_balance') %>
<%= t('spree.admin.store_credits.current_balance') %>
<% total = credits.sum(&:amount_remaining) %>
<%= Spree::Money.new(total, currency: currency) %>
</legend>

<table class="sc-table">
<thead>
<th class="wrap-text"><%= Spree::StoreCredit.human_attribute_name(:amount_credited) %></th>
<th class="wrap-text"><%= Spree::StoreCredit.human_attribute_name(:amount_used) %></th>
<th class="wrap-text"><%= Spree::StoreCredit.human_attribute_name(:amount_authorized) %></th>
<th class="wrap-text"><%= Spree::StoreCredit.human_attribute_name(:category_id) %></th>
<th class="wrap-text"><%= Spree::StoreCredit.human_attribute_name(:created_by_id) %></th>
<th class="wrap-text"><%= Spree::StoreCredit.human_attribute_name(:created_at) %></th>
<th class="wrap-text"><%= Spree::StoreCredit.human_attribute_name(:invalidated_at) %></th>
<th><%= t('spree.admin.store_credits.amount_credited') %></th>
<th><%= t('spree.admin.store_credits.amount_used') %></th>
<th><%= t('spree.admin.store_credits.amount_authorized') %></th>
<th><%= t('spree.admin.store_credits.credit_type') %></th>
<th><%= t('spree.admin.store_credits.created_by') %></th>
<th><%= t('spree.admin.store_credits.created_at') %></th>
<th><%= t('spree.admin.store_credits.invalidated') %></th>
<th data-hook="admin_store_credits_index_header_actions" class="actions"></th>
</thead>
<tbody>
Expand All @@ -53,7 +53,7 @@
<span><%= l store_credit.created_at.to_date %></span>
</td>
<td>
<span><%= store_credit.invalidated? %></span>
<span><%= t store_credit.invalidated? ? 'spree.say_yes' : 'spree.say_no' %></span>
</td>
<td class="actions" data-hook="admin_store_credits_index_row_actions">
<% if can?(:show, store_credit) %>
Expand Down
26 changes: 13 additions & 13 deletions backend/app/views/spree/admin/store_credits/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<%= render 'spree/admin/users/tabs', current: :store_credits %>
<% content_for :page_actions do %>
<% if @store_credit.editable? && can?(:edit, @store_credit) %>
<li><%= link_to_with_icon 'dollar', t('spree.admin.store_credits.change_amount'), edit_amount_admin_user_store_credit_path(@user, @store_credit), class: 'button' %></li>
<li><%= link_to t('spree.admin.store_credits.change_amount'), edit_amount_admin_user_store_credit_path(@user, @store_credit), class: 'button' %></li>
<% end %>
<% if @store_credit.invalidateable? && can?(:invalidate, @store_credit) %>
<li><%= link_to_with_icon 'ban', t('spree.invalidate'), edit_validity_admin_user_store_credit_path(@user, @store_credit), class: 'button' %></li>
<li><%= link_to t('spree.invalidate'), edit_validity_admin_user_store_credit_path(@user, @store_credit), class: 'button' %></li>
<% end %>
<% end %>

Expand All @@ -23,28 +23,28 @@
</colgroup>
<tr>
<td>
<strong><%= Spree::StoreCredit.human_attribute_name(:amount) %>:</strong>
<strong><%= t('spree.admin.store_credits.amount_credited') %></strong>
</td>
<td><%= @store_credit.display_amount.to_html %></td>
<td class='actions'></td>
</tr>
<tr>
<td>
<strong><%= Spree::StoreCredit.human_attribute_name(:created_by_id) %>:</strong>
<strong><%= t('spree.admin.store_credits.created_by') %></strong>
</td>
<td><%= @store_credit.created_by_email %></td>
<td class='actions'></td>
</tr>
<tr>
<td>
<strong><%= t('spree.admin.store_credits.credit_type') %>:</strong>
<strong><%= t('spree.admin.store_credits.credit_type') %></strong>
</td>
<td><%= @store_credit.category_name %></td>
<td class='actions'></td>
</tr>
<tr id='memo-display-row'>
<td>
<strong><%= Spree::StoreCredit.human_attribute_name(:memo) %>:</strong>
<strong><%= t('spree.admin.store_credits.memo') %></strong>
</td>
<td class='js-memo-text'>
<%= @store_credit.memo %>
Expand All @@ -57,7 +57,7 @@
</tr>
<tr id='memo-edit-row' class='hidden' data-original-value='<%= @store_credit.memo %>'>
<td>
<strong><%= Spree::StoreCredit.human_attribute_name(:memo) %>:</strong>
<strong><%= t('spree.admin.store_credits.memo') %></strong>
</td>
<td>
<%= form_tag admin_user_store_credit_path(@user, @store_credit), method: :put, remote: true, id: 'sc_memo_edit_form' do %>
Expand All @@ -73,23 +73,23 @@
</tr>
</table>

<fieldset>
<fieldset class="no-border-bottom">
<legend align='center'><%= t('spree.admin.store_credits.history') %></legend>
<table>
<colgroup>
<col style="width: 15%;" />
<col style="width: 20%;" />
<col style="width: 10%;" />
<col style="width: 10%;" />
<col style="width: 25%;" />
<col style="width: 10%;" />
<col style="width: 30%;" />
<col style="width: 25%;" />
</colgroup>
<thead>
<tr>
<th><%= t('spree.date') %></th>
<th><%= Spree::StoreCreditEvent.human_attribute_name(:action) %></th>
<th><%= Spree::StoreCredit.human_attribute_name(:amount) %></th>
<th><%= Spree::StoreCredit.human_attribute_name(:created_by_id) %></th>
<th><%= t('spree.admin.store_credits.amount_credited') %></th>
<th><%= t('spree.admin.store_credits.created_by') %></th>
<th><%= Spree::StoreCreditEvent.human_attribute_name(:user_total_amount) %></th>
<th><%= Spree::StoreCreditUpdateReason.human_attribute_name(:name) %></th>
</tr>
Expand All @@ -98,7 +98,7 @@
<% @store_credit_events.each do |event| %>
<tr>
<td data-hook="admin_show_store_credit_date_cell">
<%= pretty_time(event.created_at) %>
<%= pretty_time(event.created_at, :short) %>
</td>
<td><%= store_credit_event_admin_action_name(event) %></td>
<td><%= event.display_amount %></td>
Expand Down
12 changes: 6 additions & 6 deletions backend/app/views/spree/admin/taxons/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<% admin_breadcrumb(link_to plural_resource_name(Spree::Product), spree.admin_products_path) %>
<% admin_breadcrumb(t('spree.admin.taxons.display_order')) %>

<% content_for :table_filter_title do %>
<%= t('spree.choose_a_taxon_to_sort_products_for') %>
<% end %>
<fieldset class="no-border-bottom">
<legend>
<%= t('spree.choose_a_taxon_to_sort_products_for') %>
</legend>

<% content_for :table_filter do %>
<div data-hook="admin_orders_index_search" class="col-4">
<input type='text' id='taxon_id' />
</div>
<% end %>
</fieldset>

<div class='col-10'>
<div class='col-12'>
<div id='taxon_products' class='list-group'></div>
</div>
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/users/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<% content_for :sidebar do %>
<nav class="menu">
<fieldset class='no-border-top' data-hook="admin_user_lifetime_stats">
<fieldset class="no-border-top no-border-bottom" data-hook="admin_user_lifetime_stats">
<dl id="user-lifetime-stats">
<dt><%= t('spree.total_sales') %>:</dt>
<dd><%= @user.display_lifetime_value.to_html %></dd>
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/users/items.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render 'spree/admin/users/tabs', current: :items %>
<%= render partial: 'spree/admin/users/user_page_actions' %>

<fieldset data-hook="admin_user_items_purchased">
<fieldset data-hook="admin_user_items_purchased" class="no-border-bottom">
<legend><%= t("spree.admin.user.items_purchased") %></legend>

<%= paginate @orders, theme: "solidus_admin" %>
Expand Down
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/users/orders.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render 'spree/admin/users/tabs', current: :orders %>
<%= render partial: 'spree/admin/users/user_page_actions' %>

<fieldset data-hook="admin_user_order_history">
<fieldset data-hook="admin_user_order_history" class="no-border-bottom">
<legend><%= t("spree.admin.user.order_history") %></legend>

<%= paginate @orders, theme: "solidus_admin" %>
Expand Down
11 changes: 7 additions & 4 deletions core/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -868,15 +868,17 @@ en:
address: Address
store_credits:
add: "Add store credit"
amount_authorized: "Amount Authorized"
amount_credited: "Amount Credited"
amount_used: "Amount Used"
amount_authorized: Authorized
amount_credited: Credited
amount_used: Used
created_at: Issued On
back_to_edit: "Back to edit"
back_to_user_list: "Back to user list"
back_to_store_credit_list: "Store credit list"
change_amount: "Change amount"
created_by: "Created By"
credit_type: "Credit type"
credit_type: Type
memo: Memo
current_balance: "Current balance:"
edit: "Editing store credit"
edit_amount: "Editing store credit amount"
Expand Down Expand Up @@ -1089,6 +1091,7 @@ en:
choose_location: Choose location
choose_promotion_action: Choose action
choose_promotion_rule: Choose rule
choose_reason: Choose reason
city: City
clear_cache: Clear Cache
clear_cache_ok: Cache was flushed
Expand Down