Merge remote-tracking branch 'XTUPLE/4_6_x' into 23607
authorLinda Nichols <lynnaloo@gmail.com>
Fri, 23 May 2014 17:32:03 +0000 (17:32 +0000)
committerLinda Nichols <lynnaloo@gmail.com>
Fri, 23 May 2014 17:32:03 +0000 (17:32 +0000)
12 files changed:
RELEASE.md
enyo-client/application/source/models/terms.js
enyo-client/application/source/views/list.js
enyo-client/database/source/update_version.sql
enyo-client/database/source/xm/javascript/item_site.sql
enyo-client/extensions/source/purchasing/client/en/strings.js
foundation-database/public/functions/itemcost.sql
lib/enyo-x/source/widgets/relation.js
lib/orm/source/xm/javascript/model.sql
lib/orm/source/xt/javascript/session.sql
node-datasource/lib/query/freetext_query.js
package.json

index 1a8e4f3..bac6b41 100644 (file)
@@ -1,3 +1,11 @@
+4.5.0 (Beta 2014/05/22)
+==================
+
+Features and bugfixes
+---------------------
+TODO: document
+
+
 4.4.1 (2014/05/09)
 ==================
 
index 6736731..8f71a64 100644 (file)
@@ -122,7 +122,7 @@ white:true*/
           return XT.Error.clone('xt1013', { params: params });
         }
         if (!_.isNumber(cutOffDay) || cutOffDay % 1 !== 0 || cutOffDay < 0 || cutOffDay > 31) {
-          params = {attr: "_cutOffDate".loc(), value: cutOffDay};
+          params = {attr: "_cutOffDay".loc(), value: cutOffDay};
           return XT.Error.clone('xt1013', { params: params });
         }
       }
index cb4b009..161d7f9 100644 (file)
@@ -2652,7 +2652,7 @@ trailing:true, white:true, strict: false*/
     components: [
       {kind: "XV.ListItem", components: [
         {kind: "FittableColumns", components: [
-          {kind: "XV.ListColumn", classes: "short",
+          {kind: "XV.ListColumn", classes: "first",
             components: [
             {kind: "XV.ListAttr", attr: "name", isKey: true}
           ]}
index fefd438..1436970 100644 (file)
@@ -1 +1 @@
-UPDATE pkghead SET pkghead_version = '4.4.1' WHERE pkghead_name = 'xt';
+UPDATE pkghead SET pkghead_version = '4.5.0Beta' WHERE pkghead_name = 'xt';
index 28dae7f..0014b8d 100644 (file)
@@ -373,7 +373,7 @@ select xt.install_js('XM','ItemSite','xtuple', $$
 
     if (options) {
       /* Convert from rest_query to XM.Model.query structure. */
-      query = XM.Model.restQueryFormat(options);
+      query = XM.Model.restQueryFormat("XM.ItemSiteListItem", options);
 
       /* Perform the query. */
       return XM.ItemSitePrivate.fetch("XM.ItemSiteListItem", "public.itemsite", query);
index 23354d1..fa285e8 100644 (file)
@@ -7,6 +7,7 @@ strict:true, trailing:true, white:true */
   "use strict";
 
   var lang = XT.stringsFor("en_US", {
+    "_activityType": "Activity Type",
     "_correctToEarliestDate?": "The due date does not fall within the lead time for this Item Source. Would you like it corrected?",
     "_correctToMinimumQuantity?": "The quantity is below the minimum order quantity for this Item Source. Would you like it corrected?",
     "_correctToMultipleQuantity?": "The quantity does not fall within the order multiple quantity for this Item Source. Would you like it corrected?",
@@ -56,6 +57,7 @@ strict:true, trailing:true, white:true */
     "_UseEarliestAvailDateOnPOItem": "Use Earliest Date",
     "_vendorItem": "Vendor Item",
     "_vendorItemNumber": "VendorItemNumber",
+    "_vendorUnit": "Vendor Unit",
     "_viewPurchaseOrders": "View Purchase Orders",
     "_vouchered": "Vouchered",
     "_warnMaxCostExceeded": "The price is above the maximum desired cost of {maximumDesiredCost} for this Item."
index d9d43d6..0d75305 100644 (file)
@@ -16,10 +16,16 @@ CREATE OR REPLACE FUNCTION itemCost(pItemid INTEGER,
 DECLARE
   _cost NUMERIC := 0.0;
 BEGIN
-  SELECT itemcost(itemsite_id) INTO _cost
-  FROM itemsite
-  WHERE (itemsite_item_id=pItemid)
-    AND (itemsite_warehous_id=pSiteid);
+  IF (fetchMetricBool('WholesalePriceCosting')) THEN
+    SELECT item_listcost INTO _cost
+    FROM item
+    WHERE (item_id=pItemid);
+  ELSE
+    SELECT itemcost(itemsite_id) INTO _cost
+    FROM itemsite
+    WHERE (itemsite_item_id=pItemid)
+      AND (itemsite_warehous_id=pSiteid);
+  END IF;
 
   RETURN _cost;
 END;
index 3cb475b..81a6027 100644 (file)
@@ -454,6 +454,10 @@ regexp:true, undef:true, trailing:true, white:true, strict:false */
       correct model will be fetched and this function will be called again
       recursively with the model.
 
+      *In case of "order" models, each order's workspace is different depending on the order type.
+      This causes the Workspace var to be null so get the value from the getWorkspace
+      defined on the relation.js sub-kind.
+
       @param {XM.Model|Number|String} Value; can be a model or the id of a model.
       @param {Object} options
      */
@@ -471,7 +475,7 @@ regexp:true, undef:true, trailing:true, white:true, strict:false */
         nameValue = "",
         descripValue = "",
         additionalValue = "",
-        Workspace = this._Workspace,
+        Workspace = this._Workspace || (newId ? this._List.prototype.getWorkspace(value) : null),
         Model = this._collection.model,
         id,
         newValue,
index a87e4eb..ef0c414 100644 (file)
@@ -325,12 +325,12 @@ select xt.install_js('XM','Model','xtuple', $$
    any REST API client queriers.
 
    Sample usage:
-    XM.Model.restQueryFormat({"query": [{"city":{"EQUALS":"Norfolk"}}], "orderby": [{"ASC": "line1"}, {"DESC": "line2"}]})
+    XM.Model.restQueryFormat("XM.Address", {"query": [{"city":{"EQUALS":"Norfolk"}}], "orderby": [{"ASC": "line1"}, {"DESC": "line2"}]})
 
    @param {Object} options: query
    @returns {Object} The formated query
   */
-  XM.Model.restQueryFormat = function (options) {
+  XM.Model.restQueryFormat = function (recordType, options) {
     options = options || {};
 
     var order = {},
@@ -371,6 +371,37 @@ select xt.install_js('XM','Model','xtuple', $$
           }
         }
       }
+
+      /* Convert free text query. */
+      if (recordType && options.q) {
+        /* Get schema and add string columns to search query. */
+        var data = Object.create(XT.Data),
+          nameSpace = recordType.beforeDot(),
+          type = recordType.afterDot(),
+          orm = data.fetchOrm(nameSpace, type),
+          schema = XT.Session.schema(nameSpace.decamelize(), type.decamelize()),
+          param = {
+            "attribute": []
+          };
+
+        for (var c = 0; c < schema[type].columns.length; c++) {
+          if (schema[type].columns[c].category === 'S') {
+            param.attribute.push(schema[type].columns[c].name);
+          }
+        }
+
+        if (param.attribute.length) {
+          /* Add all string columns to attribute query. */
+          query.parameters = query.parameters || [];
+
+          param.operator = 'MATCHES';
+
+          /* Replace any spaces with regex '.*' so multi-word search works on similar strings. */
+          param.value = options.q.replace(' ', '.*');
+          query.parameters.push(param);
+        }
+      }
+
       if (options.orderby || options.orderBy) {
         options.orderBy = options.orderby || options.orderBy;
         query.orderBy = [];
@@ -385,14 +416,17 @@ select xt.install_js('XM','Model','xtuple', $$
           }
         }
       }
+
       if (options.rowlimit || options.rowLimit) {
         options.rowLimit = options.rowlimit || options.rowLimit;
         query.rowLimit = options.rowLimit;
       }
+
       if (options.maxresults || options.maxResults) {
         options.maxResults = options.maxresults || options.maxResults;
         query.rowLimit = options.maxResults;
       }
+
       if (options.pagetoken || options.pageToken) {
         options.pageToken = options.pagetoken || options.pageToken;
         if (query.rowLimit) {
@@ -401,6 +435,7 @@ select xt.install_js('XM','Model','xtuple', $$
           query.rowOffset = (options.pageToken || 0);
         }
       }
+
       if (options.count) {
         query.count = options.count;
       }
@@ -438,7 +473,7 @@ select xt.install_js('XM','Model','xtuple', $$
     /* Convert from rest_query to XM.Model.query structure. */
     if (recordType && options) {
       formattedOptions = {
-        "query": XM.Model.restQueryFormat(options)
+        "query": XM.Model.restQueryFormat(recordType, options)
       };
     }
 
index 9b7aec0..dae5b71 100644 (file)
@@ -196,7 +196,7 @@ select xt.install_js('XT','Session','xtuple', $$
     @param {String} Schema name
     @returns {Hash}
   */
-  XT.Session.schema = function(schema) {
+  XT.Session.schema = function(schema, table) {
     var sql = 'select c.relname as "type", ' +
               '  attname as "column", ' +
               '  typcategory as "category", ' +
@@ -207,6 +207,7 @@ select xt.install_js('XT','Session','xtuple', $$
               '  join pg_type t on a.atttypid = t.oid ' +
               ' join xt.orm on lower(orm_namespace) = n.nspname and xt.decamelize(orm_type) = c.relname and not orm_ext ' +
               'where n.nspname = $1 ' +
+              (table ? ' and c.relname = $2 ' : '') +
               'and relkind = \'v\' ' +
               'and orm_context = \'xtuple\' ' +
               'union all ' +
@@ -224,12 +225,13 @@ select xt.install_js('XT','Session','xtuple', $$
               '  left join xt.grpext on ext_id=grpext_ext_id ' +
               '  left join usrgrp on usrgrp_grp_id=grpext_grp_id ' +
               'where n.nspname = $1 ' +
+              (table ? ' and c.relname = $2 ' : '') +
               ' and relkind = \'v\' ' +
               ' and orm_context != \'xtuple\' ' +
-              ' and (usrext_usr_username = $2 or usrgrp_username = $2) ' +
+              ' and (usrext_usr_username = $3 or usrgrp_username = $3) ' +
               ' group by c.relname, attname, typcategory, n.nspname, attnum ' +
               'order by type, attnum',
-      recs = plv8.execute(sql, [schema, XT.username]),
+      recs = plv8.execute(sql, [schema, table, XT.username]),
       type,
       prev = '',
       name,
index da8bff7..29a88f2 100644 (file)
@@ -45,7 +45,8 @@ noarg:true, regexp:true, undef:true, strict:true, trailing:true, white:true */
           parameters : [{
             attribute: _.pluck(columns, 'name'),
             operator: 'MATCHES',
-            value: that.query.q
+            /* Replace any spaces with regex '.*' so multi-word search works on similar strings. */
+            value: that.query.q.replace(' ', '.*')
           }]
         }, _.omit(this.query, 'q'));
 
index bac3752..aa328dd 100644 (file)
@@ -2,7 +2,7 @@
   "author": "xTuple <dev@xtuple.com>",
   "name": "xtuple",
   "description": "xTuple Enterprise Resource Planning Mobile-Web client",
-  "version": "4.4.1",
+  "version": "4.5.0-beta",
   "repository": {
     "type": "git",
     "url": "https://github.com/xtuple/xtuple.git"