Fixed the new model modal in search.

This commit is contained in:
Scott Erickson 2014-01-27 11:30:22 -08:00
parent b48fb6823e
commit 26d6c2dc5b
4 changed files with 28 additions and 24 deletions
app
lib
styles/kinds
templates/kinds
views/kinds

View file

@ -23,16 +23,15 @@ module.exports.applyErrorsToForm = (el, errors) ->
prop = error.property
input = $("[name='#{prop}']", el)
if not input[0]
if not input.length
missingErrors.push(error)
continue
controls = input.closest('.controls')
controls.append($("<span class='help-inline error-inline'>#{message}</span>"))
group = controls.closest('.control-group')
group.addClass('error')
formGroup = input.closest('.form-group')
formGroup.addClass 'has-error'
formGroup.append($("<span class='help-block'>#{message}</span>"))
return missingErrors
module.exports.clearFormAlerts = (el) ->
$('.error', el).removeClass('error')
$('.error-inline', el).remove()
$('.alert', el).remove()
$('.has-error', el).removeClass('has-error')
$('.alert', el).remove()
el.find('.help-block').remove()

View file

@ -20,3 +20,6 @@
.bar
width: 100%
form
margin: 0 20px

View file

@ -8,19 +8,20 @@ block content
hr
div.results
table
div.modal.hide.fade#new-model-modal
.modal-header
h3 Create New #{modelLabel}
.modal-body
form.form-horizontal
.control-group
label.control-label(for="name") Name
.controls
input#name.input-large(name="name", type="text")
.modal-footer
button.btn(data-dismiss="modal") Cancel
button.btn.btn-primary.new-model-submit Create
.modal-body.wait.hide
h3 Reticulating Splines...
.progress.progress-striped.active
.progress-bar
div.modal.fade#new-model-modal
.modal-dialog
.modal-content
.modal-header
h3 Create New #{modelLabel}
.modal-body
form.form-horizontal
.form-group
label.control-label(for="name") Name
input#name.form-control(name="name", type="text")
.modal-footer
button.btn(data-dismiss="modal") Cancel
button.btn.btn-primary.new-model-submit Create
.modal-body.wait.hide
h3 Reticulating Splines...
.progress.progress-striped.active
.progress-bar

View file

@ -85,6 +85,7 @@ module.exports = class ThangTypeHomeView extends View
return unless res
modal = @$el.find('.modal')
forms.clearFormAlerts(modal)
@showLoading(modal.find('.modal-body'))
res.error =>
@hideLoading()