<commit_before>class EnvironmentRuleItem extends EnvironmentItem

  constructor: (options = {}, data) ->

    options.cssClass           = 'rule'
    options.joints             = ['right']
    options.allowedConnections =
      EnvironmentDomainItem    : ['left']

    super options, data

    @setClass "disabled"  unless data.enabled

  contextMenuItems: ->
    colorSelection = new ColorSelection
      selectedColor : @getOption 'colorTag'

    colorSelection.on "ColorChanged", @bound 'setColorTag'

    items         =
      Edit        :
        disabled  : KD.isGuest()
        action    : 'edit'
      Delete      :
        disabled  : KD.isGuest()
        action    : 'delete'
        separator : yes
      customView  : colorSelection

    return items

  cmedit: ->
    modal = new AddFirewallRuleModal {}, @getData()
    modal.once "RuleUpdated", =>
      @template.update()
      {enabled} = @getData()
      if enabled then @unsetClass "disabled" else @setClass "disabled"

  confirmDestroy: ->
    data           = @getData()
    options        =
      deleteMesage : "<b>#{data.name}</b> has been removed."
      content      : "<div class='modalformline'>This will remove the rule <b>#{data.name}</b> permanently, there is no way back!</div>"

    deletionModal = new DomainDeletionModal options, @getData()
    deletionModal.on "domainRemoved", @bound "destroy"<commit_msg>Environments: Refactor data update method to reuse.<commit_after>class EnvironmentRuleItem extends EnvironmentItem

  constructor: (options = {}, data) ->

    options.cssClass           = 'rule'
    options.joints             = ['right']
    options.allowedConnections =
      EnvironmentDomainItem    : ['left']

    super options, data

    @setClass "disabled"  unless data.enabled

  contextMenuItems: ->
    colorSelection = new ColorSelection
      selectedColor : @getOption 'colorTag'

    colorSelection.on "ColorChanged", @bound 'setColorTag'

    items         =
      Edit        :
        disabled  : KD.isGuest()
        action    : 'edit'
      Delete      :
        disabled  : KD.isGuest()
        action    : 'delete'
        separator : yes
      customView  : colorSelection

    return items

  cmedit: ->
    modal = new AddFirewallRuleModal {}, @getData()
    modal.once "RuleUpdated", @bound "handleDataUpdate"

  handleDataUpdate: ->
    @template.update()
    {enabled} = @getData()
    if enabled then @unsetClass "disabled" else @setClass "disabled"

  confirmDestroy: ->
    data           = @getData()
    options        =
      deleteMesage : "<b>#{data.name}</b> has been removed."
      content      : "<div class='modalformline'>This will remove the rule <b>#{data.name}</b> permanently, there is no way back!</div>"

    deletionModal = new DomainDeletionModal options, @getData()
    deletionModal.on "domainRemoved", @bound "destroy"
{'fraction_non_alphanumeric': 0.11037373384561648, 'fraction_numerical': 0.0, 'mean_word_length': 2.5055079559363524, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 25, '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': '3432995', 'n_tokens_mistral': 812, 'n_tokens_neox': 784, 'n_words': 206}