diff --git a/app/assets/javascripts/admin/product_import/filters/filter_entries.js.coffee b/app/assets/javascripts/admin/product_import/filters/filter_entries.js.coffee index 7855b07058..7513384f9e 100644 --- a/app/assets/javascripts/admin/product_import/filters/filter_entries.js.coffee +++ b/app/assets/javascripts/admin/product_import/filters/filter_entries.js.coffee @@ -7,17 +7,13 @@ angular.module("ofn.admin").filter 'entriesFilterValid', -> angular.forEach entries, (entry, line_number) -> validates_as = entry.validates_as - if type == 'valid' and (validates_as != '') - filtered[line_number] = entry - if type == 'invalid' and (validates_as == '') - filtered[line_number] = entry - if type == 'create_product' and (validates_as == 'new_product' or validates_as == 'new_variant') - filtered[line_number] = entry - if type == 'update_product' and validates_as == 'existing_variant' - filtered[line_number] = entry - if type == 'create_inventory' and validates_as == 'new_inventory_item' - filtered[line_number] = entry - if type == 'update_inventory' and validates_as == 'existing_inventory_item' + + if type == 'valid' and validates_as != '' \ + or type == 'invalid' and validates_as == '' \ + or type == 'create_product' and validates_as == 'new_product' or validates_as == 'new_variant' \ + or type == 'update_product' and validates_as == 'existing_variant' \ + or type == 'create_inventory' and validates_as == 'new_inventory_item' \ + or type == 'update_inventory' and validates_as == 'existing_inventory_item' filtered[line_number] = entry filtered diff --git a/app/controllers/admin/product_import_controller.rb b/app/controllers/admin/product_import_controller.rb index 351a0cb7e5..1a02272edd 100644 --- a/app/controllers/admin/product_import_controller.rb +++ b/app/controllers/admin/product_import_controller.rb @@ -17,12 +17,6 @@ class Admin::ProductImportController < Spree::Admin::BaseController @shipping_categories = Spree::ShippingCategory.order('name ASC') end - # def save - # @importer = ProductImporter.new(File.new(params[:filepath]), spree_current_user, params[:settings]) - # @importer.save_all if @importer.has_valid_entries? - # @import_into = params[:settings][:import_into] - # end - def process_data @importer = ProductImporter.new(File.new(params[:filepath]), spree_current_user, start: params[:start], end: params[:end], settings: params[:settings]) diff --git a/app/controllers/admin/variant_overrides_controller.rb b/app/controllers/admin/variant_overrides_controller.rb index dbe914521e..dee8ed8e67 100644 --- a/app/controllers/admin/variant_overrides_controller.rb +++ b/app/controllers/admin/variant_overrides_controller.rb @@ -56,10 +56,20 @@ module Admin variant_override_enterprises_per_hub @inventory_items = InventoryItem.where(enterprise_id: @hubs) + @import_dates = inventory_import_dates.uniq.to_json + end - import_dates = [{id: '0', name: 'All'}] - inventory_import_dates.map { |i| import_dates.push(id: i.to_date, name: i.to_date.to_formatted_s(:long)) } - @import_dates = import_dates.uniq.to_json + def inventory_import_dates + options = [{id: '0', name: 'All'}] + + import_dates = VariantOverride. + select('variant_overrides.import_date'). + where('variant_overrides.hub_id IN (?) + AND variant_overrides.import_date IS NOT NULL', editable_enterprises.collect(&:id)) + + import_dates.uniq.collect(&:import_date).sort.reverse.map { |i| options.push(id: i.to_date, name: i.to_date.to_formatted_s(:long)) } + + options end def load_collection diff --git a/app/models/spreadsheet_entry.rb b/app/models/spreadsheet_entry.rb index 39dd45a129..42e9acdd63 100644 --- a/app/models/spreadsheet_entry.rb +++ b/app/models/spreadsheet_entry.rb @@ -80,12 +80,10 @@ class SpreadsheetEntry end def is_a_valid?(type) - #@validates_as[type] @validates_as == type end def is_a_valid(type) - #@validates_as.push type @validates_as = type end