mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-12 23:27:48 +00:00
Fill the from with model
This commit is contained in:
@@ -1,13 +1,21 @@
|
||||
angular.module("admin.customers").directive 'editAddressDialog', ($compile, $templateCache, DialogDefaults, CurrentShop, Customers) ->
|
||||
angular.module("admin.customers").directive 'editAddressDialog', ($compile, $templateCache, $filter, DialogDefaults, Customers) ->
|
||||
restrict: 'A'
|
||||
scope: true
|
||||
link: (scope, element, attr) ->
|
||||
scope.$watch 'country', (newVal) ->
|
||||
scope.$watch 'address.country_id', (newVal) ->
|
||||
if newVal
|
||||
scope.states = newVal.states
|
||||
scope.states = scope.filter_states(newVal)
|
||||
|
||||
scope.updateAddress = ->
|
||||
console.log(scope.edit_address_form)
|
||||
|
||||
template = $compile($templateCache.get('admin/edit_address_dialog.html'))(scope)
|
||||
template.dialog(DialogDefaults)
|
||||
|
||||
element.bind 'click', (e) ->
|
||||
scope.address = scope.customer.bill_address
|
||||
template.dialog('open')
|
||||
scope.$apply()
|
||||
|
||||
scope.filter_states = (countryID) ->
|
||||
$filter('filter')(scope.availableCountries, {id: countryID})[0].states
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#edit-address-dialog
|
||||
%h2 Edit Shipping Address
|
||||
%form{ name: 'edit_address_form', novalidate: true, ng: { submit: 'editAddress()'}}
|
||||
%form{ name: 'edit_address_form', novalidate: true, ng: { submit: 'updateAddress()'}}
|
||||
.row
|
||||
Required fields are denoted with an asterisk (
|
||||
%span.required *
|
||||
@@ -11,38 +11,38 @@
|
||||
Address1
|
||||
%span.required *
|
||||
%td
|
||||
%input{ type: 'text', name: 'address1', required: true, ng: { model: 'address1'} }
|
||||
%input{ type: 'text', name: 'address1', required: true, ng: { model: 'address.address1'} }
|
||||
%tr
|
||||
%td
|
||||
Address2:
|
||||
%td
|
||||
%input{ type: 'text', name: 'address2', ng: { model: 'address2'} }
|
||||
%input{ type: 'text', name: 'address2', ng: { model: 'address.address2'} }
|
||||
%tr
|
||||
%td
|
||||
Phone:
|
||||
%td
|
||||
%input{ type: 'text', name: 'phone', required: true, ng: { model: 'phone'} }
|
||||
%input{ type: 'text', name: 'phone', required: true, ng: { model: 'address.phone'} }
|
||||
%tr
|
||||
%td
|
||||
City:
|
||||
%td
|
||||
%input{ type: 'text', name: 'city', required: true, ng: { model: 'city'} }
|
||||
%input{ type: 'text', name: 'city', required: true, ng: { model: 'address.city'} }
|
||||
%tr
|
||||
%td
|
||||
Zipcode:
|
||||
%td
|
||||
%input{ type: 'text', name: 'zipcode', required: true, ng: { model: 'zipcode'} }
|
||||
%input{ type: 'text', name: 'zipcode', required: true, ng: { model: 'address.zipcode'} }
|
||||
%tr
|
||||
%td
|
||||
Country:
|
||||
%td
|
||||
%select{name: 'country', required: true, ng: {model: 'country', options: 'country as country.name for country in availableCountries track by country.id'}}
|
||||
%select{name: 'country', required: true, ng: {model: 'address.country_id', options: 'country.id as country.name for country in availableCountries'}}
|
||||
%option{value: ''} Select Country
|
||||
%tr
|
||||
%td
|
||||
State:
|
||||
%td
|
||||
%select{name: 'state', required: true, ng: {model: 'state', options: 'state as state.name for state in states track by state.id'}}
|
||||
%select{name: 'state', required: true, ng: {model: 'address.state_id', options: 'state.id as state.name for state in states'}}
|
||||
%option{value: ''} Select State
|
||||
|
||||
.text-center
|
||||
|
||||
Reference in New Issue
Block a user