<commit_before>class NewDNSRecordFormView extends KDCustomHTMLView

  constructor:(options={}, data)->
    options.cssClass = "record-form-view"
    super options, data

    {domain} = @getData()

    @typeLabel        = new KDLabelView
      title : "Record Type"

    @hostLabel    = new KDLabelView
      title : "Host"

    @destinationLabel = new KDLabelView
      title : "Value"

    @ttlLabel         = new KDLabelView
      title : "TTL"

    @priorityLabel    = new KDLabelView
      cssClass : "hidden"
      title    : "Priority"

    @header = new KDCustomHTMLView
      tagName: "header"
      partial: domain.domainType

    @typeSelectBox    = new KDSelectBox
      selectOptions : [
        {title: "A", value: "A"}
        {title: "CNAME", value: "CNAME"}
        {title: "MX", value: "MX"}
        {title: "TXT", value: "TXT"}
        {title: "NS", value: "NS"}
        {title: "SRV", value: "SRV"}
        {title: "AAAA", value: "AAAA"}
      ]
      change:=>
        if @typeSelectBox.getValue() isnt "MX"
          @priorityLabel.hide()
          @priorityInput.hide()
        else
          @priorityLabel.show()
          @priorityInput.show()

    @hostInput        = new KDInputView
    @destinationInput = new KDInputView
    @ttlInput         = new KDInputView
    @priorityInput    = new KDInputView
      cssClass : "hidden"

    @addButton = new KDButtonView
      title    : "Add Record"
      callback : @bound "createNewRecord"

  createNewRecord:->
    {domain} = @getData()

    recordType = @typeSelectBox.getValue()
    host       = @hostInput.getValue()
    value      = @destinationInput.getValue()
    ttl        = @ttlInput.getValue()
    priority   = @priorityInput.getValue()

    recordObj = {recordType, host, value, ttl, priority}

    domain.createDNSRecord recordObj, (err, record)=>
      log record, err
      if record
        return new KDNotificationView {title: "Your record has been saved."}
        @emit "newRecordCreated", recordObj
      else
        return new KDNotificationView
          title: "You need to activate your FREE DNS Services before you can perform this action"

  viewAppended: JView::viewAppended

  pistachio:->
    """
      {{> @header}}
      <section class="clearfix">
        <div class="input-container record-type">
          {{> @typeLabel}}
          <div>{{> @typeSelectBox }}</div>
        </div>
        <div class="input-container">
          {{> @hostLabel}}
          {{> @hostInput }}
        </div>
        <div class="input-container">
          {{> @destinationLabel}}
          {{> @destinationInput }}
        </div>
        <div class="input-container priority">
          {{> @priorityLabel }}
          {{> @priorityInput }}
        </div>
        <div class="input-container">
          {{> @ttlLabel}}
          {{> @ttlInput }}
        </div>
        <div class="input-container add-record">
          {{> @addButton }}
        </div>
      </section>
    """<commit_msg>fixed ttl problem<commit_after>class NewDNSRecordFormView extends KDCustomHTMLView

  constructor:(options={}, data)->
    options.cssClass = "record-form-view"
    super options, data

    {domain} = @getData()

    @typeLabel        = new KDLabelView
      title : "Record Type"

    @hostLabel    = new KDLabelView
      title : "Host"

    @destinationLabel = new KDLabelView
      title : "Value"

    @ttlLabel         = new KDLabelView
      title : "TTL"

    @priorityLabel    = new KDLabelView
      cssClass : "hidden"
      title    : "Priority"

    @header = new KDCustomHTMLView
      tagName: "header"
      # partial: domain.domainType
      partial: "Add our NameServers: <b>ns0.koding.com, ns1.koding.com</b>" if domain.domainType is "existing"


    @typeSelectBox    = new KDSelectBox
      selectOptions : [
        {title: "A", value: "A"}
        {title: "CNAME", value: "CNAME"}
        {title: "MX", value: "MX"}
        {title: "TXT", value: "TXT"}
        {title: "NS", value: "NS"}
        {title: "SRV", value: "SRV"}
        {title: "AAAA", value: "AAAA"}
      ]
      change:=>
        if @typeSelectBox.getValue() isnt "MX"
          @priorityLabel.hide()
          @priorityInput.hide()
        else
          @priorityLabel.show()
          @priorityInput.show()

    @hostInput        = new KDInputView
    @destinationInput = new KDInputView
    @ttlInput         = new KDInputView
    @priorityInput    = new KDInputView
      cssClass : "hidden"

    @addButton = new KDButtonView
      title    : "Add Record"
      callback : @bound "createNewRecord"

  createNewRecord:->
    {domain} = @getData()

    recordType = @typeSelectBox.getValue()
    host       = @hostInput.getValue()
    value      = @destinationInput.getValue()
    ttl        = @ttlInput.getValue()
    priority   = @priorityInput.getValue()

    recordObj = {recordType, host, value, ttl, priority}

    domain.createDNSRecord recordObj, (err, record)=>
      log record, err
      if record
        return new KDNotificationView {title: "Your record has been saved."}
        @emit "newRecordCreated", recordObj
      else
        return new KDNotificationView
          title: "You need to activate your FREE DNS Services before you can perform this action"

  viewAppended: JView::viewAppended

  pistachio:->
    """
      {{> @header}}
      <section class="clearfix">
        <div class="input-container record-type">
          {{> @typeLabel}}
          <div>{{> @typeSelectBox }}</div>
        </div>
        <div class="input-container">
          {{> @hostLabel}}
          {{> @hostInput }}
        </div>
        <div class="input-container">
          {{> @destinationLabel}}
          {{> @destinationInput }}
        </div>
        <div class="input-container">
          {{> @ttlLabel}}
          {{> @ttlInput }}
        </div>
        <div class="input-container priority">
          {{> @priorityLabel }}
          {{> @priorityInput }}
        </div>
        <div class="input-container add-record">
          {{> @addButton }}
        </div>
      </section>
    """
{'fraction_non_alphanumeric': 0.13067807768268597, 'fraction_numerical': 0.0003291639236339697, 'mean_word_length': 2.1084398976982097, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '684581', 'n_tokens_mistral': 1831, 'n_tokens_neox': 1779, 'n_words': 438}