<commit_before>### define
underscore : _
backbone.marionette : marionette
libs/toast : Toast
app : app
./team_list_item_view : TeamListItemView
admin/models/team/team_collection : TeamCollection
admin/models/team/team_model : TeamModel
###

class TeamListView extends Backbone.Marionette.CompositeView

  template : _.template("""
    <h3>Teams</h3>
    <form method="post">
      <table class="table table-striped">
        <thead>
          <tr>
            <th><input type="checkbox" class="select-all-rows"> </th>
            <th>Name</th>
            <th>Owner</th>
            <th>Roles</th>
            <th></th>
          </tr>
        </thead>
        <tbody></tbody>
      </table>
      <div class="form-actions navbar-fixed-bottom">
        <div class="btn-group">
          <a class="btn btn-primary" id="new-team">
            <i class="fa fa-plus"></i>Add New Team
          </a>
        </div>
      </div>
    </form>
    <div class="modal hide fade">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h3>Add a New Team</h3>
      </div>
      <div class="modal-body">
        <form class="form-horizontal">
          <div class="control-group">
            <div class="control-group">
              <label class="control-label" for="inputName">Name</label>
              <div class="controls">
                <input type="text" id="inputName" placeholder="Name" required autofocus>
              </div>
            </div>
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <a href="#" class="btn btn-primary" data-dismiss="modal">Add</a>
        <a href="#" class="btn" data-dismiss="modal">Close</a>
      </div>
    </div>
  """)
  className : "team-administration container wide"
  itemView : TeamListItemView
  itemViewContainer : "tbody"

  ui :
    "modal" : ".modal"
    "inputName" : "#inputName"

  events :
    "click #new-team" : "showModal"
    "click .modal .btn-primary" : "addNewTeam"

  initialize : ->

    @listenTo(app.vent, "paginationView:filter", @filter)

    @collection = new TeamCollection()
    @collection.fetch(
      data:
        "isEditable=true"
      silent: true
    ).done( =>
      @collection.goTo(1)
    )


  addNewTeam : ->

    team = new TeamModel(
      name : @ui.inputName.val(),
    )
    @collection.create(team, {wait: true})


  filter : (filterQuery) ->

    @collection.setFilter(["name", "owner"], filterQuery)<commit_msg>#190 enabled pagination<commit_after>### define
underscore : _
backbone.marionette : marionette
libs/toast : Toast
app : app
./team_list_item_view : TeamListItemView
admin/models/team/team_collection : TeamCollection
admin/models/team/team_model : TeamModel
###

class TeamListView extends Backbone.Marionette.CompositeView

  template : _.template("""
    <h3>Teams</h3>
    <form method="post">
      <table class="table table-striped">
        <thead>
          <tr>
            <th><input type="checkbox" class="select-all-rows"> </th>
            <th>Name</th>
            <th>Owner</th>
            <th>Roles</th>
            <th></th>
          </tr>
        </thead>
        <tbody></tbody>
      </table>
      <div class="form-actions navbar-fixed-bottom">
        <div class="btn-group">
          <a class="btn btn-primary" id="new-team">
            <i class="fa fa-plus"></i>Add New Team
          </a>
        </div>
      </div>
    </form>
    <div class="modal hide fade">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h3>Add a New Team</h3>
      </div>
      <div class="modal-body">
        <form class="form-horizontal">
          <div class="control-group">
            <div class="control-group">
              <label class="control-label" for="inputName">Name</label>
              <div class="controls">
                <input type="text" id="inputName" placeholder="Name" required autofocus>
              </div>
            </div>
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <a href="#" class="btn btn-primary" data-dismiss="modal">Add</a>
        <a href="#" class="btn" data-dismiss="modal">Close</a>
      </div>
    </div>
  """)
  className : "team-administration container wide"
  itemView : TeamListItemView
  itemViewContainer : "tbody"

  ui :
    "modal" : ".modal"
    "inputName" : "#inputName"

  events :
    "click #new-team" : "showModal"
    "click .modal .btn-primary" : "addNewTeam"

  initialize : ->

    @listenTo(app.vent, "paginationView:filter", @filter)

    @collection.fetch(
      data : "isEditable=true"
      silent : true
    ).done( =>
      @collection.goTo(1)
    )


  addNewTeam : ->

    team = new TeamModel(
      name : @ui.inputName.val(),
    )
    @collection.create(team, {wait: true})


  filter : (filterQuery) ->

    @collection.setFilter(["name", "owner"], filterQuery)
{'fraction_non_alphanumeric': 0.16463779684693675, 'fraction_numerical': 0.002594292556375973, 'mean_word_length': 2.2736773350751145, 'pattern_counts': {'":': 0, '<': 119, '<?xml version=': 0, '>': 127, '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': '6034905', 'n_tokens_mistral': 1618, 'n_tokens_neox': 1570, 'n_words': 320}