Backup
This commit is contained in:
parent
942772ec03
commit
c1175122d0
|
@ -4,4 +4,5 @@ rules:
|
|||
no-redeclare: 0
|
||||
no-mixed-spaces-and-tabs: 0
|
||||
no-console: 0
|
||||
no-cond-assign: 0
|
||||
no-cond-assign: 0
|
||||
no-unexpected-multiline: 0
|
|
@ -1,11 +1,12 @@
|
|||
<vn>
|
||||
<vn-group>
|
||||
<db-form id="debt">
|
||||
<db-model property="model">
|
||||
SELECT clientGetDebt() debt
|
||||
</db-model>
|
||||
</db-form>
|
||||
</vn-group>
|
||||
<vn-lot-query id="params">
|
||||
<vn-spec name="from" type="Date"/>
|
||||
</vn-lot-query>
|
||||
<db-form id="debt">
|
||||
<db-model property="model">
|
||||
SELECT clientGetDebt() debt
|
||||
</db-model>
|
||||
</db-form>
|
||||
<h1 id="title">
|
||||
<t>LastOrders</t>
|
||||
</h1>
|
||||
|
|
|
@ -42,6 +42,11 @@ module.exports = new Class
|
|||
|
||||
var res = this.builderResultInit (builder);
|
||||
|
||||
var paramsLot = res.$('params');
|
||||
|
||||
if (paramsLot)
|
||||
paramsLot.source = this.hash;
|
||||
|
||||
var models = res.getByTagName ('db-model');
|
||||
|
||||
for (var i = 0; i < models.length; i++)
|
||||
|
|
|
@ -81,7 +81,7 @@ module.exports = new Class
|
|||
{
|
||||
var parser = new DOMParser ();
|
||||
var xmlDoc = parser.parseFromString (xmlString, 'text/xml');
|
||||
return this.loadFromXmlDoc (xmlDoc);
|
||||
return this.loadFromXmlDoc (xmlDoc, dstDocument);
|
||||
}
|
||||
|
||||
,loadFromXmlDoc: function (xmlDoc, dstDocument)
|
||||
|
@ -194,7 +194,7 @@ module.exports = new Class
|
|||
this._doc = dstDocument ? dstDocument : document;
|
||||
}
|
||||
|
||||
,_compileEnd: function (node)
|
||||
,_compileEnd: function ()
|
||||
{
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -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
|
||||
* @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 {*} 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 () {}
|
||||
|
||||
/**
|
||||
* Emits the 'change' signal on the set.
|
||||
* Emits the 'change' signal on the lot.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
|
|
@ -1,22 +1,10 @@
|
|||
|
||||
var Lot = require ('./lot');
|
||||
var LotIface = require ('./lot-iface');
|
||||
var Spec = require ('./spec');
|
||||
var Value = require ('./value');
|
||||
|
||||
var Klass = new Class ();
|
||||
module.exports = Klass;
|
||||
|
||||
var Type =
|
||||
{
|
||||
INCLUDE: 1,
|
||||
EXCLUDE: 2
|
||||
};
|
||||
|
||||
Klass.extend
|
||||
({
|
||||
Type: Type
|
||||
});
|
||||
|
||||
Klass.implement
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Lot
|
||||
,Tag: 'vn-lot-query'
|
||||
|
@ -47,82 +35,69 @@ Klass.implement
|
|||
{
|
||||
return this._source;
|
||||
}
|
||||
},
|
||||
type:
|
||||
{
|
||||
enumType: Type
|
||||
,set: function (x)
|
||||
{
|
||||
this._type = x;
|
||||
this._onSourceChange ();
|
||||
}
|
||||
,get: function ()
|
||||
{
|
||||
return this._type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
,_fields: null
|
||||
,_source: null
|
||||
,_type: Type.INCLUDE
|
||||
,_sourceFields: null
|
||||
,initialize: function (props)
|
||||
{
|
||||
Object.assign (this, {
|
||||
_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 ()
|
||||
{
|
||||
var changed = false;
|
||||
var params = this._source ? this._source.params : {};
|
||||
var myParams = {};
|
||||
|
||||
if (this._fields)
|
||||
switch (this._type)
|
||||
{
|
||||
case Type.EXCLUDE:
|
||||
changed = this.typeExclude (params);
|
||||
break;
|
||||
default:
|
||||
changed = this.typeInclude (params);
|
||||
}
|
||||
else
|
||||
changed = true;
|
||||
for (var key in this._specs)
|
||||
myParams[key] = Value.simpleClone (params[key]);
|
||||
|
||||
if (changed)
|
||||
this.changed ();
|
||||
this.assign (myParams);
|
||||
}
|
||||
|
||||
,typeInclude: function (params)
|
||||
,transformParams: function (params)
|
||||
{
|
||||
var changed = false;
|
||||
var fields = this._fields;
|
||||
var newParams = {};
|
||||
|
||||
for (var i = fields.length; i--;)
|
||||
for (var key in this._specs)
|
||||
{
|
||||
var field = fields[i];
|
||||
|
||||
if (this._params[field] !== params[field])
|
||||
{
|
||||
this._params[field] = params[field];
|
||||
changed = true;
|
||||
}
|
||||
var spec = this._specs[key];
|
||||
if (params[key])
|
||||
newParams[key] = cast (params[key], spec.type);
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
,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;
|
||||
return Object.assign (params, newParams);
|
||||
}
|
||||
});
|
||||
|
||||
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)
|
||||
{
|
||||
params = this.transformParams (params);
|
||||
var diff = Value.partialDiff (this._params, params);
|
||||
|
||||
if (diff)
|
||||
|
@ -66,6 +67,7 @@ module.exports = new Class
|
|||
|
||||
,setAll: function (params)
|
||||
{
|
||||
params = this.transformParams (params);
|
||||
var diff = Value.diff (this._params, params);
|
||||
|
||||
if (diff)
|
||||
|
@ -77,10 +79,22 @@ module.exports = new Class
|
|||
}
|
||||
|
||||
/**
|
||||
* Called when lot params changes, can be implemented by child classes to
|
||||
* be notified about changes.
|
||||
* Called when lot params changes, can be implemented by child classes to be
|
||||
* notified about changes.
|
||||
*
|
||||
* @param {Object} diff Changed parameters and its new values
|
||||
*/
|
||||
,_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')
|
||||
,ParamIface : require ('./param-iface')
|
||||
,Param : require ('./param')
|
||||
,Spec : require ('./spec')
|
||||
,ModelIface : require ('./model-iface')
|
||||
,ModelProxy : require ('./model-proxy')
|
||||
,JsonModel : require ('./json-model')
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
"name": "hedera-web",
|
||||
"version": "2.0.4",
|
||||
"description": "Verdnatura web page",
|
||||
"license": "GPL-3.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.verdnatura.es/hedera-web"
|
||||
},
|
||||
"devDependencies": {
|
||||
"assets-webpack-plugin": "^3.5.1",
|
||||
"bundle-loader": "^0.5.4",
|
||||
|
@ -12,9 +17,9 @@
|
|||
"raw-loader": "^0.5.1",
|
||||
"style-loader": "^0.13.1",
|
||||
"url-loader": "^0.5.7",
|
||||
"webpack": "^2.5.1",
|
||||
"webpack": "^3.0.0",
|
||||
"webpack-chunk-hash": "^0.4.0",
|
||||
"webpack-dev-server": "^2.4.5",
|
||||
"webpack-dev-server": "^2.5.0",
|
||||
"webpack-merge": "^3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
@ -72,8 +72,8 @@ var devConfig = {
|
|||
port: wpConfig.devServerPort,
|
||||
headers: { "Access-Control-Allow-Origin": "*" },
|
||||
stats: { chunks: false }
|
||||
}/*,
|
||||
devtool: 'eval-source-map'*/
|
||||
},
|
||||
devtool: 'eval'
|
||||
};
|
||||
|
||||
var mrgConfig = devMode ? devConfig : prodConfig;
|
||||
|
|
Loading…
Reference in New Issue