<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
      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"
          @unsetClass "mx-selected"
        else
          @setClass "mx-selected"

    @hostInput        = new KDInputView
    @destinationInput = new KDInputView
    @ttlInput         = new KDInputView
    @priorityInput    = new KDInputView

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

    @addRecordLabel  = new KDLabelView
      title : ""

  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
        new KDNotificationView {title: "Your record has been saved."}
        @emit "newRecordCreated", recordObj
      else
        return new KDNotificationView
          title: "#{err}"

  viewAppended: JView::viewAppended


  pistachio:->
    """
      {{> @header}}
      <section class="clearfix">
        <div class="input-container record-type">
          {{> @typeLabel}}
          <div>{{> @typeSelectBox }}</div>
        </div>
        <div class="input-container host">
          {{> @hostLabel}}
          {{> @hostInput }}
        </div>
        <div class="input-container value">
          {{> @destinationLabel}}
          {{> @destinationInput }}
        </div>
        <div class="input-container ttl">
          {{> @ttlLabel}}
          {{> @ttlInput }}
        </div>
        <div class="input-container priority">
          {{> @priorityLabel }}
          {{> @priorityInput }}
        </div>
        <div class="input-container add-record">
          {{> @addRecordLabel}}
          {{> @addButton }}
        </div>
      </section>
    """<commit_msg>change register domain params<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
      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"
          @unsetClass "mx-selected"
        else
          @setClass "mx-selected"

    @hostInput        = new KDInputView
    @destinationInput = new KDInputView
    @ttlInput         = new KDInputView
    @priorityInput    = new KDInputView

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

    @addRecordLabel  = new KDLabelView
      title : ""

  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
        new KDNotificationView {title: "Your record has been saved."}
        @emit "newRecordCreated", recordObj
      else
        return new KDNotificationView
          title: "#{err}"

  viewAppended: JView::viewAppended


  pistachio:->
    """
      {{> @header}}
      <section class="clearfix">
        <div class="input-container record-type">
          {{> @typeLabel}}
          <div>{{> @typeSelectBox }}</div>
        </div>
        <div class="input-container host">
          {{> @hostLabel}}
          {{> @hostInput }}
        </div>
        <div class="input-container value">
          {{> @destinationLabel}}
          {{> @destinationInput }}
        </div>
        <div class="input-container ttl">
          {{> @ttlLabel}}
          {{> @ttlInput }}
        </div>
        <div class="input-container priority">
          {{> @priorityLabel }}
          {{> @priorityInput }}
        </div>
        <div class="input-container add-record">
          {{> @addRecordLabel}}
          {{> @addButton }}
        </div>
      </section>
    """
{'fraction_non_alphanumeric': 0.13335523074396452, 'fraction_numerical': 0.0006569223189357859, 'mean_word_length': 2.0495743615423136, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 75, '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': '7254641', 'n_tokens_mistral': 1885, 'n_tokens_neox': 1831, 'n_words': 429}