<commit_before>var _ = require('underscore');
var View = require('cdb/core/view');
var template = require('./filter_template.tpl');

/**
 * Category filter view
 */
module.exports = View.extend({

  className: 'Widget-filter Widget-contentSpaced Widget-contentSpaced--sideMargins',

  events: {
    'click .js-all': '_onSelectAll',
    'click .js-none': '_onUnselectAll',
    'click .js-apply':'_onApplyClick'
  },

  initialize: function() {
    this.filter = this.options.filter;
    this.dataModel = this.options.dataModel;
    this.viewModel = this.options.viewModel;
    this.search = this.options.search;
    this._initBinds();
  },

  render: function() {
    var totalCats = this.dataModel.getData().size();
    var rejectedCats = this.filter.getRejected().size();
    var acceptedCats = this.filter.getAccepted().size();

    this.$el.html(
      template({
        isLocked: this.dataModel.isLocked(),
        totalLocked: this.dataModel.getLockedSize(),
        isSearchEnabled: this.viewModel.isSearchEnabled(),
        isSearchApplied: this.dataModel.isSearchApplied(),
        totalCats: totalCats,
        rejectedCats: rejectedCats,
        acceptedCats: acceptedCats
      })
    );
    return this;
  },

  _initBinds: function() {
    this.dataModel.bind('change:data change:filter change:locked', this.render, this);
    this.viewModel.bind('change:search', this.render, this);
    this.search.bind('change:data', this.render, this);
    this.add_related_model(this.dataModel);
    this.add_related_model(this.search);
    this.add_related_model(this.viewModel);
  },

  _onUnselectAll: function() {
    this.filter.rejectAll(
      this.model.getData().pluck('name')
    );
  },

  _onSelectAll: function() {
    this.filter.acceptAll();
  },

  _onApplyClick: function() {
    this.viewModel.toggleSearch();
    this.dataModel.applyFilters();<commit_msg>Fixed problem trying to unselect all categories from filter view (category widget)<commit_after>var _ = require('underscore');
var View = require('cdb/core/view');
var template = require('./filter_template.tpl');

/**
 * Category filter view
 */
module.exports = View.extend({

  className: 'Widget-filter Widget-contentSpaced Widget-contentSpaced--sideMargins',

  events: {
    'click .js-all': '_onSelectAll',
    'click .js-none': '_onUnselectAll',
    'click .js-apply':'_onApplyClick'
  },

  initialize: function() {
    this.filter = this.options.filter;
    this.dataModel = this.options.dataModel;
    this.viewModel = this.options.viewModel;
    this.search = this.options.search;
    this._initBinds();
  },

  render: function() {
    var totalCats = this.dataModel.getData().size();
    var rejectedCats = this.filter.getRejected().size();
    var acceptedCats = this.filter.getAccepted().size();

    this.$el.html(
      template({
        isLocked: this.dataModel.isLocked(),
        totalLocked: this.dataModel.getLockedSize(),
        isSearchEnabled: this.viewModel.isSearchEnabled(),
        isSearchApplied: this.dataModel.isSearchApplied(),
        totalCats: totalCats,
        rejectedCats: rejectedCats,
        acceptedCats: acceptedCats
      })
    );
    return this;
  },

  _initBinds: function() {
    this.dataModel.bind('change:data change:filter change:locked', this.render, this);
    this.viewModel.bind('change:search', this.render, this);
    this.search.bind('change:data', this.render, this);
    this.add_related_model(this.dataModel);
    this.add_related_model(this.search);
    this.add_related_model(this.viewModel);
  },

  _onUnselectAll: function() {
    this.filter.rejectAll(
      this.dataModel.getData().pluck('name')
    );
  },

  _onSelectAll: function() {
    this.filter.acceptAll();
  },

  _onApplyClick: function() {
    this.viewModel.toggleSearch();
    this.dataModel.applyFilters();
{'fraction_non_alphanumeric': 0.145359477124183, 'fraction_numerical': 0.0, 'mean_word_length': 3.543942992874109, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5989945', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1204, 'n_words': 196}