<commit_before>kd                   = require 'kd'
KDView               = kd.View
KDListItemView       = kd.ListItemView
KDCustomHTMLView     = kd.CustomHTMLView
KDListViewController = kd.ListViewController


module.exports = class TeamMembersCommonView extends KDView

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

    options.noItemFoundWidget or= new KDCustomHTMLView
    options.listViewItemClass or= KDListItemView

    super options, data

    @createListController()
    @listMembers()


  createListController: ->

    { listViewItemClass, noItemFoundWidget } = @getOptions

    @listController       = new KDListViewController
      itemClass           : listViewItemClass
      noItemFoundWidget   : noItemFoundWidget
      startWithLazyLoader : yes
      lazyLoadThreshold   : .90
      lazyLoaderOptions   :
        spinnerOptions    :
          size            : width: 28

    @addSubView @listController.getView()


  ###*
    This method needs to be implemented in subclasses.

    @abstract
  ###
  listMembers: -> throw new Error 'Method needs to be implemented in subclasses'<commit_msg>TeamMembersCommonView: Implement base fetch and listing flow.<commit_after>kd                   = require 'kd'
KDView               = kd.View
MemberItemView       = require './memberitemview'
KDListItemView       = kd.ListItemView
KDCustomHTMLView     = kd.CustomHTMLView
KDListViewController = kd.ListViewController


module.exports = class TeamMembersCommonView extends KDView

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

    options.noItemFoundWidget   or= new KDCustomHTMLView
    options.listViewItemClass   or= MemberItemView
    options.listViewItemOptions or= {}
    options.itemLimit            ?= 10

    super options, data

    @skip = 0

    @createListController()
    @fetchMembers()


  createListController: ->

    { listViewItemClass, noItemFoundWidget, listViewItemOptions } = @getOptions()

    @listController       = new KDListViewController
      viewOptions         :
        wrapper           : yes
        itemClass         : listViewItemClass
        itemOptions       : listViewItemOptions
      noItemFoundWidget   : noItemFoundWidget
      startWithLazyLoader : yes
      lazyLoadThreshold   : .90
      lazyLoaderOptions   :
        spinnerOptions    :
          size            : width: 28

    @addSubView @listController.getView()


  fetchMembers: ->

    selector = @query or ''
    options  =
      limit  : @getOptions().itemLimit
      sort   : { timestamp: -1 }
      skip   : @skip

    @getData().searchMembers selector, options, (err, members) =>
      return kd.warn err  if err
      @listMembers members


  listMembers: (members) ->

    return  unless members.length

    @skip += members.length

    for member in members
      @listController.addItem member

    @listController.lazyLoader.hide()
{'fraction_non_alphanumeric': 0.07245867041857193, 'fraction_numerical': 0.004220893422441084, 'mean_word_length': 2.481028151774786, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6886896', 'n_tokens_mistral': 811, 'n_tokens_neox': 754, 'n_words': 184}