forked from verdnatura/hedera-web
Db.Model soporta actualizaciones bajo demanda, edicion de consignatarios, errores solucionados
This commit is contained in:
parent
d64160d891
commit
0a738a55d7
|
@ -1,5 +1,5 @@
|
|||
Package: hedera-web
|
||||
Version: 1.0-42
|
||||
Version: 1.0-43
|
||||
Architecture: all
|
||||
Maintainer: Juan Ferrer Toribio <juan@verdnatura.es>
|
||||
Depends: apache2, php5-mysql, php-vn-web
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
|
||||
Vn.Address = new Class
|
||||
({
|
||||
Extends: Vn.Module
|
||||
|
||||
,activate: function ()
|
||||
{
|
||||
this.$('return').addEventListener ('click', this.onReturnClick.bind (this));
|
||||
this.$('accept').addEventListener ('click', this.onAcceptClick.bind (this));
|
||||
this.$('iter').on ('status-changed', this.onStatusChange, this);
|
||||
this.$('model').on ('operations-done', this.onOperationsDone, this);
|
||||
}
|
||||
|
||||
,onStatusChange: function (form)
|
||||
{
|
||||
if (this.$('address').value == 0)
|
||||
form.insertRow ();
|
||||
}
|
||||
|
||||
,onOperationsDone: function ()
|
||||
{
|
||||
(new Htk.Toast ()).showMessage (_('ConsigneeChangedSuccessfully'));
|
||||
this.onReturnClick ();
|
||||
}
|
||||
|
||||
,onAcceptClick: function ()
|
||||
{
|
||||
this.$('iter').performOperations ();
|
||||
}
|
||||
|
||||
,onReturnClick: function ()
|
||||
{
|
||||
window.history.back();
|
||||
}
|
||||
});
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
.address
|
||||
{
|
||||
padding: 1em;
|
||||
}
|
||||
.address .box
|
||||
{
|
||||
max-width: 40em;
|
||||
}
|
||||
.address .box .body
|
||||
{
|
||||
margin: 0 auto;
|
||||
max-width: 25em;
|
||||
padding: 3em;
|
||||
}
|
||||
div.form-group
|
||||
{
|
||||
padding: 0.4em;
|
||||
}
|
||||
.address label
|
||||
{
|
||||
display: block;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
.address input,
|
||||
.address select
|
||||
{
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
<vn>
|
||||
<vn-group>
|
||||
<vn-param id="address">
|
||||
<vn-hash-link key="address"/>
|
||||
</vn-param>
|
||||
<db-form id="iter">
|
||||
<db-model id="model">
|
||||
SELECT id, name, consignee, city, zip_code, province_id
|
||||
FROM address_view
|
||||
WHERE active != FALSE AND id = #address
|
||||
<sql-batch property="batch">
|
||||
<item name="address" param="address"/>
|
||||
</sql-batch>
|
||||
</db-model>
|
||||
</db-form>
|
||||
</vn-group>
|
||||
<div id="form" class="address">
|
||||
<div class="box">
|
||||
<div class="header">
|
||||
<h1><t>EditConsignee</t></h1>
|
||||
<div class="action-bar">
|
||||
<button id="return">
|
||||
<img src="image/dark/go-previous.svg" alt=""/>
|
||||
<t>Return</t>
|
||||
</button>
|
||||
<button id="accept">
|
||||
<img src="image/dark/ok.svg" alt=""/>
|
||||
<t>Accept</t>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="body">
|
||||
<div class="form-group">
|
||||
<label><t>Name:</t></label>
|
||||
<htk-entry column="consignee" form="iter"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><t>Adress:</t></label>
|
||||
<htk-entry column="name" form="iter"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><t>City:</t></label>
|
||||
<htk-entry column="city" form="iter"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><t>ZipCode:</t></label>
|
||||
<htk-entry column="zip_code" form="iter"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><t>Province:</t></label>
|
||||
<htk-combo column="province_id" form="iter">
|
||||
<db-model property="model">
|
||||
SELECT province_id, name FROM vn2008.province
|
||||
ORDER BY name
|
||||
</db-model>
|
||||
</htk-combo>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</vn>
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
Vn.Account = new Class
|
||||
Vn.Conf = new Class
|
||||
({
|
||||
Extends: Vn.Module
|
||||
|
||||
|
@ -13,6 +13,15 @@ Vn.Account = new Class
|
|||
this.$('new-password').addEventListener ('change', this.onPasswordChange.bind (this));
|
||||
this.$('repeat-password').addEventListener ('change', this.onPasswordChange.bind (this));
|
||||
this.$('user-name').addEventListener ('change', this.onUserChange.bind (this));
|
||||
this.$('add').addEventListener ('click', this.onAddClick.bind (this));
|
||||
}
|
||||
|
||||
,onAddClick: function ()
|
||||
{
|
||||
this.hash.set ({
|
||||
'form': 'account/address',
|
||||
'address': 0
|
||||
});
|
||||
}
|
||||
|
||||
,onUserDataReady: function (form)
|
|
@ -0,0 +1,42 @@
|
|||
|
||||
.conf
|
||||
{
|
||||
padding: 1em;
|
||||
}
|
||||
.conf .box
|
||||
{
|
||||
max-width: 40em;
|
||||
}
|
||||
.conf .form
|
||||
{
|
||||
margin: 0 auto;
|
||||
max-width: 25em;
|
||||
padding: 2em;
|
||||
}
|
||||
.conf .form-group
|
||||
{
|
||||
padding: 0.4em;
|
||||
}
|
||||
.conf .form-group label
|
||||
{
|
||||
display: block;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
.conf .form-group input[type=text],
|
||||
.conf .form-group input[type=password]
|
||||
{
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
}
|
||||
.conf .form-group input[type=password]
|
||||
{
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
.consignee
|
||||
{
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
.consignee p
|
||||
{
|
||||
margin: 0.2em 0;
|
||||
}
|
|
@ -8,8 +8,14 @@
|
|||
ON u.id = c.user_id
|
||||
</db-model>
|
||||
</db-form>
|
||||
<db-model id="consignees">
|
||||
SELECT id, consignee, p.name province, zip_code, city, a.name
|
||||
FROM address_view a
|
||||
JOIN vn2008.province p ON a.province_id = p.province_id
|
||||
WHERE active != FALSE
|
||||
</db-model>
|
||||
</vn-group>
|
||||
<div id="form" class="account">
|
||||
<div id="form" class="conf">
|
||||
<div class="box">
|
||||
<div class="header">
|
||||
<h1><t>Configuration</t></h1>
|
||||
|
@ -17,7 +23,7 @@
|
|||
<div class="form">
|
||||
<div class="form-group">
|
||||
<label for="user-id"><t>UserNumber</t></label>
|
||||
<htk-label column="id" form="user-form"/>
|
||||
<htk-text column="id" form="user-form"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="user-name"><t>UserName</t></label>
|
||||
|
@ -38,5 +44,33 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box">
|
||||
<div class="header">
|
||||
<h1><t>Consignees</t></h1>
|
||||
<div class="action-bar">
|
||||
<button id="add">
|
||||
<img src="image/dark/add.svg" alt=""/>
|
||||
<t>Add</t>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form">
|
||||
<htk-repeater model="consignees" form-id="iter">
|
||||
<div class="consignee">
|
||||
<h2><htk-text form="iter" column="consignee"/></h2>
|
||||
<p>
|
||||
<htk-text form="iter" column="name"/>
|
||||
</p>
|
||||
<p>
|
||||
<htk-text form="iter" column="zip_code"/> -
|
||||
<htk-text form="iter" column="city"/>
|
||||
</p>
|
||||
<p>
|
||||
<htk-text form="iter" column="province"/>
|
||||
</p>
|
||||
</div>
|
||||
</htk-repeater>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</vn>
|
|
@ -1,34 +0,0 @@
|
|||
|
||||
.account
|
||||
{
|
||||
padding: 1em;
|
||||
}
|
||||
.account .box
|
||||
{
|
||||
max-width: 40em;
|
||||
}
|
||||
.account .form
|
||||
{
|
||||
margin: 0 auto;
|
||||
max-width: 25em;
|
||||
padding: 2em;
|
||||
}
|
||||
.account .form-group
|
||||
{
|
||||
padding: 0.4em;
|
||||
}
|
||||
.account .form-group label
|
||||
{
|
||||
display: block;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
.account .form-group input[type=text],
|
||||
.account .form-group input[type=password]
|
||||
{
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
}
|
||||
.account .form-group input[type=password]
|
||||
{
|
||||
margin-bottom: 0.5em;
|
||||
}
|
|
@ -12,6 +12,7 @@ Vn.Catalog = new Class
|
|||
model.setFieldFlags ('id', Db.Conn.Flag.AI);
|
||||
model.setFieldFlags ('Id_Article', Db.Conn.Flag.PRI_KEY);
|
||||
|
||||
this.$('price').renderer = this.priceRenderer;
|
||||
this.$('type-column').renderer = this.typeRenderer.bind (this);
|
||||
this.$('cat').renderer = this.catRenderer;
|
||||
this.$('basket-button').addEventListener ('click', this.basketClicked.bind (this));
|
||||
|
@ -26,17 +27,12 @@ Vn.Catalog = new Class
|
|||
this.$('warehouse').value = 1;
|
||||
this.$('date').value = new Date ();
|
||||
|
||||
if (!Vn.Url.getQuery ('guest'))
|
||||
{
|
||||
var orderId = Vn.Cookie.getInt ('order');
|
||||
|
||||
if (!orderId)
|
||||
this.configureView ();
|
||||
else
|
||||
this.$('order-batch').addValue ('order', orderId);
|
||||
}
|
||||
var orderId = Vn.Cookie.getInt ('order');
|
||||
|
||||
if (!orderId)
|
||||
this.configureView ();
|
||||
else
|
||||
this.$('order').value = 0;
|
||||
this.$('order-batch').addValue ('order', orderId);
|
||||
}
|
||||
|
||||
,onRealmsReload: function (model, status)
|
||||
|
@ -189,17 +185,6 @@ Vn.Catalog = new Class
|
|||
Vn.Cookie.unset ('order');
|
||||
|
||||
this.$('order').value = orderId;
|
||||
|
||||
var priceCol = new Htk.ColumnSpin
|
||||
({
|
||||
title: 'Price'
|
||||
,digits: 2
|
||||
,unit: '€'
|
||||
,column: 'price'
|
||||
,renderer: this.priceRenderer
|
||||
});
|
||||
grid.insertColumn (11, priceCol);
|
||||
|
||||
this.$('basket-button').disabled = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
<db-model result-index="1" main-table="m" updatable="false" id="items-model">
|
||||
CALL item (#warehouse, #date);
|
||||
SELECT i.grouping, m.amount, Foto, i.available, Article, Categoria,
|
||||
Medida, Tallos, Color, o.Abreviatura, price, fixed, m.id,
|
||||
Id_Article
|
||||
Medida, Tallos, Color, o.Abreviatura, price, fixed, m.id, Id_Article
|
||||
FROM vn2008.Articles a
|
||||
INNER JOIN vn2008.item_catalog i ON i.item_id = a.Id_Article
|
||||
LEFT JOIN vn2008.Origen o ON a.id_origen = o.id
|
||||
|
@ -106,6 +105,7 @@
|
|||
<htk-column-text title="_Color" column="Color"/>
|
||||
<htk-column-text title="_Tallos" column="Tallos"/>
|
||||
<htk-column-text title="_Origin" column="Abreviatura"/>
|
||||
<htk-column-text title="_Price" column="price" digits="2" unit="€" id="price"/>
|
||||
</htk-grid>
|
||||
<p class="footer-message">
|
||||
<t>IndicativePhotos</t>
|
||||
|
|
|
@ -5,11 +5,15 @@ Vn.New = new Class
|
|||
|
||||
,activate: function ()
|
||||
{
|
||||
this.$('new-cancel').addEventListener ('click', this.onCancelClick.bind (this));
|
||||
this.$('new-accept').addEventListener ('click', this.onAcceptClick.bind (this));
|
||||
this.$('new-form').on ('status-changed', this.onStatusChange, this);
|
||||
this.$('new-body').on ('changed', this.onBodyChange, this);
|
||||
this.$('html-editor').id = 'html-editor';
|
||||
this.$('return').addEventListener ('click', this.onReturnClick.bind (this));
|
||||
this.$('accept').addEventListener ('click', this.onAcceptClick.bind (this));
|
||||
this.$('body').on ('changed', this.onBodyChange, this);
|
||||
this.$('iter').on ('status-changed', this.onStatusChange, this);
|
||||
this.$('model').on ('operations-done', this.onOperationsDone, this);
|
||||
this.$('model').mode = Db.Model.Mode.ON_DEMAND;
|
||||
this.$('model').setDefault ('user_id', 'news',
|
||||
new Sql.Func ({schema: 'account', name: 'user_get_id'}));
|
||||
|
||||
tinymce.init ({
|
||||
mode : 'exact'
|
||||
|
@ -36,54 +40,36 @@ Vn.New = new Class
|
|||
|
||||
,onStatusChange: function (form)
|
||||
{
|
||||
if (this.$('new-param').value == 0)
|
||||
if (this.$('new-id').value == 0)
|
||||
form.insertRow ();
|
||||
}
|
||||
|
||||
,onOperationsDone: function ()
|
||||
{
|
||||
(new Htk.Toast ()).showMessage (_('NewChangedSuccessfully'));
|
||||
this.onReturnClick ();
|
||||
}
|
||||
|
||||
,onBodyChange: function ()
|
||||
{
|
||||
var newHtml = this.$('new-form').get ('text');
|
||||
var newHtml = this.$('iter').get ('text');
|
||||
|
||||
if (!newHtml)
|
||||
newHtml = '';
|
||||
|
||||
tinyMCE.get ('html-editor').setContent (newHtml);
|
||||
}
|
||||
|
||||
,onCancelClick: function ()
|
||||
{
|
||||
this.hash.set ({'form': 'news/news'});
|
||||
}
|
||||
|
||||
,onAcceptClick: function ()
|
||||
{
|
||||
var form = this.$('new-form');
|
||||
var newHtml = tinyMCE.get ('html-editor').getContent ();
|
||||
|
||||
if (this.$('new-param').value == 0)
|
||||
{
|
||||
var batch = new Sql.Batch ();
|
||||
batch.addValue ('title', form.get ('title'));
|
||||
batch.addValue ('tag', form.get ('tag'));
|
||||
batch.addValue ('text', newHtml);
|
||||
|
||||
var query = 'INSERT INTO news (title, text, tag, user_id) '
|
||||
+'VALUES (#title, #text, #tag, account.user_get_id())';
|
||||
|
||||
this.conn.execQuery (query, this.newAdded.bind (this), batch);
|
||||
// this.$('new-form').performOperations ();
|
||||
}
|
||||
else
|
||||
{
|
||||
form.set ('text', newHtml);
|
||||
this.onCancelClick ();
|
||||
}
|
||||
this.$('iter').set ('text', newHtml);
|
||||
this.$('iter').performOperations ();
|
||||
}
|
||||
|
||||
,newAdded: function (resultSet)
|
||||
|
||||
,onReturnClick: function ()
|
||||
{
|
||||
if (resultSet.fetchResult ())
|
||||
this.onCancelClick ();
|
||||
this.hash.set ({'form': 'news/news'});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<vn>
|
||||
<vn-group>
|
||||
<vn-param id="new-param">
|
||||
<vn-param id="new-id">
|
||||
<vn-hash-link key="new"/>
|
||||
</vn-param>
|
||||
<db-form id="new-form">
|
||||
<db-param column="text" id="new-body"/>
|
||||
<db-model>
|
||||
SELECT id, user_id, title, text, tag
|
||||
<db-form id="iter">
|
||||
<db-param column="text" id="body"/>
|
||||
<db-model id="model">
|
||||
SELECT id, title, text, tag
|
||||
FROM news WHERE id = #new
|
||||
<sql-batch property="batch">
|
||||
<item name="new" param="new-param"/>
|
||||
<item name="new" param="new-id"/>
|
||||
</sql-batch>
|
||||
</db-model>
|
||||
</db-form>
|
||||
|
@ -18,15 +18,25 @@
|
|||
<div class="box">
|
||||
<div class="header">
|
||||
<h1><t>AddNew</t></h1>
|
||||
<div class="action-bar">
|
||||
<button id="return">
|
||||
<img src="image/dark/go-previous.svg" alt=""/>
|
||||
<t>Return</t>
|
||||
</button>
|
||||
<button id="accept">
|
||||
<img src="image/dark/ok.svg" alt=""/>
|
||||
<t>Accept</t>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form">
|
||||
<div class="form-group">
|
||||
<label><t>Title:</t></label>
|
||||
<htk-entry column="title" form="new-form"/>
|
||||
<htk-entry column="title" form="iter"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><t>Tag:</t></label>
|
||||
<htk-combo column="tag" form="new-form">
|
||||
<htk-combo column="tag" form="iter">
|
||||
<db-model property="model">
|
||||
SELECT name, description FROM news_tag
|
||||
ORDER BY description
|
||||
|
@ -37,10 +47,6 @@
|
|||
<label><t>NewBody:</t></label>
|
||||
<textarea id="html-editor"/>
|
||||
</div>
|
||||
<div class="foot">
|
||||
<button id="new-cancel" class="vn"><t>Cancel</t></button>
|
||||
<button id="new-accept" class="vn"><t>Accept</t></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -204,7 +204,7 @@ Db.Conn.implement
|
|||
if (results[i] !== true)
|
||||
{
|
||||
var data = results[i].data;
|
||||
var columns = results[i].field;
|
||||
var columns = results[i].columns;
|
||||
|
||||
for (var j = 0; j < columns.length; j++)
|
||||
{
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
Vn.HttpRequest = new Class
|
||||
({
|
||||
kvPairs: {}
|
||||
|
||||
,add: function (map)
|
||||
{
|
||||
for (var key in map)
|
||||
this.kvPairs[key] = map[key];
|
||||
}
|
||||
|
||||
,send: function (file, callback)
|
||||
{
|
||||
this.request = new XMLHttpRequest ();
|
||||
this.request.open ('post', file, true);
|
||||
this.request.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');
|
||||
this.request.onreadystatechange = this.requestStateChanged.bind (this, callback);
|
||||
this.request.send (Vn.Url.makeUri (this.kvPairs));
|
||||
}
|
||||
|
||||
,requestStateChanged: function (callback)
|
||||
{
|
||||
if (this.request.readyState == 4)
|
||||
callback (this, this.request.status == 200);
|
||||
}
|
||||
|
||||
,getJson: function ()
|
||||
{
|
||||
return eval ('('+ this.request.responseText +')');
|
||||
}
|
||||
});
|
File diff suppressed because it is too large
Load Diff
|
@ -46,7 +46,7 @@ Db.ResultSet = new Class
|
|||
if (result !== null)
|
||||
{
|
||||
if (result.data instanceof Array)
|
||||
return new Db.Result (result.data, result.field);
|
||||
return new Db.Result (result);
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -6,20 +6,22 @@ Db.Result = new Class
|
|||
/**
|
||||
* Initilizes the result object.
|
||||
**/
|
||||
initialize: function (data, columns)
|
||||
initialize: function (result)
|
||||
{
|
||||
this.data = data;
|
||||
this.columns = columns;
|
||||
this.columnMap = null;
|
||||
this.data = result.data;
|
||||
this.tables = result.tables;
|
||||
this.columns = result.columns;
|
||||
this.row = -1;
|
||||
|
||||
if (columns)
|
||||
if (this.columns)
|
||||
{
|
||||
this.columnMap = {};
|
||||
|
||||
for (var i = 0; i < columns.length; i++)
|
||||
this.columnMap[columns[i].name] = i;
|
||||
for (var i = 0; i < this.columns.length; i++)
|
||||
this.columnMap[this.columns[i].name] = i;
|
||||
}
|
||||
else
|
||||
this.columnMap = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,12 @@ Sql.Dml = new Class
|
|||
this.field.push (new Sql.Field ({name: fieldName}));
|
||||
}
|
||||
|
||||
,addExpr: function (fieldName, expr)
|
||||
{
|
||||
this.expr.push (expr);
|
||||
this.field.push (new Sql.Field ({name: fieldName}));
|
||||
}
|
||||
|
||||
,delSet: function ()
|
||||
{
|
||||
this.field.splice (0, this.field.length);
|
||||
|
|
|
@ -14,6 +14,11 @@ Sql.Func = new Class
|
|||
type: String
|
||||
,value: null
|
||||
},
|
||||
schema:
|
||||
{
|
||||
type: String
|
||||
,value: null
|
||||
},
|
||||
params:
|
||||
{
|
||||
type: Sql.List
|
||||
|
@ -23,6 +28,7 @@ Sql.Func = new Class
|
|||
|
||||
,render: function (batch)
|
||||
{
|
||||
return this.name + '()';
|
||||
var sql = (this.schema) ? '`' + this.schema + '`.' : '';
|
||||
return sql + '`' + this.name + '`()';
|
||||
}
|
||||
});
|
||||
|
|
|
@ -13,6 +13,11 @@ Sql.MultiStmt = new Class
|
|||
return this.stmts.push (stmt);
|
||||
}
|
||||
|
||||
,getStmt: function (stmtIndex)
|
||||
{
|
||||
return this.stmts[index];
|
||||
}
|
||||
|
||||
,stmtChanged: function ()
|
||||
{
|
||||
this.signalEmit ('changed');
|
||||
|
@ -35,7 +40,12 @@ Sql.MultiStmt = new Class
|
|||
var sql = '';
|
||||
|
||||
for (var i = 0; i < this.stmts.length; i++)
|
||||
sql += this.stmts[i].render (batch) + '; ';
|
||||
{
|
||||
if (i > 0)
|
||||
sql += ";\n";
|
||||
|
||||
sql += this.stmts[i].render (batch);
|
||||
}
|
||||
|
||||
return sql;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ Vn.Builder = new Class
|
|||
,loadXmlFromNode: function (node)
|
||||
{
|
||||
this.contexts = [];
|
||||
var mainNode = this.loadNode (node, null);
|
||||
var mainNode = this.loadNode (node);
|
||||
this.resolveProperties ();
|
||||
delete this.contexts;
|
||||
return mainNode;
|
||||
|
@ -53,8 +53,9 @@ Vn.Builder = new Class
|
|||
this.objectMap[id] = object;
|
||||
}
|
||||
|
||||
,loadNode: function (node, parentContext)
|
||||
,loadNode: function (node)
|
||||
{
|
||||
var customNode;
|
||||
var htmlNode = null;
|
||||
var tagName = null;
|
||||
|
||||
|
@ -69,59 +70,32 @@ Vn.Builder = new Class
|
|||
{
|
||||
htmlNode = document.importNode (node, false);
|
||||
}
|
||||
else if ((customNode = this.loadCustomNode (node, null)))
|
||||
{
|
||||
if (customNode instanceof Htk.Widget)
|
||||
htmlNode = customNode.getNode ();
|
||||
}
|
||||
else
|
||||
{
|
||||
var vnObject = null;
|
||||
var context = null;
|
||||
var htmlNode = null;
|
||||
var klass = Vn.customTags[tagName];
|
||||
var nodeId = node.getAttribute ('id');
|
||||
htmlNode = document.createElement (tagName);
|
||||
|
||||
if (klass)
|
||||
{
|
||||
var vnObject = new klass ();
|
||||
|
||||
if (vnObject instanceof Htk.Widget)
|
||||
htmlNode = vnObject.getNode ();
|
||||
|
||||
if (!this.tags[tagName])
|
||||
this.tags[tagName] = [];
|
||||
|
||||
this.tags[tagName].push (vnObject);
|
||||
|
||||
context = {
|
||||
node: node
|
||||
,parent: parentContext
|
||||
,object: vnObject
|
||||
,klass: klass
|
||||
};
|
||||
this.contexts.push (context);
|
||||
}
|
||||
else
|
||||
{
|
||||
htmlNode = document.createElement (tagName);
|
||||
vnObject = htmlNode;
|
||||
var a = node.attributes;
|
||||
|
||||
var a = node.attributes;
|
||||
for (var i = 0; i < a.length; i++)
|
||||
if (a[i].nodeName !== 'id')
|
||||
htmlNode.setAttribute (a[i].nodeName,
|
||||
this.translateValue (a[i].nodeValue));
|
||||
|
||||
for (var i = 0; i < a.length; i++)
|
||||
if (a[i].nodeName !== 'id')
|
||||
htmlNode.setAttribute (a[i].nodeName,
|
||||
this.translateValue (a[i].nodeValue));
|
||||
}
|
||||
|
||||
if (nodeId)
|
||||
this.objectMap[nodeId] = vnObject;
|
||||
this.registerObject (node, htmlNode);
|
||||
|
||||
var childs = node.childNodes;
|
||||
|
||||
if (childs)
|
||||
for (var i = 0; i < childs.length; i++)
|
||||
{
|
||||
var htmlChild =
|
||||
this.loadNode (childs[i], context);
|
||||
var htmlChild = this.loadNode (childs[i]);
|
||||
|
||||
if (htmlChild && htmlNode)
|
||||
if (htmlChild)
|
||||
htmlNode.appendChild (htmlChild);
|
||||
}
|
||||
}
|
||||
|
@ -129,6 +103,51 @@ Vn.Builder = new Class
|
|||
return htmlNode;
|
||||
}
|
||||
|
||||
,loadCustomNode: function (node, parentContext)
|
||||
{
|
||||
if (!node.tagName)
|
||||
return null;
|
||||
|
||||
var tagName = node.tagName.toLowerCase ();
|
||||
var klass = Vn.customTags[tagName];
|
||||
|
||||
if (!klass)
|
||||
return null;
|
||||
|
||||
var customNode = new klass ();
|
||||
|
||||
if (!this.tags[tagName])
|
||||
this.tags[tagName] = [];
|
||||
|
||||
this.tags[tagName].push (customNode);
|
||||
|
||||
var context = {
|
||||
node: node
|
||||
,parent: parentContext
|
||||
,object: customNode
|
||||
,klass: klass
|
||||
};
|
||||
this.contexts.push (context);
|
||||
|
||||
this.registerObject (node, customNode);
|
||||
|
||||
var childs = node.childNodes;
|
||||
|
||||
if (childs)
|
||||
for (var i = 0; i < childs.length; i++)
|
||||
this.loadCustomNode (childs[i], context);
|
||||
|
||||
return customNode;
|
||||
}
|
||||
|
||||
,registerObject: function (node, object)
|
||||
{
|
||||
var nodeId = node.getAttribute ('id');
|
||||
|
||||
if (nodeId)
|
||||
this.objectMap[nodeId] = object;
|
||||
}
|
||||
|
||||
,translateValue: function (value)
|
||||
{
|
||||
var chr = value.charAt (0);
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
,"Title:": "Títol:"
|
||||
,"NewBody:": "Cos:"
|
||||
|
||||
,"Cancel": "Cancel"
|
||||
,"Return": "Tornar"
|
||||
,"Accept": "Acceptar"
|
||||
|
||||
,"NewChangedSuccessfully": "Notícia modificada correctament"
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
,"Title:": "Título:"
|
||||
,"NewBody:": "Cuerpo:"
|
||||
|
||||
,"Cancel": "Cancelar"
|
||||
,"Return": "Volver"
|
||||
,"Accept": "Aceptar"
|
||||
|
||||
,"NewChangedSuccessfully": "Noticia modificada correctamente"
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
,"Title:": "Titre:"
|
||||
,"NewBody:": "Corps:"
|
||||
|
||||
,"Cancel": "Annuler"
|
||||
,"Return": "Reviens"
|
||||
,"Accept": "Accepter"
|
||||
|
||||
,"NewChangedSuccessfully": "Nouvelles modifié avec succès"
|
||||
}
|
||||
|
|
|
@ -21,12 +21,14 @@ class RestMod extends Rest\Module
|
|||
|
||||
if ($result !== FALSE)
|
||||
{
|
||||
$tableMap = [];
|
||||
$columns = $result->fetch_fields ();
|
||||
|
||||
$resultMap =
|
||||
[
|
||||
'data' => [],
|
||||
'field' => []
|
||||
'data' => [],
|
||||
'columns' => [],
|
||||
'tables' => []
|
||||
];
|
||||
|
||||
for ($i = 0; $i < $result->field_count; $i++)
|
||||
|
@ -62,23 +64,39 @@ class RestMod extends Rest\Module
|
|||
default;
|
||||
$type = TYPE_STRING;
|
||||
}
|
||||
|
||||
if (!isset ($tableMap[$column->table]))
|
||||
{
|
||||
$resultMap['tables'][] =
|
||||
[
|
||||
'name' => $column->table,
|
||||
'orgname' => $column->orgtable,
|
||||
'schema' => $column->db,
|
||||
'pks' => []
|
||||
];
|
||||
$tableIndex = count ($resultMap['tables']) - 1;
|
||||
$tableMap[$column->table] = $tableIndex;
|
||||
}
|
||||
else
|
||||
$tableIndex = $tableMap[$column->table];
|
||||
|
||||
if ($column->flags & MYSQLI_PRI_KEY_FLAG)
|
||||
$resultMap['tables'][$tableIndex]['pks'][] = $i;
|
||||
|
||||
$default = $this->castValue ($column->def, $type);
|
||||
|
||||
$resultMap['field'][] =
|
||||
$resultMap['columns'][] =
|
||||
[
|
||||
'type' => $type,
|
||||
'flags' => $column->flags,
|
||||
'def' => $default,
|
||||
'name' => $column->name,
|
||||
'orgname' => $column->orgname,
|
||||
'table' => $column->table,
|
||||
'orgtable' => $column->orgtable,
|
||||
'def' => $default,
|
||||
'db' => $column->db,
|
||||
'flags' => $column->flags,
|
||||
'type' => $type
|
||||
'table' => $tableIndex
|
||||
];
|
||||
}
|
||||
|
||||
$columns = $resultMap['field'];
|
||||
$columns = $resultMap['columns'];
|
||||
|
||||
while ($row = $result->fetch_row ())
|
||||
{
|
||||
|
@ -95,6 +113,8 @@ class RestMod extends Rest\Module
|
|||
$results[] = TRUE;
|
||||
}
|
||||
while ($conn->moreResults () && $conn->nextResult ());
|
||||
|
||||
$conn->checkError ();
|
||||
}
|
||||
catch (Db\Exception $e)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue