<commit_before>_                      = require("lodash")
Marionette             = require("backbone.marionette")
ProjectListItemView    = require("./project_list_item_view")
CreateProjectModalView = require("./create_project_modal_view")

class ProjectsListView extends Marionette.CompositeView

  template : _.template("""
    <h3>Projects</h3>
    <table class="table table-striped table-details" id="projectlist-table">
      <thead>
        <tr>
          <th>Name</th>
          <th>Team</th>
          <th>Owner</th>
          <th>Open Assignments</th>
          <th>Actions</th>
        </tr>
      </thead>
      <tbody></tbody>
    </table>
    <div id="modal-wrapper"></div>
  """)

  className : "container wide project-administration"
  childView : ProjectListItemView
  childViewContainer : "tbody"

  ui :
    "modalWrapper" : "#modal-wrapper"


  initialize : ->

    @collection.fetch()

    @listenTo(app.vent, "paginationView:filter", @filterBySearch)
    @listenTo(app.vent, "modal:destroy", @render)
    @listenTo(app.vent, "paginationView:addElement", @showModal)


  filterBySearch : (searchQuery) ->

    @collection.setFilter(["name", "team"], searchQuery)


  showModal : ->

    modalView = new CreateProjectModalView(projectCollection : @collection)
    @ui.modalWrapper.html(modalView.render().el)

    modalView.show()

module.exports = ProjectsListView<commit_msg>added sorting to project table<commit_after>_                      = require("lodash")
Marionette             = require("backbone.marionette")
ProjectListItemView    = require("./project_list_item_view")
CreateProjectModalView = require("./create_project_modal_view")
SortTableBehavior       = require("libs/behaviors/sort_table_behavior")

class ProjectsListView extends Marionette.CompositeView

  template : _.template("""
    <h3>Projects</h3>
    <table class="table table-striped table-details sortable-table" id="projectlist-table">
      <thead>
        <tr>
          <th data-sort="name">Name</th>
          <th data-sort="team">Team</th>
          <th data-sort="owner">Owner</th>
          <th data-sort="numberOfOpenAssignments">Open Assignments</th>
          <th>Actions</th>
        </tr>
      </thead>
      <tbody></tbody>
    </table>
    <div id="modal-wrapper"></div>
  """)

  className : "container wide project-administration"
  childView : ProjectListItemView
  childViewContainer : "tbody"

  behaviors :
    SortTableBehavior:
      behaviorClass: SortTableBehavior

  ui :
    "modalWrapper" : "#modal-wrapper"


  initialize : ->

    @collection.fetch()
    @collection.setSorting("numberOfOpenAssignments", "desc")

    @listenTo(app.vent, "paginationView:filter", @filterBySearch)
    @listenTo(app.vent, "modal:destroy", @render)
    @listenTo(app.vent, "paginationView:addElement", @showModal)


  filterBySearch : (searchQuery) ->

    @collection.setFilter(["name", "team"], searchQuery)


  showModal : ->

    modalView = new CreateProjectModalView(projectCollection : @collection)
    @ui.modalWrapper.html(modalView.render().el)

    modalView.show()

module.exports = ProjectsListView
{'fraction_non_alphanumeric': 0.13905799423261775, 'fraction_numerical': 0.001281640499839795, 'mean_word_length': 3.3542538354253835, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 53, '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': '6647782', 'n_tokens_mistral': 977, 'n_tokens_neox': 926, 'n_words': 156}