Fix admin price UI

#475
This commit is contained in:
Artur Beljajev 2017-04-27 16:51:47 +03:00
parent b775555c00
commit 9530fd939d
7 changed files with 28 additions and 17 deletions

View file

@ -1,15 +1,8 @@
<tr> <tr>
<td><%= price.zone_name %></td> <td><%= link_to price.zone_name, edit_admin_price_path(price), id: 'admin-edit-price-btn' %></td>
<td><%= price.duration.sub('mons', 'months') %></td> <td><%= price.duration.sub('mons', 'months') %></td>
<td><%= price.operation_category %></td> <td><%= price.operation_category %></td>
<td><%= number_to_currency price.price %></td> <td><%= number_to_currency price.price %></td>
<td><%= l price.valid_from, format: :date %></td> <td><%= l price.valid_from, format: :date %></td>
<td><%= l price.valid_to, format: :date %></td> <td><%= l price.valid_to, format: :date %></td>
<td>
<%= link_to t('.edit_btn'), edit_admin_price_path(price), class: 'btn btn-xs btn-primary' %>
<%= link_to(t('.delete_btn'), admin_price_path(price),
method: :delete,
data: { confirm: t('.delete_btn_confirm') },
class: 'btn btn-xs btn-danger') %>
</td>
</tr> </tr>

View file

@ -3,7 +3,18 @@
</ol> </ol>
<div class="page-header"> <div class="page-header">
<div class="row">
<div class="col-sm-10">
<h1><%= t '.title' %></h1> <h1><%= t '.title' %></h1>
</div>
<div class="col-sm-2 text-right">
<%= link_to(t('.delete_btn'), admin_price_path(@price),
method: :delete,
data: { confirm: t('.delete_btn_confirm') },
class: 'btn btn-danger') %>
</div>
</div>
</div> </div>
<% if @price.persisted? && @price.errors.none? %> <% if @price.persisted? && @price.errors.none? %>

View file

@ -20,7 +20,6 @@
<th><%= sort_link(@q, 'price', t(:price)) %></th> <th><%= sort_link(@q, 'price', t(:price)) %></th>
<th><%= sort_link(@q, 'valid_from', t(:valid_from)) %></th> <th><%= sort_link(@q, 'valid_from', t(:valid_from)) %></th>
<th><%= sort_link(@q, 'valid_to', t(:valid_to)) %></th> <th><%= sort_link(@q, 'valid_to', t(:valid_to)) %></th>
<th></th>
</tr> </tr>
</thead> </thead>

View file

@ -15,6 +15,8 @@ en:
edit: edit:
title: Edit price title: Edit price
delete_btn: Delete
delete_btn_confirm: Are you sure you want to delete price?
update: update:
updated: Price has been updated updated: Price has been updated
@ -25,8 +27,3 @@ en:
form: form:
create_btn: Create price create_btn: Create price
update_btn: Update price update_btn: Update price
price:
edit_btn: Edit
delete_btn: Delete
delete_btn_confirm: Are you sure you want to delete price?

View file

@ -9,8 +9,15 @@ RSpec.feature 'Deleting price in admin area', settings: false do
scenario 'deletes price' do scenario 'deletes price' do
visit admin_prices_url visit admin_prices_url
click_link_or_button t('admin.billing.prices.price.delete_btn') open_form
click_link_or_button t('admin.billing.prices.edit.delete_btn')
expect(page).to have_text(t('admin.billing.prices.destroy.destroyed')) expect(page).to have_text(t('admin.billing.prices.destroy.destroyed'))
end end
private
def open_form
click_link_or_button 'admin-edit-price-btn'
end
end end

View file

@ -15,8 +15,10 @@ RSpec.feature 'Editing price in admin area', settings: false do
expect(page).to have_text(t('admin.billing.prices.update.updated')) expect(page).to have_text(t('admin.billing.prices.update.updated'))
end end
private
def open_form def open_form
click_link_or_button t('admin.billing.prices.price.edit_btn') click_link_or_button 'admin-edit-price-btn'
end end
def submit_form def submit_form

View file

@ -16,6 +16,8 @@ RSpec.feature 'New price in admin area', settings: false do
expect(page).to have_text(t('admin.billing.prices.create.created')) expect(page).to have_text(t('admin.billing.prices.create.created'))
end end
private
def open_list def open_list
click_link_or_button t('admin.menu.prices') click_link_or_button t('admin.menu.prices')
end end