spree_zone_pricing 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/controllers/spree/admin/zone_prices_controller.rb +55 -0
- data/app/views/spree/admin/shared/_product_sub_menu.html.erb +1 -1
- data/app/views/spree/admin/zone_prices/_form.html.erb +60 -0
- data/app/views/spree/admin/zone_prices/edit.html.erb +15 -0
- data/app/views/spree/admin/zone_prices/index.html.erb +45 -0
- data/app/views/spree/admin/zone_prices/new.html.erb +9 -0
- data/config/routes.rb +9 -1
- metadata +6 -1
@@ -0,0 +1,55 @@
|
|
1
|
+
class Spree::Admin::ZonePricesController < Spree::Admin::BaseController
|
2
|
+
|
3
|
+
def index
|
4
|
+
search = params[:search] || { "meta_sort" => "updated_at.desc" }
|
5
|
+
@search = ZonePrice.search(search)
|
6
|
+
@zone_prices = @search.page(params[:page]||1).per(20)
|
7
|
+
end
|
8
|
+
|
9
|
+
def new
|
10
|
+
@zone_price = ZonePrice.new
|
11
|
+
@form_target = admin_zone_prices_path
|
12
|
+
@form_method = :post
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
@zone_price = ZonePrice.new(params[:zone_price])
|
17
|
+
|
18
|
+
if @zone_price.save
|
19
|
+
#cache_reset
|
20
|
+
redirect_to admin_zone_prices_path, notice: 'Item was successfully created.'
|
21
|
+
else
|
22
|
+
@form_target = admin_zone_prices_path
|
23
|
+
@form_method = :post
|
24
|
+
render action: "new"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def edit
|
29
|
+
@zone_price = ZonePrice.find(params[:id])
|
30
|
+
@form_target = admin_zone_price_path(@zone_price)
|
31
|
+
@form_method = :put
|
32
|
+
end
|
33
|
+
|
34
|
+
def update
|
35
|
+
@zone_price = ZonePrice.find(params[:id])
|
36
|
+
|
37
|
+
if @zone_price.update_attributes(params[:zone_price])
|
38
|
+
#cache_reset
|
39
|
+
redirect_to admin_zone_prices_path, notice: 'Item was successfully updated.'
|
40
|
+
else
|
41
|
+
@form_target = admin_zone_price_path(@zone_price)
|
42
|
+
@form_method = :put
|
43
|
+
render action: "edit"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def destroy
|
48
|
+
@zone_price = ZonePrice.find(params[:id])
|
49
|
+
|
50
|
+
@zone_price.destroy
|
51
|
+
#cache_reset
|
52
|
+
redirect_to admin_zone_prices_url
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
<%= nested_form_for @press, :url => @form_target, :method => @form_method do |f| %>
|
2
|
+
|
3
|
+
<% if @press.errors.any? %>
|
4
|
+
<div class="alert-message block-message error">
|
5
|
+
<p><strong><%= pluralize(@press.errors.count, "error") %></strong> prohibited this form from being saved:</p>
|
6
|
+
<ul>
|
7
|
+
<% @press.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%= msg %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<fieldset data-hook="new_press">
|
15
|
+
|
16
|
+
<%= f.field_container :address do %>
|
17
|
+
<%= f.label :address %> <span class="required">*</span><br />
|
18
|
+
<%= f.text_field :address, :class => 'fullwidth title' %>
|
19
|
+
<%= f.error_message_on :address %>
|
20
|
+
<% end %>
|
21
|
+
|
22
|
+
<div class="clearfix" data-hook="new_press_attrs">
|
23
|
+
|
24
|
+
<div class="left">
|
25
|
+
|
26
|
+
<%= f.field_container :city do %>
|
27
|
+
<%= f.label :city %> <span class="required">*</span><br />
|
28
|
+
<%= f.text_field :city %>
|
29
|
+
<%= f.error_message_on :city %>
|
30
|
+
<% end %>
|
31
|
+
|
32
|
+
<%= f.field_container :country do %>
|
33
|
+
<%= f.label :country %> <span class="required">*</span><br />
|
34
|
+
<%= f.text_field :country %>
|
35
|
+
<%= f.error_message_on :country %>
|
36
|
+
<% end %>
|
37
|
+
|
38
|
+
<%= f.field_container :geocoords do %>
|
39
|
+
<%= f.label :geocoords %> <br />
|
40
|
+
<%= f.text_field :geocoords %>
|
41
|
+
<%= f.error_message_on :geocoords %>
|
42
|
+
<% end %>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div class="right">
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
</div>
|
51
|
+
|
52
|
+
</div>
|
53
|
+
|
54
|
+
<div class="actions">
|
55
|
+
<%= f.submit :class => "btn primary" %>
|
56
|
+
</div>
|
57
|
+
|
58
|
+
</fieldset>
|
59
|
+
|
60
|
+
<% end %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<div data-hook="admin_press_edit_header">
|
2
|
+
<%
|
3
|
+
=begin
|
4
|
+
%>
|
5
|
+
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @order } %>
|
6
|
+
<%
|
7
|
+
=end
|
8
|
+
%>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div data-hook="admin_press_edit_form">
|
12
|
+
<div id="press-form-wrapper">
|
13
|
+
<%= render :partial => 'form', :locals => { :press => @press } %>
|
14
|
+
</div>
|
15
|
+
</div>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<div class='toolbar order-links'>
|
2
|
+
<%= button_link_to "New Press", new_admin_press_url, :icon => 'add', :id => 'admin_new_press' %>
|
3
|
+
</div>
|
4
|
+
|
5
|
+
<h1>Listing Presses</h1>
|
6
|
+
|
7
|
+
<table class="index" id="listing_orders" data-hook>
|
8
|
+
<thead>
|
9
|
+
<tr data-hook="admin_orders_index_headers">
|
10
|
+
<th><%= sort_link @search, :title, t(:title) %></th>
|
11
|
+
<th><%= sort_link @search, :download_url, t(:download_url) %></th>
|
12
|
+
<th data-hook="admin_events_index_header_actions"></th>
|
13
|
+
</tr>
|
14
|
+
</thead>
|
15
|
+
<tbody>
|
16
|
+
<% @presses.each do |press| %>
|
17
|
+
<tr data-hook="admin_presses_index_rows">
|
18
|
+
<td><%= link_to press.title, edit_admin_press_path(press) %></td>
|
19
|
+
<td><%= press.download_url %></td>
|
20
|
+
<td class='actions' data-hook="admin_presses_index_row_actions">
|
21
|
+
<%= link_to_edit_url edit_admin_press_path(press), :title => "admin_edit_#{dom_id(press)}" %>
|
22
|
+
|
23
|
+
<a href="#" onclick="jConfirm('Are you sure?', 'Confirm Deletion', function(r) {
|
24
|
+
if(r){
|
25
|
+
$.ajax({
|
26
|
+
type: 'POST',
|
27
|
+
url: '<%= admin_press_path(press) %>',
|
28
|
+
data: ({_method: 'delete', authenticity_token: AUTH_TOKEN}),
|
29
|
+
dataType:'script',
|
30
|
+
success: function(r){ $('#spree_image_1').fadeOut('hide'); },
|
31
|
+
error: function(jqXHR, textStatus, errorThrown){ if(jqXHR.status == 500) { show_flash_error(jqXHR.responseText); } else { press.reload(); } }
|
32
|
+
});
|
33
|
+
}
|
34
|
+
});; return false;"><img alt="Delete" src="/assets/admin/icons/delete.png" /> Delete</a>
|
35
|
+
</td>
|
36
|
+
</tr>
|
37
|
+
<% end %>
|
38
|
+
</tbody>
|
39
|
+
</table>
|
40
|
+
|
41
|
+
<%= paginate @presses %>
|
42
|
+
|
43
|
+
<% content_for :sidebar do %>
|
44
|
+
|
45
|
+
<% end %>
|
data/config/routes.rb
CHANGED
@@ -2,4 +2,12 @@
|
|
2
2
|
# admin.resources :products do |product|
|
3
3
|
# product.resources :variants, :member => {:zone_prices => :get}
|
4
4
|
# end
|
5
|
-
#end
|
5
|
+
#end
|
6
|
+
|
7
|
+
Spree::Core::Engine.routes.prepend do
|
8
|
+
namespace :admin do
|
9
|
+
|
10
|
+
resources :zone_prices, :except => [ :show ]
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_zone_pricing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -19,8 +19,13 @@ executables: []
|
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
|
+
- app/controllers/spree/admin/zone_prices_controller.rb
|
22
23
|
- app/models/zone_price.rb
|
23
24
|
- app/views/spree/admin/shared/_product_sub_menu.html.erb
|
25
|
+
- app/views/spree/admin/zone_prices/_form.html.erb
|
26
|
+
- app/views/spree/admin/zone_prices/edit.html.erb
|
27
|
+
- app/views/spree/admin/zone_prices/index.html.erb
|
28
|
+
- app/views/spree/admin/zone_prices/new.html.erb
|
24
29
|
- config/routes.rb
|
25
30
|
- config/locales/en_spree.yml
|
26
31
|
- db/seeds.rb
|