Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add configuration page for active_shipping settings

The page shows up in the configuration tab and allows you to set all of the settings available in the extension.

Signed-off-by: Nathan Lowrie <nate@finelineautomation.com>

Fixes #47
  • Loading branch information...
commit f5d1e93cb23331acdf2ac9216582ab86b30f7a65 1 parent c42ea23
@FineLineAutomation FineLineAutomation authored radar committed
View
24 app/controllers/spree/admin/active_shipping_settings_controller.rb
@@ -0,0 +1,24 @@
+class Spree::Admin::ActiveShippingSettingsController < Spree::Admin::BaseController
+
+ def show
+ @config = Spree::ActiveShippingConfiguration.new
+ end
+
+ def edit
+ @config = Spree::ActiveShippingConfiguration.new
+ end
+
+ def update
+ config = Spree::ActiveShippingConfiguration.new
+
+ params.each do |name, value|
+ next unless config.has_preference? name
+ config[name] = value
+ end
+
+ redirect_to admin_active_shipping_settings_path
+ end
+
+end
+
+
View
7 app/overrides/add_active_shipping_settings_link.rb
@@ -0,0 +1,7 @@
+Deface::Override.new(:virtual_path => "spree/admin/configurations/index",
+ :name => "add_active_shipping_settings_link",
+ :insert_after => "[data-hook='admin_configurations_menu'], #admin_configurations_menu[data-hook]",
+ :text => "<tr>
+ <td><%= link_to \"Active Shipping\", admin_active_shipping_settings_path %></td>
+ <td><%= \"Configure Active Shipping Settings\" %></td>
+ </tr>")
View
4 app/overrides/add_active_shipping_settings_tab.rb
@@ -0,0 +1,4 @@
+Deface::Override.new(:virtual_path => "spree/admin/shared/_configuration_menu",
+ :name => "add_active_shipping_settings_tab",
+ :insert_bottom => "[data-hook='admin_configurations_sidebar_menu'], #admin_configurations_sidebar_menu[data-hook]",
+ :text => "<li<%== ' class=\"active\"' if controller.controller_name == 'theme_settings' %>><%= link_to \"Active Shipping\", admin_active_shipping_settings_path %></li>")
View
88 app/views/spree/admin/active_shipping_settings/edit.html.erb
@@ -0,0 +1,88 @@
+<%= render :partial => 'spree/admin/shared/configuration_menu' %>
+
+<h1>Active Shipping Settings</h1>
+
+<%= form_for(@config, :as => "active_shipping_configuration", :url => admin_active_shipping_settings_path, :method => :put) do |form| %>
+ <fieldset id="preferences">
+ <%= form.field_container :ups_login do %>
+ <%= form.label(:ups_login, "UPS Login: ") + tag(:br) %>
+ <%= preference_field_tag(:ups_login, @config[:ups_login], :type => :string) %>
+ <% end %>
+ <%= form.field_container :ups_password do %>
+ <%= form.label(:ups_password,"UPS Password: ") + tag(:br) %>
+ <%= preference_field_tag(:ups_password, @config[:ups_password], :type => :string) %>
+ <% end %>
+ <%= form.field_container :ups_key do %>
+ <%= form.label(:ups_key, "UPS Key: ") + tag(:br) %>
+ <%= preference_field_tag(:ups_key, @config[:ups_key], :type => :string) %>
+ <% end %>
+ <%= form.field_container :shipper_number do %>
+ <%= form.label(:shipper_number, "UPS Shipper Number: ") + tag(:br) %>
+ <%= preference_field_tag(:shipper_number, @config[:shipper_number], :type => :string) %>
+ <% end %>
+ <%= form.field_container :fedex_login do %>
+ <%= form.label(:fedex_login, "FedEx Login: ") + tag(:br) %>
+ <%= preference_field_tag(:fedex_login, @config[:fedex_login], :type => :string) %>
+ <% end %>
+ <%= form.field_container :fedex_password do %>
+ <%= form.label(:fedex_password, "FedEx Password: ") + tag(:br) %>
+ <%= preference_field_tag(:fedex_password, @config[:fedex_password], :type => :string) %>
+ <% end %>
+ <%= form.field_container :fedex_account do %>
+ <%= form.label(:fedex_account, "FedEx Account: ") + tag(:br) %>
+ <%= preference_field_tag(:fedex_account, @config[:fedex_account], :type => :string) %>
+ <% end %>
+ <%= form.field_container :fedex_key do %>
+ <%= form.label(:fedex_key, "FedEx Key: ") + tag(:br) %>
+ <%= preference_field_tag(:fedex_key, @config[:fedex_key], :type => :string) %>
+ <% end %>
+ <%= form.field_container :usps_login do %>
+ <%= form.label(:usps_login, "USPS Login: ") + tag(:br) %>
+ <%= preference_field_tag(:usps_login, @config[:usps_login], :type => :string) %>
+ <% end %>
+ <%= form.field_container :canada_post_login do %>
+ <%= form.label(:canada_post_login, "Canada Post Login: ") + tag(:br) %>
+ <%= preference_field_tag(:canada_post_login, @config[:canada_post_login], :type => :string) %>
+ <% end %>
+ <%= form.field_container :origin_country do %>
+ <%= form.label(:origin_country, "Origin Country: ") + tag(:br) %>
+ <%= preference_field_tag(:origin_country, @config[:origin_country], :type => :string) %>
+ <% end %>
+ <%= form.field_container :origin_state do %>
+ <%= form.label(:origin_state, "Origin State: ") + tag(:br) %>
+ <%= preference_field_tag(:origin_state, @config[:origin_state], :type => :string) %>
+ <% end %>
+ <%= form.field_container :origin_city do %>
+ <%= form.label(:origin_city, "Origin City: ") + tag(:br) %>
+ <%= preference_field_tag(:origin_city, @config[:origin_city], :type => :string) %>
+ <% end %>
+ <%= form.field_container :origin_zip do %>
+ <%= form.label(:origin_zip, "Origin Zip Code: ") + tag(:br) %>
+ <%= preference_field_tag(:origin_zip, @config[:origin_zip], :type => :string) %>
+ <% end %>
+ <%= form.field_container :units do %>
+ <%= form.label(:units, "Units: ") + tag(:br) %>
+ <%= preference_field_tag(:units, @config[:units], :type => :string) %>
+ <% end %>
+ <%= form.field_container :unit_multiplier do %>
+ <%= form.label(:unit_multiplier, "unit_multiplier: ") + tag(:br) %>
+ <%= preference_field_tag(:unit_multiplier, @config[:unit_multiplier], :type => :integer) %>
+ <% end %>
+ <%= form.field_container :default_weight do %>
+ <%= form.label(:default_weight, "Default Weight: ") + tag(:br) %>
+ <%= preference_field_tag(:default_weight, @config[:default_weight], :type => :integer) %>
+ <% end %>
+ <%= form.field_container :handling_fee do %>
+ <%= form.label(:handling_fee, "Handling Fee: ") + tag(:br) %>
+ <%= preference_field_tag(:handling_fee, @config[:handling_fee], :type => :integer) %>
+ <% end %>
+ <%= form.field_container :test_mode do %>
+ <%= form.label(:test_mode, "Test Mode: ") + tag(:br) %>
+ <%= preference_field_tag(:test_mode, @config[:test_mode], :type => :boolean) %>
+ <% end %>
+ </fieldset>
+ <p class="form-buttons">
+ <%= button t('update') %>
+ <%= t("or") %> <%= link_to t("cancel"), admin_active_shipping_settings_url %>
+ </p>
+<% end %>
View
115 app/views/spree/admin/active_shipping_settings/show.html.erb
@@ -0,0 +1,115 @@
+<%= render :partial => 'spree/admin/shared/configuration_menu' %>
+
+<h1>Active Shipping Settings</h1>
+
+<table>
+ <tr>
+ <td>Origin Country:</td>
+ <td><%= @config[:origin_country] %></td>
+ </tr>
+ <tr>
+ <td>Origin State:</td>
+ <td><%= @config[:origin_state] %></td>
+ </tr>
+ <tr>
+ <td>Origin City:</td>
+ <td><%= @config[:origin_city] %></td>
+ </tr>
+ <tr>
+ <td>Origin Zip Code:</td>
+ <td><%= @config[:origin_zip] %></td>
+ </tr>
+</table>
+
+<table>
+ <tr>
+ <td>Units:</td>
+ <td><%= @config[:units] %></td>
+ </tr>
+ <tr>
+ <td>Unit Multiplier: <span>Default is 16 oz./lb - assumes variant weights are in lbs</span></td>
+ <td><%= @config[:unit_multiplier] %></td>
+ </tr>
+ <tr>
+ <td>Default Weight:</td>
+ <td><%= @config[:default_weight] %></td>
+ </tr>
+ <tr>
+ <td>Handling Fee:</td>
+ <td><%= @config[:handling_fee] %></td>
+ </tr>
+ <tr>
+ <td>Test Mode:</td>
+ <td><%= @config[:test_mode] %></td>
+ </tr>
+</table>
+
+<table>
+ <tr>
+ <td>FedEx Login:</td>
+ <td><%= @config[:fedex_login] %></td>
+ </tr>
+ <tr>
+ <td>FedEx Password:</td>
+ <td><%= @config[:fedex_password] %></td>
+ </tr>
+ <tr>
+ <td>FedEx Key:</td>
+ <td><%= @config[:fedex_key] %></td>
+ </tr>
+ <tr>
+ <td>FedEx Account:</td>
+ <td><%= @config[:fedex_account] %></td>
+ </tr>
+</table>
+
+<table>
+ <tr>
+ <td>UPS Login:</td>
+ <td><%= @config[:ups_login] %></td>
+ </tr>
+ <tr>
+ <td>UPS Password:</td>
+ <td><%= @config[:ups_password] %></td>
+ </tr>
+ <tr>
+ <td>UPS Key:</td>
+ <td><%= @config[:ups_key] %></td>
+ </tr>
+ <tr>
+ <td>UPS Shipper Number:</td>
+ <td><%= @config[:shipper_number] %></td>
+ </tr>
+</table>
+
+<table>
+ <tr>
+ <td>FedEx Login:</td>
+ <td><%= @config[:fedex_login] %></td>
+ </tr>
+ <tr>
+ <td>FedEx Password:</td>
+ <td><%= @config[:fedex_password] %></td>
+ </tr>
+ <tr>
+ <td>FedEx Key:</td>
+ <td><%= @config[:fedex_key] %></td>
+ </tr>
+ <tr>
+ <td>FedEx Account:</td>
+ <td><%= @config[:fedex_account] %></td>
+ </tr>
+</table>
+
+<table>
+ <tr>
+ <td>USPS Login:</td>
+ <td><%= @config[:usps_login] %></td>
+ </tr>
+ <tr>
+ <td>Canada Post Login:</td>
+ <td><%= @config[:canada_post_login] %></td>
+ </tr>
+</table>
+
+<p><%= link_to_with_icon 'edit', t("edit"), edit_admin_active_shipping_settings_path %></p>
View
5 config/routes.rb
@@ -0,0 +1,5 @@
+Spree::Core::Engine.routes.draw do
+ namespace :admin do
+ resource :active_shipping_settings, :only => ['show', 'update', 'edit']
+ end
+end

0 comments on commit f5d1e93

Please sign in to comment.
Something went wrong with that request. Please try again.