Backup
This commit is contained in:
parent
c2c0a8dde1
commit
1659c32fee
|
@ -0,0 +1,2 @@
|
|||
node_modules
|
||||
hedera-web.js
|
13
app.js
13
app.js
|
@ -1,9 +1,10 @@
|
|||
|
||||
//Vn.includeCss ('pages/main/style.css');
|
||||
var Hedera = require ('hedera/hedera');
|
||||
Vn.includeCss ('pages/main/style.css');
|
||||
|
||||
var Hedera = require ('./js/hedera/main');
|
||||
var App = require ('./js/hedera/app');
|
||||
window.onload = function main ()
|
||||
{
|
||||
hederaWeb = new Hedera.App ();
|
||||
hederaWeb.run ();
|
||||
}
|
||||
|
||||
hederaWeb = new App ();
|
||||
hederaWeb.run ();
|
||||
window.hederaWeb = hederaWeb;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Alias /hedera-web /usr/share/hedera-web/
|
||||
# Alias /vn-image-data /var/lib/hedera-web/image-db/
|
||||
# Alias /image-db /var/lib/hedera-web/image-db/
|
||||
|
||||
<Directory /usr/share/hedera-web/>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vn.AddressList = new Class
|
||||
Hedera.AddressList = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,activate: function ()
|
||||
{
|
||||
|
|
|
@ -47,13 +47,13 @@
|
|||
form="iter"
|
||||
column="id"
|
||||
tip="_RemoveAddress"
|
||||
image="image/delete.svg"
|
||||
icon="delete"
|
||||
on-click="onRemoveAddressClick"/>
|
||||
<htk-button
|
||||
form="iter"
|
||||
column="id"
|
||||
tip="_EditAddress"
|
||||
image="image/edit.svg"
|
||||
icon="edit"
|
||||
on-click="onEditAddressClick"/>
|
||||
</div>
|
||||
<p class="important">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vn.Address = new Class
|
||||
Hedera.Address = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,activate: function ()
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vn.Conf = new Class
|
||||
Hedera.Conf = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,activate: function ()
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
Vn.AccessLog = new Class
|
||||
Hedera.AccessLog = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
});
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vn.Connections = new Class
|
||||
Hedera.Connections = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,_timeoutId: null
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vn.Items = new Class
|
||||
Hedera.Items = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,activate: function ()
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vn.Links = new Class
|
||||
Hedera.Links = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,repeaterFunc: function (res, form)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vn.Photos = new Class
|
||||
Hedera.Photos = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,activate: function ()
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vn.Queries = new Class
|
||||
Hedera.Queries = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,activate: function ()
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vn.Shelves = new Class
|
||||
Hedera.Shelves = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,activate: function ()
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vn.Users = new Class
|
||||
Hedera.Users = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,onAccessLogClick: function (button, form)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vn.Visits = new Class
|
||||
Hedera.Visits = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,activate: function ()
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vn.Packages = new Class
|
||||
Hedera.Packages = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,onShowClick: function (column, agencyId)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
Vn.Provinces = new Class
|
||||
Hedera.Provinces = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
});
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
Vn.About = new Class
|
||||
Hedera.About = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
});
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vn.Contact = new Class
|
||||
Hedera.Contact = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,activate: function ()
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vn.Home = new Class
|
||||
Hedera.Home = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,onStartOrderClick: function ()
|
||||
{
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
var gmapsIsLoaded = false;
|
||||
|
||||
Vn.Location = new Class
|
||||
Hedera.Location = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,locations: null
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
Vn.Training = new Class
|
||||
Hedera.Training = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
Vn.Why = new Class
|
||||
Hedera.Why = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
});
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
|
||||
Vn.Basket = new Class
|
||||
Hedera.Basket = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,open: function ()
|
||||
{
|
||||
this.close ();
|
||||
this.isOpen = true;
|
||||
|
||||
Vn.BasketChecker.check (this.conn,
|
||||
Hedera.BasketChecker.check (this.conn,
|
||||
this.onBasketCheck.bind (this));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vn.Catalog = new Class
|
||||
Hedera.Catalog = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,_menuShown: false
|
||||
|
||||
|
@ -10,9 +10,9 @@ Vn.Catalog = new Class
|
|||
this.close ();
|
||||
this.isOpen = true;
|
||||
|
||||
if (!Vn.Cookie.check ('hedera_guest'))
|
||||
if (!localStorage.getItem ('hederaGuest'))
|
||||
{
|
||||
Vn.BasketChecker.check (this.conn,
|
||||
Hedera.BasketChecker.check (this.conn,
|
||||
this.onBasketCheck.bind (this));
|
||||
}
|
||||
else
|
||||
|
@ -35,9 +35,9 @@ Vn.Catalog = new Class
|
|||
this.$('items-model').setInfo ('a', 'Articles', 'vn2008', ['item_id']);
|
||||
|
||||
if (localStorage.getItem ('hederaView'))
|
||||
this.setView (parsetInt (localStorage.getItem ('hederaView')));
|
||||
this.setView (parseInt (localStorage.getItem ('hederaView')));
|
||||
else
|
||||
this.setView (Vn.Catalog.View.GRID);
|
||||
this.setView (Hedera.Catalog.View.GRID);
|
||||
}
|
||||
|
||||
,deactivate: function ()
|
||||
|
@ -49,22 +49,22 @@ Vn.Catalog = new Class
|
|||
|
||||
,setView: function (view)
|
||||
{
|
||||
if (view === Vn.Catalog.View.GRID)
|
||||
if (view === Hedera.Catalog.View.GRID)
|
||||
{
|
||||
this.$('view-button').setProperties ({
|
||||
image: 'image/dark/view-list.svg',
|
||||
icon: 'view-list',
|
||||
tip: _('List view')
|
||||
});
|
||||
this.view = Vn.Catalog.View.GRID;
|
||||
this.view = Hedera.Catalog.View.GRID;
|
||||
var className = 'grid-view';
|
||||
}
|
||||
else
|
||||
{
|
||||
this.$('view-button').setProperties ({
|
||||
image: 'image/dark/view-grid.svg',
|
||||
image: 'view-grid',
|
||||
tip: _('Grid view')
|
||||
});
|
||||
this.view = Vn.Catalog.View.LIST;
|
||||
this.view = Hedera.Catalog.View.LIST;
|
||||
var className = 'list-view';
|
||||
}
|
||||
|
||||
|
@ -75,8 +75,8 @@ Vn.Catalog = new Class
|
|||
|
||||
,onSwitchViewClick: function ()
|
||||
{
|
||||
this.setView (this.view === Vn.Catalog.View.LIST ?
|
||||
Vn.Catalog.View.GRID : Vn.Catalog.View.LIST);
|
||||
this.setView (this.view === Hedera.Catalog.View.LIST ?
|
||||
Hedera.Catalog.View.GRID : Hedera.Catalog.View.LIST);
|
||||
}
|
||||
|
||||
,onBasketReady: function (form)
|
||||
|
@ -237,7 +237,7 @@ Vn.Catalog = new Class
|
|||
|
||||
,isGuest: function ()
|
||||
{
|
||||
if (Vn.Cookie.check ('hedera_guest'))
|
||||
if (localStorage.getItem ('hederaGuest'))
|
||||
{
|
||||
Htk.Toast.showError (_('YouMustBeLoggedIn'));
|
||||
return true;
|
||||
|
@ -348,7 +348,7 @@ Vn.Catalog = new Class
|
|||
}
|
||||
});
|
||||
|
||||
Vn.Catalog.extend
|
||||
Hedera.Catalog.extend
|
||||
({
|
||||
View: {
|
||||
LIST: 0,
|
||||
|
@ -496,9 +496,11 @@ Vn.Filter = new Class
|
|||
this._onCloseClick.bind (this, li));
|
||||
li.appendChild (button);
|
||||
|
||||
var img = document.createElement ('img');
|
||||
img.src = 'image/close.svg';
|
||||
button.appendChild (img);
|
||||
var icon = new Htk.Icon ({
|
||||
icon: 'close',
|
||||
alt: _('Close')
|
||||
});
|
||||
button.appendChild (icon);
|
||||
|
||||
var text = this._label = document.createTextNode ('');
|
||||
li.appendChild (text);
|
||||
|
|
|
@ -450,20 +450,22 @@
|
|||
<htk-column-text title="_Pack" column="grouping" format="x%.0d"/>
|
||||
<htk-column-button
|
||||
column="id"
|
||||
image="image/add.svg"
|
||||
icon="add"
|
||||
tip="_Add"
|
||||
on-clicked="onAddLotClick"/>
|
||||
</htk-grid>
|
||||
<div class="footer">
|
||||
<button on-click="onEraseClick" title="_Erase" class="erase">
|
||||
<img
|
||||
src="image/dark/delete.svg"
|
||||
<htk-icon
|
||||
icon="delete"
|
||||
theme="dark"
|
||||
alt="_Erase"/>
|
||||
</button>
|
||||
<htk-text id="amount"/>
|
||||
<button on-click="onConfirmClick" title="_Confirm" class="confirm">
|
||||
<img
|
||||
src="image/dark/ok.svg"
|
||||
<htk-icon
|
||||
icon="ok"
|
||||
theme="dark"
|
||||
alt="_Confirm"/>
|
||||
</button>
|
||||
<div class="clear"/>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vn.Checkout = new Class
|
||||
Hedera.Checkout = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,activate: function ()
|
||||
{
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
|
||||
Vn.Confirm = new Class
|
||||
Hedera.Confirm = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,open: function ()
|
||||
{
|
||||
this.close ();
|
||||
this.isOpen = true;
|
||||
|
||||
Vn.BasketChecker.check (this.conn,
|
||||
Hedera.BasketChecker.check (this.conn,
|
||||
this.onBasketCheck.bind (this));
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ Vn.Confirm = new Class
|
|||
else
|
||||
var payAmount = this.$('total-amount').value;
|
||||
|
||||
var tpv = new Vn.Tpv ({conn: this.conn});
|
||||
var tpv = new Hedera.Tpv ({conn: this.conn});
|
||||
tpv.pay (payAmount, this.$('order-form').get ('company_id'));
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vn.Invoices = new Class
|
||||
Hedera.Invoices = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,onDownloadClick: function (column, invoiceId)
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<htk-column-spin title="_Import" column="amount" unit="€" digits="2"/>
|
||||
<htk-column-button
|
||||
column="invoice_id"
|
||||
image="image/download.svg"
|
||||
icon="download"
|
||||
tip="_Download PDF"
|
||||
on-clicked="onDownloadClick"/>
|
||||
</htk-grid>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
Vn.Orders = new Class
|
||||
Hedera.Orders = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,activate: function ()
|
||||
{
|
||||
this.tpv = new Vn.Tpv ({conn: this.conn});
|
||||
this.tpv = new Hedera.Tpv ({conn: this.conn});
|
||||
this.tpv.check (this._onTpvCheck.bind (this));
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
<htk-popup id="error-dialog" modal="true">
|
||||
<div property="child-node" class="dialog">
|
||||
<div>
|
||||
<img src="image/error.svg" alt="_Error"/>
|
||||
<htk-icon icon="error" alt="_Error"/>
|
||||
<p><t>An error has been in the payment</t></p>
|
||||
<div class="clear"/>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vn.Ticket = new Class
|
||||
Hedera.Ticket = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,onPrintClick: function (event)
|
||||
{
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
|
||||
Vn.include ('js/misc/tinymce/tinymce.min');
|
||||
Vn.include ('node_modules/tinymce/tinymce.min');
|
||||
Vn.define (function () {
|
||||
|
||||
Vn.New = new Class
|
||||
Hedera.New = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,activate: function ()
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vn.News = new Class
|
||||
Hedera.News = new Class
|
||||
({
|
||||
Extends: Vn.Form
|
||||
Extends: Hedera.Form
|
||||
|
||||
,editNew: function (newId)
|
||||
{
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
|
||||
var Calc = require ('./calc');
|
||||
|
||||
/**
|
||||
* Computes a sum of data in the model.
|
||||
**/
|
||||
Db.CalcSum = new Class
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Db.Calc
|
||||
Extends: Calc
|
||||
,Tag: 'db-calc-sum'
|
||||
|
||||
,getRowValue: function (row)
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
|
||||
var Model = require ('./model');
|
||||
var SimpleIterator = require ('./simple-iterator');
|
||||
|
||||
/**
|
||||
* Interface for handle foreach operations on the model.
|
||||
**/
|
||||
Db.Calc = new Class
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Vn.Param
|
||||
,Tag: 'db-calc'
|
||||
|
@ -9,7 +13,7 @@ Db.Calc = new Class
|
|||
{
|
||||
model:
|
||||
{
|
||||
type: Db.Model
|
||||
type: Model
|
||||
,set: function (x)
|
||||
{
|
||||
this.link ({_model: x},
|
||||
|
@ -21,7 +25,7 @@ Db.Calc = new Class
|
|||
,'row-inserted': this.onRowInsert
|
||||
});
|
||||
|
||||
var set = new Db.SimpleIterator ({model: x});
|
||||
var set = new SimpleIterator ({model: x});
|
||||
this.link ({_set: set});
|
||||
}
|
||||
,get: function ()
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
/**
|
||||
* Simulates a connection to a database by making asynchronous requests to a
|
||||
* remote REST service that returns the results in JSON format.
|
||||
|
@ -8,27 +9,33 @@
|
|||
* class or you could have a serious security hole in you application becasuse
|
||||
* the user can send any statement to the server. For example: DROP DATABASE
|
||||
**/
|
||||
Db.Connection = new Class ().extend
|
||||
var Connection = new Class ();
|
||||
module.exports = Connection;
|
||||
|
||||
var Flag =
|
||||
{
|
||||
NOT_NULL : 1
|
||||
,PRI_KEY : 2
|
||||
,AI : 512 | 2 | 1
|
||||
};
|
||||
|
||||
var Type =
|
||||
{
|
||||
BOOLEAN : 1
|
||||
,INTEGER : 3
|
||||
,DOUBLE : 4
|
||||
,STRING : 5
|
||||
,DATE : 8
|
||||
,DATE_TIME : 9
|
||||
};
|
||||
|
||||
Connection.extend
|
||||
({
|
||||
Flag:
|
||||
{
|
||||
NOT_NULL : 1
|
||||
,PRI_KEY : 2
|
||||
,AI : 512 | 2 | 1
|
||||
}
|
||||
|
||||
,Type:
|
||||
{
|
||||
BOOLEAN : 1
|
||||
,INTEGER : 3
|
||||
,DOUBLE : 4
|
||||
,STRING : 5
|
||||
,DATE : 8
|
||||
,DATE_TIME : 9
|
||||
}
|
||||
Flag: Flag
|
||||
,Type: Type
|
||||
});
|
||||
|
||||
Db.Connection.implement
|
||||
Connection.implement
|
||||
({
|
||||
Extends: Vn.JsonConnection
|
||||
|
||||
|
@ -96,9 +103,9 @@ Db.Connection.implement
|
|||
|
||||
switch (columns[j].type)
|
||||
{
|
||||
case Db.Connection.Type.DATE:
|
||||
case Db.Connection.Type.DATE_TIME:
|
||||
case Db.Connection.Type.TIMESTAMP:
|
||||
case Type.DATE:
|
||||
case Type.DATE_TIME:
|
||||
case Type.TIMESTAMP:
|
||||
castFunc = this.valueToDate;
|
||||
break;
|
||||
}
|
||||
|
|
22
js/db/db.js
22
js/db/db.js
|
@ -1,5 +1,19 @@
|
|||
/**
|
||||
* The namespace.
|
||||
**/
|
||||
var Db = {};
|
||||
|
||||
require ('sql/sql');
|
||||
|
||||
Vn.Locale.loadScript ('js/db.js');
|
||||
|
||||
Db = module.exports = {
|
||||
Connection : require ('./connection')
|
||||
,Result : require ('./result')
|
||||
,ResultSet : require ('./result-set')
|
||||
,Model : require ('./model')
|
||||
,Iterator : require ('./iterator')
|
||||
,SimpleIterator : require ('./simple-iterator')
|
||||
,Form : require ('./form')
|
||||
,Param : require ('./param')
|
||||
,Query : require ('./query')
|
||||
,Calc : require ('./calc')
|
||||
,CalcSum : require ('./calc-sum')
|
||||
};
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
|
||||
Db.Form = new Class
|
||||
var Iterator = require ('./iterator');
|
||||
var Model = require ('./model');
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Vn.Object
|
||||
,Implements: Db.Iterator
|
||||
,Implements: Iterator
|
||||
,Tag: 'db-form'
|
||||
,Child: 'model'
|
||||
,Properties:
|
||||
{
|
||||
/**
|
||||
|
@ -12,7 +14,7 @@ Db.Form = new Class
|
|||
**/
|
||||
model:
|
||||
{
|
||||
type: Db.Model
|
||||
type: Model
|
||||
,set: function (x)
|
||||
{
|
||||
this.link ({_model: x},
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
|
||||
Db.Iterator = new Class
|
||||
var Model = require ('./model');
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Properties:
|
||||
{
|
||||
|
@ -8,7 +10,7 @@ Db.Iterator = new Class
|
|||
**/
|
||||
model:
|
||||
{
|
||||
type: Db.Model
|
||||
type: Model
|
||||
},
|
||||
/**
|
||||
* The row where the form positioned, has -1 if the row is unselected.
|
||||
|
@ -128,20 +130,5 @@ Db.Iterator = new Class
|
|||
{
|
||||
return this._model.setByIndex (this._row, column, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a param from the form.
|
||||
*
|
||||
* @param {String} columnName The column name
|
||||
* @return {Db.Param} The new parameter
|
||||
**/
|
||||
,getParam: function (columnName)
|
||||
{
|
||||
return new Db.Param
|
||||
({
|
||||
form: this
|
||||
,column: columnName
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
|
||||
Vn.include ('js/sql/main');
|
||||
Vn.includeLib ('db',
|
||||
[
|
||||
'db'
|
||||
,'connection'
|
||||
,'result'
|
||||
,'result-set'
|
||||
,'model'
|
||||
,'iterator'
|
||||
,'simple-iterator'
|
||||
,'form'
|
||||
,'param'
|
||||
,'query'
|
||||
,'calc'
|
||||
,'calc-sum'
|
||||
]);
|
||||
|
160
js/db/model.js
160
js/db/model.js
|
@ -1,3 +1,6 @@
|
|||
|
||||
var Connection = require ('./connection');
|
||||
|
||||
/**
|
||||
* Class to handle the Database select results. Also allows
|
||||
* updates, insertions and deletions on tables where the primary key is
|
||||
|
@ -7,34 +10,45 @@
|
|||
* otherwise updates are not allowed on that table/column. If two tables or
|
||||
* columns have the same name, an alias should be used to make it updatable.
|
||||
**/
|
||||
Db.Model = new Class ().extend
|
||||
var Model = new Class ();
|
||||
module.exports = Model;
|
||||
|
||||
var Status =
|
||||
{
|
||||
CLEAN : 1
|
||||
,LOADING : 2
|
||||
,READY : 3
|
||||
,ERROR : 4
|
||||
};
|
||||
|
||||
var Mode =
|
||||
{
|
||||
ON_CHANGE : 1
|
||||
,ON_DEMAND : 2
|
||||
};
|
||||
|
||||
var Operation =
|
||||
{
|
||||
INSERT : 1 << 1
|
||||
,UPDATE : 1 << 2
|
||||
,DELETE : 1 << 3
|
||||
};
|
||||
|
||||
var SortWay =
|
||||
{
|
||||
ASC : 1
|
||||
,DESC : 2
|
||||
};
|
||||
|
||||
Model.extend
|
||||
({
|
||||
Status:
|
||||
{
|
||||
CLEAN : 1
|
||||
,LOADING : 2
|
||||
,READY : 3
|
||||
,ERROR : 4
|
||||
},
|
||||
Mode:
|
||||
{
|
||||
ON_CHANGE: 1
|
||||
,ON_DEMAND: 2
|
||||
},
|
||||
Operation:
|
||||
{
|
||||
INSERT: 1 << 1
|
||||
,UPDATE: 1 << 2
|
||||
,DELETE: 1 << 3
|
||||
}
|
||||
,SortWay:
|
||||
{
|
||||
ASC : 1,
|
||||
DESC : 2
|
||||
}
|
||||
Status: Status
|
||||
,Mode: Mode
|
||||
,Operation: Operation
|
||||
,SortWay: SortWay
|
||||
});
|
||||
|
||||
Db.Model.implement
|
||||
Model.implement
|
||||
({
|
||||
Extends: Vn.Object
|
||||
,Tag: 'db-model'
|
||||
|
@ -45,7 +59,7 @@ Db.Model.implement
|
|||
**/
|
||||
conn:
|
||||
{
|
||||
type: Db.Connection
|
||||
type: Connection
|
||||
,set: function (x)
|
||||
{
|
||||
this._conn = x;
|
||||
|
@ -188,7 +202,7 @@ Db.Model.implement
|
|||
type: Boolean
|
||||
,get: function ()
|
||||
{
|
||||
return this._status == Db.Model.Status.READY;
|
||||
return this._status == Status.READY;
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
@ -196,8 +210,8 @@ Db.Model.implement
|
|||
**/
|
||||
mode:
|
||||
{
|
||||
enumType: Db.Model.Mode
|
||||
,value: Db.Model.Mode.ON_CHANGE
|
||||
enumType: Mode
|
||||
,value: Mode.ON_CHANGE
|
||||
},
|
||||
/**
|
||||
* Wether to execute the model query automatically.
|
||||
|
@ -213,7 +227,7 @@ Db.Model.implement
|
|||
,_resultIndex: 0
|
||||
,_batch: null
|
||||
,_stmt: null
|
||||
,_status: Db.Model.Status.CLEAN
|
||||
,_status: Status.CLEAN
|
||||
,data: null
|
||||
,tables: null
|
||||
,columns: null
|
||||
|
@ -238,7 +252,7 @@ Db.Model.implement
|
|||
{
|
||||
this.parent (props);
|
||||
this._cleanData ();
|
||||
this._setStatus (Db.Model.Status.CLEAN);
|
||||
this._setStatus (Status.CLEAN);
|
||||
}
|
||||
|
||||
,loadXml: function (builder, node)
|
||||
|
@ -290,7 +304,7 @@ Db.Model.implement
|
|||
|
||||
if (ready)
|
||||
{
|
||||
this._setStatus (Db.Model.Status.LOADING);
|
||||
this._setStatus (Status.LOADING);
|
||||
this._conn.execStmt (this._stmt, this._selectDone.bind (this), this._batch);
|
||||
}
|
||||
else
|
||||
|
@ -300,7 +314,7 @@ Db.Model.implement
|
|||
,clean: function ()
|
||||
{
|
||||
this._cleanData ();
|
||||
this._setStatus (Db.Model.Status.CLEAN);
|
||||
this._setStatus (Status.CLEAN);
|
||||
}
|
||||
|
||||
,_selectDone: function (resultSet)
|
||||
|
@ -338,10 +352,10 @@ Db.Model.implement
|
|||
if (sortColumn !== -1)
|
||||
this._realSort (sortColumn, this._sortWay);
|
||||
|
||||
this._setStatus (Db.Model.Status.READY);
|
||||
this._setStatus (Status.READY);
|
||||
}
|
||||
else
|
||||
this._setStatus (Db.Model.Status.ERROR);
|
||||
this._setStatus (Status.ERROR);
|
||||
}
|
||||
|
||||
,_refreshRowIndexes: function (start)
|
||||
|
@ -574,7 +588,7 @@ Db.Model.implement
|
|||
var row = this.data[rowIndex];
|
||||
|
||||
var op = this._createOperation (rowIndex);
|
||||
op.type |= Db.Model.Operation.UPDATE;
|
||||
op.type |= Operation.UPDATE;
|
||||
|
||||
if (!op.oldValues)
|
||||
op.oldValues = [];
|
||||
|
@ -585,20 +599,20 @@ Db.Model.implement
|
|||
|
||||
if (!tableOp)
|
||||
{
|
||||
tableOp = Db.Model.Operation.UPDATE;
|
||||
tableOp = Operation.UPDATE;
|
||||
var pks = this.tables[tableIndex].pks;
|
||||
|
||||
for (var i = 0; i < pks.length; i++)
|
||||
if (!row[pks[i]] && !op.oldValues[pks[i]])
|
||||
{
|
||||
tableOp = Db.Model.Operation.INSERT;
|
||||
tableOp = Operation.INSERT;
|
||||
break;
|
||||
}
|
||||
|
||||
op.tables[tableIndex] = tableOp;
|
||||
}
|
||||
|
||||
if (tableOp & Db.Model.Operation.UPDATE
|
||||
if (tableOp & Operation.UPDATE
|
||||
&& op.oldValues[col] === undefined)
|
||||
op.oldValues[col] = row[col];
|
||||
|
||||
|
@ -606,8 +620,8 @@ Db.Model.implement
|
|||
row[col] = value;
|
||||
this.signalEmit ('row-updated', rowIndex, [col]);
|
||||
|
||||
if (this.mode == Db.Model.Mode.ON_CHANGE
|
||||
&& !(op.type & Db.Model.Operation.INSERT))
|
||||
if (this.mode == Mode.ON_CHANGE
|
||||
&& !(op.type & Operation.INSERT))
|
||||
this.performOperations ();
|
||||
}
|
||||
|
||||
|
@ -623,7 +637,7 @@ Db.Model.implement
|
|||
return;
|
||||
|
||||
var op = this._createOperation (rowIndex);
|
||||
op.type |= Db.Model.Operation.DELETE;
|
||||
op.type |= Operation.DELETE;
|
||||
|
||||
if (!this._requestedMainTable)
|
||||
{
|
||||
|
@ -654,7 +668,7 @@ Db.Model.implement
|
|||
this.signalEmit ('row-updated', rowIndex, updatedCols);
|
||||
}
|
||||
|
||||
if (this.mode === Db.Model.Mode.ON_CHANGE)
|
||||
if (this.mode === Mode.ON_CHANGE)
|
||||
this.performOperations ();
|
||||
}
|
||||
|
||||
|
@ -681,7 +695,7 @@ Db.Model.implement
|
|||
newRow.index = rowIndex;
|
||||
|
||||
var op = this._createOperation (rowIndex);
|
||||
op.type |= Db.Model.Operation.INSERT;
|
||||
op.type |= Operation.INSERT;
|
||||
|
||||
this.signalEmit ('row-inserted', rowIndex);
|
||||
|
||||
|
@ -711,9 +725,9 @@ Db.Model.implement
|
|||
query = null;
|
||||
var op = ops[i];
|
||||
|
||||
if (op.type & Db.Model.Operation.DELETE)
|
||||
if (op.type & Operation.DELETE)
|
||||
{
|
||||
if (op.type & Db.Model.Operation.INSERT)
|
||||
if (op.type & Operation.INSERT)
|
||||
continue;
|
||||
|
||||
var where = this._createWhere (this._mainTable, op, true);
|
||||
|
@ -724,7 +738,7 @@ Db.Model.implement
|
|||
query.addTarget (this._createTarget (this._mainTable));
|
||||
}
|
||||
}
|
||||
else if (op.type & (Db.Model.Operation.INSERT | Db.Model.Operation.UPDATE))
|
||||
else if (op.type & (Operation.INSERT | Operation.UPDATE))
|
||||
{
|
||||
query = new Sql.MultiStmt ();
|
||||
|
||||
|
@ -771,7 +785,7 @@ Db.Model.implement
|
|||
var row = op.row;
|
||||
var cols = this.columns;
|
||||
|
||||
if (op.tables[tableIndex] & Db.Model.Operation.INSERT)
|
||||
if (op.tables[tableIndex] & Operation.INSERT)
|
||||
{
|
||||
var dmlQuery = new Sql.Insert ();
|
||||
var table = this.tables[tableIndex];
|
||||
|
@ -849,15 +863,15 @@ Db.Model.implement
|
|||
var op = ops[i];
|
||||
var row = op.row;
|
||||
|
||||
if (!(op.type & Db.Model.Operation.DELETE
|
||||
&& op.type & Db.Model.Operation.INSERT))
|
||||
if (!(op.type & Operation.DELETE
|
||||
&& op.type & Operation.INSERT))
|
||||
isOperation = true;
|
||||
|
||||
if (op.type & Db.Model.Operation.DELETE)
|
||||
if (op.type & Operation.DELETE)
|
||||
{
|
||||
resultSet.fetchResult ();
|
||||
}
|
||||
else if (op.type & (Db.Model.Operation.INSERT | Db.Model.Operation.UPDATE))
|
||||
else if (op.type & (Operation.INSERT | Operation.UPDATE))
|
||||
{
|
||||
this.signalEmit ('row-updated-before', row.index);
|
||||
|
||||
|
@ -872,7 +886,7 @@ Db.Model.implement
|
|||
resultSet.fetchResult ();
|
||||
var newValues = resultSet.fetchRow ();
|
||||
|
||||
if (op.tables[tableIndex] & Db.Model.Operation.INSERT)
|
||||
if (op.tables[tableIndex] & Operation.INSERT)
|
||||
{
|
||||
for (var i = 0; i < cols.length; i++)
|
||||
if (cols[i].table === tableIndex)
|
||||
|
@ -913,13 +927,13 @@ Db.Model.implement
|
|||
var op = this._operations[i];
|
||||
var row = op.row;
|
||||
|
||||
if (op.type & Db.Model.Operation.DELETE
|
||||
&& !(op.type & Db.Model.Operation.INSERT))
|
||||
if (op.type & Operation.DELETE
|
||||
&& !(op.type & Operation.INSERT))
|
||||
{
|
||||
this.data.splice (row.index, 0, row);
|
||||
this.signalEmit ('row-inserted', row.index);
|
||||
}
|
||||
else if (op.type & Db.Model.Operation.UPDATE)
|
||||
else if (op.type & Operation.UPDATE)
|
||||
{
|
||||
this.signalEmit ('row-updated-before', row.index);
|
||||
|
||||
|
@ -977,7 +991,7 @@ Db.Model.implement
|
|||
* Orders the model by the specified column name.
|
||||
*
|
||||
* @param {integer} column The column name
|
||||
* @param {Db.Model.SortWay} way The sort way
|
||||
* @param {SortWay} way The sort way
|
||||
**/
|
||||
,sortByName: function (columnName, way)
|
||||
{
|
||||
|
@ -994,7 +1008,7 @@ Db.Model.implement
|
|||
* Orders the model by the specified column.
|
||||
*
|
||||
* @param {integer} column The column index
|
||||
* @param {Db.Model.SortWay} way The sort way
|
||||
* @param {SortWay} way The sort way
|
||||
**/
|
||||
,sort: function (column, way)
|
||||
{
|
||||
|
@ -1009,16 +1023,16 @@ Db.Model.implement
|
|||
|
||||
,_sort: function (column, way)
|
||||
{
|
||||
this._setStatus (Db.Model.Status.LOADING);
|
||||
this._setStatus (Status.LOADING);
|
||||
this._realSort (column, way);
|
||||
this._setStatus (Db.Model.Status.READY);
|
||||
this._setStatus (Status.READY);
|
||||
}
|
||||
|
||||
,_realSort: function (column, way)
|
||||
{
|
||||
if (column !== this._sortColumn)
|
||||
{
|
||||
if (way === Db.Model.SortWay.DESC)
|
||||
if (way === SortWay.DESC)
|
||||
var sortFunction = this.sortFunctionDesc;
|
||||
else
|
||||
var sortFunction = this.sortFunctionAsc;
|
||||
|
@ -1047,7 +1061,7 @@ Db.Model.implement
|
|||
{
|
||||
this._requestedIndexes[column] = true;
|
||||
|
||||
if (this._status === Db.Model.Status.READY)
|
||||
if (this._status === Status.READY)
|
||||
this._buildIndex (column);
|
||||
}
|
||||
|
||||
|
@ -1062,9 +1076,9 @@ Db.Model.implement
|
|||
|
||||
switch (this.columns[columnIndex].type)
|
||||
{
|
||||
case Db.Conn.Type.TIMESTAMP:
|
||||
case Db.Conn.Type.DATE_TIME:
|
||||
case Db.Conn.Type.DATE:
|
||||
case Connection.Type.TIMESTAMP:
|
||||
case Connection.Type.DATE_TIME:
|
||||
case Connection.Type.DATE:
|
||||
for (var i = 0; i < data.length; i++)
|
||||
index[data[i][columnIndex].toString ()] = i;
|
||||
break;
|
||||
|
@ -1109,13 +1123,13 @@ Db.Model.implement
|
|||
if (value)
|
||||
switch (this.columns[col].type)
|
||||
{
|
||||
case Db.Conn.Type.BOOLEAN:
|
||||
case Connection.Type.BOOLEAN:
|
||||
value = !!value;
|
||||
break;
|
||||
case Db.Conn.Type.INTEGER:
|
||||
case Connection.Type.INTEGER:
|
||||
value = parseInt (value);
|
||||
break;
|
||||
case Db.Conn.Type.DOUBLE:
|
||||
case Connection.Type.DOUBLE:
|
||||
value = parseFloat (value);
|
||||
break;
|
||||
default:
|
||||
|
@ -1140,9 +1154,9 @@ Db.Model.implement
|
|||
|
||||
switch (this.columns[col].type)
|
||||
{
|
||||
case Db.Conn.Type.TIMESTAMP:
|
||||
case Db.Conn.Type.DATE_TIME:
|
||||
case Db.Conn.Type.DATE:
|
||||
case Connection.Type.TIMESTAMP:
|
||||
case Connection.Type.DATE_TIME:
|
||||
case Connection.Type.DATE:
|
||||
{
|
||||
for (var i = 0; i < data.length; i++)
|
||||
if (value === data[i][col].toString ());
|
||||
|
@ -1204,7 +1218,7 @@ Db.Model.implement
|
|||
|
||||
if (pkValue)
|
||||
equalOp.exprs.add (new Sql.Value ({value: pkValue}));
|
||||
else if (column.flags & Db.Conn.Flag.AI && !useOldValues)
|
||||
else if (column.flags & Connection.Flag.AI && !useOldValues)
|
||||
equalOp.exprs.add (new Sql.Func ({name: 'LAST_INSERT_ID'}));
|
||||
else
|
||||
return null;
|
||||
|
@ -1300,7 +1314,7 @@ Db.Model.implement
|
|||
var colIndex = this.getColumnIndex (tableInfo.ai);
|
||||
|
||||
if (colIndex !== -1)
|
||||
this.columns[colIndex].flags |= Db.Conn.Flag.AI;
|
||||
this.columns[colIndex].flags |= Connection.Flag.AI;
|
||||
else
|
||||
console.warn ('Db.Model: Can\'t repair autoincrement column: `%s`.`%s`'
|
||||
,tableInfo.orgname
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
Db.Param = new Class
|
||||
|
||||
var Form = require ('./form');
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Vn.Param
|
||||
,Tag: 'db-param'
|
||||
|
@ -26,7 +29,7 @@ Db.Param = new Class
|
|||
**/
|
||||
form:
|
||||
{
|
||||
type: Db.Form
|
||||
type: Form
|
||||
,set: function (x)
|
||||
{
|
||||
this.link ({_form: x},
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
|
||||
Db.Query = new Class
|
||||
var Connection = require ('./connection');
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Vn.Object
|
||||
,Tag: 'db-query'
|
||||
|
@ -10,7 +12,7 @@ Db.Query = new Class
|
|||
**/
|
||||
conn:
|
||||
{
|
||||
type: Db.Conn
|
||||
type: Connection
|
||||
,set: function (x)
|
||||
{
|
||||
this._conn = x;
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
|
||||
var Result = require ('./result');
|
||||
|
||||
/**
|
||||
* This class stores the database results.
|
||||
**/
|
||||
Db.ResultSet = new Class
|
||||
module.exports = new Class
|
||||
({
|
||||
results: null
|
||||
,error: null
|
||||
|
@ -46,7 +49,7 @@ Db.ResultSet = new Class
|
|||
if (result !== null)
|
||||
{
|
||||
if (result.data instanceof Array)
|
||||
return new Db.Result (result);
|
||||
return new Result (result);
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* This class stores a database result.
|
||||
**/
|
||||
Db.Result = new Class
|
||||
module.exports = new Class
|
||||
({
|
||||
/**
|
||||
* Initilizes the result object.
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
|
||||
var Iterator = require ('./iterator');
|
||||
var Model = require ('./model');
|
||||
|
||||
/**
|
||||
* A light iterator for models.
|
||||
**/
|
||||
Db.SimpleIterator = new Class
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Vn.Object
|
||||
,Implements: Db.Iterator
|
||||
,Implements: Iterator
|
||||
,Properties:
|
||||
{
|
||||
/**
|
||||
|
@ -12,7 +16,7 @@ Db.SimpleIterator = new Class
|
|||
**/
|
||||
model:
|
||||
{
|
||||
type: Db.Model
|
||||
type: Model
|
||||
,set: function (x)
|
||||
{
|
||||
this._model = x;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
|
||||
Vn.App = new Class
|
||||
var Login = require ('./login');
|
||||
var Gui = require ('./gui');
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Vn.Object,
|
||||
Properties:
|
||||
|
@ -49,7 +52,7 @@ Vn.App = new Class
|
|||
}
|
||||
else
|
||||
{
|
||||
var login = this._login = new Vn.Login ({conn: this._conn});
|
||||
var login = this._login = new Login ({conn: this._conn});
|
||||
login.on ('login', this._onLogin, this);
|
||||
login.show ();
|
||||
}
|
||||
|
@ -97,7 +100,7 @@ Vn.App = new Class
|
|||
{
|
||||
this._freeLogin ();
|
||||
|
||||
var gui = this._gui = new Vn.Gui ({conn: this._conn});
|
||||
var gui = this._gui = new Gui ({conn: this._conn});
|
||||
gui.on ('logout', this._onLogout, this);
|
||||
gui.show ();
|
||||
}
|
||||
|
@ -217,3 +220,4 @@ Vn.App = new Class
|
|||
this._conn.unref ();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
module.exports =
|
||||
{
|
||||
check: function (conn, callback)
|
||||
{
|
||||
conn.execQuery ('CALL basket_check ()',
|
||||
this._onBasketCheck.bind (this, callback));
|
||||
}
|
||||
|
||||
,_onBasketCheck: function (callback, resultSet)
|
||||
{
|
||||
var status = resultSet.fetchValue ();
|
||||
|
||||
if (!status)
|
||||
return;
|
||||
|
||||
var isOk = status == 'UPDATED' || status == 'OK';
|
||||
|
||||
if (status == 'UPDATED')
|
||||
Htk.Toast.showWarning (_('OrderItemsUpdated'));
|
||||
if (callback)
|
||||
callback (isOk);
|
||||
if (!isOk)
|
||||
Vn.Hash.set ({'form': 'ecomerce/checkout'});
|
||||
}
|
||||
};
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
Vn.Form = new Class
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Vn.Object
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
Vn.resource ('js/hedera/gui.xml');
|
||||
Vn.define (function () {
|
||||
var Module = require ('./module');
|
||||
var Tpl = require ('./gui.xml');
|
||||
|
||||
Vn.Gui = new Class
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Widget,
|
||||
Properties:
|
||||
|
@ -44,7 +44,7 @@ Vn.Gui = new Class
|
|||
|
||||
,initialize: function (props)
|
||||
{
|
||||
this.builderInit ('js/hedera/gui.xml');
|
||||
this.builderInitString (Tpl);
|
||||
|
||||
this.loadingCount = 0;
|
||||
|
||||
|
@ -399,7 +399,7 @@ Vn.Gui = new Class
|
|||
|
||||
if (!formInfo)
|
||||
{
|
||||
formInfo = new Vn.Module ('forms', formPath);
|
||||
formInfo = new Module ('forms', formPath);
|
||||
this.forms[formPath] = formInfo;
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,6 @@ Vn.Gui = new Class
|
|||
|
||||
this.activeForm = new formInfo.klass (this, formInfo);
|
||||
this.activeForm.open ();
|
||||
|
||||
}
|
||||
|
||||
,setForm: function (form)
|
||||
|
@ -482,7 +481,7 @@ Vn.Gui = new Class
|
|||
{
|
||||
this.loaderPush ();
|
||||
|
||||
var module = new Vn.Module ('reports', reportName);
|
||||
var module = new Module ('reports', reportName);
|
||||
module.addCallback (this._onReportLoad.bind (this, batch));
|
||||
}
|
||||
|
||||
|
@ -558,5 +557,3 @@ Vn.Gui = new Class
|
|||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<div id="top-bar" class="navbar">
|
||||
<div id="action-bar" class="action-bar"/>
|
||||
<button id="menu-button" class="menu-button">
|
||||
<img src="image/dark/menu.svg" alt="_Menu"/>
|
||||
<img src="image/icon/dark/menu.svg" alt="_Menu"/>
|
||||
</button>
|
||||
<div id="title" class="title"/>
|
||||
<htk-spinner id="loader" class="loader dark"/>
|
||||
|
@ -20,7 +20,7 @@
|
|||
</div>
|
||||
<div id="supplant" class="supplant user-info">
|
||||
<button class="logout" on-click="onSupplantExitClick" title="_Exit">
|
||||
<img src="image/dark/exit.svg" alt="_Exit"/>
|
||||
<img src="image/icon/dark/exit.svg" alt="_Exit"/>
|
||||
</button>
|
||||
<p id="supplanted"/>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,17 @@
|
|||
/**
|
||||
* Namespace
|
||||
**/
|
||||
var Hedera = {};
|
||||
|
||||
require ('htk/htk');
|
||||
|
||||
Vn.includeCss ('js/hedera/style.css');
|
||||
Vn.Locale.loadScript ('js/hedera.js');
|
||||
|
||||
Hedera = module.exports = {
|
||||
Login : require ('./login')
|
||||
,Gui : require ('./gui')
|
||||
,Module : require ('./module')
|
||||
,Form : require ('./form')
|
||||
,Report : require ('./report')
|
||||
,App : require ('./app')
|
||||
,Tpv : require ('./tpv')
|
||||
,BasketChecker : require ('./basket-checker')
|
||||
};
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
|
||||
Vn.includeCss ('js/hedera/login.css');
|
||||
Vn.resource ('js/hedera/login.xml');
|
||||
Vn.define (function () {
|
||||
var Css = require ('./login.css');
|
||||
var Tpl = require ('./login.xml');
|
||||
|
||||
Vn.Login = new Class
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Widget,
|
||||
Properties:
|
||||
|
@ -28,7 +27,7 @@ Vn.Login = new Class
|
|||
|
||||
,initialize: function (props)
|
||||
{
|
||||
this.builderInit ('js/hedera/login.xml');
|
||||
this.builderInitString (Tpl);
|
||||
|
||||
var self = this;
|
||||
this.$('form').onsubmit = function ()
|
||||
|
@ -42,19 +41,10 @@ Vn.Login = new Class
|
|||
|
||||
,_onConnLoadChange: function (conn, isLoading)
|
||||
{
|
||||
this._disableUi (isLoading);
|
||||
}
|
||||
|
||||
,_disableUi: function (disabled)
|
||||
{
|
||||
if (disabled)
|
||||
if (isLoading)
|
||||
this.$('spinner').start ();
|
||||
else
|
||||
this.$('spinner').stop ();
|
||||
|
||||
this.$('user').disabled = disabled;
|
||||
this.$('pass').disabled = disabled;
|
||||
this.$('submit').disabled = disabled;
|
||||
}
|
||||
|
||||
,show: function ()
|
||||
|
@ -81,6 +71,13 @@ Vn.Login = new Class
|
|||
userEntry.select ();
|
||||
}
|
||||
|
||||
,_disableUi: function (disabled)
|
||||
{
|
||||
this.$('user').disabled = disabled;
|
||||
this.$('pass').disabled = disabled;
|
||||
this.$('submit').disabled = disabled;
|
||||
}
|
||||
|
||||
,_onSubmit: function ()
|
||||
{
|
||||
this._conn.open (
|
||||
|
@ -89,11 +86,14 @@ Vn.Login = new Class
|
|||
this.$('remember').checked,
|
||||
this._onConnOpen.bind (this)
|
||||
);
|
||||
|
||||
this._disableUi (true);
|
||||
}
|
||||
|
||||
,_onConnOpen: function (conn, success, error)
|
||||
{
|
||||
this.$('pass').value = '';
|
||||
this._disableUi (false);
|
||||
|
||||
if (success)
|
||||
{
|
||||
|
@ -144,4 +144,3 @@ Vn.Login = new Class
|
|||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
|
||||
Vn.includeCss ('js/hedera/style.css');
|
||||
Vn.include ('js/htk/main');
|
||||
Vn.includeLib ('hedera',
|
||||
[
|
||||
'hedera'
|
||||
,'login'
|
||||
,'gui'
|
||||
,'module'
|
||||
,'form'
|
||||
,'report'
|
||||
,'app'
|
||||
,'tpv'
|
||||
]);
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
Vn.Module = new Class
|
||||
module.exports = new Class
|
||||
({
|
||||
basePath: null
|
||||
,path: null
|
||||
|
@ -68,7 +68,7 @@ Vn.Module = new Class
|
|||
var klassName = this.toCamelCase (this.moduleName);
|
||||
|
||||
try {
|
||||
this.klass = Vn[klassName];
|
||||
this.klass = Hedera[klassName];
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
Vn.Report = new Class
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Vn.Object
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
Vn.Tpv = new Class
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Vn.Object
|
||||
|
||||
|
@ -120,29 +120,3 @@ Vn.Tpv = new Class
|
|||
}
|
||||
});
|
||||
|
||||
Vn.BasketChecker =
|
||||
{
|
||||
check: function (conn, callback)
|
||||
{
|
||||
conn.execQuery ('CALL basket_check ()',
|
||||
this._onBasketCheck.bind (this, callback));
|
||||
}
|
||||
|
||||
,_onBasketCheck: function (callback, resultSet)
|
||||
{
|
||||
var status = resultSet.fetchValue ();
|
||||
|
||||
if (!status)
|
||||
return;
|
||||
|
||||
var isOk = status == 'UPDATED' || status == 'OK';
|
||||
|
||||
if (status == 'UPDATED')
|
||||
Htk.Toast.showWarning (_('OrderItemsUpdated'));
|
||||
if (callback)
|
||||
callback (isOk);
|
||||
if (!isOk)
|
||||
Vn.Hash.set ({'form': 'ecomerce/checkout'});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
|
||||
Htk.AssitantBar = new Class
|
||||
var Widget = require ('./widget');
|
||||
var Assistant = require ('./assistant');
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Widget
|
||||
Extends: Widget
|
||||
,Tag: 'htk-assistant-bar'
|
||||
,Properties:
|
||||
{
|
||||
assistant:
|
||||
{
|
||||
type: Htk.Assistant
|
||||
type: Assistant
|
||||
,set: function (x)
|
||||
{
|
||||
this.link ({_assistant: x}, {'step-change': this.onStepChange});
|
||||
|
@ -44,7 +47,7 @@ Htk.AssitantBar = new Class
|
|||
bar.className = 'htk-assistant-bar';
|
||||
|
||||
var previousButton = document.createElement ('img');
|
||||
previousButton.src = 'image/go-previous.svg';
|
||||
previousButton.src = 'image/icon/light/go-previous.svg';
|
||||
previousButton.className = 'previous';
|
||||
previousButton.title = _('Previous');
|
||||
previousButton.addEventListener ('click', this.movePrevious.bind (this));
|
||||
|
@ -54,7 +57,7 @@ Htk.AssitantBar = new Class
|
|||
bar.appendChild (steps);
|
||||
|
||||
var nextButton = document.createElement ('img');
|
||||
nextButton.src = 'image/go-next.svg';
|
||||
nextButton.src = 'image/icon/light/go-next.svg';
|
||||
nextButton.className = 'next';
|
||||
nextButton.title = _('Next');
|
||||
nextButton.addEventListener ('click', this.moveNext.bind (this));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
Htk.Assistant = new Class
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Vn.Object
|
||||
,Tag: 'htk-assistant'
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Represents a grid column. This is an abstract class and should not be
|
||||
* instantiated directly.
|
||||
**/
|
||||
Htk.Column = new Class
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Vn.Object
|
||||
,Tag: 'htk-column'
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Htk.ColumnButton = new Class
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Column
|
||||
,Tag: 'htk-column-button'
|
||||
|
@ -9,6 +10,19 @@ Htk.ColumnButton = new Class
|
|||
type: String
|
||||
,value: null
|
||||
},
|
||||
icon:
|
||||
{
|
||||
type: String
|
||||
,set: function (x)
|
||||
{
|
||||
this._icon = x;
|
||||
this.image = 'image/icon/light/'+ x + '.svg';
|
||||
}
|
||||
,get: function ()
|
||||
{
|
||||
return this._icon;
|
||||
}
|
||||
},
|
||||
tip:
|
||||
{
|
||||
type: String
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Htk.ColumnCheck = new Class
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Column
|
||||
,Tag: 'htk-column-check'
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Htk.ColumnDate = new Class
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Column
|
||||
,Tag: 'htk-column-date'
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Htk.ColumnImage = new Class
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Column
|
||||
,Tag: 'htk-column-image'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
Htk.ColumnLink = new Class
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Column
|
||||
,Tag: 'htk-column-link'
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Htk.ColumnRadio = new Class
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Column
|
||||
,Tag: 'htk-column-radio'
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Htk.ColumnSpin = new Class
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Column
|
||||
,Tag: 'htk-column-spin'
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Htk.ColumnText = new Class
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Column
|
||||
,Tag: 'htk-column-text'
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
|
||||
Htk.Field = new Class
|
||||
var Widget = require ('./widget');
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Widget
|
||||
Extends: Widget
|
||||
,Tag: 'htk-field'
|
||||
,Child: 'param'
|
||||
,Properties:
|
||||
|
@ -98,7 +100,11 @@ Htk.Field = new Class
|
|||
,bindToForm: function ()
|
||||
{
|
||||
if (this._form && this._paramName)
|
||||
this.param = this._form.getParam (this._paramName);
|
||||
this.param = new Db.Param
|
||||
({
|
||||
form: this._form
|
||||
,column: this._paramName
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
Htk.BarButton = new Class
|
||||
|
||||
var Button = require ('./button');
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Button
|
||||
Extends: Button
|
||||
,Tag: 'htk-bar-button'
|
||||
,Properties:
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Htk.Button = new Class
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Field
|
||||
,Tag: 'htk-button'
|
||||
|
@ -13,7 +14,7 @@ Htk.Button = new Class
|
|||
}
|
||||
|
||||
},
|
||||
/* icon:
|
||||
icon:
|
||||
{
|
||||
type: String
|
||||
,set: function (x)
|
||||
|
@ -22,7 +23,7 @@ Htk.Button = new Class
|
|||
}
|
||||
|
||||
},
|
||||
*/ tip:
|
||||
tip:
|
||||
{
|
||||
type: String
|
||||
,set: function (x)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Htk.Calendar = new Class
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Field
|
||||
,Tag: 'htk-calendar'
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Htk.Check = new Class
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Field
|
||||
,Tag: 'htk-check'
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
|
||||
Htk.DateChooser = new Class
|
||||
var Calendar = require ('./calendar');
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Field
|
||||
,Tag: 'htk-date-chooser'
|
||||
|
@ -53,7 +55,7 @@ Htk.DateChooser = new Class
|
|||
this.button.appendChild (this.label);
|
||||
this.node.appendChild (this.button);
|
||||
|
||||
this.calendar = new Htk.Calendar ();
|
||||
this.calendar = new Calendar ();
|
||||
this.calendar.on ('changed', this._onCalendarChange.bind (this));
|
||||
|
||||
this.popup = new Htk.Popup ();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Htk.Entry = new Class
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Field
|
||||
,Tag: 'htk-entry'
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Htk.Html = new Class
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Field
|
||||
,Tag: 'htk-html'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Class to display or edit an image. Also it allows to show it's full version.
|
||||
**/
|
||||
Htk.Image = new Class
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Field
|
||||
,Tag: 'htk-image'
|
||||
|
@ -122,9 +122,8 @@ Htk.Image = new Class
|
|||
button.title = _('UpdateImage');
|
||||
this.node.appendChild (button);
|
||||
|
||||
var img = document.createElement ('img');
|
||||
img.src = 'image/add-photo.svg';
|
||||
button.appendChild (img);
|
||||
var icon = new Htk.Icon ({icon: 'add-photo'});
|
||||
button.appendChild (icon.getNode ());
|
||||
|
||||
this.editButton = button;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Htk.Label = new Class
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Field
|
||||
,Tag: 'htk-label'
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Htk.RadioGroup = new Class
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Field
|
||||
,Tag: 'htk-radio-group'
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
Htk.Radio = new Class
|
||||
|
||||
var RadioGroup = require ('./radio-group');
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Field
|
||||
,Tag: 'htk-radio'
|
||||
|
@ -15,7 +18,7 @@ Htk.Radio = new Class
|
|||
},
|
||||
radioGroup:
|
||||
{
|
||||
type: Htk.RadioGroup
|
||||
type: RadioGroup
|
||||
,set: function (x)
|
||||
{
|
||||
this.link ({_radioGroup: x}, {'changed': this._onRadioGroupChange});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
Htk.SearchEntry = new Class
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Field
|
||||
,Tag: 'htk-search-entry'
|
||||
|
@ -9,10 +9,11 @@ Htk.SearchEntry = new Class
|
|||
var div = this.createElement ('div');
|
||||
div.className = 'htk-search-entry';
|
||||
|
||||
var img = document.createElement ('img');
|
||||
img.alt = _('Search');
|
||||
img.src = 'image/search.svg';
|
||||
div.appendChild (img);
|
||||
var icon = new Htk.Icon ({
|
||||
icon: 'search',
|
||||
alt: _('Search')
|
||||
});
|
||||
div.appendChild (icon.node);
|
||||
|
||||
var input = document.createElement ('input');
|
||||
input.className = 'entry';
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
|
||||
Htk.Select = new Class
|
||||
var ColumnText = require ('../column/text');
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Field
|
||||
,Implements: Db.Iterator
|
||||
|
@ -161,7 +163,7 @@ Htk.Select = new Class
|
|||
var gridNode = grid.getNode ();
|
||||
gridNode.addEventListener ('click', this._onGridClicked.bind (this, grid));
|
||||
|
||||
var column = new Htk.ColumnText ({columnIndex: this.showColumnIndex});
|
||||
var column = new ColumnText ({columnIndex: this.showColumnIndex});
|
||||
grid.appendColumn (column);
|
||||
grid.model = model;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Htk.Spin = new Class
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Field
|
||||
,Tag: 'htk-spin'
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
Htk.Table = new Class
|
||||
|
||||
var Entry = require ('./entry');
|
||||
var ColumnRadio = require ('../column/radio');
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Entry
|
||||
Extends: Entry
|
||||
,Tag: 'htk-table'
|
||||
|
||||
,initialize: function (props)
|
||||
|
@ -8,7 +12,7 @@ Htk.Table = new Class
|
|||
var tv = new Htk.TreeView ();
|
||||
this.node.appendChild (tv.getNode ());
|
||||
|
||||
var renderer = new Htk.CellRendererRadio ();
|
||||
var renderer = new ColumnRadio ();
|
||||
tv.appendColumn (0, renderer, '');
|
||||
|
||||
var rbGroup = renderer.rbGroup;
|
||||
|
@ -44,7 +48,7 @@ Htk.Table = new Class
|
|||
|
||||
,modelRefresh: function (model, status)
|
||||
{
|
||||
if (status == DB_MODEL_STATUS_READY)
|
||||
if (status == Db.Model.Status.READY)
|
||||
this.selectValue ();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Htk.TextArea = new Class
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Field
|
||||
,Tag: 'htk-textarea'
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Htk.Text = new Class
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Field
|
||||
,Tag: 'htk-text'
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
|
||||
Htk.FullImage = new Class
|
||||
var Popup = require ('./popup');
|
||||
var Spinner = require ('./spinner');
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Vn.Object
|
||||
,Properties:
|
||||
|
@ -23,7 +26,7 @@ Htk.FullImage = new Class
|
|||
|
||||
,show: function (src)
|
||||
{
|
||||
var popup = new Htk.Popup ({class: 'htk-full-image', modal: true});
|
||||
var popup = new Popup ({class: 'htk-full-image', modal: true});
|
||||
|
||||
var img = document.createElement ('img');
|
||||
img.className = 'htk-full-image';
|
||||
|
@ -35,7 +38,7 @@ Htk.FullImage = new Class
|
|||
{
|
||||
img.addEventListener ('load', this._onImageLoad.bind (this, popup, img));
|
||||
|
||||
var spinner = new Htk.Spinner ();
|
||||
var spinner = new Spinner ();
|
||||
spinner.start ();
|
||||
popup.child = spinner;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
|
||||
Htk.Grid = new Class
|
||||
var Widget = require ('./widget');
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Widget
|
||||
Extends: Widget
|
||||
,Tag: 'htk-grid'
|
||||
,Child: 'model'
|
||||
,Properties:
|
||||
|
@ -172,7 +174,7 @@ Htk.Grid = new Class
|
|||
{
|
||||
this.internalColumn = new Htk.ColumnButton
|
||||
({
|
||||
image: 'image/delete.svg'
|
||||
icon: 'delete'
|
||||
,tip: _('Remove')
|
||||
});
|
||||
this.internalColumn.on ('clicked', this.removeClicked, this);
|
||||
|
@ -212,10 +214,10 @@ Htk.Grid = new Class
|
|||
this.showMessage (_('Loading'), null);
|
||||
break;
|
||||
case Db.Model.Status.CLEAN:
|
||||
this.showMessage (this.emptyMessage, 'refresh.svg');
|
||||
this.showMessage (this.emptyMessage, 'refresh');
|
||||
break;
|
||||
case Db.Model.Status.ERROR:
|
||||
this.showMessage (_('ErrorLoadingData'), 'error.svg');
|
||||
this.showMessage (_('ErrorLoadingData'), 'error');
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -225,7 +227,7 @@ Htk.Grid = new Class
|
|||
,showNoRecordsFound: function (count)
|
||||
{
|
||||
if (this._model.numRows == 0)
|
||||
this.showMessage (_('EmptyList'), 'clean.svg');
|
||||
this.showMessage (_('EmptyList'), 'clean');
|
||||
}
|
||||
|
||||
,showMessage: function (message, src)
|
||||
|
@ -245,7 +247,7 @@ Htk.Grid = new Class
|
|||
{
|
||||
var img = document.createElement ('img');
|
||||
img.alt = '';
|
||||
img.src = 'image/'+ src;
|
||||
img.src = 'image/icon/light/'+ src +'.svg';
|
||||
td.appendChild (img);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,4 +1,53 @@
|
|||
/**
|
||||
* The namespace.
|
||||
**/
|
||||
var Htk = {};
|
||||
|
||||
require ('db/db');
|
||||
require ('./style.css');
|
||||
|
||||
Vn.Locale.loadScript ('js/htk.js');
|
||||
|
||||
Htk = module.exports = {
|
||||
Widget : require ('./widget')
|
||||
,Popup : require ('./popup')
|
||||
,Toast : require ('./toast')
|
||||
,Repeater : require ('./repeater')
|
||||
,Grid : require ('./grid')
|
||||
,Spinner : require ('./spinner')
|
||||
,Icon : require ('./icon')
|
||||
,FullImage : require ('./full-image')
|
||||
,ImageEditor : require ('./image-editor')
|
||||
,Assistant : require ('./assistant')
|
||||
,AssistantBar : require ('./assistant-bar')
|
||||
,Field : require ('./field')
|
||||
,Column : require ('./column')
|
||||
};
|
||||
|
||||
var Fields = {
|
||||
Text : require ('./field/text')
|
||||
,Html : require ('./field/html')
|
||||
,Entry : require ('./field/entry')
|
||||
,RadioGroup : require ('./field/radio-group')
|
||||
,Radio : require ('./field/radio')
|
||||
,Label : require ('./field/label')
|
||||
,TextArea : require ('./field/text-area')
|
||||
,Spin : require ('./field/spin')
|
||||
,Check : require ('./field/check')
|
||||
,Select : require ('./field/select')
|
||||
,Calendar : require ('./field/calendar')
|
||||
,DateChooser : require ('./field/date-chooser')
|
||||
,Image : require ('./field/image')
|
||||
,Button : require ('./field/button')
|
||||
,BarButton : require ('./field/bar-button')
|
||||
,Table : require ('./field/table')
|
||||
,SearchEntry : require ('./field/search-entry')
|
||||
,ColumnButton : require ('./column/button')
|
||||
,ColumnLink : require ('./column/link')
|
||||
,ColumnDate : require ('./column/date')
|
||||
,ColumnImage : require ('./column/image')
|
||||
,ColumnRadio : require ('./column/radio')
|
||||
,ColumnSpin : require ('./column/spin')
|
||||
,ColumnText : require ('./column/text')
|
||||
,ColumnCheck : require ('./column/check')
|
||||
};
|
||||
|
||||
for (var field in Fields)
|
||||
Htk[field] = Fields[field];
|
||||
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
|
||||
var Widget = require ('./widget');
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Widget
|
||||
,Tag: 'htk-icon'
|
||||
,Properties:
|
||||
{
|
||||
icon:
|
||||
{
|
||||
type: String
|
||||
,set: function (x)
|
||||
{
|
||||
this._icon = x;
|
||||
this.render ();
|
||||
}
|
||||
,get: function ()
|
||||
{
|
||||
return this._icon;
|
||||
}
|
||||
|
||||
},
|
||||
theme:
|
||||
{
|
||||
type: String
|
||||
,set: function (x)
|
||||
{
|
||||
this._theme = x;
|
||||
this.render ();
|
||||
}
|
||||
,get: function ()
|
||||
{
|
||||
return this._theme;
|
||||
}
|
||||
},
|
||||
alt:
|
||||
{
|
||||
type: String
|
||||
,set: function (x)
|
||||
{
|
||||
this.node.alt = x;
|
||||
}
|
||||
,get: function ()
|
||||
{
|
||||
return this.node.alt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
,_icon: null
|
||||
|
||||
,initialize: function (props)
|
||||
{
|
||||
this.createElement ('img');
|
||||
this.parent (props);
|
||||
}
|
||||
|
||||
,render: function ()
|
||||
{
|
||||
var theme = this._theme ? this._theme : 'light';
|
||||
this.node.src = 'image/icon/'+ theme +'/'+ this._icon +'.svg';
|
||||
}
|
||||
});
|
|
@ -1,14 +1,15 @@
|
|||
|
||||
Vn.resource ('js/htk/image-editor.xml');
|
||||
Vn.define (function () {
|
||||
var Widget = require ('./widget');
|
||||
var Toast = require ('./toast');
|
||||
var Tpl = require ('./image-editor.xml');
|
||||
|
||||
/**
|
||||
* A form to handle the image database, it allows to add new images or
|
||||
* replace it.
|
||||
**/
|
||||
Htk.ImageEditor = new Class
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Widget
|
||||
Extends: Widget
|
||||
,Properties:
|
||||
{
|
||||
/**
|
||||
|
@ -22,7 +23,7 @@ Htk.ImageEditor = new Class
|
|||
|
||||
,initialize: function (props)
|
||||
{
|
||||
this.builderInit (this.constructor.Xml);
|
||||
this.builderInitString (Tpl);
|
||||
|
||||
var self = this;
|
||||
this.$('form').onsubmit = function ()
|
||||
|
@ -57,11 +58,11 @@ Htk.ImageEditor = new Class
|
|||
|
||||
if (json)
|
||||
{
|
||||
Htk.Toast.showMessage (_('ImageAdded'));
|
||||
Toast.showMessage (_('ImageAdded'));
|
||||
this.signalEmit ('file-uploaded', this.$('name').value);
|
||||
}
|
||||
else
|
||||
Htk.Toast.showError (error.message);
|
||||
Toast.showError (error.message);
|
||||
}
|
||||
|
||||
,setData: function (image, directory)
|
||||
|
@ -69,9 +70,5 @@ Htk.ImageEditor = new Class
|
|||
this.$('name').value = image;
|
||||
this.$('schema').value = directory;
|
||||
}
|
||||
}).extend
|
||||
({
|
||||
Xml: 'js/htk/image-editor.xml'
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
|
||||
Vn.includeCss ('js/htk/style.css');
|
||||
Vn.include ('js/db/main');
|
||||
Vn.includeLib ('htk',
|
||||
[
|
||||
'htk'
|
||||
,'widget'
|
||||
,'popup'
|
||||
,'toast'
|
||||
,'repeater'
|
||||
,'grid'
|
||||
,'spinner'
|
||||
,'full-image'
|
||||
,'image-editor'
|
||||
,'assistant'
|
||||
,'assistant-bar'
|
||||
,'field'
|
||||
,'field/text'
|
||||
,'field/html'
|
||||
,'field/entry'
|
||||
,'field/radio-group'
|
||||
,'field/radio'
|
||||
,'field/label'
|
||||
,'field/text-area'
|
||||
,'field/spin'
|
||||
,'field/check'
|
||||
,'field/select'
|
||||
,'field/calendar'
|
||||
,'field/date-chooser'
|
||||
,'field/image'
|
||||
,'field/button'
|
||||
,'field/bar-button'
|
||||
,'field/table'
|
||||
,'field/search-entry'
|
||||
,'column'
|
||||
,'column/button'
|
||||
,'column/link'
|
||||
,'column/date'
|
||||
,'column/image'
|
||||
,'column/radio'
|
||||
,'column/spin'
|
||||
,'column/text'
|
||||
,'column/check'
|
||||
]);
|
|
@ -1,9 +1,12 @@
|
|||
|
||||
var Widget = require ('./widget');
|
||||
|
||||
/**
|
||||
* Class to handle popups.
|
||||
**/
|
||||
Htk.Popup = new Class
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Widget
|
||||
Extends: Widget
|
||||
,Tag: 'htk-popup'
|
||||
,Properties:
|
||||
{
|
||||
|
@ -12,7 +15,7 @@ Htk.Popup = new Class
|
|||
**/
|
||||
child:
|
||||
{
|
||||
type: Htk.Widget
|
||||
type: Widget
|
||||
,set: function (x)
|
||||
{
|
||||
this._child = x;
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
Htk.Repeater = new Class
|
||||
|
||||
var Widget = require ('./widget');
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Widget
|
||||
Extends: Widget
|
||||
,Tag: 'htk-repeater'
|
||||
,Child: 'model'
|
||||
,Properties:
|
||||
|
@ -156,10 +159,10 @@ Htk.Repeater = new Class
|
|||
this._showMessage (_('Loading'), null);
|
||||
break;
|
||||
case Db.Model.Status.CLEAN:
|
||||
this._showMessage (this.emptyMessage, 'refresh.svg');
|
||||
this._showMessage (this.emptyMessage, 'refresh');
|
||||
break;
|
||||
case Db.Model.Status.ERROR:
|
||||
this._showMessage (_('ErrorLoadingData'), 'error.svg');
|
||||
this._showMessage (_('ErrorLoadingData'), 'error');
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -170,7 +173,7 @@ Htk.Repeater = new Class
|
|||
,_showNoRecordsFound: function (count)
|
||||
{
|
||||
if (this._model.numRows === 0)
|
||||
this._showMessage (_('EmptyList'), 'clean.svg');
|
||||
this._showMessage (_('EmptyList'), 'clean');
|
||||
}
|
||||
|
||||
,_showMessage: function (message, src)
|
||||
|
@ -183,7 +186,7 @@ Htk.Repeater = new Class
|
|||
{
|
||||
var img = document.createElement ('img');
|
||||
img.alt = '';
|
||||
img.src = 'image/'+ src;
|
||||
img.src = 'image/icon/light/'+ src +'.svg';
|
||||
div.appendChild (img);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
Htk.Spinner = new Class
|
||||
|
||||
var Widget = require ('./widget');
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Htk.Widget
|
||||
Extends: Widget
|
||||
,Tag: 'htk-spinner'
|
||||
|
||||
,_started: false
|
||||
|
@ -35,3 +38,4 @@ Htk.Spinner = new Class
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Class to show toast messages.
|
||||
**/
|
||||
Htk.Toast =
|
||||
module.exports =
|
||||
{
|
||||
maxMessages: 6
|
||||
,timeout: 10 /* Seconds */
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Htk.Widget = new Class
|
||||
|
||||
module.exports = new Class
|
||||
({
|
||||
Extends: Vn.Object
|
||||
,Properties:
|
||||
|
@ -27,7 +28,19 @@ Htk.Widget = new Class
|
|||
var builder = new Vn.Builder ();
|
||||
builder.signalData = this;
|
||||
builder.loadXml (path);
|
||||
|
||||
this.builderResultInit (builder);
|
||||
}
|
||||
|
||||
,builderInitString: function (xmlString)
|
||||
{
|
||||
var builder = new Vn.Builder ();
|
||||
builder.signalData = this;
|
||||
builder.loadFromString (xmlString);
|
||||
this.builderResultInit (builder);
|
||||
}
|
||||
|
||||
,builderResultInit: function (builder)
|
||||
{
|
||||
var res = this.builder = builder.load ();
|
||||
this.node = res.$('main');
|
||||
res.link ();
|
||||
|
@ -79,3 +92,4 @@ Htk.Widget = new Class
|
|||
this.parent ();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue