Merge branch 'master' into 2-0-stable-nov-8th

This commit is contained in:
luisramos0
2018-11-08 11:18:54 +00:00
101 changed files with 4970 additions and 760 deletions

View File

@@ -54,12 +54,14 @@
//= require i18n/translations
//= require darkswarm/i18n.translate.js
//= require moment
//= require moment/de.js
//= require moment/en-gb.js
//= require moment/es.js
//= require moment/fr.js
//= require moment/it.js
//= require moment/nb.js
//= require moment/pt-br.js
//= require moment/pt.js
//= require moment/sv.js
//= require ../shared/mm-foundation-tpls-0.9.0-20180826174721.min.js
//= require angularjs-file-upload

View File

@@ -65,13 +65,6 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout
DirtyProducts.clear()
StatusMessage.clear()
# $scope.matchProducer = (product) ->
# for producer in $scope.producers
# if angular.equals(producer.id, product.producer)
# product.producer = producer
# break
$scope.updateOnHand = (product) ->
on_demand_variants = []
if product.variants

View File

@@ -1,4 +1,4 @@
angular.module("admin.customers").directive 'editAddressDialog', ($compile, $templateCache, $filter, DialogDefaults, Customers, StatusMessage) ->
angular.module("admin.customers").directive 'editAddressDialog', ($compile, $templateCache, DialogDefaults, Customers, StatusMessage, CountryStates) ->
restrict: 'A'
scope: true
link: (scope, element, attr) ->
@@ -6,9 +6,10 @@ angular.module("admin.customers").directive 'editAddressDialog', ($compile, $tem
scope.errors = []
scope.$watch 'address.country_id', (newCountryID) ->
if newCountryID
scope.states = scope.filterStates(newCountryID)
scope.clearState() unless scope.addressStateMatchesCountry()
return unless newCountryID
scope.states = CountryStates.statesFor(scope.availableCountries, newCountryID)
unless CountryStates.addressStateMatchesCountryStates(scope.states, scope.address.state_id)
scope.address.state_id = ""
scope.updateAddress = ->
scope.edit_address_form.$setPristine()
@@ -27,19 +28,9 @@ angular.module("admin.customers").directive 'editAddressDialog', ($compile, $tem
else
scope.addressType = 'ship_address'
scope.address = scope.customer[scope.addressType]
scope.states = scope.filterStates(scope.address?.country_id)
scope.states = CountryStates.statesFor(scope.availableCountries, scope.address?.country_id)
template = $compile($templateCache.get('admin/edit_address_dialog.html'))(scope)
template.dialog(DialogDefaults)
template.dialog('open')
scope.$apply()
scope.filterStates = (countryID) ->
return [] unless countryID
$filter('filter')(scope.availableCountries, {id: parseInt(countryID)}, true)[0].states
scope.clearState = ->
scope.address.state_id = ""
scope.addressStateMatchesCountry = ->
scope.states.some (state) -> state.id == scope.address.state_id

View File

@@ -3,7 +3,7 @@ angular.module("admin.productImport").controller "ImportFormCtrl", ($scope, $htt
$scope.entries = {}
$scope.update_counts = {}
$scope.reset_counts = {}
$scope.supplier_product_counts = ams_data.supplier_product_counts
$scope.enterprise_product_counts = ams_data.enterprise_product_counts
$scope.updates = {}
$scope.updated_total = 0
@@ -19,7 +19,7 @@ angular.module("admin.productImport").controller "ImportFormCtrl", ($scope, $htt
}
$scope.countResettable = () ->
angular.forEach $scope.supplier_product_counts, (value, key) ->
angular.forEach $scope.enterprise_product_counts, (value, key) ->
$scope.reset_counts[key] = value
if $scope.update_counts[key]
$scope.reset_counts[key] -= $scope.update_counts[key]

View File

@@ -17,7 +17,7 @@ angular.module("admin.productImport").controller "ImportOptionsFormCtrl", ($scop
confirmed = confirm t('js.product_import.confirmation') if checked
if confirmed or !checked
ProductImportService.updateResetAbsent($scope.supplierId, $scope.reset_counts[$scope.supplierId], checked)
ProductImportService.updateResetAbsent($scope.enterpriseId, $scope.reset_counts[$scope.enterpriseId], checked)
else
$scope.settings['reset_all_absent'] = false

View File

@@ -18,15 +18,15 @@ angular.module("admin.productImport").filter 'entriesFilterValid', ->
filtered
angular.module("admin.productImport").filter 'entriesFilterSupplier', ->
(entries, supplier) ->
if supplier == 'all'
angular.module("admin.productImport").filter 'entriesFilterEnterprise', ->
(entries, enterprise) ->
if enterprise == 'all'
return entries
filtered = {}
angular.forEach entries, (entry, line_number) ->
if supplier == entry.attributes['supplier']
if enterprise == entry.attributes['enterprise']
filtered[line_number] = entry
filtered

View File

@@ -1,15 +1,15 @@
angular.module("admin.productImport").factory "ProductImportService", ($rootScope) ->
new class ProductImportService
suppliers: {}
enterprises: {}
resetTotal: 0
settings: {}
updateResetAbsent: (supplierId, resetCount, resetAbsent) ->
updateResetAbsent: (enterpriseId, resetCount, resetAbsent) ->
if resetAbsent
@suppliers[supplierId] = resetCount
@enterprises[enterpriseId] = resetCount
@resetTotal += resetCount
else
@suppliers[supplierId] = null
@enterprises[enterpriseId] = null
@resetTotal -= resetCount
$rootScope.resetTotal = @resetTotal

View File

@@ -1,6 +1,7 @@
angular.module("admin.resources").factory 'OrderResource', ($resource) ->
$resource('/admin/orders/:id/:action.json', {}, {
'index':
url: '/api/orders.json'
method: 'GET'
'update':
method: 'PUT'

View File

@@ -1,10 +1,20 @@
angular.module("admin.subscriptions").controller "AddressController", ($scope, $filter, StatusMessage, availableCountries) ->
angular.module("admin.subscriptions").controller "AddressController", ($scope, StatusMessage, availableCountries, CountryStates) ->
$scope.countries = availableCountries
$scope.statesFor = (country_id) ->
return [] unless country_id
$filter('filter')(availableCountries, {id: country_id})[0].states
$scope.billStates = $scope.statesFor($scope.subscription.bill_address.country_id)
$scope.shipStates = $scope.statesFor($scope.subscription.ship_address.country_id)
$scope.billStates = CountryStates.statesFor(availableCountries, $scope.subscription.bill_address.country_id)
$scope.shipStates = CountryStates.statesFor(availableCountries, $scope.subscription.ship_address.country_id)
$scope.$watch 'subscription.bill_address.country_id', (newCountryID) ->
return unless newCountryID
$scope.billStates = CountryStates.statesFor(availableCountries, newCountryID)
unless CountryStates.addressStateMatchesCountryStates($scope.billStates, $scope.subscription.bill_address.state_id)
$scope.subscription.bill_address.state_id = ""
$scope.$watch 'subscription.ship_address.country_id', (newCountryID) ->
return unless newCountryID
$scope.shipStates = CountryStates.statesFor(availableCountries, newCountryID)
unless CountryStates.addressStateMatchesCountryStates($scope.shipStates, $scope.subscription.ship_address.state_id)
$scope.subscription.ship_address.state_id = ""
$scope.registerNextCallback 'address', ->
$scope.subscription_form.$submitted = true
@@ -18,9 +28,3 @@ angular.module("admin.subscriptions").controller "AddressController", ($scope, $
$scope.registerBackCallback 'address', ->
StatusMessage.clear()
$scope.setView('details')
$scope.$watch 'subscription.bill_address.country_id', (newValue, oldValue) ->
$scope.billStates = $scope.statesFor(newValue) if newValue?
$scope.$watch 'subscription.ship_address.country_id', (newValue, oldValue) ->
$scope.shipStates = $scope.statesFor(newValue) if newValue?

View File

@@ -0,0 +1,11 @@
angular.module("admin.utils").factory "CountryStates", ($filter) ->
new class CountryStates
statesFor: (countries, country_id) ->
return [] unless country_id
country = $filter('filter')(countries, {id: parseInt(country_id)}, true)[0]
return [] unless country
country.states
addressStateMatchesCountryStates: (countryStates, stateId) ->
countryStates.some (state) -> state.id == stateId