mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-24 11:22:38 +00:00
Get validation working with address fields and Angular digest loop
This commit is contained in:
parent
2a78a7843a
commit
3731c62e17
2 changed files with 14 additions and 13 deletions
|
@ -128,22 +128,22 @@ block content
|
|||
hr
|
||||
.row
|
||||
.col-md-12
|
||||
.form-group
|
||||
.form-group(ng-class="validation.errorFields.address1 ? 'has-error' : ''")
|
||||
label #{translate("billing_address")}
|
||||
input.form-control(type='text', value='', maxlength='255', tabindex='1', onkeyup='', ng-model="data.address1", placeholder="#{translate('address')}")
|
||||
.form-group
|
||||
.form-group(ng-class="validation.errorFields.address2 ? 'has-error' : ''")
|
||||
input.form-control(type='text', value='', maxlength='255', tabindex='1', onkeyup='', ng-model="data.address2", placeholder="#{translate('address')}")
|
||||
.form-group
|
||||
.form-group(ng-class="validation.errorFields.state ? 'has-error' : ''")
|
||||
input.form-control(type='text', value='', maxlength='255', tabindex='1', onkeyup='', ng-model="data.state", placeholder="#{translate('state')}")
|
||||
.row
|
||||
.col-md-7
|
||||
.form-group
|
||||
.form-group(ng-class="validation.errorFields.city ? 'has-error' : ''")
|
||||
input.form-control(type='text', value='', maxlength='255', tabindex='1', onkeyup='', data-recurly="city", ng-model="data.city", placeholder="#{translate('city')}")
|
||||
.col-md-5
|
||||
.col-md-5(ng-class="validation.errorFields.postal_code ? 'has-error' : ''")
|
||||
input.form-control(type='text', value='', maxlength='255', tabindex='1', onkeyup='', data-recurly="postal_code", ng-model="data.postal_code", placeholder="#{translate('zip_post_code')}")
|
||||
.row
|
||||
.col-md-7
|
||||
.form-group
|
||||
.form-group(ng-class="validation.errorFields.country ? 'has-error' : ''")
|
||||
select.form-control(data-recurly="country", ng-model="data.country", ng-change="updateCountry()", required)
|
||||
mixin countries_options()
|
||||
.row
|
||||
|
|
|
@ -81,9 +81,10 @@ define [
|
|||
completeSubscription = (err, recurly_token_id) ->
|
||||
$scope.validation.errorFields = {}
|
||||
if err?
|
||||
$scope.processing = false
|
||||
$scope.genericError = err.message
|
||||
_.each err.fields, (field)-> $scope.validation.errorFields[field] = true
|
||||
$scope.$apply () ->
|
||||
$scope.processing = false
|
||||
$scope.genericError = err.message
|
||||
_.each err.fields, (field)-> $scope.validation.errorFields[field] = true
|
||||
else
|
||||
postData =
|
||||
_csrf: window.csrfToken
|
||||
|
@ -92,10 +93,10 @@ define [
|
|||
currencyCode:pricing.items.currency
|
||||
plan_code:pricing.items.plan.code
|
||||
$http.post("/user/subscription/create", postData)
|
||||
.success (data, status, headers)->
|
||||
window.location.href = "/user/subscription/thank-you"
|
||||
.error (data, status, headers)->
|
||||
$scope.processing = false
|
||||
.success (data, status, headers)->
|
||||
window.location.href = "/user/subscription/thank-you"
|
||||
.error (data, status, headers)->
|
||||
$scope.processing = false
|
||||
$scope.genericError = "Something went wrong processing the request"
|
||||
|
||||
$scope.submit = ->
|
||||
|
|
Loading…
Reference in a new issue