<commit_before>

getCurrentIronTableController = ->
  if Router.current?()?.classID is "IronTableController"
    Router.current()
  #else
  #    console.log("Bad controller", Router.current?())
  #    null


#Template.ironTable.created = ->
#  console.log("ironTable created")


Template.ironTable.rendered = ->
  $('[rel="tooltip"]').tooltip()
  

Template.ironTable.helpers

  inabox: ->
    getCurrentIronTableController()?.inabox

  loading: ->
    loading = not getCurrentIronTableController()?.ready() and not getCurrentIronTableController()?.haveData()
    #console.log("loading", loading)
    loading

  haveData: ->
    #console.log("haveData Template")
    getCurrentIronTableController()?.haveData()


  # NOTE: Iron Router 7.1 and Meteor 8.2 not playing well together !?!?!?
  #       Moved from gettting in data to getting from controller in helpers
  
  showFilter: ->
    getCurrentIronTableController()?.showFilter

  recordsName: ->
    getCurrentIronTableController()?.getRecordsName()


Template.ironTable.events

  "click .iron-table-delete-record": (e, tmpl) ->
    e.preventDefault()
    #e.stopImmediatePropagation()
    
    if not currentController = getCurrentIronTableController()
      CoffeeAlerts.error("Internal Error: Could not get controller")
      return false
    
    CoffeeModal.confirm "Are you sure you want to delete #{@recordDisplayName}?", (yesNo) =>
      if yesNo
        currentController.removeRecord(@)
    , "Delete"
      
  "click .iron-table-edit-record": (e, tmpl) ->
    e.preventDefault()
    #e.stopImmediatePropagation()

    if not currentController = getCurrentIronTableController()
      CoffeeAlerts.error("Internal Error: Could not get controller")
      false
    else<commit_msg>hide tooltips<commit_after>

getCurrentIronTableController = ->
  if Router.current?()?.classID is "IronTableController"
    Router.current()
  #else
  #    console.log("Bad controller", Router.current?())
  #    null


#Template.ironTable.created = ->
#  console.log("ironTable created")


Template.ironTable.rendered = ->
  $('[rel="tooltip"]').tooltip()
  

Template.ironTable.helpers

  inabox: ->
    getCurrentIronTableController()?.inabox

  loading: ->
    loading = not getCurrentIronTableController()?.ready() and not getCurrentIronTableController()?.haveData()
    #console.log("loading", loading)
    loading

  haveData: ->
    #console.log("haveData Template")
    getCurrentIronTableController()?.haveData()


  # NOTE: Iron Router 7.1 and Meteor 8.2 not playing well together !?!?!?
  #       Moved from gettting in data to getting from controller in helpers
  
  showFilter: ->
    getCurrentIronTableController()?.showFilter

  recordsName: ->
    getCurrentIronTableController()?.getRecordsName()


Template.ironTable.events

  "click .iron-table-delete-record": (e, tmpl) ->
    e.preventDefault()
    #e.stopImmediatePropagation()
    $('.iron-table-delete-record').tooltip('hide')
    
    if not currentController = getCurrentIronTableController()
      CoffeeAlerts.error("Internal Error: Could not get controller")
      return false
    
    CoffeeModal.confirm "Are you sure you want to delete #{@recordDisplayName}?", (yesNo) =>
      if yesNo
        currentController.removeRecord(@)
    , "Delete"
      
  "click .iron-table-edit-record": (e, tmpl) ->
    e.preventDefault()
    #e.stopImmediatePropagation()
    $('.iron-table-edit-record').tooltip('hide')

    if not currentController = getCurrentIronTableController()
      CoffeeAlerts.error("Internal Error: Could not get controller")
      false
    else
{'fraction_non_alphanumeric': 0.1260457334076966, 'fraction_numerical': 0.002230897936419409, 'mean_word_length': 3.6463730569948187, 'pattern_counts': {'":': 4, '<': 3, '<?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': '3183290', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1047, 'n_words': 224}