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

View file

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

View file

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

View file

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