 Template.listNav.helpers
   nav: () ->
     # console.log 'listNav:nav', this
-=======
-    if data.items? and typeof data.items is 'function'
-      for item in data.items()
-        data = Object.reject(data, 'items')
-        item.context = data
-        items.add item
-
-      if items.length > 0
-        return items
-
-Template.listNav.helpers
-  nav: () ->
->>>>>>> 2d6d00a2da830ee8d011084d970a22eed0949f7f
     data = this
     single = data.single
     plural = data.plural

        $(".#{single}-search-query").attr('value','')
        Session.set("#{single}Find",{})
        return false
=======
    navEvents[templateEvent] = (event, template) ->
      context = template.data
      single = context.single
      klass = context.klass
      console.log "You have not defined a custom add handler for #{data.title}.  Using the default."
      if typeof context.newItemCallback isnt 'undefined'
        _id = context.newItemCallback()
      else
        _id = klass.insert()
 
      # Show the edit form after a 100ms delay after the item is inserted .
      showForm = () ->
        $("##{_id}").removeClass('hidden')

      setTimeout showForm, 100, _id

      return false  
    # ---------------------------------------------------------------------------------------

    templateEvent = "click .purge-disabled-#{data.plural}"
    navEvents[templateEvent] = (event, template) ->
      context = template.data
      plural = context.plural
      console.log "You have not defined a custom purge handler for #{data.title}.  Using the default."
      confirm_dialog = """
      Are you sure you want to purge the diabled #{plural}?
      <br><br>
      <div class='alert alert-error'>
        <h4>Severe Warning</h4>
        All purged #{plural} cannot be recovered.  This will be your ONLY warning.
      </div>
      """

      bootbox.confirm confirm_dialog, (confirmed) ->
        if confirmed
          Meteor.call "purge#{context.title}",
          (error, result) ->
            if error
              Meteor.Errors.throw error
            if result
              Meteor.Notices.throw('Your disabled records have been purged.', 'success')
      return false
    # ---------------------------------------------------------------------------------------

    templateEvent = "click .reset"
    navEvents[templateEvent] = (event, template) ->
      context = template.data
      single = context.single
      $(".#{single}-search").addClass('hide')
      $(".#{single}-search-query").attr('value','')
      Session.set("#{single}Find",{})
      return false
>>>>>>> 2d6d00a2da830ee8d011084d970a22eed0949f7f

    # ---------------------------------------------------------------------------------------
    # Search
    # At the moment the query for search uses name as the key.  Need to revist this
    # to make it so that the package user can set what the default
    templateEvent = "keyup .#{data.single}-search-query"
<<<<<<< HEAD
    if not DMUtils.find(Template.listNav._events, 'selector', ".#{data.single}-search-query")
      navEvents[templateEvent] = (event, template) ->
        context = template.data

    # Build up an array of the items to be in the list
    # adding in the context data
    items = []
    # if data.parent_id
    #   data.subscribeCallback(data.parent_id)
    # else
