     insertInDOM: (rowView)->
       @_insertInDOM rowView.defaultRowDetailParent
 
+  viewRowDetail.Templates = {
+    textbox: (cid, key, key_label = key, input_class = '') ->
+      @field """<input type="text" name="#{key}" id="#{cid}" class="#{input_class}" />""", cid, key_label
+
+    checkbox: (cid, key, key_label = key, input_label = 'Yes') ->
+      @field """<input type="checkbox" name="#{key}" id="#{cid}"/> <label for="#{cid}">#{input_label}</label>""", cid, key_label
+
+    field: (input, cid, key_label) ->
+      """
+      <div class="card__settings__fields__field">
+        <label for="#{cid}">#{key_label}:</label>
+        <span class="settings__input">
+          #{input}
+        </span>
+      </div>
+      """
+
   viewRowDetail.DetailViewMixins = {}
 
   viewRowDetail.DetailViewMixins.type =

  viewRowDetail.DetailViewMixins.name =
    html: ->
      @fieldTab = "active"
      # @listenTo @model, "change:value", ()=>
      #   @render()
      #   @afterRender()
      @$el.addClass("card__settings__fields--#{@fieldTab}")
      """
      <div class="card__settings__fields__field">
        <label for="#{@cid}">#{@model.key}: </label>
        <span class="settings__input">
          <input type="text" name="#{@model.key}" id="#{@cid}" class="text" />
        </span>
      </div>
      """
    afterRender: ->
      @$el.find('input').eq(0).val(@model.get("value"))
      @listenForInputChange(transformFn: (value)-> $modelUtils.sluggify(value, lowerCase:false))
    # insertInDom: (rowView)->
    #   # default behavior...
    #   rowView.defaultRowDetailParent.append(@el)

  viewRowDetail.DetailViewMixins.default =
    html: ->
      @fieldTab = "active"
      # @listenTo @model, "change:value", ()=>
      #   @render()
      #   @afterRender()
      @$el.addClass("card__settings__fields--#{@fieldTab}")
      """
      <div class="card__settings__fields__field">
        <label for="#{@cid}">#{@model.key}: </label>
        <span class="settings__input">
          <input type="text" name="#{@model.key}" id="#{@cid}" class="text" />
        </span>
      </div>
      """
    afterRender: ->
      @$el.find('input').eq(0).val(@model.get("value"))
      @listenForInputChange()

    # insertInDom: (rowView)->
    #   # default behavior...
    #   rowView.defaultRowDetailParent.append(@el)

  viewRowDetail.DetailViewMixins.calculation =
    html: -> false

  viewRowDetail.DetailViewMixins._isRepeat =
    html: ->
      @$el.addClass("card__settings__fields--active")
      viewRowDetail.Templates.checkbox @cid, @model.key, 'Repeat'
    afterRender: ->
      @listenForCheckboxChange()

  viewRowDetail.DetailViewMixins.required =
    html: ->
      @$el.addClass("card__settings__fields--active")
      viewRowDetail.Templates.checkbox @cid, @model.key, 'Required'
    afterRender: ->
      @listenForCheckboxChange()

  viewRowDetail.DetailViewMixins.appearance =
    html: ->
      @$el.addClass("card__settings__fields--active")
      if @model._parent.constructor.key == 'group'
        viewRowDetail.Templates.checkbox @cid, @model.key, 'Appearance', 'Show all questions in this groups on the same screen'
      else
        viewRowDetail.Templates.textbox @cid, @model.key, 'Appearance', 'text'
    afterRender: ->
      if @model._parent.constructor.key == 'group'
        $checkbox = @$('input[type=checkbox]').eq(0)
        value_lookup = ['', 'field-list']
        $checkbox.on 'change', () =>
          @model.set('value', value_lookup[+$checkbox.prop('checked')])
      else
        @listenForInputChange()

