<commit_before>kd                    = require 'kd'
JView                 = require 'app/jview'
KDButtonViewWithMenu  = kd.ButtonViewWithMenu
ActivityItemMenuItem  = require 'activity/views/activityitemmenuitem'


module.exports = class BaseStackTemplateListItem extends kd.ListItemView

  JView.mixin @prototype

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

    super options, data

    @createSettingsMenu()


  createSettingsMenu: ->

    @menu = {}

    @settings        = new KDButtonViewWithMenu
      cssClass       : 'stack-settings-menu'
      itemChildClass : ActivityItemMenuItem
      delegate       : this
      iconClass      : 'arrow'
      menu           : @bound 'settingsMenu'
      style          : 'resurrection'
      callback       : (event) => @settings.contextMenu event


  addMenuItem: (title, callback) -> @menu[title] = { callback }


  settingsMenu: ->

    listView  = @getDelegate()
    @menu    ?= {}

    @addMenuItem 'Show', listView.lazyBound 'showItemContent', this
    @addMenuItem 'Edit', @bound 'editStackTemplate'
    @addMenuItem 'Generate Stack', @bound 'generateStackFromTemplate'

    if listView.items.length > 1
      @addMenuItem 'Delete',  listView.lazyBound 'deleteItem', this

    return @menu<commit_msg>BaseStackTemplateList: allow delete option by default<commit_after>kd                    = require 'kd'
JView                 = require 'app/jview'
KDButtonViewWithMenu  = kd.ButtonViewWithMenu
ActivityItemMenuItem  = require 'activity/views/activityitemmenuitem'


module.exports = class BaseStackTemplateListItem extends kd.ListItemView

  JView.mixin @prototype

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

    super options, data

    @createSettingsMenu()


  createSettingsMenu: ->

    @menu = {}

    @settings        = new KDButtonViewWithMenu
      cssClass       : 'stack-settings-menu'
      itemChildClass : ActivityItemMenuItem
      delegate       : this
      iconClass      : 'arrow'
      menu           : @bound 'settingsMenu'
      style          : 'resurrection'
      callback       : (event) => @settings.contextMenu event


  addMenuItem: (title, callback) -> @menu[title] = { callback }


  settingsMenu: ->

    listView  = @getDelegate()
    @menu    ?= {}

    @addMenuItem 'Show', listView.lazyBound 'showItemContent', this
    @addMenuItem 'Edit', @bound 'editStackTemplate'
    @addMenuItem 'Generate Stack', @bound 'generateStackFromTemplate'
    @addMenuItem 'Delete', listView.lazyBound 'deleteItem', this

    return @menu
{'fraction_non_alphanumeric': 0.0998801438274071, 'fraction_numerical': 0.00039952057530962844, 'mean_word_length': 2.75975975975976, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '5522679', 'n_tokens_mistral': 724, 'n_tokens_neox': 683, 'n_words': 161}