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

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()