mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Validate and add error status to contact form
This commit is contained in:
parent
63eacad899
commit
66d18bcbcd
2 changed files with 67 additions and 34 deletions
|
@ -7,36 +7,61 @@ script(type='text/ng-template', id='supportModalTemplate')
|
||||||
) ×
|
) ×
|
||||||
h3 #{translate("contact_us")}
|
h3 #{translate("contact_us")}
|
||||||
.modal-body.contact-us-modal
|
.modal-body.contact-us-modal
|
||||||
span(ng-show="sent == false")
|
form(name="contactForm")
|
||||||
label
|
span(ng-show="sent == false")
|
||||||
| #{translate("subject")}
|
.alert.alert-danger(ng-show="error") Something went wrong sending your request :(
|
||||||
.form-group
|
label
|
||||||
input.field.text.medium.span8.form-control(
|
| #{translate("subject")}
|
||||||
ng-model="form.subject",
|
.form-group
|
||||||
ng-model-options="{ updateOn: 'default blur', debounce: {'default': 350, 'blur': 0} }"
|
input.field.text.medium.span8.form-control(
|
||||||
maxlength='255',
|
name="subject",
|
||||||
tabindex='1',
|
required
|
||||||
onkeyup='')
|
ng-model="form.subject",
|
||||||
.contact-suggestions(ng-show="suggestions.length")
|
ng-model-options="{ updateOn: 'default blur', debounce: {'default': 350, 'blur': 0} }"
|
||||||
p.contact-suggestion-label !{translate("kb_suggestions_enquiry", { kbLink: "<a href='learn/kb' target='_blank'>__kb__</a>", kb: translate("knowledge_base") })}
|
maxlength='255',
|
||||||
ul.contact-suggestion-list
|
tabindex='1',
|
||||||
li(ng-repeat="suggestion in suggestions")
|
onkeyup='')
|
||||||
a.contact-suggestion-list-item(ng-href="{{ suggestion.url }}", ng-click="clickSuggestionLink(suggestion.url);" target="_blank")
|
.contact-suggestions(ng-show="suggestions.length")
|
||||||
span(ng-bind-html="suggestion.name")
|
p.contact-suggestion-label !{translate("kb_suggestions_enquiry", { kbLink: "<a href='learn/kb' target='_blank'>__kb__</a>", kb: translate("knowledge_base") })}
|
||||||
i.fa.fa-angle-right
|
ul.contact-suggestion-list
|
||||||
label.desc(ng-show="'"+getUserEmail()+"'.length < 1")
|
li(ng-repeat="suggestion in suggestions")
|
||||||
| #{translate("email")}
|
a.contact-suggestion-list-item(ng-href="{{ suggestion.url }}", ng-click="clickSuggestionLink(suggestion.url);" target="_blank")
|
||||||
.form-group(ng-show="'"+getUserEmail()+"'.length < 1")
|
span(ng-bind-html="suggestion.name")
|
||||||
input.field.text.medium.span8.form-control(ng-model="form.email", ng-init="form.email = '"+getUserEmail()+"'", type='email', spellcheck='false', value='', maxlength='255', tabindex='2')
|
i.fa.fa-angle-right
|
||||||
label#title12.desc
|
label.desc(ng-show="'"+getUserEmail()+"'.length < 1")
|
||||||
| #{translate("project_url")} (#{translate("optional")})
|
| #{translate("email")}
|
||||||
.form-group
|
.form-group(ng-show="'"+getUserEmail()+"'.length < 1")
|
||||||
input.field.text.medium.span8.form-control(ng-model="form.project_url", tabindex='3', onkeyup='')
|
input.field.text.medium.span8.form-control(
|
||||||
label.desc
|
name="email",
|
||||||
| #{translate("contact_message_label")}
|
required
|
||||||
.form-group
|
ng-model="form.email",
|
||||||
textarea.field.text.medium.span8.form-control(ng-model="form.message",type='text', value='', tabindex='4', onkeyup='')
|
ng-init="form.email = '"+getUserEmail()+"'",
|
||||||
.form-group.text-center
|
type='email', spellcheck='false',
|
||||||
input.btn-success.btn.btn-lg(type='submit', ng-disabled="sending", ng-click="contactUs()" value=translate("contact_us"))
|
value='',
|
||||||
|
maxlength='255',
|
||||||
|
tabindex='2')
|
||||||
|
label#title12.desc
|
||||||
|
| #{translate("project_url")} (#{translate("optional")})
|
||||||
|
.form-group
|
||||||
|
input.field.text.medium.span8.form-control(ng-model="form.project_url", tabindex='3', onkeyup='')
|
||||||
|
label.desc
|
||||||
|
| #{translate("contact_message_label")}
|
||||||
|
.form-group
|
||||||
|
textarea.field.text.medium.span8.form-control(
|
||||||
|
name="body",
|
||||||
|
required
|
||||||
|
ng-model="form.message",
|
||||||
|
type='text',
|
||||||
|
value='',
|
||||||
|
tabindex='4',
|
||||||
|
onkeyup=''
|
||||||
|
)
|
||||||
|
.form-group.text-center
|
||||||
|
input.btn-success.btn.btn-lg(
|
||||||
|
type='submit',
|
||||||
|
ng-disabled="contactForm.$invalid || sending",
|
||||||
|
ng-click="contactUs()"
|
||||||
|
value=translate("contact_us")
|
||||||
|
)
|
||||||
span(ng-show="sent")
|
span(ng-show="sent")
|
||||||
p #{translate("request_sent_thank_you")}
|
p #{translate("request_sent_thank_you")}
|
||||||
|
|
|
@ -30,7 +30,7 @@ define [
|
||||||
$scope.suggestions = suggestions
|
$scope.suggestions = suggestions
|
||||||
|
|
||||||
$scope.contactUs = ->
|
$scope.contactUs = ->
|
||||||
if !$scope.form.email?
|
if !$scope.form.email? or $scope.form.email == ""
|
||||||
console.log "email not set"
|
console.log "email not set"
|
||||||
return
|
return
|
||||||
$scope.sending = true
|
$scope.sending = true
|
||||||
|
@ -46,8 +46,16 @@ define [
|
||||||
about: "<div>browser: #{platform?.name} #{platform?.version}</div>
|
about: "<div>browser: #{platform?.name} #{platform?.version}</div>
|
||||||
<div>os: #{platform?.os?.family} #{platform?.os?.version}</div>"
|
<div>os: #{platform?.os?.family} #{platform?.os?.version}</div>"
|
||||||
|
|
||||||
Groove.createTicket params, (err, json)->
|
Groove.createTicket params, (response)->
|
||||||
$scope.sent = true
|
$scope.sending = false
|
||||||
|
if response.responseText == "" # Blocked request or similar
|
||||||
|
$scope.error = true
|
||||||
|
else
|
||||||
|
data = JSON.parse(response.responseText)
|
||||||
|
if data.errors?
|
||||||
|
$scope.error = true
|
||||||
|
else
|
||||||
|
$scope.sent = true
|
||||||
$scope.$apply()
|
$scope.$apply()
|
||||||
|
|
||||||
$scope.$watch "form.subject", (newVal, oldVal) ->
|
$scope.$watch "form.subject", (newVal, oldVal) ->
|
||||||
|
|
Loading…
Reference in a new issue