<commit_before>/**
 * @license
 * Copyright 2017 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

foam.CLASS({
  package: 'foam.u2.view',
  name: 'ReciprocalSearch',
  extends: 'foam.u2.View',

  requires: [
    'foam.u2.search.SearchManager',
    'foam.u2.view.SearchViewWrapper'
  ],

  imports: [
    'dao'
  ],

  exports: [
    'as filterController',
    'as data'
  ],

  // TODO: CSS classname shouldn't be .net-nanopay-ui-ActionView, fix.
  css: `
    ^ {
      background-color: white;
      border-radius: 2px;
      min-width: 300px;
      font-size: medium;
    }

    ^ input {
      font-size: medium;
    }

    ^ .foam-u2-tag-Input {
      background-image: url("images/ic-search.svg");
      background-repeat: no-repeat;
      background-position: 8px;
      border-radius: 2px;
      border: 1px solid #dce0e7;
      color: #093649;
      font-size: 14px;
      height: 40px;
      padding: 0 21px 0 38px;
      width: 100%;
    }

    ^ input:focus, ^ select:focus {
      outline: none;
      border: 1px solid #59a5d5;
    }

    ^count {
      font-size: 14pt;
      color: #555;
      margin: 20px 20px 0 20px;
    }

    ^ .net-nanopay-ui-ActionView-clear {
      background-color: rgba(164, 179, 184, 0.1);
      border: solid 1px rgba(164, 179, 184, 0.5);
      border-radius: 2px;
      color: #093649;
      font-family: Roboto;
      font-size: 14px;
      font-stretch: normal;
      font-style: normal;
      font-weight: normal;
      height: 40px;
      letter-spacing: 0.2px;
      line-height: 2.86;
      text-align: center;
      width: 60px;
      margin: 20px;
    }
  `,

  properties: [
    {
      class: 'Class',
      name: 'of'
    },
    {
      name: 'data'
    },
    {
      class: 'Array',
      name: 'filters',
      factory: null,
      expression: function(dao) {
        var of = dao && dao.of;

        if ( ! of ) return [];

        if ( of.model_.searchColumns ) return of.model_.searchColumns;

        if ( of.model_.tableColumns ) {
          return of.model_.tableColumns.filter(function(c) {
            var axiom = of.getAxiomByName(c);
            return axiom && axiom.searchView;
          });
        }

        return of.getAxiomsByClass(foam.core.Property)
            .filter((prop) => prop.searchView && ! prop.hidden)
            .map(foam.core.Property.NAME.f);
      }
    },
    {
      class: 'Int',
      name: 'selectedCount'
    },
    {
      class: 'Int',
      name: 'totalCount'
    },
  ],

  methods: [
    function initE() {
      var self = this;

      this.dao.on.sub(this.updateTotalCount);
      this.updateTotalCount();

      this.
        addClass(self.myClass()).
        add(this.slot(function(filters) {
          self.show(filters.length);

          var searchManager = self.SearchManager.create({
            dao$: self.dao$,
            predicate$: self.data$
          });

          searchManager.filteredDAO$.sub(self.updateSelectedCount);
          self.updateSelectedCount(0, 0, 0, searchManager.filteredDAO$);

          var e = this.E('div');

          e.onDetach(searchManager);

          e.forEach(filters, function(f) {<commit_msg>Add general MQL query to ReciprocalSearch<commit_after>/**
 * @license
 * Copyright 2017 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

foam.CLASS({
  package: 'foam.u2.view',
  name: 'ReciprocalSearch',
  extends: 'foam.u2.View',

  requires: [
    'foam.u2.search.SearchManager',
    'foam.u2.view.SearchViewWrapper'
  ],

  imports: [
    'dao'
  ],

  exports: [
    'as filterController',
    'as data'
  ],

  // TODO: CSS classname shouldn't be .net-nanopay-ui-ActionView, fix.
  css: `
    ^ {
      background-color: white;
      border-radius: 2px;
      min-width: 300px;
      font-size: medium;
    }

    ^ input {
      font-size: medium;
    }

    ^ .foam-u2-tag-Input {
      background-image: url("images/ic-search.svg");
      background-repeat: no-repeat;
      background-position: 8px;
      border-radius: 2px;
      border: 1px solid #dce0e7;
      color: #093649;
      font-size: 14px;
      height: 40px;
      padding: 0 21px 0 38px;
      width: 100%;
    }

    ^ input:focus, ^ select:focus {
      outline: none;
      border: 1px solid #59a5d5;
    }

    ^ .general-query {
      padding: 20px;
    }

    ^count {
      font-size: 14pt;
      color: #555;
      margin: 20px 20px 0 20px;
    }

    ^ .net-nanopay-ui-ActionView-clear {
      background-color: rgba(164, 179, 184, 0.1);
      border: solid 1px rgba(164, 179, 184, 0.5);
      border-radius: 2px;
      color: #093649;
      font-family: Roboto;
      font-size: 14px;
      font-stretch: normal;
      font-style: normal;
      font-weight: normal;
      height: 40px;
      letter-spacing: 0.2px;
      line-height: 2.86;
      text-align: center;
      width: 60px;
      margin: 20px;
    }
  `,

  properties: [
    {
      class: 'Class',
      name: 'of'
    },
    {
      name: 'data'
    },
    {
      class: 'Array',
      name: 'filters',
      factory: null,
      expression: function(dao) {
        var of = dao && dao.of;

        if ( ! of ) return [];

        if ( of.model_.searchColumns ) return of.model_.searchColumns;

        if ( of.model_.tableColumns ) {
          return of.model_.tableColumns.filter(function(c) {
            var axiom = of.getAxiomByName(c);
            return axiom && axiom.searchView;
          });
        }

        return of.getAxiomsByClass(foam.core.Property)
            .filter((prop) => prop.searchView && ! prop.hidden)
            .map(foam.core.Property.NAME.f);
      }
    },
    {
      class: 'Int',
      name: 'selectedCount'
    },
    {
      class: 'Int',
      name: 'totalCount'
    },
  ],

  methods: [
    function initE() {
      var self = this;

      this.dao.on.sub(this.updateTotalCount);
      this.updateTotalCount();

      this.
        addClass(self.myClass()).
        add(this.slot(function(filters) {
          self.show(filters.length);

          var searchManager = self.SearchManager.create({
            dao$: self.dao$,
            predicate$: self.data$
          });

          searchManager.filteredDAO$.sub(self.updateSelectedCount);
          self.updateSelectedCount(0, 0, 0, searchManager.filteredDAO$);

          var e = this.E('div');

          e.onDetach(searchManager);

          var generalQueryView = foam.u2.ViewSpec.createView(
              { class: 'foam.u2.search.TextSearchView' },
              {
                richSearch: true,
                of: self.dao.of.id,
                onKey: true
              },
              this,
              this.__subSubContext__);
          searchManager.add(generalQueryView);
          e.start(generalQueryView).addClass('general-query').end();

          e.forEach(filters, function(f) {
{'fraction_non_alphanumeric': 0.13789596047660563, 'fraction_numerical': 0.03022377215925603, 'mean_word_length': 1.8383505154639175, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3382134', 'n_tokens_mistral': 2509, 'n_tokens_neox': 2290, 'n_words': 443}