mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Move options to first page
This commit is contained in:
@@ -2,37 +2,24 @@ angular.module("admin.productImport").controller "ImportOptionsFormCtrl", ($scop
|
||||
|
||||
$scope.initForm = () ->
|
||||
$scope.settings = {} if $scope.settings == undefined
|
||||
$scope.settings[$scope.supplierId] = {
|
||||
import_into: 'product_list'
|
||||
defaults:
|
||||
count_on_hand:
|
||||
mode: 'overwrite_all'
|
||||
on_hand:
|
||||
mode: 'overwrite_all'
|
||||
tax_category_id:
|
||||
mode: 'overwrite_all'
|
||||
shipping_category_id:
|
||||
mode: 'overwrite_all'
|
||||
available_on:
|
||||
mode: 'overwrite_all'
|
||||
$scope.settings = {
|
||||
import_into: 'product_list',
|
||||
reset_all_absent: false
|
||||
}
|
||||
$scope.import_into = 'product_list'
|
||||
|
||||
$scope.updateImportInto = () ->
|
||||
$scope.import_into = $scope.settings[$scope.supplierId]['import_into']
|
||||
|
||||
$scope.$watch 'settings', (updated) ->
|
||||
ProductImportService.updateSettings(updated)
|
||||
, true
|
||||
|
||||
$scope.toggleResetAbsent = (id) ->
|
||||
checked = $scope.settings[id]['reset_all_absent']
|
||||
$scope.toggleResetAbsent = ->
|
||||
checked = $scope.settings['reset_all_absent']
|
||||
confirmed = confirm t('js.product_import.confirmation') if checked
|
||||
|
||||
if confirmed or !checked
|
||||
ProductImportService.updateResetAbsent($scope.supplierId, $scope.reset_counts[$scope.supplierId], checked)
|
||||
else
|
||||
$scope.settings[id]['reset_all_absent'] = false
|
||||
$scope.settings['reset_all_absent'] = false
|
||||
|
||||
$scope.resetTotal = ProductImportService.resetTotal
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ module ProductImport
|
||||
end
|
||||
|
||||
def import_into_inventory?(entry)
|
||||
entry.supplier_id && @import_settings[:settings][entry.supplier_id.to_s]['import_into'] == 'inventories'
|
||||
entry.supplier_id && @import_settings[:settings]['import_into'] == 'inventories'
|
||||
end
|
||||
|
||||
def save_new_inventory_item(entry)
|
||||
@@ -228,7 +228,7 @@ module ProductImport
|
||||
end
|
||||
|
||||
def import_into_inventory_by_supplier?(supplier_id)
|
||||
@import_settings[:settings] && @import_settings[:settings][supplier_id.to_s] && @import_settings[:settings][supplier_id.to_s]['import_into'] == 'inventories'
|
||||
@import_settings[:settings] && @import_settings[:settings][supplier_id.to_s] && @import_settings[:settings]['import_into'] == 'inventories'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -221,7 +221,7 @@ module ProductImport
|
||||
end
|
||||
|
||||
def import_into_inventory?(entry)
|
||||
entry.supplier_id && @import_settings[:settings][entry.supplier_id.to_s]['import_into'] == 'inventories'
|
||||
entry.supplier_id && @import_settings[:settings]['import_into'] == 'inventories'
|
||||
end
|
||||
|
||||
def validate_inventory_item(entry, variant_override)
|
||||
|
||||
@@ -3,38 +3,31 @@
|
||||
|
||||
- @importer.suppliers_index.each do |name, supplier_id|
|
||||
- if name and supplier_id and @importer.permission_by_id?(supplier_id)
|
||||
%div.panel-section.import-settings{ng: {controller: 'DropdownPanelsCtrl'}}
|
||||
%div.panel-section.import-settings
|
||||
%div.panel-header{ng: {click: 'togglePanel()', class: '{active: active}'}}
|
||||
%div.header-caret
|
||||
%i{ng: {class: "{'icon-chevron-down': active, 'icon-chevron-right': !active}"}}
|
||||
%div.header-icon.neutral
|
||||
%i.fa.fa-edit
|
||||
%div.header-icon.success
|
||||
%i.fa.fa-check-circle
|
||||
%div.header-description
|
||||
= name
|
||||
%div.panel-content{ng: {hide: '!active'}}
|
||||
= render 'options_form', supplier_id: supplier_id, name: name
|
||||
- elsif name and supplier_id
|
||||
%div.panel-section.import-settings{ng: {controller: 'DropdownPanelsCtrl'}}
|
||||
%div.panel-section.import-settings
|
||||
%div.panel-header
|
||||
%div.header-caret
|
||||
%div.header-icon.error
|
||||
%i.fa.fa-warning
|
||||
%div.header-description
|
||||
= name
|
||||
%span.header-error= " - #{t('admin.product_import.import.no_permission')}"
|
||||
- elsif name
|
||||
%div.panel-section.import-settings{ng: {controller: 'DropdownPanelsCtrl'}}
|
||||
%div.panel-section.import-settings
|
||||
%div.panel-header
|
||||
%div.header-caret
|
||||
%div.header-icon.error
|
||||
%i.fa.fa-warning
|
||||
%div.header-description
|
||||
= name
|
||||
%span.header-error= " - #{t('admin.product_import.import.not_found')}"
|
||||
- else
|
||||
%div.panel-section.import-settings{ng: {controller: 'DropdownPanelsCtrl'}}
|
||||
%div.panel-section.import-settings
|
||||
%div.panel-header
|
||||
%div.header-caret
|
||||
%div.header-icon.error
|
||||
%i.fa.fa-warning
|
||||
%div.header-description
|
||||
|
||||
@@ -1,11 +1,30 @@
|
||||
%div{ng: {app: 'admin.productImport'}}
|
||||
%div{ng: {app: 'admin.productImport', controller: 'ImportOptionsFormCtrl', init: "initForm()"}}
|
||||
|
||||
%h5= t('admin.product_import.index.select_file')
|
||||
%br
|
||||
= form_tag main_app.admin_product_import_path, multipart: true, class: 'product-import' do
|
||||
%label #{t('admin.product_import.index.spreadsheet')}
|
||||
|
||||
%h6= t('admin.product_import.index.choose_import_type')
|
||||
%br
|
||||
= select_tag "import_into", options_for_select({"#{t('admin.product_import.index.product_list')}" => :product_list, "#{t('admin.product_import.index.inventories')}" => :inventories}), {class: 'select2 select2-no-search', 'ng-model' => 'settings.import_into'}
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
|
||||
%h6= t('admin.product_import.index.select_file')
|
||||
%br
|
||||
= file_field_tag :file
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
|
||||
%h6= t('admin.product_import.import.reset_absent?')
|
||||
%br
|
||||
= hidden_field_tag "settings[reset_all_absent]", 0
|
||||
= check_box_tag "settings[reset_all_absent]", 1, false, 'ng-model' => 'settings.reset_all_absent'
|
||||
%span= t('admin.product_import.import.reset_absent_tip')
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
|
||||
= submit_tag "#{t('admin.product_import.index.upload')}"
|
||||
%br
|
||||
%br
|
||||
|
||||
@@ -466,7 +466,8 @@ en:
|
||||
index:
|
||||
select_file: Select a spreadsheet to upload
|
||||
spreadsheet: Spreadsheet
|
||||
import_into: "Import into:"
|
||||
choose_import_type: Select import type
|
||||
import_into: Import type
|
||||
product_list: Product list
|
||||
inventories: Inventories
|
||||
import: Import
|
||||
@@ -496,7 +497,8 @@ en:
|
||||
not_found: enterprise could not be found in database
|
||||
no_name: No name
|
||||
blank_supplier: some products have blank supplier name
|
||||
reset_absent?: Reset absent products?
|
||||
reset_absent?: Reset absent products
|
||||
reset_absent_tip: Set stock to zero for all exiting products not present in the file
|
||||
overwrite_all: Overwrite all
|
||||
overwrite_empty: Overwrite if empty
|
||||
default_stock: Set stock level
|
||||
|
||||
@@ -44,7 +44,7 @@ describe ProductImport::ProductImporter do
|
||||
end
|
||||
File.write('/tmp/test-m.csv', csv_data)
|
||||
file = File.new('/tmp/test-m.csv')
|
||||
settings = {enterprise.id.to_s => {'import_into' => 'product_list'}}
|
||||
settings = {'import_into' => 'product_list'}
|
||||
@importer = ProductImport::ProductImporter.new(file, admin, start: 1, end: 100, settings: settings)
|
||||
end
|
||||
after { File.delete('/tmp/test-m.csv') }
|
||||
@@ -131,7 +131,7 @@ describe ProductImport::ProductImporter do
|
||||
end
|
||||
File.write('/tmp/test-m.csv', csv_data)
|
||||
file = File.new('/tmp/test-m.csv')
|
||||
settings = {enterprise.id.to_s => {'import_into' => 'product_list'}}
|
||||
settings = {'import_into' => 'product_list'}
|
||||
@importer = ProductImport::ProductImporter.new(file, admin, start: 1, end: 100, settings: settings)
|
||||
end
|
||||
after { File.delete('/tmp/test-m.csv') }
|
||||
|
||||
Reference in New Issue
Block a user