0
1
Fork 0

Checkpoint

This commit is contained in:
Juan Ferrer 2022-06-06 18:02:17 +02:00
parent 30052408de
commit 2307c16748
44 changed files with 159 additions and 153 deletions

View File

@ -17,6 +17,10 @@ Hedera.Catalog = new Class({
}
}
,refreshColors() {
this.$.colors.lazyRefresh();
}
,onBasketCheck: function(isOk) {
if (isOk)
this.loadUi();
@ -104,8 +108,7 @@ Hedera.Catalog = new Class({
$.items.clean();
for (const tag of tags)
if (params[tag] != null)
$[`${tag}`].lot = this.getFilter(params, tags);
$[`${tag}s`].lot = this.getFilter(params, tags, tag);
}
,refreshTitle: function() {

View File

@ -266,7 +266,7 @@
placeholder="_Color"
form="params"
column="color"
on-click="$.colors.refresh()">
on-mousedown="this.refreshColors()">
<db-model
id="colors"
property="model"
@ -286,7 +286,7 @@
placeholder="_Producer"
form="params"
column="producer"
on-click="$.producers.refresh()">
on-mousedown="$.producers.lazyRefresh()">
<db-model
id="producers"
property="model"
@ -306,7 +306,7 @@
placeholder="_Origin"
form="params"
column="origin"
on-click="$.origins.refresh()">
on-mousedown="$.origins.lazyRefresh()">
<db-model
id="origins"
property="model"
@ -327,7 +327,7 @@
placeholder="_Category"
form="params"
column="category"
on-click="$.categorys.refresh()">
on-mousedown="$.categorys.lazyRefresh()">
<db-model
id="categorys"
property="model"

View File

@ -151,11 +151,6 @@ Hedera.Checkout = new Class({
this.$.assistant.moveNext();
},
addressRenderer: function(builder, form) {
builder.$.address.addEventListener('click',
this.onAddressClick.bind(this, form.$.id));
},
onAddressClick: function(addressId) {
this.$.lot.set('address', addressId);
this.goNextStep();
@ -195,7 +190,7 @@ Hedera.Checkout = new Class({
}
this.autoStepLocked = true;
this.$.agency.value = agency;
this.$.lot.assign({agency});
this.autoStepLocked = false;
} else
Htk.Toast.showError(_('NoAgeciesAvailableForDate'));

View File

@ -72,7 +72,8 @@
<div class="answers radio">
<htk-radio-group
id="rg-method"
param="method"
form="lot"
column="method"
on-changed="onMethodChange"/>
<div>
<label>
@ -97,7 +98,8 @@
<htk-calendar
id="calendar"
class="thin-calendar"
param="date"
form="lot"
column="date"
restrict-func="calendarRestrict"
on-changed="onFieldChange"/>
</div>
@ -112,8 +114,7 @@
<htk-repeater
id="repeater"
form-id="iter"
on-change="onAddressChange"
renderer="addressRenderer">
on-change="onAddressChange">
<db-model property="model" id="addresses">
SELECT a.id, a.nickname, p.name province, a.city, a.street, a.isActive, c.country
FROM myAddress a
@ -122,13 +123,12 @@
WHERE a.isActive
</db-model>
<custom>
<div class="address" id="address">
<p class="consignee">
<htk-text form="iter" column="nickname"/>
</p>
<p>
<htk-text form="iter" column="street"/>
</p>
<div
class="address"
on-click="this.onAddressClick(iter.id)"
id="address">
<p class="consignee">{{iter.nickname}}</p>
<p>{{iter.street}}</p>
</div>
</custom>
</htk-repeater>
@ -142,7 +142,8 @@
<div class="answers target">
<htk-combo
id="agency-combo"
param="agency"
form="lot"
column="agency"
on-changed="onFieldChange"
model="agencies"/>
</div>
@ -155,7 +156,8 @@
<div class="answers target">
<htk-combo
id="warehouse-combo"
param="agency"
form="lot"
column="agency"
on-changed="onFieldChange"
model="warehouses"/>
</div>
@ -166,7 +168,7 @@
<div class="answers target">
<p>
<t>Arrival</t>
<htk-text format="%D" param="date"/>
<htk-text format="%D" form="lot" column="date"/>
</p>
<p>
<htk-text form="address-form" column="street"/>
@ -184,7 +186,7 @@
<div class="answers target">
<p>
<t>Pickup</t>
<htk-text format="%D" param="date"/>
<htk-text format="%D" form="lot" column="date"/>
</p>
<p>
<t>Warehouse</t>

View File

@ -58,7 +58,7 @@ module.exports = new Class({
,initialize: function(props) {
this.model = new Model();
this.parent(props);
Vn.Form.prototype.initialize.call(this, props);
}
,appendChild: function(child) {

View File

@ -197,6 +197,7 @@ Model.implement({
,columns: null
,columnMap: null
,_updatable: false
,_paramsChanged: true
,_requestedSortIndex: -1
,_requestedSortName: null
@ -213,7 +214,7 @@ Model.implement({
,_requestedMainTable: null
,initialize: function(props) {
this.parent(props);
Vn.Object.prototype.initialize.call(this, props);
this._cleanData();
this._setStatus(Status.CLEAN);
}
@ -224,7 +225,7 @@ Model.implement({
}
,loadXml: function(builder, node) {
this.parent(builder, node);
Vn.Object.prototype.loadXml.call(this, builder, node);
var query = node.firstChild.nodeValue;
@ -277,11 +278,11 @@ Model.implement({
,_onLotChange: function() {
const params = this._getHolderValues();
const isEqual = Vn.Value.equals(params, this._lastParams);
this._paramsChanged = !Vn.Value.equals(params, this._lastParams);
this._lastParams = params;
if (!isEqual)
this._autoLoad();
if (this.autoLoad)
this.lazyRefresh();
}
,_autoLoad: function() {
@ -302,6 +303,11 @@ Model.implement({
return true;
}
,lazyRefresh: function() {
if (this._paramsChanged)
this.refresh();
}
/**
* Refresh the model data reexecuting the query on the database.
*/
@ -310,6 +316,7 @@ Model.implement({
if (this._isReady(params)) {
this._setStatus(Status.LOADING);
this._paramsChanged = false;
this._conn.execStmt(this._stmt,
this._selectDone.bind(this), params);
} else

View File

@ -72,7 +72,7 @@ module.exports = new Class({
}
,loadXml: function(builder, node) {
this.parent(builder, node);
Vn.Object.prototype.loadXml.call(this, builder, node);
var query = node.firstChild.nodeValue;

View File

@ -103,7 +103,7 @@ module.exports = new Class({
,_destroy: function() {
this.close();
this.parent();
Vn.Object.prototype._destroy.call(this);
}
});

View File

@ -39,7 +39,7 @@ module.exports = new Class({
event.stopPropagation();
});
this.parent(props);
Vn.Component.prototype.initialize.call(this, props);
var sql = 'SELECT id, name, nickname FROM account.myUser;'
+'SELECT defaultForm FROM config;'
@ -512,7 +512,6 @@ module.exports = new Class({
,_destroy: function() {
this.hide();
this.parent();
Vn.Component.prototype.initialize.call(this);
}
});

View File

@ -19,7 +19,7 @@ module.exports = new Class({
}
,initialize: function(props) {
this.parent(props);
Vn.Component.prototype.initialize.call(this, props);
this.loadTemplateFromString(Tpl);
//this.$.socialBar.conn = this._conn;

View File

@ -6,7 +6,7 @@ module.exports = new Class({
this.info = moduleInfo;
this.gui = gui;
this.conn = gui.conn;
this.parent(null);
Vn.Object.prototype.initialize.call(this);
}
,open: function(lot) {

View File

@ -83,7 +83,7 @@ module.exports = new Class({
initialize: function(props) {
var node = this.createRoot('div');
node.className = 'htk-assistant';
this.parent(props);
Component.prototype.initialize.call(this, props);
},
appendChild: function(step) {

View File

@ -1,31 +1,26 @@
module.exports = new Class
({
module.exports = new Class({
Extends: Htk.Field
,Tag: 'htk-check'
,render: function ()
{
var node = this.createRoot ('input');
,render: function() {
var node = this.createRoot('input');
node.type = 'checkbox';
node.addEventListener ('change', this.changed.bind (this));
node.addEventListener('change', this.changed.bind(this));
}
,changed: function ()
{
this.valueChanged (this.node.checked);
,changed: function() {
this.valueChanged(this.node.checked);
}
,putValue: function (value)
{
,putValue: function(value) {
if (value)
this.node.checked = true;
else
this.node.checked = false;
}
,setEditable: function (editable)
{
,setEditable: function(editable) {
this.node.disabled = !editable;
}
});

View File

@ -8,8 +8,7 @@ var NodeBuilder = require('../../vn/node-builder');
module.exports = new Class({
Extends: NodeBuilder
,Tag: 'htk-column'
,Properties:
{
,Properties: {
value: {
type: String
,value: null
@ -57,7 +56,7 @@ module.exports = new Class({
* Initializes the column.
*/
,initialize: function(props) {
this.parent(props);
NodeBuilder.prototype.initialize.call(this, props);
this.td = this.createElement('td');
}

View File

@ -1,3 +1,4 @@
require('./style.scss');
module.exports = new Class({
Extends: Htk.Column,
@ -36,11 +37,11 @@ module.exports = new Class({
initialize: function(props) {
this._cssClass = 'cell-button';
this.parent(props);
Htk.Column.prototype.initialize.call(this, props);
},
render: function(tr) {
const td = this.parent(tr);
const td = Htk.Column.prototype.render.call(this, tr);
let button;

View File

@ -1,19 +1,4 @@
@import "./variables";
th.cell-spin {
text-align: right;
}
td.cell-spin {
width: 2.5em;
text-align: right;
}
th.cell-check,
th.cell-radio {
text-align: center;
}
td.cell-button {
max-width: 20px;
text-align: center;
@ -46,14 +31,3 @@ td.cell-button {
padding: 0;
}
}
td.cell-image {
text-align: center;
.htk-image {
max-width: 2.5em;
max-height: 2.5em;
display: block;
margin: auto;
}
}

View File

@ -1,3 +1,4 @@
require('./style.scss');
module.exports = new Class({
Extends: Htk.Column
@ -5,7 +6,7 @@ module.exports = new Class({
,initialize: function(props) {
this._cssClass = 'cell-check';
this.parent(props);
Htk.Column.prototype.initialize.call(this, props);
}
,render: function(tr) {
@ -19,7 +20,7 @@ module.exports = new Class({
else
checkButton.disabled = true;
var td = this.parent(tr);
var td = Htk.Column.prototype.render.call(this, tr);
td.appendChild(checkButton);
return td;
}

View File

@ -0,0 +1,5 @@
th.cell-check,
th.cell-radio {
text-align: center;
}

View File

@ -24,13 +24,13 @@ module.exports = new Class
,initialize: function(props) {
this._cssClass = 'cell-date';
this.parent(props);
Htk.Column.prototype.initialize.call(this, props);
}
,render: function(tr) {
var text = Vn.Date.strftime(this.value, this._format);
var td = this.parent(tr);
var td = Htk.Column.prototype.render.call(this, tr);
td.appendChild(this.createTextNode(text));
return td;

View File

@ -1,3 +1,4 @@
require('./style.scss');
module.exports = new Class({
Extends: Htk.Column
@ -34,7 +35,7 @@ module.exports = new Class({
,initialize: function(props) {
this._cssClass = 'cell-image';
this.parent(props);
Htk.Column.prototype.initialize.call(this, props);
}
,render: function(tr) {
@ -47,7 +48,7 @@ module.exports = new Class({
,doc: this.doc
});
var td = this.parent(tr);
var td = Htk.Column.prototype.render.call(this, tr);
td.appendChild(image.node);
return td;
}

View File

@ -0,0 +1,11 @@
td.cell-image {
text-align: center;
.htk-image {
max-width: 2.5em;
max-height: 2.5em;
display: block;
margin: auto;
}
}

View File

@ -27,7 +27,7 @@ module.exports = new Class({
if (this.target)
link.target = this.target;
var td = this.parent(tr);
var td = Htk.Column.prototype.render.call(this, tr);
td.appendChild(link);
return td;
}

View File

@ -14,11 +14,11 @@ module.exports = new Class({
,initialize: function(props) {
this._cssClass = 'cell-radio';
this.radioGroup = new Htk.RadioGroup(this.doc);
this.parent(props);
Htk.Column.prototype.initialize.call(this, props);
}
,render: function(tr) {
var td = this.parent(tr);
var td = Htk.Column.prototype.render.call(this, tr);
var radio = this.radioGroup.createButton(this.value);
td.appendChild(radio);

View File

@ -1,3 +1,4 @@
require('./style.scss');
module.exports = new Class({
Extends: Htk.Column
@ -21,17 +22,17 @@ module.exports = new Class({
,initialize: function(props) {
this._cssClass = 'cell-spin';
this.parent(props);
Htk.Column.prototype.initialize.call(this, props);
}
,renderHeader: function() {
var th = this.parent();
var th = Htk.Column.prototype.renderHeader.call(this, );
th.className = 'cell-spin';
return th;
}
,render: function(tr) {
var td = this.parent(tr);
var td = Htk.Column.prototype.render.call(this, tr);
var valueString = null;

View File

@ -0,0 +1,8 @@
th.cell-spin {
text-align: right;
}
td.cell-spin {
width: 2.5em;
text-align: right;
}

View File

@ -21,7 +21,7 @@ module.exports = new Class({
,initialize: function(props) {
this._cssClass = 'cell-text';
this.parent(props);
Htk.Column.prototype.initialize.call(this, props);
}
,render: function(tr) {
@ -39,7 +39,7 @@ module.exports = new Class({
node = this.createTextNode(
Vn.Value.format(this.value, this._format));
var td = this.parent(tr);
var td = Htk.Column.prototype.render.call(this, tr);
td.appendChild(node);
return td;
}

View File

@ -97,7 +97,7 @@ Dialog.implement({
,_buttons: Button.ACCEPT
,open: function() {
this.parent();
Popup.prototype.open.call(this);
// Dialog body
@ -146,7 +146,7 @@ Dialog.implement({
,hide(response) {
if (!this._isOpen) return;
this.parent();
Popup.prototype.hide.call(this);
this.emit('response', response);
}

View File

@ -26,7 +26,7 @@ module.exports = new Class({
self._onSubmit(); return false;
};
this.parent(props);
Component.prototype.initialize.call(this, props);
},
onNameChange: function() {

View File

@ -55,7 +55,7 @@ module.exports = new Class({
,initialize: function(props) {
this._bgMouseDownHandler = this._bgMouseDown.bind(this);
this.parent(props);
Component.prototype.initialize.call(this, props);
}
,render: function() {

View File

@ -9,7 +9,7 @@ module.exports = new Class({
,initialize: function(props) {
this.clear();
this.parent(props);
Htk.Field.prototype.initialize.call(this, props);
}
,clear: function() {

View File

@ -91,7 +91,7 @@ module.exports = new Class({
}
,loadXml: function(scope, node) {
this.parent(scope, node);
Component.prototype.loadXml.call(this, scope, node);
this._parentScope = scope;
var builder = this._builder = new Vn.Builder();
@ -233,7 +233,7 @@ module.exports = new Class({
,destroy: function() {
this._freeChildsData();
this.parent();
Component.prototype.destroy.call(this);
}
});

View File

@ -22,7 +22,7 @@ module.exports = new Class({
initialize: function(props) {
var node = this.createRoot('div');
node.className = 'htk-step';
this.parent(props);
Component.prototype.initialize.call(this, props);
},
show: function() {

View File

@ -4,5 +4,4 @@
@import "./spacing";
@import "./text";
@import "./width";
@import "./components";
@import "./material-symbols";

View File

@ -1,11 +1,11 @@
var Object = require('./object');
var SqlObject = require('./object');
/**
* List of Sql.Object
*/
module.exports = new Class({
Extends: Object
Extends: SqlObject
,objects: []
@ -65,7 +65,7 @@ module.exports = new Class({
for (var i = 0; i < this.objects.length; i++)
this._unrefObject(this.objects[i]);
this.parent();
SqlObject.prototype._destroy.call(this);
}
});

View File

@ -7,8 +7,9 @@ module.exports = Klass;
Klass.extend({Classes: ''});
const ComponentClass = {
Extends: NodeBuilder
,Properties: {
Extends: NodeBuilder,
Tag: 'vn-component',
Properties: {
/**
* Main HTML node that represents the component
*/
@ -101,7 +102,7 @@ const ComponentClass = {
,initialize: function(props) {
this.doc = document;
this.renderBase();
this.parent(props);
NodeBuilder.prototype.initialize.call(this, props);
}
,createRoot: function(tagName) {
@ -142,7 +143,7 @@ const ComponentClass = {
this.addEventListener(id,
callback.bind(instance, this));
} else
this.parent(id, callback, instance);
NodeBuilder.prototype.on.call(this, id, callback, instance);
}
,loadTemplateFromFile: function(path) {
@ -169,7 +170,7 @@ const ComponentClass = {
if (this.scope)
this.scope.unref();
this.parent();
NodeBuilder.prototype._destroy.call(this, );
}
};

View File

@ -44,7 +44,7 @@ module.exports = new Class({
_lastRow: 0
,_lastReady: false
});
this.parent(props);
Iterator.prototype.initialize.call(this, props);
}
,onModelChange: function() {

View File

@ -33,7 +33,7 @@ module.exports = new Class({
,_window: null
,_hashChangedHandler: this._hashChanged.bind(this)
});
this.parent(props);
Lot.prototype.initialize.call(this, props);
}
,_paramsChanged: function() {
@ -159,6 +159,6 @@ module.exports = new Class({
,_destroy: function() {
this._window.removeEventListener('hashchange', this._hashChangedHandler);
this._window = null;
this.parent();
Lot.prototype._destroy.call(this);
}
});

View File

@ -53,7 +53,7 @@ module.exports = new Class({
_row: -1
,_rowLock: false
});
this.parent(props);
Lot.prototype.initialize.call(this, props);
}
,_paramsChanged: function(diff) {

View File

@ -1,12 +1,12 @@
var Object = require('./object');
var VnObject = require('./object');
var JsonException = require('./json-exception');
/**
* Handler for JSON rest connections.
*/
module.exports = new Class({
Extends: Object
Extends: VnObject
,_connected: false
,_requestsCount: 0
@ -16,7 +16,7 @@ module.exports = new Class({
* Initilizes the connection object.
*/
,initialize: function() {
this.parent();
VnObject.prototype.initialize.call(this);
this.fetchToken();
}

View File

@ -37,7 +37,7 @@ module.exports = new Class({
_lockSource: false,
_specs: {}
});
this.parent(props);
Lot.prototype.initialize.call(this, props);
}
,appendChild: function(child) {

View File

@ -30,7 +30,7 @@ module.exports = new Class({
,initialize: function(props) {
this._params = {};
this.parent(props);
VnObject.prototype.initialize.call(this, props);
}
,keys: function() {

View File

@ -11,11 +11,11 @@ module.exports = new Class({
}
,createElement: function(tagName) {
return document.createElement(tagName);
return this.doc.createElement(tagName);
}
,createTextNode: function(text) {
return document.createTextNode(text);
return this.doc.createTextNode(text);
}
,render: function() {}

View File

@ -3,27 +3,27 @@
* The main base class. Manages the signal system. Objects based on this class
* can be instantiated declaratively using XML.
*/
module.exports = new Class({
module.exports = class VnObject {
/**
* Tag to be used when the class instance is defined via XML. All classes
* must define this attribute, even if it is not used.
*/
Tag: 'vn-object'
static Tag = 'vn-object';
/**
* Class public properties.
*/
,Properties: {}
static Properties = {};
/*
* Reference count.
*/
,_refCount: 1
* Reference count.
*/
_refCount = 1;
/*
* Signal handlers data.
*/
,_thisArg: null
* Signal handlers data.
*/
_thisArg = null;
/**
* Initializes the object and sets all properties passed to the class
@ -31,7 +31,11 @@ module.exports = new Class({
*
* @param {Object} props The properties passed to the contructor
*/
,initialize: function(props) {
constructor(props) {
this.setProperties(props);
}
initialize(props) {
this.setProperties(props);
}
@ -40,7 +44,7 @@ module.exports = new Class({
*
* @param {Object} props Properties
*/
,setProperties: function(props) {
setProperties(props) {
for (var prop in props)
this[prop] = props[prop];
}
@ -48,7 +52,7 @@ module.exports = new Class({
/**
* Increases the object reference count.
*/
,ref: function() {
ref() {
this._refCount++;
return this;
}
@ -56,7 +60,7 @@ module.exports = new Class({
/**
* Decreases the object reference count.
*/
,unref: function() {
unref() {
this._refCount--;
if (this._refCount === 0)
@ -70,7 +74,7 @@ module.exports = new Class({
* @param {Vn.Scope} scope The scope instance
* @param {Node} node The custom tag child nodes
*/
,loadXml: function() {}
loadXml() {}
/**
* Called from @Vn.Builder when it finds a a child tag that isn't
@ -78,7 +82,7 @@ module.exports = new Class({
*
* @param {Object} child The child object instance
*/
,appendChild: function() {}
appendChild() {}
/**
* Conects a signal with a function.
@ -87,7 +91,7 @@ module.exports = new Class({
* @param {function} callback The callback
* @param {Object} instance The instance
*/
,on: function(id, callback, instance) {
on(id, callback, instance) {
if (!(callback instanceof Function)) {
console.warn('Vn.Object: Invalid callback for signal \'%s\'', id);
return;
@ -113,7 +117,7 @@ module.exports = new Class({
* @param {function} callback The callback
* @param {boolean} block %true for lock the signal, %false for unlock
*/
,blockSignal: function(id, callback, block, instance) {
blockSignal(id, callback, block, instance) {
if (!this._thisArg)
return;
@ -133,7 +137,7 @@ module.exports = new Class({
*
* @param {string} id The signal identifier
*/
,emit: function(id) {
emit(id) {
if (!this._thisArg)
return;
@ -160,7 +164,7 @@ module.exports = new Class({
* @param {function} callback The connected callback
* @param {Object} instance The instance
*/
,disconnect: function(id, callback, instance) {
disconnect(id, callback, instance) {
if (!this._thisArg)
return;
@ -178,7 +182,7 @@ module.exports = new Class({
*
* @param {Object} instance The instance
*/
,disconnectByInstance: function(instance) {
disconnectByInstance(instance) {
if (!this._thisArg)
return;
@ -199,7 +203,7 @@ module.exports = new Class({
* the last reference to the object. It can be overwritten by child classes
* but should always call the parent method.
*/
,_destroy: function() {
_destroy() {
if (!this._thisArg)
return;
@ -217,7 +221,7 @@ module.exports = new Class({
* @param {Object} prop The linked property
* @param {Object} handlers The object events to listen with
*/
,link: function(prop, handlers) {
link(prop, handlers) {
this._signalInit();
var links = this._thisArg.links;
@ -240,16 +244,16 @@ module.exports = new Class({
}
}
,_unlink: function(object) {
_unlink(object) {
object.disconnectByInstance(this);
object.unref();
}
,_signalInit: function() {
_signalInit() {
if (!this._thisArg)
this._thisArg = {
signals: {},
links: {}
};
}
});
}

View File

@ -53,6 +53,6 @@ module.exports = new Class({
if (objects[i] instanceof VnObject)
objects[i].unref();
this.parent();
VnObject.prototype._destroy.call(this);
}
});