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