Checkpoint
gitea/hedera-web/pipeline/head This commit looks good Details

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) { ,onBasketCheck: function(isOk) {
if (isOk) if (isOk)
this.loadUi(); this.loadUi();
@ -104,8 +108,7 @@ Hedera.Catalog = new Class({
$.items.clean(); $.items.clean();
for (const tag of tags) for (const tag of tags)
if (params[tag] != null) $[`${tag}s`].lot = this.getFilter(params, tags, tag);
$[`${tag}`].lot = this.getFilter(params, tags);
} }
,refreshTitle: function() { ,refreshTitle: function() {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,3 +1,4 @@
require('./style.scss');
module.exports = new Class({ module.exports = new Class({
Extends: Htk.Column, Extends: Htk.Column,
@ -36,11 +37,11 @@ module.exports = new Class({
initialize: function(props) { initialize: function(props) {
this._cssClass = 'cell-button'; this._cssClass = 'cell-button';
this.parent(props); Htk.Column.prototype.initialize.call(this, props);
}, },
render: function(tr) { render: function(tr) {
const td = this.parent(tr); const td = Htk.Column.prototype.render.call(this, tr);
let button; 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 { td.cell-button {
max-width: 20px; max-width: 20px;
text-align: center; text-align: center;
@ -46,14 +31,3 @@ td.cell-button {
padding: 0; 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({ module.exports = new Class({
Extends: Htk.Column Extends: Htk.Column
@ -5,7 +6,7 @@ module.exports = new Class({
,initialize: function(props) { ,initialize: function(props) {
this._cssClass = 'cell-check'; this._cssClass = 'cell-check';
this.parent(props); Htk.Column.prototype.initialize.call(this, props);
} }
,render: function(tr) { ,render: function(tr) {
@ -19,7 +20,7 @@ module.exports = new Class({
else else
checkButton.disabled = true; checkButton.disabled = true;
var td = this.parent(tr); var td = Htk.Column.prototype.render.call(this, tr);
td.appendChild(checkButton); td.appendChild(checkButton);
return td; 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) { ,initialize: function(props) {
this._cssClass = 'cell-date'; this._cssClass = 'cell-date';
this.parent(props); Htk.Column.prototype.initialize.call(this, props);
} }
,render: function(tr) { ,render: function(tr) {
var text = Vn.Date.strftime(this.value, this._format); 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)); td.appendChild(this.createTextNode(text));
return td; return td;

View File

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

View File

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

View File

@ -1,3 +1,4 @@
require('./style.scss');
module.exports = new Class({ module.exports = new Class({
Extends: Htk.Column Extends: Htk.Column
@ -21,17 +22,17 @@ module.exports = new Class({
,initialize: function(props) { ,initialize: function(props) {
this._cssClass = 'cell-spin'; this._cssClass = 'cell-spin';
this.parent(props); Htk.Column.prototype.initialize.call(this, props);
} }
,renderHeader: function() { ,renderHeader: function() {
var th = this.parent(); var th = Htk.Column.prototype.renderHeader.call(this, );
th.className = 'cell-spin'; th.className = 'cell-spin';
return th; return th;
} }
,render: function(tr) { ,render: function(tr) {
var td = this.parent(tr); var td = Htk.Column.prototype.render.call(this, tr);
var valueString = null; 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) { ,initialize: function(props) {
this._cssClass = 'cell-text'; this._cssClass = 'cell-text';
this.parent(props); Htk.Column.prototype.initialize.call(this, props);
} }
,render: function(tr) { ,render: function(tr) {
@ -39,7 +39,7 @@ module.exports = new Class({
node = this.createTextNode( node = this.createTextNode(
Vn.Value.format(this.value, this._format)); Vn.Value.format(this.value, this._format));
var td = this.parent(tr); var td = Htk.Column.prototype.render.call(this, tr);
td.appendChild(node); td.appendChild(node);
return td; return td;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,11 +1,11 @@
var Object = require('./object'); var SqlObject = require('./object');
/** /**
* List of Sql.Object * List of Sql.Object
*/ */
module.exports = new Class({ module.exports = new Class({
Extends: Object Extends: SqlObject
,objects: [] ,objects: []
@ -65,7 +65,7 @@ module.exports = new Class({
for (var i = 0; i < this.objects.length; i++) for (var i = 0; i < this.objects.length; i++)
this._unrefObject(this.objects[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: ''}); Klass.extend({Classes: ''});
const ComponentClass = { const ComponentClass = {
Extends: NodeBuilder Extends: NodeBuilder,
,Properties: { Tag: 'vn-component',
Properties: {
/** /**
* Main HTML node that represents the component * Main HTML node that represents the component
*/ */
@ -101,7 +102,7 @@ const ComponentClass = {
,initialize: function(props) { ,initialize: function(props) {
this.doc = document; this.doc = document;
this.renderBase(); this.renderBase();
this.parent(props); NodeBuilder.prototype.initialize.call(this, props);
} }
,createRoot: function(tagName) { ,createRoot: function(tagName) {
@ -142,7 +143,7 @@ const ComponentClass = {
this.addEventListener(id, this.addEventListener(id,
callback.bind(instance, this)); callback.bind(instance, this));
} else } else
this.parent(id, callback, instance); NodeBuilder.prototype.on.call(this, id, callback, instance);
} }
,loadTemplateFromFile: function(path) { ,loadTemplateFromFile: function(path) {
@ -169,7 +170,7 @@ const ComponentClass = {
if (this.scope) if (this.scope)
this.scope.unref(); this.scope.unref();
this.parent(); NodeBuilder.prototype._destroy.call(this, );
} }
}; };

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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