Product Import Guide WIP

This commit is contained in:
Matt-Yorkley
2018-02-03 19:29:31 +00:00
parent 7da97be7d2
commit b42e3eb2c9
10 changed files with 325 additions and 4 deletions

View File

@@ -26,12 +26,15 @@ angular.module("admin.productImport").controller "ImportOptionsFormCtrl", ($scop
, true
$scope.toggleResetAbsent = (id) ->
resetAbsent = $scope.settings[id]['reset_all_absent']
checked = $scope.settings[id]['reset_all_absent']
confirmed = confirm t('js.product_import.confirmation') if resetAbsent
if confirmed or !resetAbsent
if confirmed or !checked
ProductImportService.updateResetAbsent($scope.supplierId, $scope.reset_counts[$scope.supplierId], resetAbsent)
if !confirmed and checked
$scope.settings[id]['reset_all_absent'] = false
$scope.resetTotal = ProductImportService.resetTotal
$rootScope.$watch 'resetTotal', (newValue) ->

View File

@@ -1,3 +1,38 @@
.product-import-introduction {
h1, h2, h3, h4, h5, h6 {
margin: 1.5em 0 1em;
}
h6 {
font-size: 1em;
}
p {
margin-bottom: 1em;
}
span.category {
display: inline-block;
background-color: #f3f3f3;
padding: 0.4em 0.8em;
margin: 0 0.4em 0.5em 0;
}
table {
&.product-import-columns tr:hover td {
background-color: transparent;
}
thead th {
text-transform: none;
font-size: 100%;
text-align: left;
}
}
}
div.panel-section {
.neutral {

View File

@@ -2,7 +2,13 @@ require 'roo'
module Admin
class ProductImportController < Spree::Admin::BaseController
before_filter :validate_upload_presence, except: %i[index validate_data]
before_filter :validate_upload_presence, except: %i[index guide validate_data]
def guide
@product_categories = Spree::Taxon.order('name ASC').pluck(:name)
@tax_categories = Spree::TaxCategory.order('name ASC').pluck(:name)
@shipping_categories = Spree::ShippingCategory.order('name ASC').pluck(:name)
end
def import
# Save uploaded file to tmp directory

View File

@@ -177,7 +177,7 @@ class AbilityDecorator
can [:admin, :index, :read, :search], Spree::Taxon
can [:admin, :index, :read, :create, :edit], Spree::Classification
can [:admin, :index, :import, :save, :save_data, :validate_data, :reset_absent_products], ProductImport::ProductImporter
can [:admin, :index, :guide, :import, :save, :save_data, :validate_data, :reset_absent_products], ProductImport::ProductImporter
# Reports page
can [:admin, :index, :customers, :orders_and_distributors, :group_buys, :bulk_coop, :payments, :orders_and_fulfillment, :products_and_inventory, :order_cycle_management, :packing], :report

View File

@@ -0,0 +1,69 @@
- content_for :page_title do
Product Import Guide
- content_for :page_actions do
%div.toolbar{ 'data-hook' => "toolbar" }
%ul.actions.header-action-links.inline-menu
%li
= button_link_to 'Back to Import', main_app.admin_product_import_path
= render partial: 'spree/admin/shared/product_sub_menu'
.product-import-introduction
%h5 Spreadsheet Columns
= render 'admin/product_import/guide/columns'
%h5 Weight, volume, or single items
%p
When creating a product you can specify a number of options. If the product is measured
by weight, unit_value should be set to a number and unit_type should be set to either
g for grams, Kg for kilograms, or T for tonnes.
%p
For items such as liquids, the unit_type can be ml for millilitres, L for litres or
Kl for kilolitres.
%p
For other items that are sold in different units such as "a bunch of carrots", you can
enter 1 for units, leave unit_type blank, and enter a name in the variant_unit_name
column such as "loaf" or "bunch".
%h6 Example spreadsheet data:
= render 'admin/product_import/guide/units'
%h5 Product Variants
%p
Variants are distinguished by the units and display_name fields and grouped by product name.
The example below shows a salad that comes in 500g and 750g variants, and a cake that comes in
multiple flavours.
%h6 Example spreadsheet data:
= render 'admin/product_import/guide/variants'
%h5 Category Values
%p
Listed below are the available Product categories, as well as Tax and Shipping categories.
%h6 Product Categories
- @product_categories.each do |pc|
%span.category= pc
%h6 Tax Categories
- @tax_categories.each do |tc|
%span.category= tc
%h6 Shipping Categories
- @shipping_categories.each do |sc|
%span.category= sc

View File

@@ -0,0 +1,93 @@
%table.product-import-columns
%thead
%tr
%th Column Title
%th Required
%th Examples
%th Description
%th Notes
%tbody
%tr
%td
%strong name
%td Yes
%td Potatoes
%td The name of the product
%td
%tr
%td
%strong supplier
%td Yes
%td Pennylane Farm
%td The name of the product's supplier
%td
%tr
%td
%strong category
%td Yes
%td Vegetables
%td The product category
%td See below for a list of available categories
%tr
%td
%strong on_hand
%td Yes
%td 15
%td The amount currently in stock
%td
%tr
%td
%strong price
%td Yes
%td 2.50
%td The price of the product
%td
%tr
%td
%strong units
%td Yes
%td 750
%td The weight or volume value.
%td
%tr
%td
%strong unit_type
%td Yes
%td g
%td The unit type, i.e. g for grams, Kg for Kilograms, ml for millilitres. Can be blank (see notes).
%td If unit_type is left blank, a variant_unit_name must be given.
%tr
%td
%strong variant_unit_name
%td Maybe
%td bunch
%td If the product is sold as an item such as "bunch", "loaf" or "case", that goes here.
%td Used for products that don't use a unit_type for weight or volume.
%tr
%td
%strong display_name
%td No
%td Orange
%td Used to name product variants, if they have a distinct name.
%td
%tr
%td
%strong on_demand
%td No
%td 1
%td Flag the product as "made on demand". The product will not use stock levels.
%td 1 for active, 0 for disabled, or leave blank to ignore.
%tr
%td
%strong tax_category
%td No
%td (Various, see notes)
%td Sets the product tax category
%td See below for a list of available categories
%tr
%td
%strong shipping_category
%td No
%td (Various, see notes)
%td Sets the product shipping category
%td See below for a list of available categories

View File

@@ -0,0 +1,54 @@
%table
%thead
%tr
%th
%th name
%th category
%th supplier
%th on_hand
%th price
%th units
%th unit_type
%th variant_unit_name
%tbody
%tr
%td 1
%td Salad Bag
%td Salads
%td Sue's Salads
%td 26
%td 3.50
%td 500
%td g
%td
%tr
%td 2
%td Fruit Juice
%td Drinks
%td Country Juices
%td 12
%td 3.50
%td 300
%td ml
%td
%tr
%td 3
%td Potatoes
%td Vegetables
%td Fernwell Farm
%td 67
%td 4.20
%td 1
%td kg
%td
%tr
%td 3
%td Wholemeal Bread
%td Baked goods
%td Tim's Bakery
%td 66
%td 3.00
%td 1
%td
%td loaf

View File

@@ -0,0 +1,54 @@
%table
%thead
%tr
%th
%th name
%th category
%th supplier
%th on_hand
%th price
%th units
%th unit_type
%th display_name
%tbody
%tr
%td 1
%td Salad Bag
%td Salads
%td Sue's Salads
%td 26
%td 3.50
%td 500
%td g
%td
%tr
%td 2
%td Salad Bag
%td Salads
%td Sue's Salads
%td 44
%td 5.50
%td 750
%td g
%td
%tr
%td 3
%td Cake
%td Baked goods
%td Tim's Cakes
%td 10
%td 4
%td 500
%td g
%td Banana and Walnut
%tr
%td 4
%td Cake
%td Baked goods
%td Tim's Cakes
%td 18
%td 4
%td 500
%td g
%td Carrot

View File

@@ -1,6 +1,12 @@
- content_for :page_title do
#{t('admin.product_import.title')}
- content_for :page_actions do
%div.toolbar{ 'data-hook' => "toolbar" }
%ul.actions.header-action-links.inline-menu
%li
= button_link_to 'View Guide', main_app.admin_product_import_guide_path
= render partial: 'spree/admin/shared/product_sub_menu'
= render 'upload_form'

View File

@@ -134,6 +134,7 @@ Openfoodnetwork::Application.routes.draw do
get '/inventory', to: 'variant_overrides#index'
get '/product_import', to: 'product_import#index'
get '/product_import/guide', to: 'product_import#guide', as: 'product_import_guide'
post '/product_import', to: 'product_import#import'
post '/product_import/validate_data', to: 'product_import#validate_data', as: 'product_import_process_async'
post '/product_import/save_data', to: 'product_import#save_data', as: 'product_import_save_async'