0
1
Fork 0

Htk.Repater beta, errores arreglados

This commit is contained in:
Juan Ferrer Toribio 2015-03-09 09:36:54 +01:00
parent fe120f5196
commit 92293086a1
52 changed files with 344 additions and 289 deletions

View File

@ -1,5 +1,5 @@
Package: hedera-web
Version: 1.0-40
Version: 1.0-42
Architecture: all
Maintainer: Juan Ferrer Toribio <juan@verdnatura.es>
Depends: apache2, php5-mysql, php-vn-web

View File

@ -8,7 +8,7 @@
max-width: 50em;
margin: 0 auto;
}
.access-log grid tbody tr
.access-log .htk-grid tbody tr
{
height: 3.4em;
}

View File

@ -68,12 +68,12 @@
<item name="user" param="user"/>
</sql-batch>
</db-model>
<htk-column-date title="Access" column="date_time" format="%a, %e %b %Y at %T"/>
<htk-column-text title="SO" column="platform"/>
<htk-column-text title="Browser" column="browser"/>
<htk-column-text title="Version" column="version"/>
<htk-column-check title="Javascript" column="javascript"/>
<htk-column-check title="Cookies" column="cookies"/>
<htk-column-date title="_Access" column="date_time" format="_%a, %e %b %Y at %T"/>
<htk-column-text title="_SO" column="platform"/>
<htk-column-text title="_Browser" column="browser"/>
<htk-column-text title="_Version" column="version"/>
<htk-column-check title="_Javascript" column="javascript"/>
<htk-column-check title="_Cookies" column="cookies"/>
</htk-grid>
</div>
</div>

View File

@ -136,7 +136,7 @@
<htk-column-text title="_Browser" column="browser"/>
<htk-column-spin title="_MinVersion" column="min_version" digits="1"/>
<htk-column-spin title="_MaxVersion" column="max_version" digits="1"/>
<htk-column-date title="_LastVisit" column="last_visit" format="%a, %e %b %Y at %T"/>
<htk-column-date title="_LastVisit" column="last_visit" format="_%a, %e %b %Y at %T"/>
<htk-column-spin title="_Visits" column="visits"/>
<htk-column-spin title="_NewVisits" column="new_visits"/>
</htk-grid>

View File

@ -2,142 +2,7 @@
Vn.Home = new Class
({
Extends: Vn.Module
,dateFormat: _('%a, %e %b %Y')
,activate: function ()
{
var query = 'SELECT title, date_time, text, id FROM news '
+'WHERE tag != \'course\' '
+'ORDER BY priority, date_time DESC';
this.conn.execQuery (query, this.onNewsQueryDone.bind (this));
/* this.answer = new Htk.RadioGroup ();
var query = 'SELECT question, @id := id FROM survey ORDER BY id DESC LIMIT 1; '
+'SELECT id, answer, votes FROM survey_answer WHERE survey_id = @id';
this.conn.execQuery (query, this.answersQueryDone.bind (this));
this.$('vote-button').addEventListener ('click', this.voteClicked.bind (this));
*/ }
,onNewsQueryDone: function (resultSet)
{
var newsColumn = this.$('news-column');
var res = resultSet.fetchResult ();
if (res)
while (res.next ())
{
var div = document.createElement ('div');
div.className = 'new';
var title = document.createElement ('h2');
title.appendChild (document.createTextNode (res.get ('title')));
div.appendChild (title);
var p = document.createElement ('p');
p.className = 'new-info';
div.appendChild (p);
var date = Vn.Date.strftime (res.get ('date_time'), this.dateFormat);
p.appendChild (document.createTextNode (date));
var text = document.createElement ('div');
text.className = 'new-text';
div.appendChild (text);
var html = '' + res.get ('text');
text.innerHTML = html;
var img = document.createElement ('img');
img.alt = '';
img.src = Vn.Config['image_dir'] + '/news/full/' + res.get ('id') + '.png';
div.appendChild (img);
newsColumn.appendChild (div);
}
}
,answersQueryDone: function (resultSet)
{
var value = resultSet.fetchValue ();
var question = this.$('question');
question.appendChild (document.createTextNode (value));
var res = resultSet.fetchResult ();
this.totalVotes = 0;
var answers = this.$('answers');
if (res)
while (res.next ())
{
var tr = document.createElement ('tr');
answers.appendChild (tr);
var td = document.createElement ('td');
td.className = 'radio';
tr.appendChild (td);
var radio = this.answer.createButton (res.get ('id'));
td.appendChild (radio);
var td = document.createElement ('td');
tr.appendChild (td);
var label = document.createElement ('label');
label.appendChild (document.createTextNode (res.get ('answer')));
td.appendChild (label);
var tr = document.createElement ('tr');
answers.appendChild (tr);
var td = document.createElement ('td');
tr.appendChild (td);
var td = document.createElement ('td');
tr.appendChild (td);
var text = document.createTextNode (res.get ('votes') + ' ' + _('votes'));
td.appendChild (text);
this.totalVotes += res.get ('votes');
}
this.refreshVotes ();
}
,refreshVotes: function ()
{
var totalNode = this.$('total');
Vn.Node.setText (totalNode, this.totalVotes);
}
,voteClicked: function ()
{
if (this.answer.value)
{
var query = 'CALL survey_vote (#id)';
var batch = new Sql.Batch ();
batch.addParam ('id', this.answer);
this.conn.execQuery (query, this.voteDone.bind (this), batch);
}
else
alert (_('NoAnswerSelected'));
}
,voteDone: function (resultSet)
{
if (resultSet.fetchResult ())
{
this.totalVotes++;
this.refreshVotes ();
alert (_('ThanksForVote'));
}
}
,activate: function () {}
});

View File

@ -1,17 +1,25 @@
<vn>
<vn-group>
<db-model id="news">
SELECT title, date_time, text, id FROM news
WHERE tag != 'course'
ORDER BY priority, date_time DESC
</db-model>
</vn-group>
<div id="form" class="home">
<div class="column" id="news-column"/>
<!--
<div class="survey">
<div id="question" class="question"/>
<table>
<tbody id="answers" class="answers"/>
</table>
<div class="survey-votes">
<t>Total</t> <span id="total"/> <t>votes</t>
</div>
<button id="vote-button"><t>Vote</t></button>
<div class="column" id="news-column">
<htk-repeater model="news" form-id="new">
<div class="new">
<h2><htk-text form="new" column="title"/></h2>
<p class="new-info">
<htk-text format="_%a, %e %b %Y" form="new" column="date_time"/>
</p>
<div class="new-text">
<htk-html form="new" column="text"/>
</div>
<htk-image directory="news/full" form="new" column="id"/>
</div>
</htk-repeater>
</div>
-->
</div>
</vn>

View File

@ -2,52 +2,6 @@
Vn.Training = new Class
({
Extends: Vn.Module
,dateFormat: _('%a, %e %b %Y')
,activate: function ()
{
var query = 'SELECT title, date_time, text, id FROM news '
+'WHERE tag = \'course\' '
+'ORDER BY priority, date_time DESC';
this.conn.execQuery (query, this.onCoursesQueryDone.bind (this));
}
,onCoursesQueryDone: function (resultSet)
{
var coursesColumn = this.$('courses-column');
var res = resultSet.fetchResult ();
if (res)
while (res.next ())
{
var div = document.createElement ('div');
div.className = 'new';
var title = document.createElement ('h2');
title.appendChild (document.createTextNode (res.get ('title')));
div.appendChild (title);
var p = document.createElement ('p');
p.className = 'new-info';
div.appendChild (p);
var date = Vn.Date.strftime (res.get ('date_time'), this.dateFormat);
p.appendChild (document.createTextNode (date));
var text = document.createElement ('div');
text.className = 'new-text';
div.appendChild (text);
var html = '' + res.get ('text');
text.innerHTML = html;
var img = document.createElement ('img');
img.alt = '';
img.src = Vn.Config['image_dir'] + '/news/full/' + res.get ('id') + '.png';
div.appendChild (img);
coursesColumn.appendChild (div);
}
}
,activate: function () {}
});

View File

@ -1,5 +1,25 @@
<vn>
<vn-group>
<db-model id="news">
SELECT title, date_time, text, id FROM news
WHERE tag = 'course'
ORDER BY priority, date_time DESC
</db-model>
</vn-group>
<div id="form" class="training">
<div class="column" id="courses-column"/>
<div class="column" id="courses-column">
<htk-repeater model="news" form-id="course">
<div class="new">
<h2><htk-text form="course" column="title"/></h2>
<p class="new-info">
<htk-text format="_%a, %e %b %Y" form="course" column="date_time"/>
</p>
<div class="new-text">
<htk-html form="course" column="text"/>
</div>
<htk-image directory="news/full" form="course" column="id"/>
</div>
</htk-repeater>
</div>
</div>
</vn>

View File

@ -29,7 +29,6 @@
.catalog div.main .box
{
margin: 0 auto;
min-width: 52em;
max-width: 70em;
}
@ -185,7 +184,24 @@ table.types td.grid-message
padding-top: 1em;
}
/* Items */
/* Box view */
.item-box
{
padding: 1em;
border-bottom: 1px solid #DDD;
height: 14em;
}
.item-box img
{
float: left;
margin-right: 1em;
max-width: 14em;
max-height: 14em;
}
/* List view */
table.items
{

View File

@ -25,6 +25,27 @@
<sql-search-tags param="search"/>
</sql-filter-item>
</sql-filter>
<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
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
LEFT JOIN order_row_view m
ON m.item_id = a.Id_Article AND m.order_id = #order
WHERE #filter AND available > 0
ORDER BY Article, Medida
LIMIT 400;
DROP TEMPORARY TABLE vn2008.item_catalog;
<sql-batch property="batch" id="batch">
<item name="warehouse" param="warehouse"/>
<item name="date" param="date"/>
<item name="order" param="order"/>
<item name="filter" object="filter"/>
</sql-batch>
</db-model>
</vn-group>
<div id="form" class="catalog">
<div class="center">
@ -42,28 +63,22 @@
</div>
</div>
</div>
<htk-grid empty-message="_SelectSubtype" id="items-grid" class="items">
<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
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
LEFT JOIN order_row_view m
ON m.item_id = a.Id_Article AND m.order_id = #order
WHERE #filter AND available > 0
ORDER BY Article, Medida
LIMIT 400;
DROP TEMPORARY TABLE vn2008.item_catalog;
<sql-batch property="batch" id="batch">
<item name="warehouse" param="warehouse"/>
<item name="date" param="date"/>
<item name="order" param="order"/>
<item name="filter" object="filter"/>
</sql-batch>
</db-model>
<!-- <htk-repeater model="items-model" form-id="item">
<div class="item-box">
<htk-image form="item" column="Foto" directory="catalog/200x200"/>
<p>
<htk-text form="item" column="Article"/>
</p>
<p>
<htk-text form="item" column="Categoria"/> /
<htk-text form="item" column="Medida"/> /
<htk-text form="item" column="Color"/> /
<htk-text form="item" column="Tallos"/>
</p>
<div class="clear"/>
</div>
</htk-repeater>
--> <htk-grid empty-message="_SelectSubtype" id="items-grid" class="items" model="items-model">
<htk-column-image title="*" column="Foto" directory="catalog" subdir="200x200" show-full="true" editable="true"/>
<htk-column-text title="_Pack" column="grouping" format="x%.0d"/>
<htk-column-spin title="_Aval" column="available"/>

View File

@ -7,7 +7,7 @@
{
max-width: 70em;
}
.orders .grid tbody tr
.orders .htk-grid tbody tr
{
height: 5em;
}

View File

Before

Width:  |  Height:  |  Size: 485 B

After

Width:  |  Height:  |  Size: 485 B

View File

Before

Width:  |  Height:  |  Size: 597 B

After

Width:  |  Height:  |  Size: 597 B

View File

Before

Width:  |  Height:  |  Size: 590 B

After

Width:  |  Height:  |  Size: 590 B

View File

Before

Width:  |  Height:  |  Size: 636 B

After

Width:  |  Height:  |  Size: 636 B

View File

Before

Width:  |  Height:  |  Size: 409 B

After

Width:  |  Height:  |  Size: 409 B

View File

Before

Width:  |  Height:  |  Size: 578 B

After

Width:  |  Height:  |  Size: 578 B

View File

Before

Width:  |  Height:  |  Size: 633 B

After

Width:  |  Height:  |  Size: 633 B

View File

Before

Width:  |  Height:  |  Size: 935 B

After

Width:  |  Height:  |  Size: 935 B

View File

Before

Width:  |  Height:  |  Size: 397 B

After

Width:  |  Height:  |  Size: 397 B

View File

Before

Width:  |  Height:  |  Size: 784 B

After

Width:  |  Height:  |  Size: 784 B

View File

Before

Width:  |  Height:  |  Size: 447 B

After

Width:  |  Height:  |  Size: 447 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 434 B

After

Width:  |  Height:  |  Size: 434 B

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

Before

Width:  |  Height:  |  Size: 503 B

After

Width:  |  Height:  |  Size: 503 B

View File

Before

Width:  |  Height:  |  Size: 622 B

After

Width:  |  Height:  |  Size: 622 B

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 359 B

After

Width:  |  Height:  |  Size: 359 B

View File

Before

Width:  |  Height:  |  Size: 805 B

After

Width:  |  Height:  |  Size: 805 B

View File

Before

Width:  |  Height:  |  Size: 576 B

After

Width:  |  Height:  |  Size: 576 B

View File

Before

Width:  |  Height:  |  Size: 684 B

After

Width:  |  Height:  |  Size: 684 B

View File

Before

Width:  |  Height:  |  Size: 407 B

After

Width:  |  Height:  |  Size: 407 B

View File

Before

Width:  |  Height:  |  Size: 510 B

After

Width:  |  Height:  |  Size: 510 B

View File

@ -0,0 +1,16 @@
Htk.Html = new Class
({
Extends: Htk.Field
,Tag: 'htk-html'
,initialize: function (props)
{
this.parent (props);
this.createElement ('div');
}
,putValue: function (value)
{
this.node.innerHTML = value;
}
});

View File

@ -2,18 +2,39 @@ Htk.Image = new Class
({
Extends: Htk.Entry
,Tag: 'htk-image'
,Properties:
{
/**
* The directory where the images are allocated.
**/
directory:
{
type: String
,set: function (x)
{
this._directory = x;
this.basedir = Vn.Config['image_dir'] +'/'+ x;
this.render (false);
}
,get: function ()
{
return this._directory;
}
}
}
,_directory: null
,basedir: null
,empty: false
,file: null
,initialize: function (props)
{
this.parent (props);
this.node = document.getElementById (nodeId);
this.node.addEventListener ('error', this.error.bind (this));
this.createElement ('img');
// this.node.addEventListener ('error', this.onImageError.bind (this));
}
,error: function ()
,onImageError: function ()
{
if (!this.empty)
{
@ -24,24 +45,26 @@ Htk.Image = new Class
,render: function (force)
{
if (this.realValue)
if (this._value)
{
this.file = this.realValue + '.png';
var url = '';
if (this.basedir)
url += this.basedir +'/';
url += this._value;
if (force)
this.file += '?' + (new Date()).getTime ();
url += '?' + (new Date()).getTime ();
this.empty = false;
this.node.src = this.url + '/' + this.file;
this.node.src = url;
}
else
{
this.file = null;
this.error ();
}
this.onImageError ();
}
,setRealValue: function (value)
,putValue: function (value)
{
this.render (false);
}
@ -50,11 +73,9 @@ Htk.Image = new Class
{
if (show)
{
var obj = this;
this.node.addEventListener ('mouseover',
function () { obj.mouseOver () }, false);
this.node.addEventListener ('mouseout',
function () { obj.mouseOut () }, false);
this.fullImage = new Htk.FullImage ();
this.node.addEventListener ('mouseover', this.onMouseOver.bind (this));
this.node.addEventListener ('mouseout', this.onMouseOut.bind (this));
}
}
@ -65,29 +86,29 @@ Htk.Image = new Class
var obj = this;
this.style.cursor = 'pointer';
this.node.addEventListener ('dblclick',
function (e) { obj.dblClicked (e) }, false);
this.onDoubleClick.bind (this));
}
}
,dblClicked: function (event)
,onDoubleClick: function (event)
{
var form = htkImageForm.node;
form.style.top = getPageYOffset () + (event.clientY - 80) + 'px';
form.style.left = (event.clientX + 30) + 'px';
document.body.appendChild (form);
htkImageForm.load (this);
var editor = new Htk.ImageEditor ();
editor.setData (cell.value, this._directory);
this.popup = new Htk.Popup ();
this.popup.setChild (editor);
this.popup.show (this.node);
}
,mouseOver: function ()
,onMouseOver: function (cell)
{
if (!this.empty)
htkImageFull.show (this.url + '/../full', this.file);
if (!cell.empty)
this.fullImage.show (this.basedir, cell.value);
}
,mouseOut: function ()
,onMouseOut: function ()
{
if (!this.empty)
htkImageFull.hide ();
this.fullImage.hide ();
}
});

View File

@ -13,6 +13,7 @@ Htk.Label = new Class
,set: function (x)
{
this._format = _(x);
this.putValue (this._value);
}
,get: function ()
{

View File

@ -0,0 +1,37 @@
Htk.Text = new Class
({
Extends: Htk.Field
,Tag: 'htk-text'
,Properties:
{
/**
* Format that applies to the value.
**/
format:
{
type: String
,set: function (x)
{
this._format = _(x);
this.putValue (this._value);
}
,get: function ()
{
return this._format;
}
}
}
,_format: null
,initialize: function (props)
{
this.parent (props);
this.node = document.createTextNode ('');
}
,putValue: function (value)
{
this.node.nodeValue = Vn.Value.format (value, this._format);
}
});

View File

@ -42,7 +42,7 @@ Htk.ImageEditor = new Class
this.$('name').addEventListener ('change', function ()
{
this.signalEmit ('name-changed', this.nameInput.value);
this.signalEmit ('name-changed', this.$('name').value);
}
.bind (this));
}

View File

@ -7,11 +7,14 @@ Vn\Hedera\Js::includeLib ('htk'
,'widget'
,'popup'
,'toast'
,'repeater'
,'grid'
,'radio-group'
,'full-image'
,'image-editor'
,'field'
,'field/text'
,'field/html'
,'field/entry'
,'field/radio'
,'field/label'

View File

@ -0,0 +1,102 @@
Htk.Repeater = new Class
({
Extends: Htk.Widget
,Tag: 'htk-repeater'
,Properties:
{
model:
{
type: Db.Model
,set: function (x)
{
this.link ({_model: x},
{
'status-changed': this.onModelChange
,'row-deleted': this.onRowDelete
,'row-updated': this.onRowUpdate
,'row-inserted': this.onRowInsert
,'updatable-changed': this.onUpdatableChange
});
this.onModelChange ();
}
,get: function ()
{
this._model;
}
}
,formId:
{
type: String
,set: function (x)
{
this._alias = x;
}
,get: function ()
{
this._alias;
}
}
}
,xml: null
,parentBuilder: null
,_alias: 'form'
,initialize: function ()
{
this.createElement ('div');
}
,loadXml: function (builder, node)
{
this.xml = node.firstElementChild;
this.parentBuilder = builder;
this.onModelChange ();
}
,onModelChange: function ()
{
if (!this._model || !this.xml)
return;
Vn.Node.removeChilds (this.node);
if (!this._model.ready)
return;
for (var i = 0; i < this._model.numRows; i++)
{
var builder = new Vn.Builder ();
var form = new Db.Form ();
form.model = this._model;
form.row = i;
builder.add (this._alias, form);
var mainNode = builder.loadXmlFromNode (this.xml);
this.node.appendChild (mainNode);
}
}
,onRowDelete: function (model, row)
{
var childs = this.node.childNodes;
this.node.removeChild (childs[row]);
}
,onRowUpdate: function ()
{
}
,onRowInsert: function ()
{
}
,onUpdatableChange: function ()
{
}
});

View File

@ -38,19 +38,7 @@ Htk.Widget = new Class
{
return this.node;
}
,ui: function (uiFile)
{
this.builder = new Vn.Builder ();
this.builder.load (uiFile, this.onUiReady.bind (this));
}
,onUiReady: function ()
{
this.node = this.builder.getNode ();
this.uiReady ();
}
,$: function (id)
{
if (this.builder)
@ -58,10 +46,4 @@ Htk.Widget = new Class
return null;
}
/**
* Virtual method that shoud be implemented by all widgets using the ui
* builder.
**/
,uiReady: function () {}
});

View File

@ -16,11 +16,6 @@ Vn.Builder = new Class
this.objectMap[key].destroy ();
}
}
,getNode: function ()
{
return this.mainNode;
}
,loadXml: function (xmlDoc)
{
@ -43,6 +38,20 @@ Vn.Builder = new Class
delete this.contexts;
return true;
}
,loadXmlFromNode: function (node)
{
this.contexts = [];
var mainNode = this.loadNode (node, null);
this.resolveProperties ();
delete this.contexts;
return mainNode;
}
,add: function (id, object)
{
this.objectMap[id] = object;
}
,loadNode: function (node, parentContext)
{

View File

@ -72,7 +72,7 @@ a
{
position: absolute;
margin-top: -17em;
padding: 2em;
padding: 1em;
max-width: 45em;
top: 50%;
left: 0;

View File

@ -47,6 +47,12 @@ Vn.Web =
{
event.stopPropagation ();
});
if (!Vn.Cookie.check ('hedera_cookies'))
{
Vn.Cookie.set ('hedera_cookies', true);
(new Htk.Toast ()).showWarning (_('CookiesNotification'));
}
}
,showBackground: function ()