/**
  @module ember-flexberry-gis
*/

import Ember from 'ember';
import { Query } from 'ember-flexberry-data';

/**
  Route for GIS search form.
  Loads data according to filters and paging settings

  @class GisSearchFormRoute
  @extends Ember.Route
*/
export default Ember.Route.extend({
  /**
    Configuration hash for this route's queryParams. [More info](http://emberjs.com/api/classes/Ember.Route.html#property_queryParams).

    @property queryParams
    @type Object
   */
  queryParams: {
    keyWords: { refreshModel: true },
    scaleFrom: { refreshModel: true },
    scaleTo: { refreshModel: true },
    minLng: { refreshModel: true },
    minLat: { refreshModel: true },
    maxLng: { refreshModel: true },
    maxLat: { refreshModel: true }
  },
  /**
    [Model hook](http://emberjs.com/api/classes/Ember.Route.html#method_model) that returns a model object according to request.

    @method model
    @param {Object} params
    @return {*} Model object according to request.
  */
  model(params) {
    if (params.keyWords) {
      const layerMetadataModelName = 'new-platform-flexberry-g-i-s-layer-metadata';
      const layerMetadataProjectionName = 'LayerMetadataL';
      const mapsModelName = 'new-platform-flexberry-g-i-s-map';
      const mapsProjectionName = 'MapL';

      // For the present it loads all the data
      let layerMetadataBuilder = new Query.Builder(this.get('store'))
        .from(layerMetadataModelName)
        .selectByProjection(layerMetadataProjectionName);
      let getMetadata = this.get('store').query(layerMetadataModelName, layerMetadataBuilder.build());

      let mapsBuilder = new Query.Builder(this.get('store'))
        .from(mapsModelName)
        .selectByProjection(mapsProjectionName);
      let getMaps = this.get('store').query(mapsModelName, mapsBuilder.build());

      return Ember.RSVP.all([getMetadata, getMaps]);
    }
  },
  setupController(controller, model) {
    this._super(controller, model);

    // Pass query params to search conditions
    controller.set('searchConditions', controller.getProperties(['keyWords', 'scaleFrom', 'scaleTo', 'minLng', 'minLat', 'maxLng', 'maxLat']));
  }
});

@@ -1013,37 +1013,8 @@
 ) %7B%0A
-    if (params.keyWords) %7B%0A  
     
@@ -1091,18 +1091,16 @@
 adata';%0A
-  
     cons
@@ -1149,26 +1149,24 @@
 dataL';%0A    
-  
 const mapsMo
@@ -1215,18 +1215,16 @@
 p';%0A    
- 
- 
 const ma
@@ -1255,57 +1255,8 @@
 ';%0A%0A
-      // For the present it loads all the data%0A  
     
@@ -1321,26 +1321,24 @@
 re'))%0A      
-  
 .from(layerM
@@ -1353,34 +1353,32 @@
 odelName)%0A      
- 
- 
 .selectByProject
@@ -1419,249 +1419,832 @@
     
-  
 let 
-getMetadata = this.get('store').query(layerMetadataModelName, layerMetadataBuilder.build());%0A%0A      let mapsBuilder = new Query.Builder(this.get('store'))%0A        .from(mapsModelName)%0A        .selectByProjection(mapsProjectionName
+mapsBuilder = new Query.Builder(this.get('store'))%0A      .from(mapsModelName)%0A      .selectByProjection(mapsProjectionName);%0A%0A    // If there are conditions - add them to the query%0A    if (params.keyWords) %7B%0A      let keyWordsConditions = params.keyWords.split(',').map((item) =%3E %7B%0A        let str = item.trim();%0A        return new Query.StringPredicate('keyWords').contains(str);%0A      %7D);%0A      if (keyWordsConditions.length) %7B%0A        let condition = keyWordsConditions.length %3E 1 ? new Query.ComplexPredicate(Query.Condition.And, ...keyWordsConditions) : keyWordsConditions%5B0%5D;%0A        layerMetadataBuilder = layerMetadataBuilder.where(condition);%0A        mapsBuilder = mapsBuilder.where(condition);%0A      %7D%0A    %7D%0A%0A    let getMetadata = this.get('store').query(layerMetadataModelName, layerMetadataBuilder.build()
 );%0A
-  
     
@@ -2318,19 +2318,16 @@
 ild());%0A
-%0A  
     retu
@@ -2369,22 +2369,16 @@
 Maps%5D);%0A
-    %7D%0A
   %7D,%0A  s

Add keyWord condition handling