mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-14 23:47:48 +00:00
I18n and refactoring
This commit is contained in:
@@ -11,12 +11,12 @@ angular.module("admin.customers").directive 'editAddressDialog', ($compile, $tem
|
||||
scope.updateAddress = ->
|
||||
scope.edit_address_form.$setPristine()
|
||||
if scope.edit_address_form.$valid
|
||||
Customers.update(scope.address, scope.customer, scope.current_address).$promise.then (data) ->
|
||||
Customers.update(scope.address, scope.customer, scope.addressType).$promise.then (data) ->
|
||||
scope.customer = data
|
||||
template.dialog('close')
|
||||
StatusMessage.display('success', "Address updated successfully.")
|
||||
StatusMessage.display('success', t('admin.customers.index.update_address_success'))
|
||||
else
|
||||
scope.errors.push("Sorry! Please input all of the required fields!")
|
||||
scope.errors.push(t('admin.customers.index.update_address_error'))
|
||||
|
||||
|
||||
template = $compile($templateCache.get('admin/edit_address_dialog.html'))(scope)
|
||||
@@ -24,10 +24,10 @@ angular.module("admin.customers").directive 'editAddressDialog', ($compile, $tem
|
||||
|
||||
element.bind 'click', (e) ->
|
||||
if e.target.id == 'bill-address-link'
|
||||
scope.current_address = 'bill_address'
|
||||
scope.addressType = 'bill_address'
|
||||
else
|
||||
scope.current_address = 'ship_address'
|
||||
scope.address = scope.customer[scope.current_address]
|
||||
scope.addressType = 'ship_address'
|
||||
scope.address = scope.customer[scope.addressType]
|
||||
|
||||
template.dialog('open')
|
||||
scope.$apply()
|
||||
|
||||
@@ -26,10 +26,10 @@ angular.module("admin.customers").factory "Customers", ($q, InfoDialog, RequestM
|
||||
RequestMonitor.load(request.$promise)
|
||||
request.$promise
|
||||
|
||||
update: (address, customer, current_address) ->
|
||||
update: (address, customer, addressType) ->
|
||||
params =
|
||||
id: customer.id
|
||||
customer:
|
||||
"#{current_address}_attributes": address
|
||||
"#{addressType}_attributes": address
|
||||
CustomerResource.update params
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#edit-address-dialog
|
||||
%h2 {{ current_address === 'bill_address' ? 'Edit Billing Address' : 'Edit Shipping Address'}}
|
||||
%h2 {{ addressType === 'bill_address' ? "#{t('admin.customers.index.edit_bill_address')}" : "#{t('admin.customers.index.edit_ship_address')}" }}
|
||||
%form{ name: 'edit_address_form', novalidate: true, ng: { submit: 'updateAddress()'}}
|
||||
.row
|
||||
Required fields are denoted with an asterisk (
|
||||
= t('admin.customers.index.required_fileds')
|
||||
(
|
||||
%span.required *
|
||||
)
|
||||
.error{ ng: { repeat: "error in errors", bind: "error" } }
|
||||
@@ -43,14 +44,16 @@
|
||||
%span.required *
|
||||
%td
|
||||
%select{name: 'country', required: true, ng: {model: 'address.country_id', options: 'country.id as country.name for country in availableCountries'}}
|
||||
%option{value: ''} Select Country
|
||||
%option{value: ''}
|
||||
= t('admin.customers.index.select_country')
|
||||
%tr
|
||||
%td
|
||||
= t('spree.state')
|
||||
%span.required *
|
||||
%td
|
||||
%select{name: 'state', required: true, ng: {model: 'address.state_id', options: 'state.id as state.name for state in states'}}
|
||||
%option{value: ''} Select State
|
||||
%option{value: ''}
|
||||
= t('admin.customers.index.select_state')
|
||||
|
||||
.text-center
|
||||
%input.button.red.icon-plus{ type: 'submit', value: 'Update Address'}
|
||||
|
||||
@@ -86,9 +86,9 @@
|
||||
.tag_watcher{ 'obj-for-update' => "customer", "attr-for-update" => "tag_list"}
|
||||
%tags_with_translation{ object: 'customer', 'find-tags' => 'findTags(query)' }
|
||||
%td.bill_address{ 'ng-show' => 'columns.bill_address.visible' }
|
||||
%a{ id: 'bill-address-link', href: '#', "ng-bind" => "customer.bill_address ? customer.bill_address.address1 : 'Edit' | limitTo: 15", 'edit-address-dialog' => true }
|
||||
%a{ id: 'bill-address-link', href: '#', "ng-bind" => "customer.bill_address ? customer.bill_address.address1 : '#{t('admin.customers.index.edit')}' | limitTo: 15", 'edit-address-dialog' => true }
|
||||
%td.ship_address{ 'ng-show' => 'columns.ship_address.visible' }
|
||||
%a{ id: 'ship-address-link', href: '#', "ng-bind" => "customer.ship_address ? customer.ship_address.address1 : 'Edit' | limitTo: 15", 'edit-address-dialog' => true }
|
||||
%a{ id: 'ship-address-link', href: '#', "ng-bind" => "customer.ship_address ? customer.ship_address.address1 : '#{t('admin.customers.index.edit')}' | limitTo: 15", 'edit-address-dialog' => true }
|
||||
%td.actions
|
||||
%a{ 'ng-click' => "deleteCustomer(customer)", :class => "delete-customer icon-trash no-text" }
|
||||
|
||||
|
||||
@@ -120,6 +120,14 @@ en:
|
||||
duplicate_code: "This code is used already."
|
||||
bill_address: "Billing Address"
|
||||
ship_address: "Shipping Address"
|
||||
update_address_success: 'Address updated successfully.'
|
||||
update_address_error: 'Sorry! Please input all of the required fields!'
|
||||
edit_bill_address: 'Edit Billing Address'
|
||||
edit_ship_address: 'Edit Shipping Address'
|
||||
required_fileds: 'Required fields are denoted with an asterisk '
|
||||
select_country: 'Select Country'
|
||||
select_state: 'Select State'
|
||||
edit: 'Edit'
|
||||
|
||||
products:
|
||||
bulk_edit:
|
||||
|
||||
Reference in New Issue
Block a user