When a registering an enterprise with a non-unique name, display an error message.

This commit is contained in:
Rohan Mitchell
2015-06-24 10:08:34 +10:00
parent c5526c78d9
commit 2d79177bb5
3 changed files with 21 additions and 1 deletions

View File

@@ -26,7 +26,11 @@ Darkswarm.factory "EnterpriseRegistrationService", ($http, RegistrationService,
RegistrationService.select('about')
).error((data) =>
Loading.clear()
alert('Failed to create your enterprise.\nPlease ensure all fields are completely filled out.')
if data?.errors?
errors = ("#{k.capitalize()} #{v[0]}" for k, v of data.errors when v.length > 0)
alert "Failed to create your enterprise.\n" + errors.join('\n')
else
alert('Failed to create your enterprise.\nPlease ensure all fields are completely filled out.')
)
# RegistrationService.select('about')

View File

@@ -0,0 +1,2 @@
String.prototype.capitalize = ->
this.charAt(0).toUpperCase() + this.slice(1)