Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into transifex
Browse files Browse the repository at this point in the history
Conflicts:
	config/locales/en_GB.yml
  • Loading branch information
mkllnk committed Oct 28, 2016
2 parents b78739f + fb08759 commit b66cf14
Show file tree
Hide file tree
Showing 51 changed files with 1,079 additions and 1,414 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ angular.module("admin.customers").controller "customersCtrl", ($scope, $q, $filt
$scope.RequestMonitor = RequestMonitor
$scope.submitAll = pendingChanges.submitAll
$scope.add = Customers.add
$scope.deleteCustomer = Customers.remove
$scope.customerLimit = 20
$scope.columns = Columns.columns

Expand All @@ -21,6 +20,10 @@ angular.module("admin.customers").controller "customersCtrl", ($scope, $q, $filt

$scope.shop_id = shops[0].id if shops.length == 1

$scope.deleteCustomer = (customer) ->
if confirm(t('admin.customers.index.confirm_delete'))
Customers.remove(customer)

$scope.checkForDuplicateCodes = ->
delete this.customer.code unless this.customer.code
this.duplicate = $scope.isDuplicateCode(this.customer.code)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
angular.module("admin.orders").directive 'customerSearchOverride', ->
restrict: 'C'
link: (scope, element, attr) ->
formatCustomerResult = (customer) ->
customerTemplate
customer: customer
bill_address: customer.bill_address
ship_address: customer.ship_address

element.select2
placeholder: Spree.translations.choose_a_customer
ajax:
url: '/admin/search/customers.json'
datatype: 'json'
data: (term, page) ->
{
q: term
distributor_id: $('#distributor_id').val() # modified
}
results: (data, page) ->
{ results: data }
dropdownCssClass: 'customer_search'
formatResult: formatCustomerResult
formatSelection: (customer) ->
_.each [
'bill_address'
'ship_address'
], (address) ->
data = customer[address]
address_parts = [
'firstname'
'lastname'
'company'
'address1'
'address2'
'city'
'zipcode'
'phone'
]
attribute_wrapper = '#order_' + address + '_attributes_'
if data # modified
_.each address_parts, (part) ->
$(attribute_wrapper + part).val data[part]
return
$(attribute_wrapper + 'state_id').select2 'val', data['state_id']
$(attribute_wrapper + 'country_id').select2 'val', data['country_id']
else
_.each address_parts, (part) ->
$(attribute_wrapper + part).val ''
return
$(attribute_wrapper + 'state_id').select2 'val', ''
$(attribute_wrapper + 'country_id').select2 'val', ''
return
$('#order_email').val customer.email
$('#user_id').val customer.user_id # modified
$('#guest_checkout_true').prop 'checked', false
$('#guest_checkout_false').prop 'checked', true
$('#guest_checkout_false').prop 'disabled', false
customer.email
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
Darkswarm.controller "AccordionCtrl", ($scope, storage, $timeout, $document, CurrentHub) ->
$scope.accordion =
details: true
billing: false
shipping: false
payment: false
Darkswarm.controller "AccordionCtrl", ($scope, localStorageService, $timeout, $document, CurrentHub) ->
key = "accordion_#{$scope.order.id}#{CurrentHub.hub.id}#{$scope.order.user_id}"
value = if localStorageService.get(key) then {} else { details: true, billing: false, shipping: false, payment: false }
localStorageService.bind $scope, "accordion", value, key
$scope.accordionSections = ["details", "billing", "shipping", "payment"]
storage.bind $scope, "accordion", {storeName: "accordion_#{$scope.order.id}#{CurrentHub.hub.id}#{$scope.order.user_id}"}

$scope.show = (section)->
$scope.accordion[section] = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Darkswarm.controller "CheckoutCtrl", ($scope, storage, Checkout, CurrentUser, CurrentHub) ->
Darkswarm.controller "CheckoutCtrl", ($scope, localStorageService, Checkout, CurrentUser, CurrentHub) ->
$scope.Checkout = Checkout
$scope.submitted = false

Expand All @@ -7,11 +7,11 @@ Darkswarm.controller "CheckoutCtrl", ($scope, storage, Checkout, CurrentUser, Cu
prefix = "order_#{Checkout.order.id}#{CurrentUser.id or ""}#{CurrentHub.hub.id}"

for field in $scope.fieldsToBind
storage.bind $scope, "Checkout.order.#{field}",
storeName: "#{prefix}_#{field}"
storage.bind $scope, "Checkout.ship_address_same_as_billing",
storeName: "#{prefix}_sameasbilling"
defaultValue: true
localStorageService.bind $scope, "Checkout.order.#{field}", Checkout.order[field], "#{prefix}_#{field}"

localStorageService.bind $scope, "Checkout.ship_address_same_as_billing", true, "#{prefix}_sameasbilling"
localStorageService.bind $scope, "Checkout.default_bill_address", false, "#{prefix}_defaultasbilladdress"
localStorageService.bind $scope, "Checkout.default_ship_address", false, "#{prefix}_defaultasshipaddress"

$scope.order = Checkout.order # Ordering is important
$scope.secrets = Checkout.secrets
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/darkswarm/darkswarm.js.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
window.Darkswarm = angular.module("Darkswarm", ["ngResource",
'mm.foundation',
'angularLocalStorage',
'LocalStorageModule',
'infinite-scroll',
'angular-flash.service',
'templates',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Darkswarm.directive "ofnChangeOrderCycle", (OrderCycle, Cart, storage) ->
Darkswarm.directive "ofnChangeOrderCycle", (OrderCycle, Cart) ->
# Compares chosen order cycle with pre-set OrderCycle. Will trigger
# a confirmation if they are different, and Cart isn't empty
restrict: "A"
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/darkswarm/services/cart.js.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http, $modal, $rootScope, storage)->
Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http, $modal, $rootScope, localStorageService)->
# Handles syncing of current cart/order state to server
new class Cart
dirty: false
Expand Down Expand Up @@ -114,4 +114,4 @@ Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http, $modal, $roo

clear: ->
@line_items = []
storage.clearAll() # One day this will have to be moar GRANULAR
localStorageService.clearAll() # One day this will have to be moar GRANULAR
6 changes: 4 additions & 2 deletions app/assets/javascripts/darkswarm/services/checkout.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Darkswarm.factory 'Checkout', (CurrentOrder, ShippingMethods, PaymentMethods, $h
errors: {}
secrets: {}
order: CurrentOrder.order
ship_address_same_as_billing: true

submit: ->
Loading.message = t 'submitting_order'
Expand All @@ -19,7 +18,10 @@ Darkswarm.factory 'Checkout', (CurrentOrder, ShippingMethods, PaymentMethods, $h

# Rails wants our Spree::Address data to be provided with _attributes
preprocess: ->
munged_order = {}
munged_order =
default_bill_address: !!@default_bill_address
default_ship_address: !!@default_ship_address

for name, value of @order # Clone all data from the order JSON object
switch name
when "bill_address"
Expand Down
Loading

0 comments on commit b66cf14

Please sign in to comment.