Vn.Scope: $ is now an object

This commit is contained in:
Juan Ferrer 2022-05-28 03:18:06 +02:00
parent d2ed1fb1af
commit fc22db73f2
33 changed files with 278 additions and 315 deletions

View File

@ -4,8 +4,8 @@ Hedera.AddressList = new Class
Extends: Hedera.Form Extends: Hedera.Form
,activate: function() { ,activate: function() {
this.$('user-model').setInfo('c', 'myClient', 'hedera'); this.$.userModel.setInfo('c', 'myClient', 'hedera');
this.$('addresses').setInfo('a', 'myAddress', 'hedera'); this.$.addresses.setInfo('a', 'myAddress', 'hedera');
} }
,onAddAddressClick: function() { ,onAddAddressClick: function() {
@ -21,7 +21,7 @@ Hedera.AddressList = new Class
,onSetDefaultClick: function(event, addressId) { ,onSetDefaultClick: function(event, addressId) {
if (event.defaultPrevented) return; if (event.defaultPrevented) return;
this.$('defaultAddress').value = addressId; this.$.defaultAddress.value = addressId;
Htk.Toast.showMessage(_('DefaultAddressModified')); Htk.Toast.showMessage(_('DefaultAddressModified'));
} }

View File

@ -3,14 +3,14 @@ Hedera.Address = new Class({
Extends: Hedera.Form, Extends: Hedera.Form,
activate: function() { activate: function() {
this.$('model').setInfo('a', 'myAddress', 'hedera', ['id'], 'id'); this.$.model.setInfo('a', 'myAddress', 'hedera', ['id'], 'id');
this.$('model').setDefault('clientFk', 'a', this.$.model.setDefault('clientFk', 'a',
new Sql.Function({schema: 'account', name: 'myUser_getId'})); new Sql.Function({schema: 'account', name: 'myUser_getId'}));
}, },
onStatusChange: function() { onStatusChange: function() {
if (this.$('iter').ready && this.$('address').value == 0) if (this.$.iter.ready && this.$.address.value == 0)
this.$('iter').insertRow(); this.$.iter.insertRow();
}, },
onOperationsDone: function() { onOperationsDone: function() {
@ -19,7 +19,7 @@ Hedera.Address = new Class({
}, },
onAcceptClick: function() { onAcceptClick: function() {
this.$('iter').performOperations(); this.$.iter.performOperations();
}, },
onReturnClick: function() { onReturnClick: function() {

View File

@ -3,33 +3,33 @@ Hedera.Conf = new Class({
Extends: Hedera.Form Extends: Hedera.Form
,activate: function() { ,activate: function() {
this.$('user-model').setInfo('c', 'myClient', 'hedera'); this.$.userModel.setInfo('c', 'myClient', 'hedera');
this.$('user-model').setInfo('u', 'myUser', 'account'); this.$.userModel.setInfo('u', 'myUser', 'account');
if (this.hash.get('verificationToken')) if (this.hash.get('verificationToken'))
this.onPassChangeClick(); this.onPassChangeClick();
} }
,onPassChangeClick: function() { ,onPassChangeClick: function() {
this.$('old-password').value = ''; this.$.oldPassword.value = '';
this.$('new-password').value = ''; this.$.newPassword.value = '';
this.$('repeat-password').value = ''; this.$.repeatPassword.value = '';
var verificationToken = this.hash.get('verificationToken'); var verificationToken = this.hash.get('verificationToken');
this.$('old-password').style.display = verificationToken ? 'none' : 'block'; this.$.oldPassword.style.display = verificationToken ? 'none' : 'block';
this.$('change-password').show(); this.$.changePassword.show();
if (verificationToken) if (verificationToken)
this.$('new-password').focus(); this.$.newPassword.focus();
else else
this.$('old-password').focus(); this.$.oldPassword.focus();
} }
,onPassModifyClick: function() { ,onPassModifyClick: function() {
try { try {
var oldPassword = this.$('old-password').value; var oldPassword = this.$.oldPassword.value;
var newPassword = this.$('new-password').value; var newPassword = this.$.newPassword.value;
var repeatedPassword = this.$('repeat-password').value; var repeatedPassword = this.$.repeatPassword.value;
if (newPassword == '' && repeatedPassword == '') if (newPassword == '' && repeatedPassword == '')
throw new Error(_('Passwords empty')); throw new Error(_('Passwords empty'));
@ -58,22 +58,22 @@ Hedera.Conf = new Class({
,_onPassChange: function(json, error) { ,_onPassChange: function(json, error) {
if (!error) { if (!error) {
this.$('change-password').hide(); this.$.changePassword.hide();
this.hash.unset('verificationToken'); this.hash.unset('verificationToken');
Htk.Toast.showMessage(_('Password changed!')); Htk.Toast.showMessage(_('Password changed!'));
this.$('user-form').refresh(); this.$.userForm.refresh();
} else { } else {
Htk.Toast.showError(error.message); Htk.Toast.showError(error.message);
if (this.hash.get('verificationToken')) if (this.hash.get('verificationToken'))
this.$('new-password').select(); this.$.newPassword.select();
else else
this.$('old-password').select(); this.$.oldPassword.select();
} }
} }
,onPassInfoClick: function() { ,onPassInfoClick: function() {
this.$('password-info').show(); this.$.passwordInfo.show();
} }
,onAddressesClick: function() { ,onAddressesClick: function() {

View File

@ -5,14 +5,14 @@ Hedera.Connections = new Class({
,_timeoutId: null ,_timeoutId: null
,onModelStatusChange: function() { ,onModelStatusChange: function() {
if (!this.$('sessions').ready) if (!this.$.sessions.ready)
return; return;
if (this._timeoutId) if (this._timeoutId)
clearTimeout(this._timeoutId); clearTimeout(this._timeoutId);
this._timeoutId = setTimeout( this._timeoutId = setTimeout(
() => this.$('sessions').refresh(), 60000); () => this.$.sessions.refresh(), 60000);
} }
,deactivate: function() { ,deactivate: function() {

View File

@ -3,6 +3,6 @@ Hedera.Items = new Class({
Extends: Hedera.Form, Extends: Hedera.Form,
activate: function() { activate: function() {
this.$('items').setInfo('i', 'item', 'vn', ['id']); this.$.items.setInfo('i', 'item', 'vn', ['id']);
} }
}); });

View File

@ -15,7 +15,7 @@ Hedera.Photos = new Class({
,isUploading: false ,isUploading: false
,activate: function() { ,activate: function() {
this.$('schema').value = 'catalog'; this.$.schema.value = 'catalog';
} }
,addFiles: function(files) { ,addFiles: function(files) {
@ -70,7 +70,7 @@ Hedera.Photos = new Class({
this.filesData.push(fileData); this.filesData.push(fileData);
this.$('file-list').appendChild(li); this.$.fileList.appendChild(li);
this.setImageStatus(fileData, Status.NONE, 'add', _('Pending upload')); this.setImageStatus(fileData, Status.NONE, 'add', _('Pending upload'));
} }
@ -107,10 +107,10 @@ Hedera.Photos = new Class({
fileData, Status.UPLOADING, 'upload', _('Uploading file')); fileData, Status.UPLOADING, 'upload', _('Uploading file'));
var formData = new FormData(); var formData = new FormData();
formData.append('updateMatching', this.$('update-matching').value); formData.append('updateMatching', this.$.updateMatching.value);
formData.append('image', fileData.file); formData.append('image', fileData.file);
formData.append('name', fileData.name.value); formData.append('name', fileData.name.value);
formData.append('schema', this.$('schema').value); formData.append('schema', this.$.schema.value);
formData.append('srv', 'json:image/upload'); formData.append('srv', 'json:image/upload');
this.conn.sendFormData(formData, this.conn.sendFormData(formData,
this.onFileUpload.bind(this, fileData)); this.onFileUpload.bind(this, fileData));
@ -152,7 +152,7 @@ Hedera.Photos = new Class({
} }
,onFileRemove: function(fileData) { ,onFileRemove: function(fileData) {
this.$('file-list').removeChild(fileData.li); this.$.fileList.removeChild(fileData.li);
for (var i = 0; i < this.filesData.length; i++) for (var i = 0; i < this.filesData.length; i++)
if (this.filesData[i] === fileData) { if (this.filesData[i] === fileData) {
@ -163,23 +163,23 @@ Hedera.Photos = new Class({
,onClearClick: function() { ,onClearClick: function() {
this.filesData = []; this.filesData = [];
Vn.Node.removeChilds(this.$('file-list')); Vn.Node.removeChilds(this.$.fileList);
} }
,onDropzoneClick: function() { ,onDropzoneClick: function() {
this.$('file').click(); this.$.file.click();
} }
,onFileChange: function() { ,onFileChange: function() {
this.addFiles(this.$('file').files); this.addFiles(this.$.file.files);
} }
,onDragEnter: function() { ,onDragEnter: function() {
this.$('dropzone').classList.add('dragover'); this.$.dropzone.classList.add('dragover');
} }
,onDragLeave: function() { ,onDragLeave: function() {
this.$('dropzone').classList.remove('dragover'); this.$.dropzone.classList.remove('dragover');
} }
,onDragOver: function(event) { ,onDragOver: function(event) {
@ -187,7 +187,7 @@ Hedera.Photos = new Class({
} }
,onDragEnd: function(event) { ,onDragEnd: function(event) {
this.$('dropzone').classList.remove('dragover'); this.$.dropzone.classList.remove('dragover');
event.dataTransfer.clearData(); event.dataTransfer.clearData();
} }

View File

@ -3,12 +3,12 @@ Hedera.Queries = new Class({
Extends: Hedera.Form Extends: Hedera.Form
,activate: function() { ,activate: function() {
this.$('result-index').value = 0; this.$.resultIndex.value = 0;
} }
,clean: function() { ,clean: function() {
if (this._grid) { if (this._grid) {
this.$('grid-holder').removeChild(this._grid.node); this.$.gridHolder.removeChild(this._grid.node);
this._grid.unref(); this._grid.unref();
this._grid = null; this._grid = null;
} }
@ -19,9 +19,9 @@ Hedera.Queries = new Class({
var model = new Db.Model({ var model = new Db.Model({
conn: this.conn, conn: this.conn,
query: this.$('sql').value, query: this.$.sql.value,
resultIndex: this.$('result-index').value, resultIndex: this.$.resultIndex.value,
updatable: this.$('updatable').value updatable: this.$.updatable.value
}); });
model.on('status-changed', this.onModelChange, this); model.on('status-changed', this.onModelChange, this);
} }
@ -41,7 +41,7 @@ Hedera.Queries = new Class({
Htk.Toast.showMessage(_('Query executed!')); Htk.Toast.showMessage(_('Query executed!'));
var gridHolder = this.$('grid-holder'); var gridHolder = this.$.gridHolder;
if (gridHolder.firstChild) if (gridHolder.firstChild)
gridHolder.removeChilds(gridHolder.firstChild); gridHolder.removeChilds(gridHolder.firstChild);
@ -76,7 +76,7 @@ Hedera.Queries = new Class({
column.setProperties({ column.setProperties({
title: c.name, title: c.name,
editable: this.$('updatable').value, editable: this.$.updatable.value,
columnIndex: i columnIndex: i
}); });

View File

@ -4,9 +4,9 @@ Hedera.Users = new Class({
,rendererFunc: function(scope, form) { ,rendererFunc: function(scope, form) {
var isEnabled = form.get('active') var isEnabled = form.get('active')
scope.$('disabled').style.display = isEnabled ? scope.$.disabled.style.display = isEnabled ?
'none' : 'block'; 'none' : 'block';
scope.$('impersonate').node.style.display = isEnabled ? scope.$.impersonate.node.style.display = isEnabled ?
'block' : 'none'; 'block' : 'none';
} }

View File

@ -3,12 +3,12 @@ Hedera.Visits = new Class({
Extends: Hedera.Form Extends: Hedera.Form
,activate: function() { ,activate: function() {
this.$('from').value = new Date(); this.$.from.value = new Date();
this.$('to').value = new Date(); this.$.to.value = new Date();
} }
,onRefreshClick: function() { ,onRefreshClick: function() {
this.$('visits').refresh(); this.$.visits.refresh();
} }
,onSessionsClick: function() { ,onSessionsClick: function() {

View File

@ -6,7 +6,7 @@ Hedera.Contact = new Class
,activate: function () ,activate: function ()
{ {
var self = this; var self = this;
this.$('contact-form').onsubmit = function () this.$.contactForm.onsubmit = function ()
{ self._onSubmit (); return false; }; { self._onSubmit (); return false; };
this.refreshCaptcha (); this.refreshCaptcha ();
@ -18,18 +18,18 @@ Hedera.Contact = new Class
'srv': 'rest:core/captcha', 'srv': 'rest:core/captcha',
'stamp': new Date ().getTime () 'stamp': new Date ().getTime ()
}; };
this.$('captcha-img').src = '?'+ Vn.Url.makeUri (params); this.$.captchaImg.src = '?'+ Vn.Url.makeUri (params);
} }
,_onSubmit: function () ,_onSubmit: function ()
{ {
this.conn.sendForm (this.$('contact-form'), this.conn.sendForm (this.$.contactForm,
this._onResponse.bind (this)); this._onResponse.bind (this));
} }
,_onResponse: function (json, error) ,_onResponse: function (json, error)
{ {
var form = this.$('contact-form'); var form = this.$.contactForm;
if (json) if (json)
{ {

View File

@ -44,7 +44,7 @@ Hedera.Location = new Class({
,center: new google.maps.LatLng(46.0, 4.0) ,center: new google.maps.LatLng(46.0, 4.0)
}; };
var div = this.$('form'); var div = this.$.form;
var gmap = new google.maps.Map(div, options); var gmap = new google.maps.Map(div, options);
if (this.locations) if (this.locations)

View File

@ -16,7 +16,7 @@ Hedera.Basket = new Class({
} }
,activate: function() { ,activate: function() {
this.$('items').setInfo('bi', 'myBasketItem', 'hedera'); this.$.items.setInfo('bi', 'myBasketItem', 'hedera');
} }
,onConfigureClick: function() { ,onConfigureClick: function() {

View File

@ -23,9 +23,9 @@ Hedera.Catalog = new Class({
} }
,activate: function() { ,activate: function() {
document.body.appendChild(this.$('right-panel')); document.body.appendChild(this.$.rightPanel);
this.$('items-model').setInfo('i', 'item', 'vn', ['id']); this.$.itemsModel.setInfo('i', 'item', 'vn', ['id']);
if (localStorage.getItem('hederaView')) if (localStorage.getItem('hederaView'))
this.setView(parseInt(localStorage.getItem('hederaView'))); this.setView(parseInt(localStorage.getItem('hederaView')));
@ -35,20 +35,20 @@ Hedera.Catalog = new Class({
,deactivate: function() { ,deactivate: function() {
this.hideMenu(); this.hideMenu();
this.gui.$('top-bar').style.backgroundColor = ''; this.gui.$.topBar.style.backgroundColor = '';
Vn.Node.remove(this.$('right-panel')); Vn.Node.remove(this.$.rightPanel);
} }
,setView: function(view) { ,setView: function(view) {
if (view === Hedera.Catalog.View.GRID) { if (view === Hedera.Catalog.View.GRID) {
this.$('view-button').setProperties({ this.$.viewButton.setProperties({
icon: 'view_list', icon: 'view_list',
tip: _('List view') tip: _('List view')
}); });
this.view = Hedera.Catalog.View.GRID; this.view = Hedera.Catalog.View.GRID;
var className = 'grid-view'; var className = 'grid-view';
} else { } else {
this.$('view-button').setProperties({ this.$.viewButton.setProperties({
icon: 'grid_on', icon: 'grid_on',
tip: _('Grid view') tip: _('Grid view')
}); });
@ -56,7 +56,7 @@ Hedera.Catalog = new Class({
var className = 'list-view'; var className = 'list-view';
} }
var node = this.$('grid-view').node; var node = this.$.gridView.node;
node.className = className; node.className = className;
localStorage.setItem('hederaView', this.view); localStorage.setItem('hederaView', this.view);
} }
@ -68,16 +68,16 @@ Hedera.Catalog = new Class({
,onBasketReady: function(form) { ,onBasketReady: function(form) {
if (form.get('method') != 'PICKUP') if (form.get('method') != 'PICKUP')
Vn.Node.setText(this.$('method'), _('Agency')); Vn.Node.setText(this.$.method, _('Agency'));
else else
Vn.Node.setText(this.$('method'), _('Warehouse')); Vn.Node.setText(this.$.method, _('Warehouse'));
} }
,onItemsChange: function(model, status) { ,onItemsChange: function(model, status) {
if (status !== Db.Model.Status.CLEAN) if (status !== Db.Model.Status.CLEAN)
this.$('order').style.display = 'block'; this.$.order.style.display = 'block';
else else
this.$('order').style.display = 'none'; this.$.order.style.display = 'none';
} }
,onOrderChange: function(e) { ,onOrderChange: function(e) {
@ -87,7 +87,7 @@ Hedera.Catalog = new Class({
Db.Model.SortWay.ASC : Db.Model.SortWay.DESC; Db.Model.SortWay.ASC : Db.Model.SortWay.DESC;
if (sortField) if (sortField)
this.$('items-model').sortByName(sortField, sortWay); this.$.itemsModel.sortByName(sortField, sortWay);
this.hideMenu(); this.hideMenu();
} }
@ -98,7 +98,7 @@ Hedera.Catalog = new Class({
} }
,realmRenderer: function(builder, form) { ,realmRenderer: function(builder, form) {
var link = builder.$('link'); var link = builder.$.link;
link.href = this.hash.make({ link.href = this.hash.make({
form: this.hash.get('form'), form: this.hash.get('form'),
realm: form.get('id') realm: form.get('id')
@ -107,11 +107,11 @@ Hedera.Catalog = new Class({
,onRealmChange: function(param, newValue) { ,onRealmChange: function(param, newValue) {
if (newValue) { if (newValue) {
this.$('filters').style.display = 'block'; this.$.filters.style.display = 'block';
this.$('realm-msg').style.display = 'none'; this.$.realmMsg.style.display = 'none';
} else { } else {
this.$('filters').style.display = 'none'; this.$.filters.style.display = 'none';
this.$('realm-msg').style.display = 'block'; this.$.realmMsg.style.display = 'block';
} }
this.refreshFilter(newValue, undefined); this.refreshFilter(newValue, undefined);
@ -124,27 +124,27 @@ Hedera.Catalog = new Class({
} }
,refreshFilter: function(realm, type) { ,refreshFilter: function(realm, type) {
var batch = this.$('filter-batch'); var batch = this.$.filterBatch;
batch.block(); batch.block();
this.$('realm-value').value = realm; this.$.realmValue.value = realm;
this.$('type-value').value = type; this.$.typeValue.value = type;
this.$('search').value = undefined; this.$.search.value = undefined;
this.$('color').value = undefined; this.$.color.value = undefined;
this.$('origin').value = undefined; this.$.origin.value = undefined;
this.$('category').value = undefined; this.$.category.value = undefined;
this.$('producer').value = undefined; this.$.producer.value = undefined;
batch.unblock(); batch.unblock();
batch.changed(); batch.changed();
} }
,refreshTitle: function() { ,refreshTitle: function() {
var types = this.$('types-model'); var types = this.$.typesModel;
if (!types.ready) if (!types.ready)
return; return;
var title = _('Catalog'); var title = _('Catalog');
var type = this.$('type').value; var type = this.$.type.value;
if (type) { if (type) {
var row = types.search('id', type); var row = types.search('id', type);
@ -153,7 +153,7 @@ Hedera.Catalog = new Class({
title = types.get(row, 'name'); title = types.get(row, 'name');
} }
Vn.Node.setText(this.$('title-text'), title); Vn.Node.setText(this.$.titleText, title);
} }
,onRightPanelClick: function(event) { ,onRightPanelClick: function(event) {
@ -164,7 +164,7 @@ Hedera.Catalog = new Class({
this._menuShown = true; this._menuShown = true;
event.stopPropagation(); event.stopPropagation();
this.gui.showBackground(); this.gui.showBackground();
Vn.Node.addClass(this.$('right-panel'), 'show'); Vn.Node.addClass(this.$.rightPanel, 'show');
this.hideMenuCallback = this.hideMenu.bind(this); this.hideMenuCallback = this.hideMenu.bind(this);
document.addEventListener('click', this.hideMenuCallback); document.addEventListener('click', this.hideMenuCallback);
} }
@ -174,7 +174,7 @@ Hedera.Catalog = new Class({
return; return;
this.gui.hideBackground(); this.gui.hideBackground();
Vn.Node.removeClass(this.$('right-panel'), 'show'); Vn.Node.removeClass(this.$.rightPanel, 'show');
document.removeEventListener('click', this.hideMenuCallback); document.removeEventListener('click', this.hideMenuCallback);
this.hideMenuCallback = null; this.hideMenuCallback = null;
} }
@ -208,13 +208,13 @@ Hedera.Catalog = new Class({
if (this.isGuest()) return; if (this.isGuest()) return;
this.onEraseClick(); this.onEraseClick();
this.$('card').row = form.row; this.$.card.row = form.row;
this.$('card-item').value = form.get('id'); this.$.cardItem.value = form.get('id');
this.$('card-popup').show(event.currentTarget); this.$.cardPopup.show(event.currentTarget);
} }
,onAddLotClick: function(column, value, row) { ,onAddLotClick: function(column, value, row) {
var model = this.$('item-lots'); var model = this.$.itemLots;
var grouping = model.get(row, 'grouping'); var grouping = model.get(row, 'grouping');
var warehouse = model.get(row, 'warehouseFk'); var warehouse = model.get(row, 'warehouseFk');
var available = model.get(row, 'available'); var available = model.get(row, 'available');
@ -231,7 +231,7 @@ Hedera.Catalog = new Class({
newAmount = available; newAmount = available;
this.items[warehouse] = newAmount; this.items[warehouse] = newAmount;
this.$('amount').value += newAmount - lotAmount; this.$.amount.value += newAmount - lotAmount;
} else } else
Htk.Toast.showError(_('NoMoreAmountAvailable')); Htk.Toast.showError(_('NoMoreAmountAvailable'));
} }
@ -247,7 +247,7 @@ Hedera.Catalog = new Class({
amountSum += amount; amountSum += amount;
batch.addValue('warehouse', warehouse); batch.addValue('warehouse', warehouse);
batch.addValue('item', this.$('card-item').value); batch.addValue('item', this.$.cardItem.value);
batch.addValue('amount', amount); batch.addValue('amount', amount);
sql += query.render(batch); sql += query.render(batch);
} }
@ -255,27 +255,27 @@ Hedera.Catalog = new Class({
if (amountSum > 0) { if (amountSum > 0) {
this.conn.execQuery(sql); this.conn.execQuery(sql);
var itemName = this.$('card').get('item'); var itemName = this.$.card.get('item');
Htk.Toast.showMessage( Htk.Toast.showMessage(
sprintf(_('Added%dOf%s'), amountSum, itemName)); sprintf(_('Added%dOf%s'), amountSum, itemName));
} }
this.$('card-popup').hide(); this.$.cardPopup.hide();
} }
,onEraseClick: function() { ,onEraseClick: function() {
this.$('amount').value = 0; this.$.amount.value = 0;
this.items = {}; this.items = {};
} }
,onPopupClose: function() { ,onPopupClose: function() {
this.onEraseClick(); this.onEraseClick();
this.$('card').row = -1; this.$.card.row = -1;
this.$('card-item').value = undefined; this.$.cardItem.value = undefined;
} }
,onCardLoad: function() { ,onCardLoad: function() {
this.$('card-popup').reset(); this.$.cardPopup.reset();
} }
}); });

View File

@ -4,15 +4,15 @@ Hedera.Checkout = new Class({
activate: function() { activate: function() {
this.autoStepLocked = true; this.autoStepLocked = true;
this.$('assistant').stepsIndex = this.agencySteps; this.$.assistant.stepsIndex = this.agencySteps;
this.today = new Date(); this.today = new Date();
this.today.setHours(0, 0, 0, 0); this.today.setHours(0, 0, 0, 0);
}, },
onValuesReady: function() { onValuesReady: function() {
var orderForm = this.$('order-form'); var orderForm = this.$.orderForm;
var defaultsForm = this.$('defaults'); var defaultsForm = this.$.defaults;
if (!(orderForm.ready && defaultsForm.ready)) if (!(orderForm.ready && defaultsForm.ready))
return; return;
@ -46,16 +46,16 @@ Hedera.Checkout = new Class({
date.setDate(date.getDate() + addDays); date.setDate(date.getDate() + addDays);
} }
this.$('date').value = date; this.$.date.value = date;
this.$('method').value = i.get('deliveryMethod'); this.$.method.value = i.get('deliveryMethod');
this.$('agency').value = i.get('agencyModeFk'); this.$.agency.value = i.get('agencyModeFk');
this.$('address').value = i.get('addressFk'); this.$.address.value = i.get('addressFk');
this.autoStepLocked = false; this.autoStepLocked = false;
}, },
disableButtons: function(disable) { disableButtons: function(disable) {
this.$('assistant-bar').disabled = disable; this.$.assistantBar.disabled = disable;
}, },
onConfirmClick: function() { onConfirmClick: function() {
@ -64,10 +64,10 @@ Hedera.Checkout = new Class({
var query = 'CALL myBasket_configure(#date, #method, #agency, #address)'; var query = 'CALL myBasket_configure(#date, #method, #agency, #address)';
var batch = new Sql.Batch(); var batch = new Sql.Batch();
batch.addParam('method', this.$('method')); batch.addParam('method', this.$.method);
batch.addParam('date', this.$('date')); batch.addParam('date', this.$.date);
batch.addParam('agency', this.$('agency')); batch.addParam('agency', this.$.agency);
batch.addParam('address', this.$('address')); batch.addParam('address', this.$.address);
this.conn.execQuery(query, this.conn.execQuery(query,
this.onBasketConfigured.bind(this), batch); this.onBasketConfigured.bind(this), batch);
@ -79,7 +79,7 @@ Hedera.Checkout = new Class({
if (!resultSet.fetchResult()) if (!resultSet.fetchResult())
return; return;
if (this.$('order-form').numRows > 0) if (this.$.orderForm.numRows > 0)
Htk.Toast.showMessage(_('OrderUpdated')); Htk.Toast.showMessage(_('OrderUpdated'));
else else
Htk.Toast.showMessage(_('OrderStarted')); Htk.Toast.showMessage(_('OrderStarted'));
@ -88,7 +88,7 @@ Hedera.Checkout = new Class({
}, },
onCancelClick: function() { onCancelClick: function() {
if (this.$('order-form').numRows > 0) if (this.$.orderForm.numRows > 0)
window.history.back(); window.history.back();
else else
this.hash.set({form: 'ecomerce/orders'}); this.hash.set({form: 'ecomerce/orders'});
@ -98,77 +98,77 @@ Hedera.Checkout = new Class({
pickupSteps: ['method', 'date', 'address', 'pickup', 'confirm-pickup'], pickupSteps: ['method', 'date', 'address', 'pickup', 'confirm-pickup'],
isDelivery: function() { isDelivery: function() {
return this.$('rg-method').value != 'PICKUP'; return this.$.rgMethod.value != 'PICKUP';
}, },
onMethodChange: function() { onMethodChange: function() {
this.$('assistant').stepsIndex = this.isDelivery() ? this.$.assistant.stepsIndex = this.isDelivery() ?
this.agencySteps : this.pickupSteps; this.agencySteps : this.pickupSteps;
this.onFieldChange(); this.onFieldChange();
}, },
methodValidate: function() { methodValidate: function() {
if (!this.$('rg-method').isSelected()) if (!this.$.rgMethod.isSelected())
throw new Error(_('Please select an option')); throw new Error(_('Please select an option'));
}, },
dateShow: function() { dateShow: function() {
Vn.Node.setText(this.$('date-question'), this.isDelivery() ? Vn.Node.setText(this.$.dateQuestion, this.isDelivery() ?
_('OrderDateDeliveryQuestion'): _('OrderDateDeliveryQuestion'):
_('OrderDatePickupQuestion')); _('OrderDatePickupQuestion'));
this.$('calendar').goToSelectedMonth(); this.$.calendar.goToSelectedMonth();
}, },
dateValidate: function() { dateValidate: function() {
if (!this.$('calendar').value) if (!this.$.calendar.value)
throw new Error(_('Please select a date')); throw new Error(_('Please select a date'));
}, },
addressShow: function() { addressShow: function() {
Vn.Node.setText(this.$('address-question'), this.isDelivery() ? Vn.Node.setText(this.$.addressQuestion, this.isDelivery() ?
_('AddressQuestion'): _('AddressQuestion'):
_('AddressQuestionPickup')); _('AddressQuestionPickup'));
}, },
addressValidate: function() { addressValidate: function() {
if (this.$('address-form').row == -1) if (this.$.addressForm.row == -1)
throw new Error(_('Please select an address')); throw new Error(_('Please select an address'));
}, },
agencyShow: function() { agencyShow: function() {
this.$('agencies').refresh(); this.$.agencies.refresh();
}, },
agencyValidate: function() { agencyValidate: function() {
if (this.$('agency-combo').row == -1 && this.isDelivery()) if (this.$.agencyCombo.row == -1 && this.isDelivery())
throw new Error(_('Please select an agency')); throw new Error(_('Please select an agency'));
}, },
pickupShow: function() { pickupShow: function() {
this.$('warehouses').refresh(); this.$.warehouses.refresh();
}, },
pickupValidate: function() { pickupValidate: function() {
if (this.$('warehouse-combo').row == -1) if (this.$.warehouseCombo.row == -1)
throw new Error(_('Please select a store')); throw new Error(_('Please select a store'));
}, },
onFieldChange: function() { onFieldChange: function() {
if (!this.autoStepLocked) if (!this.autoStepLocked)
this.$('assistant').moveNext(); this.$.assistant.moveNext();
}, },
goNextStep: function() { goNextStep: function() {
this.$('assistant').moveNext(); this.$.assistant.moveNext();
}, },
addressRenderer: function(builder, form) { addressRenderer: function(builder, form) {
builder.$('address').addEventListener('click', builder.$.address.addEventListener('click',
this.onAddressClick.bind(this, form.get('id'))); this.onAddressClick.bind(this, form.get('id')));
}, },
onAddressClick: function(addressId) { onAddressClick: function(addressId) {
this.$('address').value = addressId; this.$.address.value = addressId;
this.goNextStep(); this.goNextStep();
}, },
@ -176,16 +176,16 @@ Hedera.Checkout = new Class({
if (this.selectedNode) if (this.selectedNode)
Vn.Node.removeClass(this.selectedNode, 'selected'); Vn.Node.removeClass(this.selectedNode, 'selected');
var row = this.$('addresses').search('id', this.$('address').value); var row = this.$.addresses.search('id', this.$.address.value);
if (row != -1) { if (row != -1) {
var builder = this.$('repeater').getBuilder(row); var builder = this.$.repeater.getBuilder(row);
this.selectedNode = builder.$('address'); this.selectedNode = builder.$.address;
Vn.Node.addClass(this.selectedNode, 'selected'); Vn.Node.addClass(this.selectedNode, 'selected');
} }
this.$('address-form').row = row; this.$.addressForm.row = row;
}, },
onAgenciesReady: function(model) { onAgenciesReady: function(model) {
@ -194,9 +194,9 @@ Hedera.Checkout = new Class({
if (model.numRows > 0) { if (model.numRows > 0) {
var agency; var agency;
var defaults = [ var defaults = [
this.$('order-form').get('agencyModeFk'), this.$.orderForm.get('agencyModeFk'),
this.$('defaults').get('agencyModeFk'), this.$.defaults.get('agencyModeFk'),
this.$('defaults').get('defaultAgencyFk') this.$.defaults.get('defaultAgencyFk')
]; ];
for (var i = 0; i < defaults.length; i++) { for (var i = 0; i < defaults.length; i++) {
@ -206,7 +206,7 @@ Hedera.Checkout = new Class({
} }
this.autoStepLocked = true; this.autoStepLocked = true;
this.$('agency').value = agency; this.$.agency.value = agency;
this.autoStepLocked = false; this.autoStepLocked = false;
} else } else
Htk.Toast.showError(_('NoAgeciesAvailableForDate')); Htk.Toast.showError(_('NoAgeciesAvailableForDate'));

View File

@ -20,11 +20,11 @@ Hedera.Confirm = new Class({
return; return;
if (form.get('method') != 'PICKUP') { if (form.get('method') != 'PICKUP') {
Vn.Node.show(this.$('address')); Vn.Node.show(this.$.address);
Vn.Node.setText(this.$('method'), _('Agency')); Vn.Node.setText(this.$.method, _('Agency'));
} else { } else {
Vn.Node.hide(this.$('address')); Vn.Node.hide(this.$.address);
Vn.Node.setText(this.$('method'), _('Warehouse')); Vn.Node.setText(this.$.method, _('Warehouse'));
} }
var total = form.get('taxableBase') + form.get('tax'); var total = form.get('taxableBase') + form.get('tax');
@ -43,21 +43,21 @@ Hedera.Confirm = new Class({
Htk.Toast.showWarning( Htk.Toast.showWarning(
_('You have exceeded your credit.')); _('You have exceeded your credit.'));
this.$('debt').value = debt; this.$.debt.value = debt;
this.$('total-debt').value = totalDebt; this.$.totalDebt.value = totalDebt;
this.$('total-amount').value = totalDebt; this.$.totalAmount.value = totalDebt;
this.$('credit-excess').value = exceededCredit; this.$.creditExcess.value = exceededCredit;
this.$('excess-amount').value = exceededCredit; this.$.excessAmount.value = exceededCredit;
this.$('pay-amount').value = 'ALL'; this.$.payAmount.value = 'ALL';
if (credit > 0) { if (credit > 0) {
this.$('credit-info').style.display = 'table-row'; this.$.creditInfo.style.display = 'table-row';
if (creditExceededCond) { if (creditExceededCond) {
this.$('amount-selector').style.display = 'block'; this.$.amountSelector.style.display = 'block';
this.$('exceeded-info').style.display = 'table-row'; this.$.exceededInfo.style.display = 'table-row';
this.$('pay-amount').value = 'EXCEEDED'; this.$.payAmount.value = 'EXCEEDED';
} }
} }
@ -79,7 +79,7 @@ Hedera.Confirm = new Class({
for (var i = 0; i < methods.length; i++) for (var i = 0; i < methods.length; i++)
this.$(methods[i] +'-method').style.display = 'block'; this.$(methods[i] +'-method').style.display = 'block';
this.$('pay-method').value = selectedMethod; this.$.payMethod.value = selectedMethod;
}, },
onPayMethodChange: function(payMethod) { onPayMethodChange: function(payMethod) {
@ -112,8 +112,8 @@ Hedera.Confirm = new Class({
}, },
disableButtons: function(disable) { disableButtons: function(disable) {
this.$('modify').disabled = disable; this.$.modify.disabled = disable;
this.$('confirm').disabled = disable; this.$.confirm.disabled = disable;
}, },
onModifyClick: function() { onModifyClick: function() {
@ -122,25 +122,25 @@ Hedera.Confirm = new Class({
onConfirmClick: function() { onConfirmClick: function() {
this.disableButtons(true); this.disableButtons(true);
this.$('confirm-query').execute(); this.$.confirmQuery.execute();
}, },
onConfirm: function(query, resultSet) { onConfirm: function(query, resultSet) {
this.disableButtons(false); this.disableButtons(false);
if (resultSet.fetchResult()) if (resultSet.fetchResult())
this.$('success-dialog').show(); this.$.successDialog.show();
}, },
onDialogResponse: function() { onDialogResponse: function() {
if (this.$('pay-method').value === 'CARD') { if (this.$.payMethod.value === 'CARD') {
if (this.$('pay-amount').value === 'EXCEEDED') if (this.$.payAmount.value === 'EXCEEDED')
var payAmount = this.$('excess-amount').value; var payAmount = this.$.excessAmount.value;
else else
var payAmount = this.$('total-amount').value; var payAmount = this.$.totalAmount.value;
var tpv = new Hedera.Tpv({conn: this.conn}); var tpv = new Hedera.Tpv({conn: this.conn});
tpv.pay(payAmount, this.$('order-form').get('companyFk')); tpv.pay(payAmount, this.$.orderForm.get('companyFk'));
} else } else
this.hash.set({'form': 'ecomerce/orders'}); this.hash.set({'form': 'ecomerce/orders'});
} }

View File

@ -9,7 +9,7 @@ Hedera.Orders = new Class({
_onTpvCheck: function(tpv, tpvOrder, tpvStatus) { _onTpvCheck: function(tpv, tpvOrder, tpvStatus) {
if (tpvStatus === 'ko') if (tpvStatus === 'ko')
this.$('error-dialog').show(); this.$.errorDialog.show();
}, },
onBasketClick: function() { onBasketClick: function() {
@ -17,7 +17,7 @@ Hedera.Orders = new Class({
}, },
repeaterFunc: function(res, form) { repeaterFunc: function(res, form) {
res.$('link').href = this.hash.make({ res.$.link.href = this.hash.make({
form: 'ecomerce/ticket', form: 'ecomerce/ticket',
ticket: form.get('id') ticket: form.get('id')
}); });
@ -27,13 +27,13 @@ Hedera.Orders = new Class({
balanceConditionalFunc: function(field, value) { balanceConditionalFunc: function(field, value) {
if (value >= 0) if (value >= 0)
Vn.Node.removeClass(this.$('balance'), 'negative'); Vn.Node.removeClass(this.$.balance, 'negative');
else else
Vn.Node.addClass(this.$('balance'), 'negative'); Vn.Node.addClass(this.$.balance, 'negative');
}, },
onPayButtonClick: function() { onPayButtonClick: function() {
var amount = -this.$('debt').value; var amount = -this.$.debt.value;
amount = amount <= 0 ? null : amount; amount = amount <= 0 ? null : amount;
var defaultAmountStr = ''; var defaultAmountStr = '';

View File

@ -13,15 +13,15 @@ Hedera.Ticket = new Class({
onTicketReady: function(form) { onTicketReady: function(form) {
if (form.get('method') != 'PICKUP') if (form.get('method') != 'PICKUP')
Vn.Node.setText(this.$('method'), _('Agency')); Vn.Node.setText(this.$.method, _('Agency'));
else else
Vn.Node.setText(this.$('method'), _('Warehouse')); Vn.Node.setText(this.$.method, _('Warehouse'));
}, },
onPrintClick: function() { onPrintClick: function() {
let params = Vn.Url.makeUri({ let params = Vn.Url.makeUri({
authorization: this.conn.token, authorization: this.conn.token,
ticketId: this.$('ticket-id').value, ticketId: this.$.ticketId.value,
recipientId: this.gui.user.id, recipientId: this.gui.user.id,
type: 'deliveryNote' type: 'deliveryNote'
}); });
@ -29,10 +29,10 @@ Hedera.Ticket = new Class({
}, },
repeaterFunc: function(res, form) { repeaterFunc: function(res, form) {
var discount = res.$('discount'); var discount = res.$.discount;
discount.style.display = form.get('discount') ? 'inline' : 'none'; discount.style.display = form.get('discount') ? 'inline' : 'none';
res.$('discount-subtotal').value = this.discountSubtotal(form); res.$.discountSubtotal.value = this.discountSubtotal(form);
res.$('subtotal').value = this.subtotal(form); res.$.subtotal.value = this.subtotal(form);
}, },
discountSubtotal: function(form) { discountSubtotal: function(form) {
@ -45,16 +45,16 @@ Hedera.Ticket = new Class({
}, },
servicesFunc: function(res, form) { servicesFunc: function(res, form) {
res.$('subtotal').value = form.get('quantity') * form.get('price'); res.$.subtotal.value = form.get('quantity') * form.get('price');
}, },
onServicesChanged: function(model) { onServicesChanged: function(model) {
this.$('services').node.style.display = this.$.services.node.style.display =
model.numRows > 0 ? 'block' : 'none'; model.numRows > 0 ? 'block' : 'none';
}, },
onPackagesChanged: function(model) { onPackagesChanged: function(model) {
this.$('packages').node.style.display = this.$.packages.node.style.display =
model.numRows > 0 ? 'block' : 'none'; model.numRows > 0 ? 'block' : 'none';
}, },
}); });

View File

@ -7,13 +7,13 @@ Hedera.New = new Class({
,editor: null ,editor: null
,activate: function() { ,activate: function() {
this.$('model').mode = Db.Model.Mode.ON_DEMAND; this.$.model.mode = Db.Model.Mode.ON_DEMAND;
this.$('model').setDefault('userFk', 'news', this.$.model.setDefault('userFk', 'news',
new Sql.Function({schema: 'account', name: 'myUser_getId'})); new Sql.Function({schema: 'account', name: 'myUser_getId'}));
tinymce.init({ tinymce.init({
mode : 'exact' mode : 'exact'
,target: this.$('html-editor') ,target: this.$.htmlEditor
,plugins: [ ,plugins: [
"advlist autolink lists link image charmap print preview hr" "advlist autolink lists link image charmap print preview hr"
,"anchor pagebreak searchreplace wordcount visualblocks" ,"anchor pagebreak searchreplace wordcount visualblocks"
@ -46,7 +46,7 @@ Hedera.New = new Class({
if (!this.editor) if (!this.editor)
return; return;
var newHtml = this.$('iter').get('text'); var newHtml = this.$.iter.get('text');
if (!newHtml) if (!newHtml)
newHtml = ''; newHtml = '';
@ -55,8 +55,8 @@ Hedera.New = new Class({
}, },
onStatusChange: function() { onStatusChange: function() {
if (this.$('new-id').value == 0) if (this.$.newId.value == 0)
this.$('iter').insertRow(); this.$.iter.insertRow();
}, },
onOperationsDone: function() { onOperationsDone: function() {
@ -69,8 +69,8 @@ Hedera.New = new Class({
}, },
onAcceptClick: function() { onAcceptClick: function() {
this.$('iter').set('text', this.editor.getContent()); this.$.iter.set('text', this.editor.getContent());
this.$('iter').performOperations(); this.$.iter.performOperations();
}, },
onReturnClick: function() { onReturnClick: function() {

View File

@ -3,16 +3,16 @@ Hedera.ItemsForm = new Class({
Extends: Hedera.Form Extends: Hedera.Form
,activate: function() { ,activate: function() {
this.$('warehouse').value = 7; this.$.warehouse.value = 7;
this.$('realm').value = null; this.$.realm.value = null;
} }
,onPreviewClick: function() { ,onPreviewClick: function() {
var batch = new Sql.Batch(); var batch = new Sql.Batch();
batch.addValues({ batch.addValues({
warehouse: this.$('warehouse').value warehouse: this.$.warehouse.value
,realm: this.$('realm').value ,realm: this.$.realm.value
,rate: this.$('rate').value ,rate: this.$.rate.value
}); });
this.gui.openReport('items-report', batch); this.gui.openReport('items-report', batch);
} }

View File

@ -3,8 +3,8 @@ Hedera.Shelves = new Class({
Extends: Hedera.Form Extends: Hedera.Form
,activate: function() { ,activate: function() {
this.$('date').value = new Date(); this.$.date.value = new Date();
this.$('useIds').value = false; this.$.useIds.value = false;
} }
,onConfigChange: function() { ,onConfigChange: function() {
@ -21,7 +21,7 @@ Hedera.Shelves = new Class({
]; ];
for (var i = 0; i < fields.length; i++) for (var i = 0; i < fields.length; i++)
this.$(fields[i]).value = this.$('config').get(fields[i]); this.$(fields[i]).value = this.$.config.get(fields[i]);
} }
,onPreviewClick: function() { ,onPreviewClick: function() {

View File

@ -11,19 +11,6 @@ module.exports = new Class({
this.hash = gui.hash; this.hash = gui.hash;
this.formInfo = formInfo; this.formInfo = formInfo;
} }
/**
* Gets an object from the builder associated to this form.
*
* @param {string} objectId The object identifier
* @return {Object} The object, or %null if not found
*/
,$: function(objectId) {
if (this.builder)
return this.builder.getById(objectId);
return null;
}
,loadUi: function() { ,loadUi: function() {
if (!this.isOpen) if (!this.isOpen)
@ -33,9 +20,10 @@ module.exports = new Class({
builder.compileFile('forms/'+ this.formInfo.path +'/ui.xml'); builder.compileFile('forms/'+ this.formInfo.path +'/ui.xml');
var scope = this.builder = builder.load(null, this); var scope = this.builder = builder.load(null, this);
this.$ = scope.$;
scope.link(null, {conn: this.conn}); scope.link(null, {conn: this.conn});
this.node = scope.$('form'); this.node = scope.$.form;
var models = scope.getByTagName('db-model'); var models = scope.getByTagName('db-model');
@ -49,8 +37,8 @@ module.exports = new Class({
if (this.node) { if (this.node) {
this.gui.setForm(this.node); this.gui.setForm(this.node);
this.gui.setTitle(scope.$('title')); this.gui.setTitle(scope.$.title);
this.gui.setActions(scope.$('actions')); this.gui.setActions(scope.$.actions);
this.activate(); this.activate();
} }

View File

@ -33,9 +33,9 @@ module.exports = new Class({
this.builderInitString(Tpl); this.builderInitString(Tpl);
this.loadingCount = 0; this.loadingCount = 0;
this.$('background').onclick = function() {}; this.$.background.onclick = function() {};
this.$('left-panel').addEventListener('click', function(event) { this.$.leftPanel.addEventListener('click', function(event) {
event.stopPropagation(); event.stopPropagation();
}); });
@ -57,7 +57,7 @@ module.exports = new Class({
this._shown = true; this._shown = true;
this.doc.body.appendChild(this.node); this.doc.body.appendChild(this.node);
Htk.Toast.pushTop(this.$('form-holder')); Htk.Toast.pushTop(this.$.formHolder);
if (Vn.isMobile()) { if (Vn.isMobile()) {
this._onScrollHandler = this._onScroll.bind(this); this._onScrollHandler = this._onScroll.bind(this);
@ -115,7 +115,7 @@ module.exports = new Class({
// Retrieving the user name // Retrieving the user name
this.user = resultSet.fetchObject(); this.user = resultSet.fetchObject();
Vn.Node.setText(this.$('user-name'), this.user.nickname); Vn.Node.setText(this.$.userName, this.user.nickname);
// Retrieving configuration parameters // Retrieving configuration parameters
@ -135,8 +135,8 @@ module.exports = new Class({
var isTesting = !resultSet.fetchValue(); var isTesting = !resultSet.fetchValue();
if (isTesting) { if (isTesting) {
this.$('dev-info').style.display = 'block'; this.$.devInfo.style.display = 'block';
this.$('version').textContent = Vn.Cookie.get('vnVersion'); this.$.version.textContent = Vn.Cookie.get('vnVersion');
} }
// Retrieving configuration parameters // Retrieving configuration parameters
@ -152,11 +152,11 @@ module.exports = new Class({
var linkField = 'testDomain'; var linkField = 'testDomain';
} }
Vn.Node.setText(this.$('test-link'), _(linkText)); Vn.Node.setText(this.$.testLink, _(linkText));
this.$('test-link').href = '//'+ res.get(linkField); this.$.testLink.href = '//'+ res.get(linkField);
this.$('test-link').style.display = 'block'; this.$.testLink.style.display = 'block';
} else } else
this.$('test-link').style.display = 'none'; this.$.testLink.style.display = 'none';
// Loading the default form // Loading the default form
@ -184,8 +184,8 @@ module.exports = new Class({
sectionMap[parent].push(i); sectionMap[parent].push(i);
} }
Vn.Node.removeChilds(this.$('main-menu')); Vn.Node.removeChilds(this.$.mainMenu);
this.createMenu(res, sectionMap, null, this.$('main-menu')); this.createMenu(res, sectionMap, null, this.$.mainMenu);
} }
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Menu //++++++++++++++++++++++++++++++++++++++++++++++++++++++ Menu
@ -266,7 +266,7 @@ module.exports = new Class({
,showMenu: function() { ,showMenu: function() {
this.showBackground(); this.showBackground();
Vn.Node.addClass(this.$('left-panel'), 'show'); Vn.Node.addClass(this.$.leftPanel, 'show');
this.menuShown = true; this.menuShown = true;
this.hideMenuCallback = this.hideMenu.bind(this); this.hideMenuCallback = this.hideMenu.bind(this);
@ -278,7 +278,7 @@ module.exports = new Class({
return; return;
this.hideBackground(); this.hideBackground();
Vn.Node.removeClass(this.$('left-panel'), 'show'); Vn.Node.removeClass(this.$.leftPanel, 'show');
this.menuShown = false; this.menuShown = false;
this.doc.removeEventListener('click', this.hideMenuCallback); this.doc.removeEventListener('click', this.hideMenuCallback);
@ -297,7 +297,7 @@ module.exports = new Class({
if (!this._shown) if (!this._shown)
return; return;
var navbar = this.$('top-bar'); var navbar = this.$.topBar;
var yOffset = Vn.Browser.getPageYOffset(); var yOffset = Vn.Browser.getPageYOffset();
var showNavbar = this._lastYOffset > yOffset || yOffset < navbar.offsetHeight; var showNavbar = this._lastYOffset > yOffset || yOffset < navbar.offsetHeight;
@ -319,11 +319,11 @@ module.exports = new Class({
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Background //++++++++++++++++++++++++++++++++++++++++++++++++++++++ Background
,showBackground: function() { ,showBackground: function() {
Vn.Node.addClass(this.$('background'), 'show'); Vn.Node.addClass(this.$.background, 'show');
} }
,hideBackground: function() { ,hideBackground: function() {
Vn.Node.removeClass(this.$('background'), 'show'); Vn.Node.removeClass(this.$.background, 'show');
} }
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Spinner //++++++++++++++++++++++++++++++++++++++++++++++++++++++ Spinner
@ -332,7 +332,7 @@ module.exports = new Class({
this.loadingCount++; this.loadingCount++;
if (this.loadingCount == 1) if (this.loadingCount == 1)
this.$('loader').start(); this.$.loader.start();
} }
,loaderPop: function() { ,loaderPop: function() {
@ -342,7 +342,7 @@ module.exports = new Class({
this.loadingCount--; this.loadingCount--;
if (this.loadingCount == 0) if (this.loadingCount == 0)
this.$('loader').stop(); this.$.loader.stop();
} }
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Forms //++++++++++++++++++++++++++++++++++++++++++++++++++++++ Forms
@ -397,35 +397,35 @@ module.exports = new Class({
} }
,setForm: function(form) { ,setForm: function(form) {
Vn.Node.removeChilds(this.$('form-holder')); Vn.Node.removeChilds(this.$.formHolder);
if (form) { if (form) {
this.$('form-holder').appendChild(form); this.$.formHolder.appendChild(form);
setTimeout(this._onSetFormTimeout.bind(this), 0); setTimeout(this._onSetFormTimeout.bind(this), 0);
} }
} }
,_onSetFormTimeout: function() { ,_onSetFormTimeout: function() {
Vn.Node.addClass(this.$('form-holder'), 'show'); Vn.Node.addClass(this.$.formHolder, 'show');
} }
,setTitle: function(title) { ,setTitle: function(title) {
Vn.Node.removeChilds(this.$('title')); Vn.Node.removeChilds(this.$.title);
if (title) if (title)
this.$('title').appendChild(title); this.$.title.appendChild(title);
} }
,setActions: function(actions) { ,setActions: function(actions) {
Vn.Node.removeChilds(this.$('action-bar')); Vn.Node.removeChilds(this.$.actionBar);
if (actions) if (actions)
this.$('action-bar').appendChild(actions); this.$.actionBar.appendChild(actions);
} }
,closeForm: function() { ,closeForm: function() {
if (this.activeForm) { if (this.activeForm) {
Vn.Node.removeClass(this.$('form-holder'), 'show'); Vn.Node.removeClass(this.$.formHolder, 'show');
this.activeForm.close(); this.activeForm.close();
this.activeForm.unref(); this.activeForm.unref();
this.activeForm = null; this.activeForm = null;
@ -492,12 +492,12 @@ module.exports = new Class({
,_onSupplantName: function(resultSet) { ,_onSupplantName: function(resultSet) {
var userName = resultSet.fetchValue(); var userName = resultSet.fetchValue();
Vn.Node.setText(this.$('supplanted'), userName); Vn.Node.setText(this.$.supplanted, userName);
this.$('supplant').classList.toggle('show', true); this.$.supplant.classList.toggle('show', true);
} }
,onSupplantExitClick: function() { ,onSupplantExitClick: function() {
this.$('supplant').classList.toggle('show', false); this.$.supplant.classList.toggle('show', false);
this._conn.supplantEnd(); this._conn.supplantEnd();
sessionStorage.removeItem('supplantUser', sessionStorage.removeItem('supplantUser',
sessionStorage.getItem('supplantUser')); sessionStorage.getItem('supplantUser'));

View File

@ -22,10 +22,10 @@ module.exports = new Class({
this.parent(props); this.parent(props);
this.builderInitString(Tpl); this.builderInitString(Tpl);
//this.$('social-bar').conn = this._conn; //this.$.socialBar.conn = this._conn;
var self = this; var self = this;
this.$('form').onsubmit = function() { this.$.form.onsubmit = function() {
self._onSubmit(); self._onSubmit();
return false; return false;
}; };
@ -33,9 +33,9 @@ module.exports = new Class({
,_onConnLoadChange: function(conn, isLoading) { ,_onConnLoadChange: function(conn, isLoading) {
if (isLoading) if (isLoading)
this.$('spinner').start(); this.$.spinner.start();
else else
this.$('spinner').stop(); this.$.spinner.stop();
} }
,show: function() { ,show: function() {
@ -44,27 +44,27 @@ module.exports = new Class({
var lastUser = localStorage.getItem('hederaLastUser'); var lastUser = localStorage.getItem('hederaLastUser');
if (lastUser) if (lastUser)
this.$('user').value = lastUser; this.$.user.value = lastUser;
this._focusUserInput(); this._focusUserInput();
} }
,_onSubmit: function() { ,_onSubmit: function() {
this._conn.open( this._conn.open(
this.$('user').value, this.$.user.value,
this.$('pass').value, this.$.pass.value,
this.$('remember').checked, this.$.remember.checked,
this._onConnOpen.bind(this) this._onConnOpen.bind(this)
); );
this._disableUi(true); this._disableUi(true);
} }
,_onConnOpen: function(conn, success, error) { ,_onConnOpen: function(conn, success, error) {
this.$('pass').value = ''; this.$.pass.value = '';
this._disableUi(false); this._disableUi(false);
if (success) { if (success) {
var user = this.$('user').value; var user = this.$.user.value;
if (user) if (user)
localStorage.setItem('hederaLastUser', user); localStorage.setItem('hederaLastUser', user);
@ -81,19 +81,19 @@ module.exports = new Class({
} }
,_focusUserInput: function() { ,_focusUserInput: function() {
var userEntry = this.$('user'); var userEntry = this.$.user;
userEntry.focus(); userEntry.focus();
userEntry.select(); userEntry.select();
} }
,_disableUi: function(disabled) { ,_disableUi: function(disabled) {
this.$('user').disabled = disabled; this.$.user.disabled = disabled;
this.$('pass').disabled = disabled; this.$.pass.disabled = disabled;
this.$('submit').disabled = disabled; this.$.submit.disabled = disabled;
} }
,onPasswordLost: function() { ,onPasswordLost: function() {
var user = this.$('user').value; var user = this.$.user.value;
if (!user) if (!user)
Htk.Toast.showError(_('Please write your user name')); Htk.Toast.showError(_('Please write your user name'));

View File

@ -9,19 +9,6 @@ module.exports = new Class({
this.parent(null); this.parent(null);
} }
/**
* Gets an object from the builder associated to this report.
*
* @param {string} objectId The object identifier
* @return {Object} The object, or %null if not found
*/
,$: function(objectId) {
if (this.scope)
return this.scope.getById(objectId);
return null;
}
,open: function(batch) { ,open: function(batch) {
this.batch = batch; this.batch = batch;
this.createWindow(); this.createWindow();
@ -86,8 +73,9 @@ module.exports = new Class({
batch: this.batch, batch: this.batch,
conn: this.conn conn: this.conn
}); });
this.$ = scope.$;
this.doc.body.appendChild(scope.$('report')); this.doc.body.appendChild(scope.$.report);
} }
}); });

View File

@ -33,7 +33,7 @@
@media @media
(max-device-width: 383px) and (min-resolution: 192dpi), (max-device-width: 383px) and (min-resolution: 192dpi),
(max-device-width: 383px) and (-webkit-min-device-pixel-ratio: 2) { (max-device-width: 383px) and (-webkit-min-device-pixel-ratio: 2) {
body { font-size: 9pt; } body { font-size: 10pt; }
} }
@media @media
(min-device-width: 384px) and (min-resolution: 192dpi), (min-device-width: 384px) and (min-resolution: 192dpi),
@ -45,7 +45,7 @@
@media @media
(max-device-width: 411px) and (min-resolution: 249dpi), (max-device-width: 411px) and (min-resolution: 249dpi),
(max-device-width: 411px) and (-webkit-min-device-pixel-ratio: 3) { (max-device-width: 411px) and (-webkit-min-device-pixel-ratio: 3) {
body { font-size: 9pt; } body { font-size: 10pt; }
} }
@media @media
(min-device-width: 412px) and (min-resolution: 249dpi), (min-device-width: 412px) and (min-resolution: 249dpi),

View File

@ -22,14 +22,8 @@ module.exports = new Class({
const scope = this.scope = builder.load(this.doc, this); const scope = this.scope = builder.load(this.doc, this);
scope.link(); scope.link();
this._node = scope.$('main'); this.$ = scope.$;
} this._node = scope.$.main;
,$: function(id) {
if (this.scope)
return this.scope.getById(id);
return null;
} }
,_destroy: function() { ,_destroy: function() {

View File

@ -121,7 +121,6 @@ module.exports = new Class({
this.editButton = button; this.editButton = button;
} }
console.log(this.editable);
} }
,_makeSrc: function(subdir) { ,_makeSrc: function(subdir) {

View File

@ -22,7 +22,7 @@ module.exports = new Class({
this.builderInitString(Tpl); this.builderInitString(Tpl);
var self = this; var self = this;
this.$('form').onsubmit = function() { this.$.form.onsubmit = function() {
self._onSubmit(); return false; self._onSubmit(); return false;
}; };
@ -30,7 +30,7 @@ module.exports = new Class({
}, },
onNameChange: function() { onNameChange: function() {
var newValue = this.$('name').value; var newValue = this.$.name.value;
if (!newValue) if (!newValue)
newValue = null newValue = null
@ -39,28 +39,28 @@ module.exports = new Class({
}, },
_onSubmit: function() { _onSubmit: function() {
this.$('hidden-name').value = this.$('name').value; this.$.hiddenName.value = this.$.name.value;
this.$('submit').disabled = true; this.$.submit.disabled = true;
this.$('spinner').start(); this.$.spinner.start();
this.conn.sendFormMultipart(this.$('form'), this.conn.sendFormMultipart(this.$.form,
this._onResponse.bind(this)); this._onResponse.bind(this));
}, },
_onResponse: function(json, error) { _onResponse: function(json, error) {
this.$('submit').disabled = false; this.$.submit.disabled = false;
this.$('spinner').stop(); this.$.spinner.stop();
if (error) if (error)
throw error; throw error;
Toast.showMessage(_('ImageAdded')); Toast.showMessage(_('ImageAdded'));
this.signalEmit('file-uploaded', this.$('name').value); this.signalEmit('file-uploaded', this.$.name.value);
}, },
setData: function(image, directory) { setData: function(image, directory) {
this.$('name').value = image; this.$.name.value = image;
this.$('schema').value = directory; this.$.schema.value = directory;
} }
}); });

View File

@ -5,8 +5,7 @@ var Value = require('./value');
/** /**
* A map container for many Sql.Object * A map container for many Sql.Object
*/ */
module.exports = new Class module.exports = new Class({
({
Extends: Object Extends: Object
,Tag: 'sql-batch' ,Tag: 'sql-batch'
,Properties: ,Properties:

View File

@ -189,7 +189,7 @@ module.exports = new Class({
for (var i = links.length - 1; i >= 0; i--) { for (var i = links.length - 1; i >= 0; i--) {
const link = links[i]; const link = links[i];
const object = objects[link.context.id]; const object = objects[link.context.id];
const objectRef = scope._$[link.objectId]; const objectRef = scope.$[link.objectId];
if (objectRef === undefined) { if (objectRef === undefined) {
this.showError('Referenced unexistent object with id \'%s\'', this.showError('Referenced unexistent object with id \'%s\'',
@ -207,7 +207,7 @@ module.exports = new Class({
const baseExprScope = [ const baseExprScope = [
_, _,
scope._$ scope.$
].concat(exprScope); ].concat(exprScope);
this.linkExpr(scope, baseExprScope); this.linkExpr(scope, baseExprScope);

View File

@ -4,25 +4,24 @@ const kebabToCamel = require('./string-util').kebabToCamel;
module.exports = new Class({ module.exports = new Class({
Extends: VnObject Extends: VnObject
,initialize: function(builder, objects, thisArg, parentScope) { ,initialize: function(builder, objects, thisArg, parent) {
this.builder = builder; this.builder = builder;
this.objects = objects; this.objects = objects;
this.thisArg = thisArg; this.thisArg = thisArg;
this.parentScope = parentScope; this.parentScope = parent;
this.$ = parent ? Object.create(parent.$) : {};
if (!thisArg && parentScope) if (!thisArg && parent)
this.thisArg = parentScope.thisArg; this.thisArg = parent.thisArg;
} }
,link: function(exprScope, extraObjects) { ,link: function(exprScope, extraObjects) {
var contextMap = this.builder._contextMap; var contextMap = this.builder._contextMap;
var objectMap = this.parentScope ? Object.create(this.parentScope._$) : {};
this._$ = objectMap;
for (var id in extraObjects) for (var id in extraObjects)
objectMap[id] = extraObjects[id]; this.$[id] = extraObjects[id];
for (var id in contextMap) for (var id in contextMap)
objectMap[id] = this.objects[contextMap[id]]; this.$[id] = this.objects[contextMap[id]];
this.builder.link(this, exprScope); this.builder.link(this, exprScope);
} }
@ -31,13 +30,9 @@ module.exports = new Class({
return this.builder.getMain(this); return this.builder.getMain(this);
} }
,$: function(objectId) {
if (!objectId) return null;
return this._$[kebabToCamel(objectId)];
}
,getById: function(objectId) { ,getById: function(objectId) {
return this.$(objectId); if (!objectId) return null;
return this.$[kebabToCamel(objectId)];
} }
,getByTagName: function(tagName) { ,getByTagName: function(tagName) {

View File

@ -126,18 +126,18 @@ function display (text, status, error)
if (error) if (error)
{ {
text = text ? text : 'Er'; text = text ? text : 'Er';
$('error').textContent = error; $.error.textContent = error;
$('error').style.display = 'block'; $.error.style.display = 'block';
bgColor = 'red'; bgColor = 'red';
} }
else else
{ {
$('error').textContent = ''; $.error.textContent = '';
$('error').style.display = 'none'; $.error.style.display = 'none';
bgColor = 'green'; bgColor = 'green';
} }
$('text').textContent = text; $.text.textContent = text;
body.className = status ? status : ''; body.className = status ? status : '';
body.addEventListener ('transitionend', onTransitionEnd); body.addEventListener ('transitionend', onTransitionEnd);

View File

@ -4,9 +4,9 @@ Hedera.DeliveryNote = new Class({
onTicketReady: function(form) { onTicketReady: function(form) {
if (form.get('method') != 'PICKUP') if (form.get('method') != 'PICKUP')
Vn.Node.setText(this.$('method'), _('Agency')); Vn.Node.setText(this.$.method, _('Agency'));
else else
Vn.Node.setText(this.$('method'), _('Warehouse')); Vn.Node.setText(this.$.method, _('Warehouse'));
}, },
discountRenderer: function(column, form) { discountRenderer: function(column, form) {
@ -28,12 +28,12 @@ Hedera.DeliveryNote = new Class({
}, },
onServicesChanged: function(model) { onServicesChanged: function(model) {
this.$('services').node.style.display = this.$.services.node.style.display =
model.numRows > 0 ? 'block' : 'none'; model.numRows > 0 ? 'block' : 'none';
}, },
onPackagesChanged: function(model) { onPackagesChanged: function(model) {
this.$('packages').node.style.display = this.$.packages.node.style.display =
model.numRows > 0 ? 'block' : 'none'; model.numRows > 0 ? 'block' : 'none';
} }
}); });