# ----------------------------------------------------------------------------- # Author: Alexander Kravets , # Slate Studio (http://www.slatestudio.com) # # Coding Guide: # https://github.com/thoughtbot/guides/tree/master/style/coffeescript # ----------------------------------------------------------------------------- # ----------------------------------------------------------------------------- # INPUT "NESTED" FORM # ----------------------------------------------------------------------------- # Name for this input comes from the Rails gem 'nested_forms'. # # Public methods: # initialize() # hash(hash) # updateValue(@value) # showErrorMessage(message) # hideErrorMessage() # addNewForm(object) # # Dependencies: #= require ./input-form_reorder # # ----------------------------------------------------------------------------- class @InputForm constructor: (@name, @nestedObjects, @config, @object) -> @forms = [] @config.namePrefix ||= name @config.removeButton = true @config.formSchema._id = { type: 'hidden', name: 'id' } @reorderContainerClass = "nested-forms-#{@config.klassName}" @_create_el() @_add_label() @_add_forms() @_add_new_button() return this # PRIVATE =============================================== _create_el: -> @$el =$ "
" _add_label: -> @$label =$ "#{ @config.label }" @$errorMessage =$ "" @$label.append(@$errorMessage) @$el.append(@$label) _add_forms: -> @$forms =$ "