<commit_before>define([
	"dojo/_base/declare", "dgrid/Grid","dojo/store/JsonRest","dgrid/extensions/DijitRegistry","dgrid/extensions/Pagination",
	"dgrid/Keyboard", "dgrid/Selection","./formatter","dgrid/extensions/ColumnResizer","dgrid/extensions/ColumnHider",
	"dgrid/extensions/DnD","dojo/dnd/Source","dojo/_base/Deferred","dojo/aspect","dojo/_base/lang"

],
function(
	declare, Grid,Store,DijitRegistry,Pagination,
	Keyboard,Selection,formatter,ColumnResizer,
	ColumnHider,DnD,DnDSource,
	Deferred,aspect,lang
){
	return declare([Grid,Pagination,ColumnHider,DnD,Keyboard,ColumnResizer,DijitRegistry],{
		constructor: function(){
			this.dndParams.creator =lang.hitch(this,function(item, hint){
                                console.log("item: ", item, " hint:", hint, "dataType: ", this.dndDataType);
                                var avatar = dojo.create("div", {innerHTML: item.organism_name || item.ncbi_taxon_id || item.id});
                                avatar.data = item;
                                if (hint == 'avatar') {
                                        // create your avatar if you want
                                }

                                return {node: avatar,data:item,type:this.dndDataType}
                        })

		},
		store: null,
		selectionMode: "extended",
		allowTextSelection: false,
		deselectOnRefresh: false,
		rowsPerPage:200,
		minRowsPerPage: 50,
		bufferRows: 100,
		maxRowsPerPage: 1000,
		pagingDelay: 250,
//		pagingMethod: "throttleDelayed",
		farOffRemoval:2000,
		keepScrollPosition: true,
		rowHeight: 24,
		loadingMessage: "Loading...",
		dndDataType: "genome",
		dndParams: {
			accept: "none",
			selfAccept: false,
			copyOnly: true
		},
                _setApiServer: function(server, token){
                        console.log("_setapiServerAttr: ", server);
                        this.apiServer = server;
			var t = token || this.apiToken || ""
                        this.set('store', this.createStore(this.dataModel, t), this.buildQuery());
                },

		apiToken: "",
		_setTotalRows: function(rows){
			this.totalRows=rows;
			console.log("Total Rows: ",rows);
			if (this.controlButton) {
				console.log("this.controlButton: ", this.controlButton);
				if (!this._originalTitle){
					this._originalTitle = this.controlButton.get('label');
				}
				this.controlButton.set('label', this._originalTitle + " (" + rows + ")");

				console.log(this.controlButton);
			}
		},

                startup: function(){
                        if (this._started) { return; }
			var _self=this;
			aspect.before(_self, 'renderArray', function(results){
				Deferred.when(results.total, function(x){
					_self.set("totalRows", x);
	                        });
			});

			if (!this.store && this.dataModel){
	                        this.store = this.createStore(this.dataModel);
			}
                        this.inherited(arguments);
                        this._started=true;

                },
                _setActiveFilter: function(filter){
                        console.log("Set Active Filter: ", filter, "started:", this._started);
                        this.activeFilter = filter;
                        this.set("query",this.buildQuery());
                },

                buildQuery: function(table, extra){
                        var q = "?" + (this.activeFilter?( "in(gid,query(genomesummary,and(" + this.activeFilter +",limit(Infinity),values(genome_info_id))))" ):"") + (this.extra||"");
                        console.log("Feature Grid Query:" , q);
                        return q;
                },
                createStore: function(dataModel, token){
                        console.log("Create Store for ", dataModel, " at ", this.apiServer, " TOKEN: ", token);
                        var store = new Store({target: (this.apiServer?(this.apiServer):"") + "/" + dataModel + "/",idProperty:"document_id", headers:{
                                "accept": "application/json",
                                "content-type": "application/json",
                                'X-Requested-With':null,
				'Authorization': token?token:(window.App.authorizationToken||""),
                        }});
                        console.log("store: ", store);
                        return store;
                },

                getFilterPanel: function(){
                        console.log("getFilterPanel()");
                        return FilterPanel;
                }

	});

});
<commit_msg>fix trailing comma<commit_after>define([
	"dojo/_base/declare", "dgrid/Grid","dojo/store/JsonRest","dgrid/extensions/DijitRegistry","dgrid/extensions/Pagination",
	"dgrid/Keyboard", "dgrid/Selection","./formatter","dgrid/extensions/ColumnResizer","dgrid/extensions/ColumnHider",
	"dgrid/extensions/DnD","dojo/dnd/Source","dojo/_base/Deferred","dojo/aspect","dojo/_base/lang"

],
function(
	declare, Grid,Store,DijitRegistry,Pagination,
	Keyboard,Selection,formatter,ColumnResizer,
	ColumnHider,DnD,DnDSource,
	Deferred,aspect,lang
){
	return declare([Grid,Pagination,ColumnHider,DnD,Keyboard,ColumnResizer,DijitRegistry],{
		constructor: function(){
			this.dndParams.creator =lang.hitch(this,function(item, hint){
                                console.log("item: ", item, " hint:", hint, "dataType: ", this.dndDataType);
                                var avatar = dojo.create("div", {innerHTML: item.organism_name || item.ncbi_taxon_id || item.id});
                                avatar.data = item;
                                if (hint == 'avatar') {
                                        // create your avatar if you want
                                }

                                return {node: avatar,data:item,type:this.dndDataType}
                        })

		},
		store: null,
		selectionMode: "extended",
		allowTextSelection: false,
		deselectOnRefresh: false,
		rowsPerPage:200,
		minRowsPerPage: 50,
		bufferRows: 100,
		maxRowsPerPage: 1000,
		pagingDelay: 250,
//		pagingMethod: "throttleDelayed",
		farOffRemoval:2000,
		keepScrollPosition: true,
		rowHeight: 24,
		loadingMessage: "Loading...",
		dndDataType: "genome",
		dndParams: {
			accept: "none",
			selfAccept: false,
			copyOnly: true
		},
                _setApiServer: function(server, token){
                        console.log("_setapiServerAttr: ", server);
                        this.apiServer = server;
			var t = token || this.apiToken || ""
                        this.set('store', this.createStore(this.dataModel, t), this.buildQuery());
                },

		apiToken: "",
		_setTotalRows: function(rows){
			this.totalRows=rows;
			console.log("Total Rows: ",rows);
			if (this.controlButton) {
				console.log("this.controlButton: ", this.controlButton);
				if (!this._originalTitle){
					this._originalTitle = this.controlButton.get('label');
				}
				this.controlButton.set('label', this._originalTitle + " (" + rows + ")");

				console.log(this.controlButton);
			}
		},

                startup: function(){
                        if (this._started) { return; }
			var _self=this;
			aspect.before(_self, 'renderArray', function(results){
				Deferred.when(results.total, function(x){
					_self.set("totalRows", x);
	                        });
			});

			if (!this.store && this.dataModel){
	                        this.store = this.createStore(this.dataModel);
			}
                        this.inherited(arguments);
                        this._started=true;

                },
                _setActiveFilter: function(filter){
                        console.log("Set Active Filter: ", filter, "started:", this._started);
                        this.activeFilter = filter;
                        this.set("query",this.buildQuery());
                },

                buildQuery: function(table, extra){
                        var q = "?" + (this.activeFilter?( "in(gid,query(genomesummary,and(" + this.activeFilter +",limit(Infinity),values(genome_info_id))))" ):"") + (this.extra||"");
                        console.log("Feature Grid Query:" , q);
                        return q;
                },
                createStore: function(dataModel, token){
                        console.log("Create Store for ", dataModel, " at ", this.apiServer, " TOKEN: ", token);
                        var store = new Store({target: (this.apiServer?(this.apiServer):"") + "/" + dataModel + "/",idProperty:"document_id", headers:{
                                "accept": "application/json",
                                "content-type": "application/json",
                                'X-Requested-With':null,
				'Authorization': token?token:(window.App.authorizationToken||"")
                        }});
                        console.log("store: ", store);
                        return store;
                },

                getFilterPanel: function(){
                        console.log("getFilterPanel()");
                        return FilterPanel;
                }

	});

});
<|endoftext|>


<commit_before>/*  Copyright 2017 Nishant Srivastava

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License. */

var thirdPartyServicesJsonArray = [
  {
    "name": "Google Play Services",
    "model": "gps",
    "gps": true,
    "logo": "images/gps.png",
    "link": {
      "privacy": "https://www.google.com/policies/privacy/",
      "terms": ""
    }
  },
  {
    "name": "AdMob",
    "model": "admob",
    "admob": false,
    "logo": "images/admob.png",
    "link": {
      "privacy": "https://support.google.com/admob/answer/6128543?hl=en",
      "terms": ""
    }
  },
  {
    "name": "Firebase Analytics",
    "model": "firebase",
    "firebase": false,
    "logo": "images/firebase.png",
    "link": {
      "privacy": "https://firebase.google.com/policies/analytics",
      "terms": ""
    }
  },
  {
    "name": "Facebook",
    "model": "facebook",
    "facebook": false,
    "logo": "images/facebook.png",
    "link": {
      "privacy": "https://www.facebook.com/about/privacy",
      "terms": ""
    }
  },
  {
    "name": "Fabric",
    "model": "fabric",
    "fabric": false,
    "logo": "images/fabric.png",
    "link": {
      "privacy": "https://fabric.io/privacy",
      "terms": ""
    }
  },
  {
    "name": "Crashlytics",
    "model": "crashlytics",
    "crashlytics": false,
    "logo": "images/crashlytics.png",
    "link": {
      "privacy": "http://try.crashlytics.com/terms/privacy-policy.pdf",
      "terms": ""
    }
  },
  {
    "name": "Matomo",
    "model": "piwik",
    "piwik": false,
    "logo": "images/piwik.png",
    "link": {
      "privacy": "https://matomo.org/privacy-policy/",
      "terms": ""
    }
  },
  {
    "name": "Clicky",
    "model": "clicky",
    "clicky": false,
    "logo": "images/clicky.png",
    "link": {
      "privacy": "https://clicky.com/terms#privacy",
      "terms": ""
    }
  },
  {
    "name": "Flurry Analytics",
    "model": "flurry",
    "flurry": false,
    "logo": "images/flurry.png",
    "link": {
      "privacy": "https://privacy.oath.com",
      "terms": "https://developer.yahoo.com/flurry/legal-privacy/terms-service/flurry-analytics-terms-service.html"
    }
  },
  {
    "name": "Appodeal",
    "model": "appodeal",
    "appodeal": false,
    "logo": "images/appodeal.png",
    "link": {
      "privacy": "https://www.appodeal.com/home/privacy-policy/",
      "terms": "https://www.appodeal.com/home/terms-of-service/"
    }
  },
  {
    "name": "Fathom Analytics",
    "model": "fathom",
    "fathom": false,
    "logo": "images/fathom.png",
    "link": {
      "privacy": "https://usefathom.com/privacy/",
      "terms": "https://usefathom.com/terms/"
    }
  },
  {
    "name": "Unity",
    "model": "unity",
    "unity": false,
    "logo": "images/unity.png",
    "link": {
      "privacy": "https://unity3d.com/legal/privacy-policy",
      "terms": "https://unity3d.com/legal/terms-of-service"
    }
  },
  {
    "name": "GameAnalytics",
    "model": "gameanalytics",
    "gameanalytics": false,
    "logo": "images/gameanalytics.png",
    "links": {
      "privacy": "https://gameanalytics.com/privacy",
      "terms": "https://gameanalytics.com/terms"
    }
  },
  {
    "name": "SDKBOX",
    "model": "sdkbox",
    "sdkbox": false,
    "logo": "images/sdkbox.png",
    "link": {
      "privacy": "https://www.sdkbox.com/privacy"
    }
  }
]<commit_msg>🐛 fix issue with gameanalytics<commit_after>/*  Copyright 2017 Nishant Srivastava

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License. */

var thirdPartyServicesJsonArray = [
  {
    "name": "Google Play Services",
    "model": "gps",
    "gps": true,
    "logo": "images/gps.png",
    "link": {
      "privacy": "https://www.google.com/policies/privacy/",
      "terms": ""
    }
  },
  {
    "name": "AdMob",
    "model": "admob",
    "admob": false,
    "logo": "images/admob.png",
    "link": {
      "privacy": "https://support.google.com/admob/answer/6128543?hl=en",
      "terms": ""
    }
  },
  {
    "name": "Firebase Analytics",
    "model": "firebase",
    "firebase": false,
    "logo": "images/firebase.png",
    "link": {
      "privacy": "https://firebase.google.com/policies/analytics",
      "terms": ""
    }
  },
  {
    "name": "Facebook",
    "model": "facebook",
    "facebook": false,
    "logo": "images/facebook.png",
    "link": {
      "privacy": "https://www.facebook.com/about/privacy",
      "terms": ""
    }
  },
  {
    "name": "Fabric",
    "model": "fabric",
    "fabric": false,
    "logo": "images/fabric.png",
    "link": {
      "privacy": "https://fabric.io/privacy",
      "terms": ""
    }
  },
  {
    "name": "Crashlytics",
    "model": "crashlytics",
    "crashlytics": false,
    "logo": "images/crashlytics.png",
    "link": {
      "privacy": "http://try.crashlytics.com/terms/privacy-policy.pdf",
      "terms": ""
    }
  },
  {
    "name": "Matomo",
    "model": "piwik",
    "piwik": false,
    "logo": "images/piwik.png",
    "link": {
      "privacy": "https://matomo.org/privacy-policy/",
      "terms": ""
    }
  },
  {
    "name": "Clicky",
    "model": "clicky",
    "clicky": false,
    "logo": "images/clicky.png",
    "link": {
      "privacy": "https://clicky.com/terms#privacy",
      "terms": ""
    }
  },
  {
    "name": "Flurry Analytics",
    "model": "flurry",
    "flurry": false,
    "logo": "images/flurry.png",
    "link": {
      "privacy": "https://privacy.oath.com",
      "terms": "https://developer.yahoo.com/flurry/legal-privacy/terms-service/flurry-analytics-terms-service.html"
    }
  },
  {
    "name": "Appodeal",
    "model": "appodeal",
    "appodeal": false,
    "logo": "images/appodeal.png",
    "link": {
      "privacy": "https://www.appodeal.com/home/privacy-policy/",
      "terms": "https://www.appodeal.com/home/terms-of-service/"
    }
  },
  {
    "name": "Fathom Analytics",
    "model": "fathom",
    "fathom": false,
    "logo": "images/fathom.png",
    "link": {
      "privacy": "https://usefathom.com/privacy/",
      "terms": "https://usefathom.com/terms/"
    }
  },
  {
    "name": "Unity",
    "model": "unity",
    "unity": false,
    "logo": "images/unity.png",
    "link": {
      "privacy": "https://unity3d.com/legal/privacy-policy",
      "terms": "https://unity3d.com/legal/terms-of-service"
    }
  },
  {
    "name": "SDKBOX",
    "model": "sdkbox",
    "sdkbox": false,
    "logo": "images/sdkbox.png",
    "link": {
      "privacy": "https://www.sdkbox.com/privacy"
    }
  },
  {
    "name": "GameAnalytics",
    "model": "gameanalytics",
    "gameanalytics": false,
    "logo": "images/gameanalytics.png",
    "link": {
      "privacy": "https://gameanalytics.com/privacy",
      "terms": "https://gameanalytics.com/terms"
    }
  }
]<|endoftext|>


<commit_before>define([
    "backbone",
    "handlebars",
    "datum/Datum",
    "datum/DatumFieldEditView",
    "search/Search",
    "app/UpdatingCollectionView",
    "libs/Utils"
], function(
    Backbone,
    Handlebars,
    Datum,
    DatumFieldEditView,
    Search,
    UpdatingCollectionView
) {
  var SearchEditView = Backbone.View.extend(
  /** @lends SearchEditView.prototype */
  {
    /**
     * @class Search View handles the render of the global search in the corner,
     *        and the advanced power search, as well as their events.
     *
     * @property {String} format Valid values are "fullscreen" or "top".
     *
     * @description Starts the Search.
     *
     * @extends Backbone.View
     * @constructs
     */
    initialize : function() {
      Utils.debug("SEARCH init: " + this.el);

      this.advancedSearchDatumView = new UpdatingCollectionView({
        collection           : window.app.get("corpus").get("datumFields").clone(),
        childViewConstructor : DatumFieldEditView,
        childViewTagName     : 'li',
        childViewFormat      : "datum"
      });

      this.advancedSearchSessionView = new UpdatingCollectionView({
        collection           : window.app.get("corpus").get("sessionFields").clone(),
        childViewConstructor : DatumFieldEditView,
        childViewTagName     : 'li',
        childViewFormat      : "datum"
      });

      this.model.bind('change', this.render, this);
    },

    /**
     * The underlying model of the SearchEditView is a Search.
     */
    model : Search,

    /**
     * Events that the SearchEditView is listening to and their handlers.
     */
    events : {
      "click .btn-search-union" : "searchUnion",
      "click .btn-search-intersection" : "searchIntersection",
      "click .icon-search" : "searchTop"
    },

    /**
     * The Handlebars template rendered as the AdvancedSearchView.
     */
    advancedTemplate : Handlebars.templates.search_advanced_edit_embedded,

    /**
     * The Handlebars template rendered as the TopSearchView.
     */
    topTemplate : Handlebars.templates.search_edit_embedded,

    /**
     * Renders the SearchEditView.
     */
    render : function() {
      Utils.debug("SEARCH render: " + this.el);

      if (this.format == "fullscreen") {
        // Display the SearchView
        this.setElement($("#search-fullscreen"));
        $(this.el).html(this.advancedTemplate(this.model.toJSON()));

        this.advancedSearchDatumView.el = this.$('.advanced_search_datum');
        this.advancedSearchDatumView.render();

        this.advancedSearchSessionView.el = this.$('.advanced_search_session');
        this.advancedSearchSessionView.render();

        Utils.debug("\trendering search: "+ this.model.get("searchKeywords"));
      } else if (this.format == "top") {
        // Display the SearchView
        this.setElement($("#search-top"));
        $(this.el).html(this.topTemplate(this.model.toJSON()));
      }

      return this;
    },

    /**
     * Perform a search that finds the union of all the criteria.
     */
    searchUnion : function() {
      Utils.debug("In searchUnion");

      // Create a query string from the search criteria
      var queryString = this.getQueryString("union");

      // Update the search box
      appView.searchView.model.set("searchKeywords", queryString);

      // Start the search
      this.search(queryString);
    },

    /**
     * Perform a search that finds the intersection of all the criteria.
     */
    searchIntersection : function() {
      Utils.debug("In searchIntersection");

      // Create a query string from the search criteria
      var queryString = this.getQueryString("intersection");

      // Update the search box
      appView.searchView.model.set("searchKeywords", queryString);

      // Start the search
      this.search(queryString);
    },

    /**
     * Perform a search.
     */
    searchTop : function() {
      Utils.debug("Will search for " + $("#search_box").val());
            // Search for Datum that match the search criteria
      var allDatumIds = [];
      (new Datum({"corpusname": app.get("corpus").get("corpusname")})).searchByQueryString($("#search_box").val(), function(datumIds) {
        // Display the results in the DataListReadView
        appView.dataListReadLeftSideView.model.set("datumIds", datumIds);
        appView.dataListReadLeftSideView.renderNewModel();
      });
    },

    /**
     * Create a string representation of the search criteria. Each
     * Object's key is the datum field's label and its value is the datum
     * field's value (i.e the search criteria). An example object would be
     *  {
     *    utterance : "searchForThisUtterance",
     *    gloss : "searchForThisGloss",
     *    translation : "searchForThisTranslation"
     *  }
     *
     * @return {Object} The created query object.
     */
    getQueryString : function(type) {
      // All the search fields related to Datum
      var datumFieldsViews = this.advancedSearchDatumView.collection;

      // Get all the search criteria
      var searchCriteria = [];
      datumFieldsViews.each(function(datumField) {
        var value = datumField.get("value");
        if (value && value != "") {
          searchCriteria.push(datumField.get("label") + ":" + value);
        }
      });

      // Update the search box with the search string corresponding to the
      // current search criteria
      var queryString = "";
      if (type == "union") {
        queryString = searchCriteria.join(" OR ");
      } else if (type == "intersection") {
        queryString = searchCriteria.join(" AND ");
      }

      return queryString;
    },

    /**
     * Perform a search that finds either the union or the intersection or all
     * the criteria.
     *
     * @param queryString {String} The string representing the query.
     */
    search : function(queryString) {
      // Search for Datum that match the search criteria
      var allDatumIds = [];
      (new Datum({"corpusname": app.get("corpus").get("corpusname")})).searchByQueryString(queryString, function(datumIds) {
        // Display the results in the DataListReadView
        appView.dataListReadLeftSideView.model.set("datumIds", datumIds);
        appView.dataListReadLeftSideView.renderNewModel();
      });
    },

    /**
     * Initialize the sample Search.
     */
    loadSample : function() {
      this.model.set({
        searchKeywords : "naya"
      });
    }
  });

  return SearchEditView;
});<commit_msg>Removed help question marks from session fields in advanced search #297.<commit_after>define([
    "backbone",
    "handlebars",
    "datum/Datum",
    "datum/DatumFieldEditView",
    "search/Search",
    "app/UpdatingCollectionView",
    "libs/Utils"
], function(
    Backbone,
    Handlebars,
    Datum,
    DatumFieldEditView,
    Search,
    UpdatingCollectionView
) {
  var SearchEditView = Backbone.View.extend(
  /** @lends SearchEditView.prototype */
  {
    /**
     * @class Search View handles the render of the global search in the corner,
     *        and the advanced power search, as well as their events.
     *
     * @property {String} format Valid values are "fullscreen" or "top".
     *
     * @description Starts the Search.
     *
     * @extends Backbone.View
     * @constructs
     */
    initialize : function() {
      Utils.debug("SEARCH init: " + this.el);

      this.advancedSearchDatumView = new UpdatingCollectionView({
        collection           : window.app.get("corpus").get("datumFields").clone(),
        childViewConstructor : DatumFieldEditView,
        childViewTagName     : 'li',
        childViewFormat      : "datum"
      });

      this.advancedSearchSessionView = new UpdatingCollectionView({
        collection           : window.app.get("corpus").get("sessionFields").clone(),
        childViewConstructor : DatumFieldEditView,
        childViewTagName     : 'li',
        childViewFormat      : "session"
      });

      this.model.bind('change', this.render, this);
    },

    /**
     * The underlying model of the SearchEditView is a Search.
     */
    model : Search,

    /**
     * Events that the SearchEditView is listening to and their handlers.
     */
    events : {
      "click .btn-search-union" : "searchUnion",
      "click .btn-search-intersection" : "searchIntersection",
      "click .icon-search" : "searchTop"
    },

    /**
     * The Handlebars template rendered as the AdvancedSearchView.
     */
    advancedTemplate : Handlebars.templates.search_advanced_edit_embedded,

    /**
     * The Handlebars template rendered as the TopSearchView.
     */
    topTemplate : Handlebars.templates.search_edit_embedded,

    /**
     * Renders the SearchEditView.
     */
    render : function() {
      Utils.debug("SEARCH render: " + this.el);

      if (this.format == "fullscreen") {
        // Display the SearchView
        this.setElement($("#search-fullscreen"));
        $(this.el).html(this.advancedTemplate(this.model.toJSON()));

        this.advancedSearchDatumView.el = this.$('.advanced_search_datum');
        this.advancedSearchDatumView.render();

        this.advancedSearchSessionView.el = this.$('.advanced_search_session');
        this.advancedSearchSessionView.render();

        Utils.debug("\trendering search: "+ this.model.get("searchKeywords"));
      } else if (this.format == "top") {
        // Display the SearchView
        this.setElement($("#search-top"));
        $(this.el).html(this.topTemplate(this.model.toJSON()));
      }

      return this;
    },

    /**
     * Perform a search that finds the union of all the criteria.
     */
    searchUnion : function() {
      Utils.debug("In searchUnion");

      // Create a query string from the search criteria
      var queryString = this.getQueryString("union");

      // Update the search box
      appView.searchView.model.set("searchKeywords", queryString);

      // Start the search
      this.search(queryString);
    },

    /**
     * Perform a search that finds the intersection of all the criteria.
     */
    searchIntersection : function() {
      Utils.debug("In searchIntersection");

      // Create a query string from the search criteria
      var queryString = this.getQueryString("intersection");

      // Update the search box
      appView.searchView.model.set("searchKeywords", queryString);

      // Start the search
      this.search(queryString);
    },

    /**
     * Perform a search.
     */
    searchTop : function() {
      Utils.debug("Will search for " + $("#search_box").val());
            // Search for Datum that match the search criteria
      var allDatumIds = [];
      (new Datum({"corpusname": app.get("corpus").get("corpusname")})).searchByQueryString($("#search_box").val(), function(datumIds) {
        // Display the results in the DataListReadView
        appView.dataListReadLeftSideView.model.set("datumIds", datumIds);
        appView.dataListReadLeftSideView.renderNewModel();
      });
    },

    /**
     * Create a string representation of the search criteria. Each
     * Object's key is the datum field's label and its value is the datum
     * field's value (i.e the search criteria). An example object would be
     *  {
     *    utterance : "searchForThisUtterance",
     *    gloss : "searchForThisGloss",
     *    translation : "searchForThisTranslation"
     *  }
     *
     * @return {Object} The created query object.
     */
    getQueryString : function(type) {
      // All the search fields related to Datum
      var datumFieldsViews = this.advancedSearchDatumView.collection;

      // Get all the search criteria
      var searchCriteria = [];
      datumFieldsViews.each(function(datumField) {
        var value = datumField.get("value");
        if (value && value != "") {
          searchCriteria.push(datumField.get("label") + ":" + value);
        }
      });

      // Update the search box with the search string corresponding to the
      // current search criteria
      var queryString = "";
      if (type == "union") {
        queryString = searchCriteria.join(" OR ");
      } else if (type == "intersection") {
        queryString = searchCriteria.join(" AND ");
      }

      return queryString;
    },

    /**
     * Perform a search that finds either the union or the intersection or all
     * the criteria.
     *
     * @param queryString {String} The string representing the query.
     */
    search : function(queryString) {
      // Search for Datum that match the search criteria
      var allDatumIds = [];
      (new Datum({"corpusname": app.get("corpus").get("corpusname")})).searchByQueryString(queryString, function(datumIds) {
        // Display the results in the DataListReadView
        appView.dataListReadLeftSideView.model.set("datumIds", datumIds);
        appView.dataListReadLeftSideView.renderNewModel();
      });
    },

    /**
     * Initialize the sample Search.
     */
    loadSample : function() {
      this.model.set({
        searchKeywords : "naya"
      });
    }
  });

  return SearchEditView;
});<|endoftext|>


<commit_before>/**
 * debugger.io: An interactive web scripting sandbox
 * https://github.com/gavinhungry/debugger.io
 *
 * Copyright (C) 2013-2014 Gavin Lloyd <gavinhungry@gmail.com>
 * This is free software distributed under the terms of the MIT license
 */

(function() {
  'use strict';

  requirejs.config({
    baseUrl: '/src/js',

    //>> excludeStart('bustCache', pragmas.bustCache);
    urlArgs: 'v=' + (new Date().getTime()),
    //>> excludeEnd('bustCache');

    paths: {
      promise: 'plugins/requirejs-promise.min',

      // libraries
      jqueryjs: '//cdn.jsdelivr.net/jquery/2.1/jquery.min',
      underscorejs: '//cdn.jsdelivr.net/lodash/2.4/lodash.min',
      backbonejs: '//cdn.jsdelivr.net/backbonejs/1.1/backbone-min',
      codemirrorjs: '//cdn.jsdelivr.net/codemirror/4.3/codemirror.min',
      hammer: '//cdn.jsdelivr.net/hammerjs/1.1/hammer.min',

      // plugins
      ui: '//cdn.jsdelivr.net/jquery.ui/1.10/jquery-ui.min',
      touchpunch: '//cdn.jsdelivr.net/jquery.ui.touch-punch/0.2/jquery.ui.touch-punch.min',
      transit: '//cdn.jsdelivr.net/jquery.transit/0.9/jquery.transit.min',
      nano: '//cdn.jsdelivr.net/nanoscrollerjs/0.7/javascripts/jquery.nanoscroller.min',
      cookie: '//cdn.jsdelivr.net/jquery.cookie/1.4.1/jquery.cookie.min',
      storage: '//cdn.jsdelivr.net/jquery.storage-api/1.7.2/jquery.storageapi.min',
      string: '//cdn.jsdelivr.net/underscore.string/2.3/underscore.string.min',
      inflection: '//cdn.jsdelivr.net/underscore.inflection/1.0/underscore.inflection.min',
      objmap: 'plugins/_.objMapFunctions.amd',
      deepmodel: '//cdn.jsdelivr.net/backbone.deepmodel/0.10/deep-model.min',

      cm_overlay: '//cdn.jsdelivr.net/codemirror/4.3/addon/mode/overlay',
      cm_search: '//cdn.jsdelivr.net/codemirror/4.3/addon/search/searchcursor',

      // CodeMirror markup
      cm_xml: '//cdn.jsdelivr.net/codemirror/4.3/mode/xml/xml',
      cm_html: '//cdn.jsdelivr.net/codemirror/4.3/mode/htmlmixed/htmlmixed',
      cm_markdown: '//cdn.jsdelivr.net/codemirror/4.3/mode/markdown/markdown',
      cm_gfm: '//cdn.jsdelivr.net/codemirror/4.3/mode/gfm/gfm',
      cm_jade: '//cdn.jsdelivr.net/codemirror/4.3/mode/jade/jade',
      cm_ruby: '//cdn.jsdelivr.net/codemirror/4.3/mode/ruby/ruby',
      cm_haml: '//cdn.jsdelivr.net/codemirror/4.3/mode/haml/haml',

      // CodeMirror style
      cm_css: '//cdn.jsdelivr.net/codemirror/4.3/mode/css/css',

      // CodeMirror script
      cm_js: '//cdn.jsdelivr.net/codemirror/4.3/mode/javascript/javascript',
      cm_coffeescript: '//cdn.jsdelivr.net/codemirror/4.3/mode/coffeescript/coffeescript',

      jquery: 'libs/jquery',
      underscore: 'libs/underscore',
      backbone: 'libs/backbone',
      codemirror: 'libs/codemirror'
    },

    map: {
      '*': {
        '../../lib/codemirror': 'codemirrorjs',
        '../../addon/mode/overlay': 'cm_overlay',
        '../search/search': 'cm_search',
        '../xml/xml': 'cm_xml',
        '../htmlmixed/htmlmixed': 'cm_html',
        '../markdown/markdown': 'cm_markdown',
        '../gfm/gfm': 'cm_gfm',
        '../jade/jade': 'cm_jade',
        '../ruby/ruby': 'cm_ruby',
        '../haml/haml': 'cm_haml',
        '../css/css': 'cm_css',
        '../javascript/javascript': 'cm_js',
        '../coffeescript/coffeescript': 'cm_coffeescript'
      },

      cookie: {
        jquery: 'jqueryjs'
      },

      deepmodel: {
        underscore: 'underscorejs',
        backbone: 'backbonejs'
      },

      objmap: {
        underscore: 'underscorejs'
      },

      transit: {
        jquery: 'jqueryjs'
      }
    },

    shim: {
      // libraries
      jqueryjs: { exports: '$' },
      underscorejs: { exports: '_' },
      backbonejs: { deps: ['jqueryjs', 'underscorejs'], exports: 'Backbone' },
      codemirrorjs: { exports: 'CodeMirror' },

      // plugins
      ui: { deps: ['jqueryjs'], exports: '$.ui' },
      touchpunch: { deps: ['jqueryjs', 'ui'] },
      transit: { deps: ['jqueryjs'], exports: '$.transit' },
      nano: { deps: ['jqueryjs'], exports: '$.fn.nanoScroller' },
      cookie: { deps: ['jqueryjs'] },
      storage: { deps: ['jqueryjs', 'cookie'] },
      hammer: { deps: ['jqueryjs'] },
      string: { deps: ['underscorejs'], exports: '_.str' },
      inflection: { deps: ['underscorejs'] },
      objmap: { deps: ['underscorejs'] },
      deepmodel: { deps: ['underscorejs', 'backbonejs'] },

      cm_overlay: { deps: ['codemirrorjs'] },
      cm_search: { deps: ['codemirrorjs'] },
      cm_xml: { deps: ['codemirrorjs'] },
      cm_html: { deps: ['codemirrorjs'] },
      cm_markdown: { deps: ['codemirrorjs'] },
      cm_gfm: { deps: ['codemirrorjs', 'cm_overlay', 'cm_markdown'] },
      cm_jade: { deps: ['codemirrorjs'] },
      cm_ruby: { deps: ['codemirrorjs'] },
      cm_haml: { deps: ['codemirrorjs', 'cm_ruby'] },
      cm_css: { deps: ['codemirrorjs'] },
      cm_js: { deps: ['codemirrorjs'] },
      cm_coffeescript: { deps: ['codemirrorjs'] }
    }
  });

})();
<commit_msg>Expose waitSeconds on requirejs._config<commit_after>/**
 * debugger.io: An interactive web scripting sandbox
 * https://github.com/gavinhungry/debugger.io
 *
 * Copyright (C) 2013-2014 Gavin Lloyd <gavinhungry@gmail.com>
 * This is free software distributed under the terms of the MIT license
 */

(function() {
  'use strict';

  // exposed config options - can't rely on requirejs.s.contexts._.config
  requirejs._config = {
    waitSeconds: 10
  };

  var config = {
    baseUrl: '/src/js',

    //>> excludeStart('bustCache', pragmas.bustCache);
    urlArgs: 'v=' + (new Date().getTime()),
    //>> excludeEnd('bustCache');

    paths: {
      promise: 'plugins/requirejs-promise.min',

      // libraries
      jqueryjs: '//cdn.jsdelivr.net/jquery/2.1/jquery.min',
      underscorejs: '//cdn.jsdelivr.net/lodash/2.4/lodash.min',
      backbonejs: '//cdn.jsdelivr.net/backbonejs/1.1/backbone-min',
      codemirrorjs: '//cdn.jsdelivr.net/codemirror/4.3/codemirror.min',
      hammer: '//cdn.jsdelivr.net/hammerjs/1.1/hammer.min',

      // plugins
      ui: '//cdn.jsdelivr.net/jquery.ui/1.10/jquery-ui.min',
      touchpunch: '//cdn.jsdelivr.net/jquery.ui.touch-punch/0.2/jquery.ui.touch-punch.min',
      transit: '//cdn.jsdelivr.net/jquery.transit/0.9/jquery.transit.min',
      nano: '//cdn.jsdelivr.net/nanoscrollerjs/0.7/javascripts/jquery.nanoscroller.min',
      cookie: '//cdn.jsdelivr.net/jquery.cookie/1.4.1/jquery.cookie.min',
      storage: '//cdn.jsdelivr.net/jquery.storage-api/1.7.2/jquery.storageapi.min',
      string: '//cdn.jsdelivr.net/underscore.string/2.3/underscore.string.min',
      inflection: '//cdn.jsdelivr.net/underscore.inflection/1.0/underscore.inflection.min',
      objmap: 'plugins/_.objMapFunctions.amd',
      deepmodel: '//cdn.jsdelivr.net/backbone.deepmodel/0.10/deep-model.min',

      cm_overlay: '//cdn.jsdelivr.net/codemirror/4.3/addon/mode/overlay',
      cm_search: '//cdn.jsdelivr.net/codemirror/4.3/addon/search/searchcursor',

      // CodeMirror markup
      cm_xml: '//cdn.jsdelivr.net/codemirror/4.3/mode/xml/xml',
      cm_html: '//cdn.jsdelivr.net/codemirror/4.3/mode/htmlmixed/htmlmixed',
      cm_markdown: '//cdn.jsdelivr.net/codemirror/4.3/mode/markdown/markdown',
      cm_gfm: '//cdn.jsdelivr.net/codemirror/4.3/mode/gfm/gfm',
      cm_jade: '//cdn.jsdelivr.net/codemirror/4.3/mode/jade/jade',
      cm_ruby: '//cdn.jsdelivr.net/codemirror/4.3/mode/ruby/ruby',
      cm_haml: '//cdn.jsdelivr.net/codemirror/4.3/mode/haml/haml',

      // CodeMirror style
      cm_css: '//cdn.jsdelivr.net/codemirror/4.3/mode/css/css',

      // CodeMirror script
      cm_js: '//cdn.jsdelivr.net/codemirror/4.3/mode/javascript/javascript',
      cm_coffeescript: '//cdn.jsdelivr.net/codemirror/4.3/mode/coffeescript/coffeescript',

      jquery: 'libs/jquery',
      underscore: 'libs/underscore',
      backbone: 'libs/backbone',
      codemirror: 'libs/codemirror'
    },

    map: {
      '*': {
        '../../lib/codemirror': 'codemirrorjs',
        '../../addon/mode/overlay': 'cm_overlay',
        '../search/search': 'cm_search',
        '../xml/xml': 'cm_xml',
        '../htmlmixed/htmlmixed': 'cm_html',
        '../markdown/markdown': 'cm_markdown',
        '../gfm/gfm': 'cm_gfm',
        '../jade/jade': 'cm_jade',
        '../ruby/ruby': 'cm_ruby',
        '../haml/haml': 'cm_haml',
        '../css/css': 'cm_css',
        '../javascript/javascript': 'cm_js',
        '../coffeescript/coffeescript': 'cm_coffeescript'
      },

      cookie: {
        jquery: 'jqueryjs'
      },

      deepmodel: {
        underscore: 'underscorejs',
        backbone: 'backbonejs'
      },

      objmap: {
        underscore: 'underscorejs'
      },

      transit: {
        jquery: 'jqueryjs'
      }
    },

    shim: {
      // libraries
      jqueryjs: { exports: '$' },
      underscorejs: { exports: '_' },
      backbonejs: { deps: ['jqueryjs', 'underscorejs'], exports: 'Backbone' },
      codemirrorjs: { exports: 'CodeMirror' },

      // plugins
      ui: { deps: ['jqueryjs'], exports: '$.ui' },
      touchpunch: { deps: ['jqueryjs', 'ui'] },
      transit: { deps: ['jqueryjs'], exports: '$.transit' },
      nano: { deps: ['jqueryjs'], exports: '$.fn.nanoScroller' },
      cookie: { deps: ['jqueryjs'] },
      storage: { deps: ['jqueryjs', 'cookie'] },
      hammer: { deps: ['jqueryjs'] },
      string: { deps: ['underscorejs'], exports: '_.str' },
      inflection: { deps: ['underscorejs'] },
      objmap: { deps: ['underscorejs'] },
      deepmodel: { deps: ['underscorejs', 'backbonejs'] },

      cm_overlay: { deps: ['codemirrorjs'] },
      cm_search: { deps: ['codemirrorjs'] },
      cm_xml: { deps: ['codemirrorjs'] },
      cm_html: { deps: ['codemirrorjs'] },
      cm_markdown: { deps: ['codemirrorjs'] },
      cm_gfm: { deps: ['codemirrorjs', 'cm_overlay', 'cm_markdown'] },
      cm_jade: { deps: ['codemirrorjs'] },
      cm_ruby: { deps: ['codemirrorjs'] },
      cm_haml: { deps: ['codemirrorjs', 'cm_ruby'] },
      cm_css: { deps: ['codemirrorjs'] },
      cm_js: { deps: ['codemirrorjs'] },
      cm_coffeescript: { deps: ['codemirrorjs'] }
    }
  };

  Object.keys(requirejs._config).forEach(function(key) {
    config[key] = requirejs._config[key];
  });

  requirejs.config(config);

})();
<|endoftext|>


<commit_before>import * as ButtonComponents from '@/components/Button'
import * as CollapseComponents from '@/components/Collapse'
import * as InputComponents from '@/components/Input'
import * as ListDividedComponents from '@/components/ListDivided'
import * as MenuComponents from '@/components/Menu'
import Loader from '@/components/utils/Loader'
import TableWrapper from '@/components/utils/TableWrapper'

export function create (plugin) {
  return () => {
    const components = {
      ...ButtonComponents,
      ...CollapseComponents,
      ...InputComponents,
      ...ListDividedComponents,
      ...MenuComponents,
      Loader,
      TableWrapper
    }

    plugin.globalComponents = {
      ...plugin.globalComponents,
      ...components
    }
  }
}
<commit_msg>feat: expose more ui components to plugins (#1792)<commit_after>import * as ButtonComponents from '@/components/Button'
import * as CollapseComponents from '@/components/Collapse'
import * as InputComponents from '@/components/Input'
import * as ListDividedComponents from '@/components/ListDivided'
import * as MenuComponents from '@/components/Menu'
import ModalCloseConfirmation from '@/components/Modal/ModalCloseConfirmation'
import ModalConfirmation from '@/components/Modal/ModalConfirmation'
import ModalWindow from '@/components/Modal/ModalWindow'
import Loader from '@/components/utils/Loader'
import SvgIcon from '@/components/SvgIcon/SvgIcon'
import TableWrapper from '@/components/utils/TableWrapper'
import WalletIdenticon from '@/components/Wallet/WalletIdenticon'

export function create (plugin) {
  return () => {
    const components = {
      ...ButtonComponents,
      ...CollapseComponents,
      ...InputComponents,
      ...ListDividedComponents,
      ...MenuComponents,
      ModalCloseConfirmation,
      ModalConfirmation,
      ModalWindow,
      Loader,
      SvgIcon,
      TableWrapper,
      WalletIdenticon
    }

    plugin.globalComponents = {
      ...plugin.globalComponents,
      ...components
    }
  }
}
<|endoftext|>


<commit_before>/*!
 * ${copyright}
 */

sap.ui.define([
	"sap/ui/core/LayoutData",
	"sap/ui/layout/library"
], function(LayoutData) {
	"use strict";

	var mGridItemProperties = {
		gridColumnStart: "grid-column-start",
		gridColumnEnd: "grid-column-end",
		gridRowStart: "grid-row-start",
		gridRowEnd: "grid-row-end",
		gridColumn: "grid-column",
		gridRow: "grid-row"
	};

	/**
	 * Constructor for a new sap.ui.layout.cssgrid.GridItemLayoutData.
	 *
	 * @param {string} [sId] ID for the new element, generated automatically if no ID is given
	 * @param {object} [mSettings] Initial settings for the new element.
	 *
	 * @class
	 * Holds layout data for a grid item.
	 *
	 * @extends sap.ui.core.LayoutData
	 * @version ${version}
	 *
	 * @constructor
	 * @public
	 * @alias sap.ui.layout.cssgrid.GridItemLayoutData
	 * @ui5-metamodel This control/element also will be described in the UI5 (legacy) designtime metamodel
	 */
	var GridItemLayoutData = LayoutData.extend("sap.ui.layout.cssgrid.GridItemLayoutData", { metadata: {
		library: "sap.ui.layout",
		properties: {

			/**
			 * Sets the value for the CSS display:grid item property grid-column-start
			 * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column-start}
			 */
			gridColumnStart: { type: "sap.ui.layout.cssgrid.CSSGridLine", defaultValue: "" },

			/**
			 * Sets the value for the CSS display:grid item property grid-column-end
			 * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column-end}
			 */
			gridColumnEnd: { type: "sap.ui.layout.cssgrid.CSSGridLine", defaultValue: "" },

			/**
			 * Sets the value for the CSS display:grid item property grid-row-start
			 * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row-start}
			 */
			gridRowStart: { type: "sap.ui.layout.cssgrid.CSSGridLine", defaultValue: "" },

			/**
			 * Sets the value for the CSS display:grid item property grid-row-end
			 * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row-end}
			 */
			gridRowEnd: { type: "sap.ui.layout.cssgrid.CSSGridLine", defaultValue: "" },

			/**
			 * Sets the value for the CSS display:grid item property grid-column
			 * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column}
			 */
			gridColumn: { type: "sap.ui.layout.cssgrid.CSSGridLine", defaultValue: "" },

			/**
			 * Sets the value for the CSS display:grid item property grid-row
			 * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row}
			 */
			gridRow: { type: "sap.ui.layout.cssgrid.CSSGridLine", defaultValue: ""}
		}
	}});

	/**
	 * Updates the display:grid styles of a single item
	 *
	 * @private
	 * @static
	 * @param {sap.ui.core.Control} oItem The item which styles have to be updated
	 */
	GridItemLayoutData._setItemStyles = function (oItem) {

		if (!oItem) {
			return;
		}

		var oLayoutData = GridItemLayoutData._getLayoutDataForControl(oItem),
			oItemDom = oItem.getDomRef(),
			oProperties,
			sProp,
			sPropValue;

		if (!oLayoutData) {
			GridItemLayoutData._removeItemStyles(oItemDom);
			return;
		}

		oProperties = oLayoutData.getMetadata().getProperties();

		for (sProp in mGridItemProperties) {
			if (oProperties[sProp]) {
				sPropValue = oLayoutData.getProperty(sProp);

				if (typeof sPropValue !== "undefined") {
					GridItemLayoutData._setItemStyle(oItemDom, mGridItemProperties[sProp], sPropValue);
				}
			}
		}
	};

	/**
	 * Remove all grid properties from the item
	 *
	 * @private
	 * @static
	 * @param {HTMLElement} oItemDom The Item DOM reference
	 */
	GridItemLayoutData._removeItemStyles = function (oItemDom) {
		for (var sProp in mGridItemProperties) {
			oItemDom.style.removeProperty(mGridItemProperties[sProp]);
		}
	};

	/**
	 * Sets a property on the DOM element
	 *
	 * @private
	 * @static
	 * @param {HTMLElement} oItemDom The item DOM reference
	 * @param {string} sProperty The name of the property to set
	 * @param {string} sValue The value of the property to set
	 */
	GridItemLayoutData._setItemStyle = function (oItemDom, sProperty, sValue) {
		if (sValue !== "0" && !sValue) {
			oItemDom.style.removeProperty(sProperty);
		} else {
			oItemDom.style.setProperty(sProperty, sValue);
		}
	};

	/**
	 * @private
	 * @static
	 * @param {sap.ui.core.Control} oControl The control to get the layoutData from
	 * @returns {sap.ui.layout.cssgrid.GridItemLayoutData|undefined} The layoutData used by the grid item
	 */
	GridItemLayoutData._getLayoutDataForControl = function (oControl) {
		var oLayoutData,
			aLayoutData,
			oInnerLayoutData;

		if (!oControl) {
			return undefined;
		}

		oLayoutData = oControl.getLayoutData();

		if (!oLayoutData) {
			return undefined;
		}

		if (oLayoutData.isA("sap.ui.layout.cssgrid.GridItemLayoutData")) {
			return oLayoutData;
		}

		if (oLayoutData.isA("sap.ui.core.VariantLayoutData")) {
			aLayoutData = oLayoutData.getMultipleLayoutData();
			for (var i = 0; i < aLayoutData.length; i++) {
				oInnerLayoutData = aLayoutData[i];
				if (oInnerLayoutData.isA("sap.ui.layout.cssgrid.GridItemLayoutData")) {
					return oInnerLayoutData;
				}
			}
		}
	};

	return GridItemLayoutData;
});<commit_msg>[FIX] sap.ui.layout.cssgrid.GridItemLayoutData: Now works with attribute bindings<commit_after>/*!
 * ${copyright}
 */

sap.ui.define([
	"sap/ui/core/LayoutData",
	"sap/ui/layout/library"
], function(LayoutData) {
	"use strict";

	var mGridItemProperties = {
		gridColumnStart: "grid-column-start",
		gridColumnEnd: "grid-column-end",
		gridRowStart: "grid-row-start",
		gridRowEnd: "grid-row-end",
		gridColumn: "grid-column",
		gridRow: "grid-row"
	};

	/**
	 * Constructor for a new sap.ui.layout.cssgrid.GridItemLayoutData.
	 *
	 * @param {string} [sId] ID for the new element, generated automatically if no ID is given
	 * @param {object} [mSettings] Initial settings for the new element.
	 *
	 * @class
	 * Holds layout data for a grid item.
	 *
	 * @extends sap.ui.core.LayoutData
	 * @version ${version}
	 *
	 * @constructor
	 * @public
	 * @alias sap.ui.layout.cssgrid.GridItemLayoutData
	 * @ui5-metamodel This control/element also will be described in the UI5 (legacy) designtime metamodel
	 */
	var GridItemLayoutData = LayoutData.extend("sap.ui.layout.cssgrid.GridItemLayoutData", { metadata: {
		library: "sap.ui.layout",
		properties: {

			/**
			 * Sets the value for the CSS display:grid item property grid-column-start
			 * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column-start}
			 */
			gridColumnStart: { type: "sap.ui.layout.cssgrid.CSSGridLine", defaultValue: "" },

			/**
			 * Sets the value for the CSS display:grid item property grid-column-end
			 * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column-end}
			 */
			gridColumnEnd: { type: "sap.ui.layout.cssgrid.CSSGridLine", defaultValue: "" },

			/**
			 * Sets the value for the CSS display:grid item property grid-row-start
			 * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row-start}
			 */
			gridRowStart: { type: "sap.ui.layout.cssgrid.CSSGridLine", defaultValue: "" },

			/**
			 * Sets the value for the CSS display:grid item property grid-row-end
			 * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row-end}
			 */
			gridRowEnd: { type: "sap.ui.layout.cssgrid.CSSGridLine", defaultValue: "" },

			/**
			 * Sets the value for the CSS display:grid item property grid-column
			 * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column}
			 */
			gridColumn: { type: "sap.ui.layout.cssgrid.CSSGridLine", defaultValue: "" },

			/**
			 * Sets the value for the CSS display:grid item property grid-row
			 * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row}
			 */
			gridRow: { type: "sap.ui.layout.cssgrid.CSSGridLine", defaultValue: ""}
		}
	}});

	/**
	 * Updates the display:grid styles of a single item
	 *
	 * @private
	 * @static
	 * @param {sap.ui.core.Control} oItem The item which styles have to be updated
	 */
	GridItemLayoutData._setItemStyles = function (oItem) {

		if (!oItem) {
			return;
		}

		var oLayoutData = GridItemLayoutData._getLayoutDataForControl(oItem),
			oItemDom = oItem.getDomRef(),
			oProperties,
			sProp,
			sPropValue;

		if (!oItemDom) {
			return;
		}

		if (!oLayoutData) {
			GridItemLayoutData._removeItemStyles(oItemDom);
			return;
		}

		oProperties = oLayoutData.getMetadata().getProperties();

		for (sProp in mGridItemProperties) {
			if (oProperties[sProp]) {
				sPropValue = oLayoutData.getProperty(sProp);

				if (typeof sPropValue !== "undefined") {
					GridItemLayoutData._setItemStyle(oItemDom, mGridItemProperties[sProp], sPropValue);
				}
			}
		}
	};

	/**
	 * Remove all grid properties from the item
	 *
	 * @private
	 * @static
	 * @param {HTMLElement} oItemDom The Item DOM reference
	 */
	GridItemLayoutData._removeItemStyles = function (oItemDom) {
		for (var sProp in mGridItemProperties) {
			oItemDom.style.removeProperty(mGridItemProperties[sProp]);
		}
	};

	/**
	 * Sets a property on the DOM element
	 *
	 * @private
	 * @static
	 * @param {HTMLElement} oItemDom The item DOM reference
	 * @param {string} sProperty The name of the property to set
	 * @param {string} sValue The value of the property to set
	 */
	GridItemLayoutData._setItemStyle = function (oItemDom, sProperty, sValue) {
		if (sValue !== "0" && !sValue) {
			oItemDom.style.removeProperty(sProperty);
		} else {
			oItemDom.style.setProperty(sProperty, sValue);
		}
	};

	/**
	 * @private
	 * @static
	 * @param {sap.ui.core.Control} oControl The control to get the layoutData from
	 * @returns {sap.ui.layout.cssgrid.GridItemLayoutData|undefined} The layoutData used by the grid item
	 */
	GridItemLayoutData._getLayoutDataForControl = function (oControl) {
		var oLayoutData,
			aLayoutData,
			oInnerLayoutData;

		if (!oControl) {
			return undefined;
		}

		oLayoutData = oControl.getLayoutData();

		if (!oLayoutData) {
			return undefined;
		}

		if (oLayoutData.isA("sap.ui.layout.cssgrid.GridItemLayoutData")) {
			return oLayoutData;
		}

		if (oLayoutData.isA("sap.ui.core.VariantLayoutData")) {
			aLayoutData = oLayoutData.getMultipleLayoutData();
			for (var i = 0; i < aLayoutData.length; i++) {
				oInnerLayoutData = aLayoutData[i];
				if (oInnerLayoutData.isA("sap.ui.layout.cssgrid.GridItemLayoutData")) {
					return oInnerLayoutData;
				}
			}
		}
	};

	return GridItemLayoutData;
});<|endoftext|>


<commit_before>'use strict';

/*@ngInject*/
module.exports = function($scope, _) {

  var strictTypingMode = false;

  var delim = {
    open: '{',
    close: '}'
  };

  function removeDelimeters(b) {
    if (typeof(b) !== 'string') {
      throw new Error('Input must be type string removeDelimeters');
    }
    return b.replace(delim.open, '').replace(delim.close, '');
  }

  function compareEntireAnswerToBody(answer) {
    return function(b) {
      var cleaned = removeDelimeters(b);
      return answer === cleaned;
    };
  }

  function compareGrammarElementToBody(answer) {
    return function(b) {
      if (!answer) {
        return false;
      }
      //This regex will only work for one occurence of {hey grammar element}
      //It needs to be changed for when the grammar elements are more than one
      //per body line.
      var reg = new RegExp(delim.open + '(.*)' + delim.close, 'g');
      //[0]original string [1-n]substring matches
      var results = reg.exec(b);
      var grammarElements = _.rest(results);

      return _.every(grammarElements, function(element) {
        var r = new RegExp('(^|\\W{1,1})' + element + '(\\W{1,1}|$)', 'g');
        return answer.search(r) !== -1;
      });
    };
  }

  function ensureLengthIsProper(answer) {
    var threshold = 0.8;
    return function(body) {
      var b = body.replace(delim.open, '').replace(delim.close, '');
      return (answer.length / b.length) >= threshold;
    };
  }

  $scope.answerText = {
    default: 'Check Work',
    notLongEnough: 'Your answer is not long enough. Try again!',
    tryAgain: 'Try Again!',
    tryAgainButton: 'Recheck Work',
    typingErrorNonStrict: 'You are correct, but you have some typing errors. You may correct them or continue.',
    typingErrorStrict: 'You are correct, but have some typing errors. Please fix them.'
  };

  $scope.checkAnswerText = $scope.answerText.default;

  $scope.showCheckAnswerButton = true;

  $scope.checkAnswer = function() {
    var rq = $scope.ruleQuestion;
    var answer = rq.response;
    var correct = false;
    if (!answer) {
      return;
    }
    var exactMatch = _.any(rq.body, compareEntireAnswerToBody(answer));
    if (exactMatch) {
      setMessage('Correct!');
      correct = true;
    } else {
      var grammarMatch = _.any(rq.body, compareGrammarElementToBody(answer));
      var answerIsAdequateLength = _.every(rq.body, ensureLengthIsProper(answer));
      if (!answerIsAdequateLength) {
        setMessage($scope.answerText.notLongEnough);
      }
      if (grammarMatch && !strictTypingMode) {
        setMessage($scope.answerText.typingErrorNonStrict);
        correct = true;
      } else if (grammarMatch) {
        setMessage($scope.answerText.typingErrorStrict);
      } else {
        setMessage($scope.answerText.tryAgain);
      }
    }
    if (rq.attempts) {
      rq.attempts++;
    } else {
      rq.attempts = 1;
    }
    if (correct || rq.attempts >= 2) {
      $scope.$emit('answerRuleQuestion', rq, answer, correct);
      $scope.showCheckAnswerButton = false;
    } else if (!correct) {
      $scope.$emit('answerRuleQuestionIncorrect', rq);
      $scope.checkAnswerText = $scope.answerText.tryAgainButton;
    }
  };

  function setMessage(msg) {
    $scope.ruleQuestion.message = msg;
  }
};
<commit_msg>Show incorrect state<commit_after>'use strict';

/*@ngInject*/
module.exports = function($scope, _) {

  var strictTypingMode = false;

  var delim = {
    open: '{',
    close: '}'
  };

  function removeDelimeters(b) {
    if (typeof(b) !== 'string') {
      throw new Error('Input must be type string removeDelimeters');
    }
    return b.replace(delim.open, '').replace(delim.close, '');
  }

  function compareEntireAnswerToBody(answer) {
    return function(b) {
      var cleaned = removeDelimeters(b);
      return answer === cleaned;
    };
  }

  function compareGrammarElementToBody(answer) {
    return function(b) {
      if (!answer) {
        return false;
      }
      //This regex will only work for one occurence of {hey grammar element}
      //It needs to be changed for when the grammar elements are more than one
      //per body line.
      var reg = new RegExp(delim.open + '(.*)' + delim.close, 'g');
      //[0]original string [1-n]substring matches
      var results = reg.exec(b);
      var grammarElements = _.rest(results);

      return _.every(grammarElements, function(element) {
        var r = new RegExp('(^|\\W{1,1})' + element + '(\\W{1,1}|$)', 'g');
        return answer.search(r) !== -1;
      });
    };
  }

  function ensureLengthIsProper(answer) {
    var threshold = 0.8;
    return function(body) {
      var b = body.replace(delim.open, '').replace(delim.close, '');
      return (answer.length / b.length) >= threshold;
    };
  }

  $scope.answerText = {
    default: 'Check Work',
    notLongEnough: 'Your answer is not long enough. Try again!',
    tryAgain: 'Try Again!',
    tryAgainButton: 'Recheck Work',
    typingErrorNonStrict: 'You are correct, but you have some typing errors. You may correct them or continue.',
    typingErrorStrict: 'You are correct, but have some typing errors. Please fix them.',
    incorrectWithAnswer: function(answer) {
      return 'Incorrect. Correct Answer: ' + answer;
    }
  };

  $scope.checkAnswerText = $scope.answerText.default;

  $scope.showCheckAnswerButton = true;

  $scope.checkAnswer = function() {
    var rq = $scope.ruleQuestion;
    var answer = rq.response;
    var correct = false;
    if (!answer) {
      return;
    }
    var exactMatch = _.any(rq.body, compareEntireAnswerToBody(answer));
    if (exactMatch) {
      setMessage('Correct!');
      correct = true;
    } else {
      var grammarMatch = _.any(rq.body, compareGrammarElementToBody(answer));
      var answerIsAdequateLength = _.every(rq.body, ensureLengthIsProper(answer));
      if (!answerIsAdequateLength) {
        setMessage($scope.answerText.notLongEnough);
      }
      if (grammarMatch && !strictTypingMode) {
        setMessage($scope.answerText.typingErrorNonStrict);
        correct = true;
      } else if (grammarMatch) {
        setMessage($scope.answerText.typingErrorStrict);
      } else {
        setMessage($scope.answerText.tryAgain);
      }
    }
    if (rq.attempts) {
      rq.attempts++;
    } else {
      rq.attempts = 1;
    }
    if (correct || rq.attempts >= 2) {
      $scope.$emit('answerRuleQuestion', rq, answer, correct);
      $scope.showCheckAnswerButton = false;
      if (!correct) {
        setMessage($scope.answerText.incorrectWithAnswer('correct answer here'));
      }
    } else if (!correct) {
      $scope.$emit('answerRuleQuestionIncorrect', rq);
      $scope.checkAnswerText = $scope.answerText.tryAgainButton;
    }
  };

  function setMessage(msg) {
    $scope.ruleQuestion.message = msg;
  }
};
<|endoftext|>


<commit_before>/*
 * This program is part of the OpenLMIS logistics management information system platform software.
 * Copyright © 2017 VillageReach
 *
 * This program is free software: you can redistribute it and/or modify it under the terms
 * of the GNU Affero General Public License as published by the Free Software Foundation, either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Affero General Public License for more details. You should have received a copy of
 * the GNU Affero General Public License along with this program. If not, see
 * http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org.
 */

describe('stockAdjustmentCreationService', function() {

    var service, httpBackend, stockmanagementUrlFactory, messageService, lineItem1, lineItem2, lineItem3;

    beforeEach(function() {
        module('stock-adjustment-creation');

        inject(function($injector) {
            service = $injector.get('stockAdjustmentCreationService');
            httpBackend = $injector.get('$httpBackend');
            stockmanagementUrlFactory = $injector.get('stockmanagementUrlFactory');
            messageService = $injector.get('messageService');

            lineItem1 = {
                orderable: {
                    id: 'c9e65f02-f84f-4ba2-85f7-e2cb6f0989af',
                    productCode: 'C1',
                    fullProductName: 'Streptococcus Pneumoniae Vaccine II',
                    dispensable: {
                        displayUnit: ''
                    }
                },
                stockOnHand: 100,
                quantity: 233,
                reason: {
                    id: 'r1',
                    name: 'clinic return'
                },
                reasonFreeText: 'free',
                occurredDate: '2016-04-01T03:23:34.000Z',
                assignment: {
                    name: 'WH-001'
                },
                srcDstFreeText: 'good source'
            };
            lineItem2 = {
                orderable: {
                    id: '2400e410-b8dd-4954-b1c0-80d8a8e785fc',
                    productCode: 'C2',
                    fullProductName: 'Acetylsalicylic Acid',
                    dispensable: {
                        displayUnit: 'each'
                    }
                },
                stockOnHand: null,
                quantity: 4,
                reason: {
                    id: 'r1',
                    name: 'clinic return'
                },
                reasonFreeText: 'donate',
                occurredDate: '2017-04-01T04:23:34.000Z'
            };
            lineItem3 = {
                orderable: {
                    id: '2400e410-b8dd-4954-b1c0-80d8a8e785fc',
                    productCode: 'C2',
                    fullProductName: 'Acetylsalicylic Acid',
                    dispensable: {
                        displayUnit: 'each'
                    }
                },
                stockOnHand: 1000,
                quantity: null,
                reason: {
                    id: 'r2',
                    name: 'damage'
                },
                occurredDate: '2017-04-01T05:23:34.000Z',
                assignment: {
                    name: 'WH-xyz'
                },
                srcDstFreeText: 'bad destination'
            };

        });
    });

    describe('search', function() {
        var addedItems;

        beforeEach(function() {
            addedItems = [lineItem1, lineItem2, lineItem3];
        });

        it('should search by productCode', function() {
            expect(angular.equals(service.search('c2', addedItems), [lineItem2, lineItem3])).toBeTruthy();
        });

        it('should search by fullProductName', function() {
            spyOn(messageService, 'get').andCallFake(function(message) {
                if (message === 'stockProductName.productWithDisplayUnit') {
                    return 'Acetylsalicylic Acid - each';
                }
                return message;

            });

            expect(angular.equals(service.search('Vaccine', addedItems), [lineItem1])).toBeTruthy();
        });

        it('should search by stockOnHand', function() {
            expect(angular.equals(service.search('10', addedItems), [lineItem1, lineItem3])).toBeTruthy();
        });

        it('should search by reason name', function() {
            expect(angular.equals(service.search('damage', addedItems), [lineItem3])).toBeTruthy();
        });

        it('should search by reason free text', function() {
            expect(angular.equals(service.search('donate', addedItems), [lineItem2])).toBeTruthy();
        });

        it('should search by quantity', function() {
            expect(angular.equals(service.search('233', addedItems), [lineItem1])).toBeTruthy();
        });

        it('should search by occurredDate', function() {
            expect(angular.equals(service.search('01/04/2017', addedItems), [lineItem2, lineItem3])).toBeTruthy();
        });

        it('should search by assignment name', function() {
            expect(service.search('wh', addedItems)).toEqual([lineItem1, lineItem3]);
        });

        it('should search by assignment free text', function() {
            expect(service.search('destination', addedItems)).toEqual([lineItem3]);
        });

        it('should return all items when keyword is empty', function() {
            expect(angular.equals(service.search('', addedItems), [lineItem1, lineItem2, lineItem3])).toBeTruthy();
        });

        it('should search by non-existence phrase', function() {
            lineItem1.reason.name = undefined;

            expect(angular.equals(service.search('fff', addedItems), [])).toBeTruthy();
        });

    });

    describe('submit adjustments', function() {
        it('should submit adjustments', function() {
            var programId = 'p01';
            var facilityId = 'f01';
            var orderableId = 'o01';
            var reasonId = 'r01';
            var date = new Date();
            var sourceId = 'wh-001';
            var srcDstFreeText = 'donate';
            var lineItems = [{
                orderable: {
                    id: orderableId
                },
                quantity: 100,
                occurredDate: date,
                vvmStatus: 'STAGE_1',
                reason: {
                    id: reasonId,
                    isFreeTextAllowed: false
                },
                assignment: {
                    node: {
                        id: sourceId
                    }
                },
                srcDstFreeText: srcDstFreeText
            }];

            var postData = undefined;
            httpBackend.when('POST', stockmanagementUrlFactory('/api/stockEvents'))
                .respond(function(method, url, data) {
                    postData = data;
                    return [201, 'e01'];
                });

            service.submitAdjustments(programId, facilityId, lineItems, {
                state: 'receive'
            });
            httpBackend.flush();

            var event = {
                programId: programId,
                facilityId: facilityId,
                lineItems: [{
                    orderableId: orderableId,
                    lotId: null,
                    quantity: 100,
                    extraData: {
                        vvmStatus: 'STAGE_1'
                    },
                    occurredDate: date,
                    reasonId: reasonId,
                    sourceId: sourceId,
                    sourceFreeText: srcDstFreeText
                }]
            };

            expect(angular.equals(JSON.stringify(event), postData)).toBeTruthy();
        });
    });
});

<commit_msg>OLMIS-6752: Added tests for date timezone verification<commit_after>/*
 * This program is part of the OpenLMIS logistics management information system platform software.
 * Copyright © 2017 VillageReach
 *
 * This program is free software: you can redistribute it and/or modify it under the terms
 * of the GNU Affero General Public License as published by the Free Software Foundation, either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Affero General Public License for more details. You should have received a copy of
 * the GNU Affero General Public License along with this program. If not, see
 * http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org.
 */

describe('stockAdjustmentCreationService', function() {

    var service, httpBackend, stockmanagementUrlFactory, messageService, lineItem1, lineItem2, lineItem3;

    beforeEach(function() {
        module('stock-adjustment-creation');

        inject(function($injector) {
            service = $injector.get('stockAdjustmentCreationService');
            httpBackend = $injector.get('$httpBackend');
            stockmanagementUrlFactory = $injector.get('stockmanagementUrlFactory');
            messageService = $injector.get('messageService');

            lineItem1 = {
                orderable: {
                    id: 'c9e65f02-f84f-4ba2-85f7-e2cb6f0989af',
                    productCode: 'C1',
                    fullProductName: 'Streptococcus Pneumoniae Vaccine II',
                    dispensable: {
                        displayUnit: ''
                    }
                },
                stockOnHand: 100,
                quantity: 233,
                reason: {
                    id: 'r1',
                    name: 'clinic return'
                },
                reasonFreeText: 'free',
                occurredDate: '2016-04-01',
                assignment: {
                    name: 'WH-001'
                },
                srcDstFreeText: 'good source'
            };
            lineItem2 = {
                orderable: {
                    id: '2400e410-b8dd-4954-b1c0-80d8a8e785fc',
                    productCode: 'C2',
                    fullProductName: 'Acetylsalicylic Acid',
                    dispensable: {
                        displayUnit: 'each'
                    }
                },
                stockOnHand: null,
                quantity: 4,
                reason: {
                    id: 'r1',
                    name: 'clinic return'
                },
                reasonFreeText: 'donate',
                occurredDate: '2017-04-01 GMT+02:00'
            };
            lineItem3 = {
                orderable: {
                    id: '2400e410-b8dd-4954-b1c0-80d8a8e785fc',
                    productCode: 'C2',
                    fullProductName: 'Acetylsalicylic Acid',
                    dispensable: {
                        displayUnit: 'each'
                    }
                },
                stockOnHand: 1000,
                quantity: null,
                reason: {
                    id: 'r2',
                    name: 'damage'
                },
                occurredDate: '2017-04-01 GMT-02:00',
                assignment: {
                    name: 'WH-xyz'
                },
                srcDstFreeText: 'bad destination'
            };

        });
    });

    describe('search', function() {
        var addedItems;

        beforeEach(function() {
            addedItems = [lineItem1, lineItem2, lineItem3];
        });

        it('should search by productCode', function() {
            expect(angular.equals(service.search('c2', addedItems), [lineItem2, lineItem3])).toBeTruthy();
        });

        it('should search by fullProductName', function() {
            spyOn(messageService, 'get').andCallFake(function(message) {
                if (message === 'stockProductName.productWithDisplayUnit') {
                    return 'Acetylsalicylic Acid - each';
                }
                return message;

            });

            expect(angular.equals(service.search('Vaccine', addedItems), [lineItem1])).toBeTruthy();
        });

        it('should search by stockOnHand', function() {
            expect(angular.equals(service.search('10', addedItems), [lineItem1, lineItem3])).toBeTruthy();
        });

        it('should search by reason name', function() {
            expect(angular.equals(service.search('damage', addedItems), [lineItem3])).toBeTruthy();
        });

        it('should search by reason free text', function() {
            expect(angular.equals(service.search('donate', addedItems), [lineItem2])).toBeTruthy();
        });

        it('should search by quantity', function() {
            expect(angular.equals(service.search('233', addedItems), [lineItem1])).toBeTruthy();
        });

        it('should consider timezone in search by occurredDate', function() {
            expect(service.search('01/04/2017', addedItems)).toEqual([lineItem3]);
            expect(service.search('31/03/2017', addedItems)).toEqual([lineItem2]);
        });

        it('should search by assignment name', function() {
            expect(service.search('wh', addedItems)).toEqual([lineItem1, lineItem3]);
        });

        it('should search by assignment free text', function() {
            expect(service.search('destination', addedItems)).toEqual([lineItem3]);
        });

        it('should return all items when keyword is empty', function() {
            expect(angular.equals(service.search('', addedItems), [lineItem1, lineItem2, lineItem3])).toBeTruthy();
        });

        it('should search by non-existence phrase', function() {
            lineItem1.reason.name = undefined;

            expect(angular.equals(service.search('fff', addedItems), [])).toBeTruthy();
        });

    });

    describe('submit adjustments', function() {
        it('should submit adjustments', function() {
            var programId = 'p01';
            var facilityId = 'f01';
            var orderableId = 'o01';
            var reasonId = 'r01';
            var date = new Date();
            var sourceId = 'wh-001';
            var srcDstFreeText = 'donate';
            var lineItems = [{
                orderable: {
                    id: orderableId
                },
                quantity: 100,
                occurredDate: date,
                vvmStatus: 'STAGE_1',
                reason: {
                    id: reasonId,
                    isFreeTextAllowed: false
                },
                assignment: {
                    node: {
                        id: sourceId
                    }
                },
                srcDstFreeText: srcDstFreeText
            }];

            var postData = undefined;
            httpBackend.when('POST', stockmanagementUrlFactory('/api/stockEvents'))
                .respond(function(method, url, data) {
                    postData = data;
                    return [201, 'e01'];
                });

            service.submitAdjustments(programId, facilityId, lineItems, {
                state: 'receive'
            });
            httpBackend.flush();

            var event = {
                programId: programId,
                facilityId: facilityId,
                lineItems: [{
                    orderableId: orderableId,
                    lotId: null,
                    quantity: 100,
                    extraData: {
                        vvmStatus: 'STAGE_1'
                    },
                    occurredDate: date,
                    reasonId: reasonId,
                    sourceId: sourceId,
                    sourceFreeText: srcDstFreeText
                }]
            };

            expect(angular.equals(JSON.stringify(event), postData)).toBeTruthy();
        });
    });
});

<|endoftext|>


<commit_before>/*
 * Copyright 2012 Amadeus s.a.s.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * Definition of the suggestions used in the LC resource handler
 * @class aria.resources.handlers.LCResourcesHandlerBean
 */
Aria.beanDefinitions({
    $package : "aria.resources.handlers.LCResourcesHandlerBean",
    $description : "Definition of the suggestions used in the LC resource handler",
    $namespaces : {
        "base" : "aria.widgets.form.AutoCompleteBean",
        "json" : "aria.core.JsonTypes"
    },
    $beans : {
        "Suggestion" : {
            $type : "base:Suggestion",
            $description : "A Label-Code suggestion",
            $restricted : false,
            $properties : {
                "label" : {
                    $type : "json:String",
                    $description : "label for this suggestion",
                    $sample : "Paris",
                    $mandatory : true
                },
                "code" : {
                    $type : "json:String",
                    $description : "A code matching this suggestion",
                    $sample : "PAR"
                }
            }
        },
        "Configuration" : {
            $type : "json:Object",
            $description : "Configuration Object for Suggestions",
            $restricted : false,
            $properties : {
                "labelKey" : {
                    $type : "json:String",
                    $description : "Any label key for suggestions",
                    $sample : "myLabel",
                    $default : "label"
                },
                "codeKey" : {
                    $type : "json:String",
                    $description : "Any code key for suggestions",
                    $sample : "myCode",
                    $default : "code"
                },
                "sortingMethod" : {
                    $type : "json:FunctionRef",
                    $description : "An anonymous function for sorting the suggestions list"
                },
                "codeExactMatch" : {
                    $type : "json:Boolean",
                    $description : "If code has to be matched exactly to return the suggestion",
                    $default : false
                },
                "labelMatchAtWordBoundaries" : {
                    $type : "json:Boolean",
                    $description : "Whether to try starting the search for the match on all word boundaries in the multi-word label, or only from the beginning of the label",
                    $default : false
                },
                "threshold" : {
                    $type : "json:Integer",
                    $description : "Minimum number of letters typed to return suggestions",
                    $default : 1
                }
            }
        }
    }
});
<commit_msg>doc #923 Improvement in the sorting method documentation for the LCReourcesHandler<commit_after>/*
 * Copyright 2012 Amadeus s.a.s.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * Definition of the suggestions used in the LC resource handler
 * @class aria.resources.handlers.LCResourcesHandlerBean
 */
Aria.beanDefinitions({
    $package : "aria.resources.handlers.LCResourcesHandlerBean",
    $description : "Definition of the suggestions used in the LC resource handler",
    $namespaces : {
        "base" : "aria.widgets.form.AutoCompleteBean",
        "json" : "aria.core.JsonTypes"
    },
    $beans : {
        "Suggestion" : {
            $type : "base:Suggestion",
            $description : "A Label-Code suggestion",
            $restricted : false,
            $properties : {
                "label" : {
                    $type : "json:String",
                    $description : "label for this suggestion",
                    $sample : "Paris",
                    $mandatory : true
                },
                "code" : {
                    $type : "json:String",
                    $description : "A code matching this suggestion",
                    $sample : "PAR"
                }
            }
        },
        "Configuration" : {
            $type : "json:Object",
            $description : "Configuration Object for Suggestions",
            $restricted : false,
            $properties : {
                "labelKey" : {
                    $type : "json:String",
                    $description : "Any label key for suggestions",
                    $sample : "myLabel",
                    $default : "label"
                },
                "codeKey" : {
                    $type : "json:String",
                    $description : "Any code key for suggestions",
                    $sample : "myCode",
                    $default : "code"
                },
                "sortingMethod" : {
                    $type : "json:FunctionRef",
                    $description : "A function for sorting the suggestions list. If specified, when the array of suggestions is prepared, the native Array sort method is called and the sorting function is provided as a parameter. Hence, the sorting function receives two suggestions as arguments and has to return a negative number, 0 or a positive number if the first suggestion has to be considered respectively \"smaller\", \"equal\" or \"greater\" than the second one"
                },
                "codeExactMatch" : {
                    $type : "json:Boolean",
                    $description : "If code has to be matched exactly to return the suggestion",
                    $default : false
                },
                "labelMatchAtWordBoundaries" : {
                    $type : "json:Boolean",
                    $description : "Whether to try starting the search for the match on all word boundaries in the multi-word label, or only from the beginning of the label",
                    $default : false
                },
                "threshold" : {
                    $type : "json:Integer",
                    $description : "Minimum number of letters typed to return suggestions",
                    $default : 1
                }
            }
        }
    }
});
<|endoftext|>