Backup
This commit is contained in:
parent
942772ec03
commit
c1175122d0
|
@ -4,4 +4,5 @@ rules:
|
||||||
no-redeclare: 0
|
no-redeclare: 0
|
||||||
no-mixed-spaces-and-tabs: 0
|
no-mixed-spaces-and-tabs: 0
|
||||||
no-console: 0
|
no-console: 0
|
||||||
no-cond-assign: 0
|
no-cond-assign: 0
|
||||||
|
no-unexpected-multiline: 0
|
|
@ -1,11 +1,12 @@
|
||||||
<vn>
|
<vn>
|
||||||
<vn-group>
|
<vn-lot-query id="params">
|
||||||
<db-form id="debt">
|
<vn-spec name="from" type="Date"/>
|
||||||
<db-model property="model">
|
</vn-lot-query>
|
||||||
SELECT clientGetDebt() debt
|
<db-form id="debt">
|
||||||
</db-model>
|
<db-model property="model">
|
||||||
</db-form>
|
SELECT clientGetDebt() debt
|
||||||
</vn-group>
|
</db-model>
|
||||||
|
</db-form>
|
||||||
<h1 id="title">
|
<h1 id="title">
|
||||||
<t>LastOrders</t>
|
<t>LastOrders</t>
|
||||||
</h1>
|
</h1>
|
||||||
|
|
|
@ -42,6 +42,11 @@ module.exports = new Class
|
||||||
|
|
||||||
var res = this.builderResultInit (builder);
|
var res = this.builderResultInit (builder);
|
||||||
|
|
||||||
|
var paramsLot = res.$('params');
|
||||||
|
|
||||||
|
if (paramsLot)
|
||||||
|
paramsLot.source = this.hash;
|
||||||
|
|
||||||
var models = res.getByTagName ('db-model');
|
var models = res.getByTagName ('db-model');
|
||||||
|
|
||||||
for (var i = 0; i < models.length; i++)
|
for (var i = 0; i < models.length; i++)
|
||||||
|
|
|
@ -81,7 +81,7 @@ module.exports = new Class
|
||||||
{
|
{
|
||||||
var parser = new DOMParser ();
|
var parser = new DOMParser ();
|
||||||
var xmlDoc = parser.parseFromString (xmlString, 'text/xml');
|
var xmlDoc = parser.parseFromString (xmlString, 'text/xml');
|
||||||
return this.loadFromXmlDoc (xmlDoc);
|
return this.loadFromXmlDoc (xmlDoc, dstDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
,loadFromXmlDoc: function (xmlDoc, dstDocument)
|
,loadFromXmlDoc: function (xmlDoc, dstDocument)
|
||||||
|
@ -194,7 +194,7 @@ module.exports = new Class
|
||||||
this._doc = dstDocument ? dstDocument : document;
|
this._doc = dstDocument ? dstDocument : document;
|
||||||
}
|
}
|
||||||
|
|
||||||
,_compileEnd: function (node)
|
,_compileEnd: function ()
|
||||||
{
|
{
|
||||||
for (var i = this._links.length - 1; i >= 0; i--)
|
for (var i = this._links.length - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
|
|
|
@ -121,4 +121,3 @@ module.exports = new Class
|
||||||
return this._model.setByIndex (this._row, column, value);
|
return this._model.setByIndex (this._row, column, value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ module.exports = new Class
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a value from the set.
|
* Gets a value from the lot.
|
||||||
*
|
*
|
||||||
* @param {string} field The field name
|
* @param {string} field The field name
|
||||||
* @return {*} The field value
|
* @return {*} The field value
|
||||||
|
@ -35,7 +35,7 @@ module.exports = new Class
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a value on the set.
|
* Sets a value on the lot.
|
||||||
*
|
*
|
||||||
* @param {string} field The field name
|
* @param {string} field The field name
|
||||||
* @param {*} value The new field value
|
* @param {*} value The new field value
|
||||||
|
@ -48,14 +48,14 @@ module.exports = new Class
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array with the set keys.
|
* Returns an array with the lot keys.
|
||||||
*
|
*
|
||||||
* @return {Array} The set keys
|
* @return {Array} The lot keys
|
||||||
*/
|
*/
|
||||||
,keys: function () {}
|
,keys: function () {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emits the 'change' signal on the set.
|
* Emits the 'change' signal on the lot.
|
||||||
*
|
*
|
||||||
* @param {Object} changes The changed params and its values
|
* @param {Object} changes The changed params and its values
|
||||||
*/
|
*/
|
||||||
|
@ -65,7 +65,7 @@ module.exports = new Class
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies all values from another set.
|
* Copies all values from another lot.
|
||||||
*
|
*
|
||||||
* @param {Object} object The source object
|
* @param {Object} object The source object
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,22 +1,10 @@
|
||||||
|
|
||||||
var Lot = require ('./lot');
|
var Lot = require ('./lot');
|
||||||
var LotIface = require ('./lot-iface');
|
var LotIface = require ('./lot-iface');
|
||||||
|
var Spec = require ('./spec');
|
||||||
|
var Value = require ('./value');
|
||||||
|
|
||||||
var Klass = new Class ();
|
module.exports = new Class
|
||||||
module.exports = Klass;
|
|
||||||
|
|
||||||
var Type =
|
|
||||||
{
|
|
||||||
INCLUDE: 1,
|
|
||||||
EXCLUDE: 2
|
|
||||||
};
|
|
||||||
|
|
||||||
Klass.extend
|
|
||||||
({
|
|
||||||
Type: Type
|
|
||||||
});
|
|
||||||
|
|
||||||
Klass.implement
|
|
||||||
({
|
({
|
||||||
Extends: Lot
|
Extends: Lot
|
||||||
,Tag: 'vn-lot-query'
|
,Tag: 'vn-lot-query'
|
||||||
|
@ -47,82 +35,69 @@ Klass.implement
|
||||||
{
|
{
|
||||||
return this._source;
|
return this._source;
|
||||||
}
|
}
|
||||||
},
|
|
||||||
type:
|
|
||||||
{
|
|
||||||
enumType: Type
|
|
||||||
,set: function (x)
|
|
||||||
{
|
|
||||||
this._type = x;
|
|
||||||
this._onSourceChange ();
|
|
||||||
}
|
|
||||||
,get: function ()
|
|
||||||
{
|
|
||||||
return this._type;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
,_fields: null
|
,initialize: function (props)
|
||||||
,_source: null
|
{
|
||||||
,_type: Type.INCLUDE
|
Object.assign (this, {
|
||||||
,_sourceFields: null
|
_fields: null,
|
||||||
|
_source: null,
|
||||||
|
_specs: {}
|
||||||
|
});
|
||||||
|
this.parent (props);
|
||||||
|
}
|
||||||
|
|
||||||
|
,appendChild: function (child)
|
||||||
|
{
|
||||||
|
if (!(child instanceof Spec))
|
||||||
|
throw new Error ('VnLotQuery: Child must be a Vn.Spec instance');
|
||||||
|
|
||||||
|
this._specs[child.name] = child;
|
||||||
|
}
|
||||||
|
|
||||||
,_onSourceChange: function ()
|
,_onSourceChange: function ()
|
||||||
{
|
{
|
||||||
var changed = false;
|
|
||||||
var params = this._source ? this._source.params : {};
|
var params = this._source ? this._source.params : {};
|
||||||
|
var myParams = {};
|
||||||
|
|
||||||
if (this._fields)
|
for (var key in this._specs)
|
||||||
switch (this._type)
|
myParams[key] = Value.simpleClone (params[key]);
|
||||||
{
|
|
||||||
case Type.EXCLUDE:
|
|
||||||
changed = this.typeExclude (params);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
changed = this.typeInclude (params);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
changed = true;
|
|
||||||
|
|
||||||
if (changed)
|
this.assign (myParams);
|
||||||
this.changed ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,typeInclude: function (params)
|
,transformParams: function (params)
|
||||||
{
|
{
|
||||||
var changed = false;
|
var newParams = {};
|
||||||
var fields = this._fields;
|
|
||||||
|
|
||||||
for (var i = fields.length; i--;)
|
for (var key in this._specs)
|
||||||
{
|
{
|
||||||
var field = fields[i];
|
var spec = this._specs[key];
|
||||||
|
if (params[key])
|
||||||
if (this._params[field] !== params[field])
|
newParams[key] = cast (params[key], spec.type);
|
||||||
{
|
|
||||||
this._params[field] = params[field];
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return changed;
|
return Object.assign (params, newParams);
|
||||||
}
|
|
||||||
|
|
||||||
,typeExclude: function (params)
|
|
||||||
{
|
|
||||||
var changed = false;
|
|
||||||
var sourceFields = [];
|
|
||||||
|
|
||||||
for (var field in params)
|
|
||||||
if (this._fields.indexOf (field) === -1
|
|
||||||
&& this._params[field] !== params[field])
|
|
||||||
{
|
|
||||||
this._params[field] = params[field];
|
|
||||||
sourceFields.push (field);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return changed;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function cast (value, type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case Boolean:
|
||||||
|
return (/^(true|1)$/i).test (v);
|
||||||
|
case Number:
|
||||||
|
return 0 + new Number (v);
|
||||||
|
case Date:
|
||||||
|
var date = new Date (v);
|
||||||
|
date.setHours (0, 0, 0, 0);
|
||||||
|
return date;
|
||||||
|
default:
|
||||||
|
if (type instanceof Object)
|
||||||
|
return JSON.parse (v);
|
||||||
|
else
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
18
js/vn/lot.js
18
js/vn/lot.js
|
@ -54,6 +54,7 @@ module.exports = new Class
|
||||||
|
|
||||||
,assign: function (params)
|
,assign: function (params)
|
||||||
{
|
{
|
||||||
|
params = this.transformParams (params);
|
||||||
var diff = Value.partialDiff (this._params, params);
|
var diff = Value.partialDiff (this._params, params);
|
||||||
|
|
||||||
if (diff)
|
if (diff)
|
||||||
|
@ -66,6 +67,7 @@ module.exports = new Class
|
||||||
|
|
||||||
,setAll: function (params)
|
,setAll: function (params)
|
||||||
{
|
{
|
||||||
|
params = this.transformParams (params);
|
||||||
var diff = Value.diff (this._params, params);
|
var diff = Value.diff (this._params, params);
|
||||||
|
|
||||||
if (diff)
|
if (diff)
|
||||||
|
@ -77,10 +79,22 @@ module.exports = new Class
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when lot params changes, can be implemented by child classes to
|
* Called when lot params changes, can be implemented by child classes to be
|
||||||
* be notified about changes.
|
* notified about changes.
|
||||||
*
|
*
|
||||||
* @param {Object} diff Changed parameters and its new values
|
* @param {Object} diff Changed parameters and its new values
|
||||||
*/
|
*/
|
||||||
,_paramsChanged: function () {}
|
,_paramsChanged: function () {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when lot params changes to apply transformations over them, can be
|
||||||
|
* implemented by child classes.
|
||||||
|
*
|
||||||
|
* @param {Object} params New parameters
|
||||||
|
* @return {Object} Transformed parameters
|
||||||
|
*/
|
||||||
|
,transformParams: function (params)
|
||||||
|
{
|
||||||
|
return params;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
|
||||||
|
var VnObject = require ('./object');
|
||||||
|
var Type = require ('./type');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paramter specification.
|
||||||
|
*/
|
||||||
|
module.exports = new Class
|
||||||
|
({
|
||||||
|
Extends: VnObject
|
||||||
|
,Tag: 'vn-spec'
|
||||||
|
,Properties:
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The parameter name.
|
||||||
|
*/
|
||||||
|
name:
|
||||||
|
{
|
||||||
|
type: String
|
||||||
|
,set: function (x)
|
||||||
|
{
|
||||||
|
this._name = x;
|
||||||
|
}
|
||||||
|
,get: function ()
|
||||||
|
{
|
||||||
|
return this._name;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* The parameter type.
|
||||||
|
*/
|
||||||
|
type:
|
||||||
|
{
|
||||||
|
type: Type
|
||||||
|
,set: function (x)
|
||||||
|
{
|
||||||
|
this._type = x;
|
||||||
|
}
|
||||||
|
,get: function ()
|
||||||
|
{
|
||||||
|
return this._type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
|
@ -18,6 +18,7 @@ Vn = module.exports = {
|
||||||
,Hash : require ('./hash')
|
,Hash : require ('./hash')
|
||||||
,ParamIface : require ('./param-iface')
|
,ParamIface : require ('./param-iface')
|
||||||
,Param : require ('./param')
|
,Param : require ('./param')
|
||||||
|
,Spec : require ('./spec')
|
||||||
,ModelIface : require ('./model-iface')
|
,ModelIface : require ('./model-iface')
|
||||||
,ModelProxy : require ('./model-proxy')
|
,ModelProxy : require ('./model-proxy')
|
||||||
,JsonModel : require ('./json-model')
|
,JsonModel : require ('./json-model')
|
||||||
|
|
|
@ -2,6 +2,11 @@
|
||||||
"name": "hedera-web",
|
"name": "hedera-web",
|
||||||
"version": "2.0.4",
|
"version": "2.0.4",
|
||||||
"description": "Verdnatura web page",
|
"description": "Verdnatura web page",
|
||||||
|
"license": "GPL-3.0",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.verdnatura.es/hedera-web"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"assets-webpack-plugin": "^3.5.1",
|
"assets-webpack-plugin": "^3.5.1",
|
||||||
"bundle-loader": "^0.5.4",
|
"bundle-loader": "^0.5.4",
|
||||||
|
@ -12,9 +17,9 @@
|
||||||
"raw-loader": "^0.5.1",
|
"raw-loader": "^0.5.1",
|
||||||
"style-loader": "^0.13.1",
|
"style-loader": "^0.13.1",
|
||||||
"url-loader": "^0.5.7",
|
"url-loader": "^0.5.7",
|
||||||
"webpack": "^2.5.1",
|
"webpack": "^3.0.0",
|
||||||
"webpack-chunk-hash": "^0.4.0",
|
"webpack-chunk-hash": "^0.4.0",
|
||||||
"webpack-dev-server": "^2.4.5",
|
"webpack-dev-server": "^2.5.0",
|
||||||
"webpack-merge": "^3.0.0"
|
"webpack-merge": "^3.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -72,8 +72,8 @@ var devConfig = {
|
||||||
port: wpConfig.devServerPort,
|
port: wpConfig.devServerPort,
|
||||||
headers: { "Access-Control-Allow-Origin": "*" },
|
headers: { "Access-Control-Allow-Origin": "*" },
|
||||||
stats: { chunks: false }
|
stats: { chunks: false }
|
||||||
}/*,
|
},
|
||||||
devtool: 'eval-source-map'*/
|
devtool: 'eval'
|
||||||
};
|
};
|
||||||
|
|
||||||
var mrgConfig = devMode ? devConfig : prodConfig;
|
var mrgConfig = devMode ? devConfig : prodConfig;
|
||||||
|
|
Loading…
Reference in New Issue