0
1
Fork 0
This commit is contained in:
Juan Ferrer Toribio 2017-10-18 18:01:21 +02:00
parent e178c74f25
commit f6603ccc13
46 changed files with 734 additions and 606 deletions

View File

@ -16,7 +16,7 @@
</db-model> </db-model>
</vn-group> </vn-group>
<h1 id="title"> <h1 id="title">
<t>Addresses</t> _Addresses
</h1> </h1>
<div id="actions"> <div id="actions">
<htk-bar-button <htk-bar-button

View File

@ -20,7 +20,7 @@
</db-form> </db-form>
</vn-group> </vn-group>
<h1 id="title"> <h1 id="title">
<t>AddEditAddress</t> _AddEditAddress
</h1> </h1>
<div id="actions"> <div id="actions">
<htk-bar-button <htk-bar-button
@ -35,23 +35,23 @@
<div id="main" class="address"> <div id="main" class="address">
<div class="card form"> <div class="card form">
<div> <div>
<label><t>Name</t></label> <label>_Name</label>
<htk-entry lot="iter" name="consignee"/> <htk-entry lot="iter" name="consignee"/>
</div> </div>
<div> <div>
<label><t>Address</t></label> <label>_Address</label>
<htk-entry lot="iter" name="name"/> <htk-entry lot="iter" name="name"/>
</div> </div>
<div> <div>
<label><t>City</t></label> <label>_City</label>
<htk-entry lot="iter" name="city"/> <htk-entry lot="iter" name="city"/>
</div> </div>
<div> <div>
<label><t>ZipCode</t></label> <label>_ZipCode</label>
<htk-entry lot="iter" name="zip_code"/> <htk-entry lot="iter" name="zip_code"/>
</div> </div>
<div> <div>
<label><t>Country</t></label> <label>_Country</label>
<htk-combo> <htk-combo>
<vn-param <vn-param
id="country" id="country"
@ -66,7 +66,7 @@
</htk-combo> </htk-combo>
</div> </div>
<div> <div>
<label><t>Province</t></label> <label>_Province</label>
<htk-combo lot="iter" name="province_id"> <htk-combo lot="iter" name="province_id">
<db-model property="model" lot="iter"> <db-model property="model" lot="iter">
SELECT province_id, name FROM vn2008.province SELECT province_id, name FROM vn2008.province

View File

@ -6,7 +6,6 @@ Hedera.Conf = new Class
,activate: function () ,activate: function ()
{ {
this.$('user-model').setInfo ('c', 'customer_view', 'hedera'); this.$('user-model').setInfo ('c', 'customer_view', 'hedera');
this.$('addresses').setInfo ('a', 'address_view', 'hedera');
} }
,onPassChangeClick: function () ,onPassChangeClick: function ()

View File

@ -16,7 +16,7 @@
</db-form> </db-form>
</vn-group> </vn-group>
<h1 id="title"> <h1 id="title">
<t>Configuration</t> _Configuration
</h1> </h1>
<div id="actions"> <div id="actions">
<htk-bar-button <htk-bar-button
@ -31,15 +31,15 @@
<div id="main" class="conf"> <div id="main" class="conf">
<div class="card form"> <div class="card form">
<div> <div>
<label for="user-name"><t>Username</t></label> <label for="user-name">_Username</label>
<htk-text lot="user" name="name"/> <htk-text lot="user" name="name"/>
</div> </div>
<div> <div>
<label for="email"><t>Email</t></label> <label for="email">_Email</label>
<htk-entry lot="user" name="email"></htk-entry> <htk-entry lot="user" name="email"></htk-entry>
</div> </div>
<div> <div>
<label for="mail"><t>Receive invoices by email</t></label> <label for="mail">_Receive invoices by email</label>
<htk-check lot="user" name="mail"/> <htk-check lot="user" name="mail"/>
</div> </div>
</div> </div>
@ -64,10 +64,10 @@
</div> </div>
<div class="button-bar"> <div class="button-bar">
<button class="thin" on-click="onPassModifyClick"> <button class="thin" on-click="onPassModifyClick">
<t>Modify</t> _Modify
</button> </button>
<button class="thin" on-click="onPassInfoClick"> <button class="thin" on-click="onPassInfoClick">
<t>Info</t> _Info
</button> </button>
<div class="clear"/> <div class="clear"/>
</div> </div>
@ -78,28 +78,23 @@
modal="true"> modal="true">
<div property="child-node" class="htk-dialog pass-info"> <div property="child-node" class="htk-dialog pass-info">
<h3> <h3>
<t>Password requirements</t> _Password requirements
</h3> </h3>
<ul> <ul>
<li> <li>
<htk-text lot="password-form" name="length"/> <htk-text lot="password-form" name="length"/> <t>characters long</t>
<t>characters long</t>
</li> </li>
<li> <li>
<htk-text lot="password-form" name="nAlpha"/> <htk-text lot="password-form" name="nAlpha"/> <t>alphabetic characters</t>
<t>alphabetic characters</t>
</li> </li>
<li> <li>
<htk-text lot="password-form" name="nUpper"/> <htk-text lot="password-form" name="nUpper"/> <t>capital letters</t>
<t>capital letters</t>
</li> </li>
<li> <li>
<htk-text lot="password-form" name="nDigits"/> <htk-text lot="password-form" name="nDigits"/> <t>digits</t>
<t>digits</t>
</li> </li>
<li> <li>
<htk-text lot="password-form" name="nPunct"/> <htk-text lot="password-form" name="nPunct"/> <t>symbols</t>
<t>symbols</t>
</li> </li>
</ul> </ul>
</div> </div>

View File

@ -1,95 +1,95 @@
<vn> <vn>
<h1 id="title"> <h1 id="title">
<t>About</t> _About
</h1> </h1>
<div id="main" class="about"> <div id="main" class="about">
<div class="cols"> <div class="cols">
<div class="card"> <div class="card">
<h1> <h1>
<t>QualityAndVariety</t> _QualityAndVariety
</h1> </h1>
<p><t>MaximumFreshness</t></p> <p>_MaximumFreshness</p>
<h3><t>SquareMeters</t></h3> <h3>_SquareMeters</h3>
<img src="forms/cms/about/image/store.png" alt="store"/> <img src="forms/cms/about/image/store.png" alt="store"/>
<h3><t>AboutRealms</t></h3> <h3>_AboutRealms</h3>
<p><t>AboutLocation</t></p> <p>_AboutLocation</p>
<img src="forms/cms/about/image/trailer.png" alt="trailer"/> <img src="forms/cms/about/image/trailer.png" alt="trailer"/>
<p> <p>
<img src="forms/cms/about/image/dealer.png" alt="dealer"/> <img src="forms/cms/about/image/dealer.png" alt="dealer"/>
<t>PurchaseThroughWeb</t> _PurchaseThroughWeb
</p> </p>
<img src="forms/cms/about/image/palletizing.png" alt="palletizing"/> <img src="forms/cms/about/image/palletizing.png" alt="palletizing"/>
</div> </div>
<div class="card"> <div class="card">
<h1> <h1>
<t>WhatMakeUsDifferent</t> _WhatMakeUsDifferent
</h1> </h1>
<p><t>DesignVariety</t></p> <p>_DesignVariety</p>
<img src="forms/cms/about/image/differentiates_us.png" alt="differentiates_us"/> <img src="forms/cms/about/image/differentiates_us.png" alt="differentiates_us"/>
<p><t>AdaptToYourNeeds</t></p> <p>_AdaptToYourNeeds</p>
<h3><t>TheBestQuality</t></h3> <h3>_TheBestQuality</h3>
</div> </div>
<div class="card"> <div class="card">
<h1> <h1>
<t>AtYourService</t> _AtYourService
</h1> </h1>
<h2><t>BuyersAndTraders</t></h2> <h2>_BuyersAndTraders</h2>
<img src="forms/cms/about/image/commercial.png" alt="commercial"/> <img src="forms/cms/about/image/commercial.png" alt="commercial"/>
</div> </div>
<div class="card"> <div class="card">
<h1> <h1>
<t>Verdnatura training</t> _Verdnatura training
</h1> </h1>
<p><t>GoodTraining</t></p> <p>_GoodTraining</p>
<img src="forms/cms/about/image/training.png" alt="training"/> <img src="forms/cms/about/image/training.png" alt="training"/>
<p><t>SpecialTrainingPrices</t></p> <p>_SpecialTrainingPrices</p>
<img src="forms/cms/about/image/courses.png" alt="courses"/> <img src="forms/cms/about/image/courses.png" alt="courses"/>
<h2><t>YoutubeChannel</t></h2> <h2>_YoutubeChannel</h2>
<img src="forms/cms/about/image/youtube.png" alt="youtube"/> <img src="forms/cms/about/image/youtube.png" alt="youtube"/>
</div> </div>
<div class="card"> <div class="card">
<h1> <h1>
<t>HowWeWork</t> _HowWeWork
</h1> </h1>
<p><t>AalsmeerAuction</t></p> <p>_AalsmeerAuction</p>
<img src="forms/cms/about/image/auction.png" alt="auction"/> <img src="forms/cms/about/image/auction.png" alt="auction"/>
<p><t>BeforeAuction</t></p> <p>_BeforeAuction</p>
<img src="forms/cms/about/image/producers.png" alt="producers"/> <img src="forms/cms/about/image/producers.png" alt="producers"/>
<p><t>DirectlyFromProviders</t></p> <p>_DirectlyFromProviders</p>
<p><t>GoodsDischarge</t></p> <p>_GoodsDischarge</p>
<img src="forms/cms/about/image/goods_transport.png" alt="goods_transport"/> <img src="forms/cms/about/image/goods_transport.png" alt="goods_transport"/>
<h2> <h2>
<t>FirstQualityControl</t> _FirstQualityControl
<img src="forms/cms/about/image/glass.png" alt="glass"/> <img src="forms/cms/about/image/glass.png" alt="glass"/>
</h2> </h2>
<img src="forms/cms/about/image/goods_receive.png" alt="goods_receive"/> <img src="forms/cms/about/image/goods_receive.png" alt="goods_receive"/>
<p><t>GoodsTravel</t></p> <p>_GoodsTravel</p>
<img src="forms/cms/about/image/2_control.png" alt="2_control"/> <img src="forms/cms/about/image/2_control.png" alt="2_control"/>
<p><t>GoodsReception</t></p> <p>_GoodsReception</p>
<h2> <h2>
<t>SecondQualityControl</t> _SecondQualityControl
<img src="forms/cms/about/image/glass.png" alt="glass"/> <img src="forms/cms/about/image/glass.png" alt="glass"/>
</h2> </h2>
<p><t>CustomerOrders</t></p> <p>_CustomerOrders</p>
<img src="forms/cms/about/image/web.png" alt="web"/> <img src="forms/cms/about/image/web.png" alt="web"/>
<p><t>AfterOrder</t></p> <p>_AfterOrder</p>
<img src="forms/cms/about/image/4_control.png" alt="4_control"/> <img src="forms/cms/about/image/4_control.png" alt="4_control"/>
<h2> <h2>
<t>ThirdQualityControl</t> _ThirdQualityControl
<img src="forms/cms/about/image/glass.png" alt="glass"/> <img src="forms/cms/about/image/glass.png" alt="glass"/>
</h2> </h2>
<p><t>BuyerControl</t></p> <p>_BuyerControl</p>
<h2> <h2>
<t>FourthQualityControl</t> _FourthQualityControl
<img src="forms/cms/about/image/glass.png" alt="glass"/> <img src="forms/cms/about/image/glass.png" alt="glass"/>
</h2> </h2>
<p><t>EmbeddedSection</t></p> <p>_EmbeddedSection</p>
<img src="forms/cms/about/image/fit.png" alt="fit"/> <img src="forms/cms/about/image/fit.png" alt="fit"/>
<p><t>AfterEmbedAgency</t></p> <p>_AfterEmbedAgency</p>
<img src="forms/cms/about/image/agencies.png" alt="agencies"/> <img src="forms/cms/about/image/agencies.png" alt="agencies"/>
<p><t>FreshnessGuaranteed</t></p> <p>_FreshnessGuaranteed</p>
<p class="summary"> <p class="summary">
<t>AboutSummary</t> _AboutSummary
<img src="image/logo.svg" alt="Verdnatura"/> <img src="image/logo.svg" alt="Verdnatura"/>
</p> </p>
</div> </div>

View File

@ -1,6 +1,6 @@
<vn> <vn>
<h1 id="title"> <h1 id="title">
<t>IWantCustomer</t> _IWantCustomer
</h1> </h1>
<div id="main" class="contact"> <div id="main" class="contact">
<form <form
@ -8,45 +8,45 @@
<input type="hidden" name="srv" value="json:misc/contact"/> <input type="hidden" name="srv" value="json:misc/contact"/>
<div class="card form"> <div class="card form">
<p> <p>
<t>FillFormData</t> _FillFormData
</p> </p>
<p> <p>
<t>OrCallUs</t> _OrCallUs
</p> </p>
<div> <div>
<label><t>Name</t></label> <label>_Name</label>
<input type="text" name="name"/> <input type="text" name="name"/>
</div> </div>
<div> <div>
<label><t>City</t></label> <label>_City</label>
<input type="text" name="city"/> <input type="text" name="city"/>
</div> </div>
<div> <div>
<label><t>PC</t></label> <label>_PC</label>
<input type="text" name="pc"/> <input type="text" name="pc"/>
</div> </div>
<div> <div>
<label><t>Phone</t></label> <label>_Phone</label>
<input type="text" name="phone"/> <input type="text" name="phone"/>
</div> </div>
<div> <div>
<label><t>EMail</t></label> <label>_EMail</label>
<input type="text" name="email"/> <input type="text" name="email"/>
</div> </div>
<div> <div>
<label><t>Message</t></label> <label>_Message</label>
<textarea name="message"/> <textarea name="message"/>
</div> </div>
<div class="form-group captcha"> <div class="form-group captcha">
<label><t>Anti-Spam</t></label> <label>_Anti-Spam</label>
<input type="text" name="captcha"/> <input type="text" name="captcha"/>
<img alt="Captcha" id="captcha-img"/> <img alt="Captcha" id="captcha-img"/>
</div> </div>
<p class="mandatory-message"> <p class="mandatory-message">
<t>AllFieldsMandatory</t> _AllFieldsMandatory
</p> </p>
<button class="thin"> <button class="thin">
<t>Send</t> _Send
</button> </button>
</div> </div>
</form> </form>

View File

@ -539,6 +539,13 @@ Vn.Filter = new Class
this._label.nodeValue = _('Loading...'); this._label.nodeValue = _('Loading...');
} }
} }
,_destroy: function ()
{
this._select.unref ();
this._modelLot.unref ();
this.parent ();
}
}); });
})(); })();

View File

@ -218,13 +218,12 @@
<div id="filters" class="filters"> <div id="filters" class="filters">
<h2><t>Filter by</t></h2> <h2><t>Filter by</t></h2>
<vn-filter <vn-filter
lot="params"
name="type" name="type"
lot="params"
placeholder="_Family"> placeholder="_Family">
<db-model <db-model
id="types" id="types"
property="model" property="model"
conn="conn"
lot="params" lot="params"
result-index="1" result-index="1"
on-status-changed="refreshTitle"> on-status-changed="refreshTitle">
@ -240,8 +239,8 @@
</vn-filter> </vn-filter>
<vn-filter <vn-filter
id="test" id="test"
lot="params"
name="color" name="color"
lot="params"
placeholder="_Color" placeholder="_Color"
filter="filter"> filter="filter">
<db-model property="model" auto-load="false" result-index="1"> <db-model property="model" auto-load="false" result-index="1">
@ -257,8 +256,8 @@
</db-model> </db-model>
</vn-filter> </vn-filter>
<vn-filter <vn-filter
lot="params"
name="producer" name="producer"
lot="params"
placeholder="_Producer" placeholder="_Producer"
filter="filter"> filter="filter">
<db-model property="model" auto-load="false" result-index="1"> <db-model property="model" auto-load="false" result-index="1">
@ -273,8 +272,8 @@
</db-model> </db-model>
</vn-filter> </vn-filter>
<vn-filter <vn-filter
lot="params"
name="origin" name="origin"
lot="params"
placeholder="_Origin" placeholder="_Origin"
filter="filter"> filter="filter">
<db-model property="model" auto-load="false" result-index="1"> <db-model property="model" auto-load="false" result-index="1">
@ -290,8 +289,8 @@
</db-model> </db-model>
</vn-filter> </vn-filter>
<vn-filter <vn-filter
lot="params"
name="category" name="category"
lot="params"
placeholder="_Category" placeholder="_Category"
filter="filter"> filter="filter">
<db-model property="model" auto-load="false" result-index="1"> <db-model property="model" auto-load="false" result-index="1">

View File

@ -171,7 +171,7 @@ Hedera.Checkout = new Class
if (row != -1) if (row != -1)
{ {
var builder = this.$('repeater').getBuilder (row); var builder = this.$('repeater').getScope (row);
this.selectedNode = builder.$('address'); this.selectedNode = builder.$('address');
Vn.Node.addClass (this.selectedNode, 'selected'); Vn.Node.addClass (this.selectedNode, 'selected');

View File

@ -23,7 +23,7 @@
</db-model> </db-model>
</vn-group> </vn-group>
<h1 id="title"> <h1 id="title">
<t>ConfigureOrder</t> _ConfigureOrder
</h1> </h1>
<div id="actions"> <div id="actions">
<htk-bar-button <htk-bar-button
@ -40,7 +40,7 @@
node="assistant-node"/> node="assistant-node"/>
<div id="assistant-node"> <div id="assistant-node">
<div id="method-step"> <div id="method-step">
<h2><t>DeliveryOrPickupQuestion</t></h2> <h2>_DeliveryOrPickupQuestion</h2>
<div class="answers radio"> <div class="answers radio">
<htk-radio-group <htk-radio-group
id="rg-method" id="rg-method"
@ -48,21 +48,21 @@
name="method" name="method"
on-changed="onFieldChange"/> on-changed="onFieldChange"/>
<div> <div>
<htk-radio radio-group="rg-method" value="AGENCY"/> <htk-radio radio-group="rg-method" id="r-agency" value="AGENCY"/>
<label><t>ReceiveThroughtAgency</t></label> <label for="r-agency">_ReceiveThroughtAgency</label>
</div> </div>
<div> <div>
<htk-radio radio-group="rg-method" value="DELIVERY"/> <htk-radio radio-group="rg-method" id="r-delivery" value="DELIVERY"/>
<label><t>ReceiveThroughtRoute</t></label> <label for="r-delivery">_ReceiveThroughtRoute</label>
</div> </div>
<div> <div>
<htk-radio radio-group="rg-method" value="PICKUP"/> <htk-radio radio-group="rg-method" id="r-pickup" value="PICKUP"/>
<label><t>PickupInStore</t></label> <label for="r-pickup">_PickupInStore</label>
</div> </div>
</div> </div>
</div> </div>
<div id="date-step"> <div id="date-step">
<h2 id="date-question"><t>OrderDateDeliveryQuestion</t></h2> <h2 id="date-question">_OrderDateDeliveryQuestion</h2>
<div class="answers"> <div class="answers">
<htk-calendar <htk-calendar
id="calendar" id="calendar"
@ -70,11 +70,11 @@
lot="lot" lot="lot"
name="date" name="date"
restrict-func="calendarRestrict" restrict-func="calendarRestrict"
on-changed="onFieldChange"/> on-pick="onFieldChange"/>
</div> </div>
</div> </div>
<div id="address-step"> <div id="address-step">
<h2><t>AddressQuestion</t></h2> <h2>_AddressQuestion</h2>
<db-form id="address-form" model="addresses"/> <db-form id="address-form" model="addresses"/>
<div class="answers target"> <div class="answers target">
<htk-repeater <htk-repeater
@ -103,7 +103,7 @@
</div> </div>
</div> </div>
<div id="agency-step"> <div id="agency-step">
<h2><t>AgencyQuestion</t></h2> <h2>_AgencyQuestion</h2>
<div class="answers target"> <div class="answers target">
<htk-combo <htk-combo
id="agency-combo" id="agency-combo"
@ -114,7 +114,7 @@
</div> </div>
</div> </div>
<div id="pickup-step"> <div id="pickup-step">
<h2><t>PickupWarehouseQuestion</t></h2> <h2>_PickupWarehouseQuestion</h2>
<div class="answers target"> <div class="answers target">
<htk-combo <htk-combo
id="warehouse-combo" id="warehouse-combo"
@ -125,57 +125,52 @@
</div> </div>
</div> </div>
<div id="confirm-agency-step" class="confirm"> <div id="confirm-agency-step" class="confirm">
<h2><t>ConfirmToAccessCatalog</t></h2> <h2>_ConfirmToAccessCatalog</h2>
<div class="answers target"> <div class="answers target">
<p> <p>
<t>Arrival</t> <t>Arrival</t> <htk-text format="%D" lot="lot" name="date"/>
<htk-text format="%D" lot="lot" name="date"/>
</p> </p>
<p> <p>
<htk-text lot="address-form" name="name"/> <htk-text lot="address-form" name="name"/>
</p> </p>
<p> <p>
<t>Agency</t> <t>Agency</t> <htk-text lot="agency-combo" name="description"/>
<htk-text lot="agency-combo" name="description"/>
</p> </p>
<button id="confirm-agency" class="thin" on-click="onConfirmClick"> <button id="confirm-agency" class="thin" on-click="onConfirmClick">
<t>Confirm</t> _Confirm
</button> </button>
<div class="clear"/> <div class="clear"/>
</div> </div>
</div> </div>
<div id="confirm-delivery-step" class="confirm"> <div id="confirm-delivery-step" class="confirm">
<h2><t>ConfirmToAccessCatalog</t></h2> <h2>_ConfirmToAccessCatalog</h2>
<div class="answers target"> <div class="answers target">
<p> <p>
<t>Arrival</t> <t>Arrival</t> <htk-text format="%D" lot="lot" name="date"/>
<htk-text format="%D" lot="lot" name="date"/>
</p> </p>
<p> <p>
<htk-text lot="address-form" name="name"/> <htk-text lot="address-form" name="name"/>
</p> </p>
<p> <p>
<t>ReceiveThroughtRoute</t> _ReceiveThroughtRoute
</p> </p>
<button id="confirm-delivery" class="thin" on-click="onConfirmClick"> <button id="confirm-delivery" class="thin" on-click="onConfirmClick">
<t>Confirm</t> _Confirm
</button> </button>
<div class="clear"/> <div class="clear"/>
</div> </div>
</div> </div>
<div id="confirm-pickup-step" class="confirm"> <div id="confirm-pickup-step" class="confirm">
<h2><t>ConfirmToAccessCatalog</t></h2> <h2>_ConfirmToAccessCatalog</h2>
<div class="answers target"> <div class="answers target">
<p> <p>
<t>Pickup</t> <t>Pickup</t> <htk-text format="%D" lot="lot" name="date"/>
<htk-text format="%D" lot="lot" name="date"/>
</p> </p>
<p> <p>
<t>Warehouse</t> <t>Warehouse</t> <htk-text lot="warehouse-combo" name="description"/>
<htk-text lot="warehouse-combo" name="description"/>
</p> </p>
<button id="confirm-pickup" class="thin" on-click="onConfirmClick"> <button id="confirm-pickup" class="thin" on-click="onConfirmClick">
<t>Confirm</t> _Confirm
</button> </button>
<div class="clear"/> <div class="clear"/>
</div> </div>

View File

@ -14,7 +14,7 @@
<vn-param lot="iter" name="text" on-changed="onBodyChange"/> <vn-param lot="iter" name="text" on-changed="onBodyChange"/>
</vn-group> </vn-group>
<h1 id="title"> <h1 id="title">
<t>AddEditNew</t> _AddEditNew
</h1> </h1>
<div id="actions"> <div id="actions">
<htk-bar-button <htk-bar-button
@ -29,11 +29,11 @@
<div id="main" class="new"> <div id="main" class="new">
<div class="card form"> <div class="card form">
<div> <div>
<label><t>Title</t></label> <label>_Title</label>
<htk-entry lot="iter" name="title"/> <htk-entry lot="iter" name="title"/>
</div> </div>
<div> <div>
<label><t>Tag</t></label> <label>_Tag</label>
<htk-combo lot="iter" name="tag"> <htk-combo lot="iter" name="tag">
<db-model property="model"> <db-model property="model">
SELECT name, description FROM news_tag SELECT name, description FROM news_tag
@ -42,11 +42,11 @@
</htk-combo> </htk-combo>
</div> </div>
<div> <div>
<label><t>Priority</t></label> <label>_Priority</label>
<htk-entry form="iter" column="priority"/> <htk-entry form="iter" column="priority"/>
</div> </div>
<div> <div>
<label><t>NewBody</t></label> <label>_NewBody</label>
<textarea id="html-editor"/> <textarea id="html-editor"/>
</div> </div>
</div> </div>

View File

@ -1,6 +1,6 @@
<vn> <vn>
<h1 id="title"> <h1 id="title">
<t>NewsManagement</t> _NewsManagement
</h1> </h1>
<div id="actions"> <div id="actions">
<htk-bar-button <htk-bar-button

View File

@ -1,6 +1,6 @@
<vn> <vn>
<h1 id="title"> <h1 id="title">
<t>Preview</t> _Preview
</h1> </h1>
<div id="actions"> <div id="actions">
<htk-bar-button <htk-bar-button

View File

@ -5,19 +5,15 @@ Hedera.ItemsForm = new Class
,activate: function () ,activate: function ()
{ {
this.$('warehouse').value = 7; this.$('lot').assign ({
this.$('realm').value = null; warehouse: 7,
realm: null
});
} }
,onPreviewClick: function () ,onShowClick: function ()
{ {
var batch = new Sql.Batch (); this.gui.openReport ('items-report', this.$('lot').params);
batch.addValues ({
'warehouse': this.$('warehouse').value
,'realm': this.$('realm').value
,'rate': this.$('rate').value
});
this.gui.openReport ('items-report', batch);
} }
}); });

View File

@ -1,7 +1,7 @@
<vn> <vn>
<vn-lot id="lot"/> <vn-lot id="lot"/>
<h1 id="title"> <h1 id="title">
<t>Item list</t> _Item list
</h1> </h1>
<div id="actions" class="action-bar"> <div id="actions" class="action-bar">
<htk-bar-button <htk-bar-button
@ -12,7 +12,7 @@
<div id="main" class="items"> <div id="main" class="items">
<div class="card form"> <div class="card form">
<div> <div>
<label><t>Store</t></label> <label>_Store</label>
<htk-combo lot="lot" name="warehouse"> <htk-combo lot="lot" name="warehouse">
<db-model property="model"> <db-model property="model">
SELECT id, name FROM vn2008.warehouse SELECT id, name FROM vn2008.warehouse
@ -21,7 +21,7 @@
</htk-combo> </htk-combo>
</div> </div>
<div> <div>
<label><t>Realm</t></label> <label>_Realm</label>
<htk-combo lot="lot" name="realm" not-null="false"> <htk-combo lot="lot" name="realm" not-null="false">
<db-model property="model"> <db-model property="model">
SELECT id, reino FROM vn2008.reinos SELECT id, reino FROM vn2008.reinos
@ -30,7 +30,7 @@
</htk-combo> </htk-combo>
</div> </div>
<div> <div>
<label><t>Rate</t></label> <label>_Rate</label>
<select id="rate"> <select id="rate">
<option>3</option> <option>3</option>
<option>2</option> <option>2</option>

View File

@ -4,7 +4,7 @@
</vn-lot-query> </vn-lot-query>
<vn-lot id="lot"/> <vn-lot id="lot"/>
<h1 id="title"> <h1 id="title">
<t>Shelves</t> _Shelves
</h1> </h1>
<div id="actions"> <div id="actions">
<htk-bar-button <htk-bar-button
@ -15,7 +15,7 @@
<div id="main" class="shelves"> <div id="main" class="shelves">
<div class="card form"> <div class="card form">
<div> <div>
<label><t>Configuration</t></label> <label>_Configuration</label>
<htk-combo <htk-combo
id="config" id="config"
placeholder="_Select config" placeholder="_Select config"
@ -33,11 +33,11 @@
</htk-combo> </htk-combo>
</div> </div>
<div> <div>
<label><t>Date</t></label> <label>_Date</label>
<htk-date-chooser lot="lot" name="date"/> <htk-date-chooser lot="lot" name="date"/>
</div> </div>
<div> <div>
<label><t>Reign</t></label> <label>_Reign</label>
<htk-combo lot="lot" name="realm"> <htk-combo lot="lot" name="realm">
<db-model property="model"> <db-model property="model">
SELECT id, reino FROM vn2008.reinos SELECT id, reino FROM vn2008.reinos
@ -46,7 +46,7 @@
</htk-combo> </htk-combo>
</div> </div>
<div> <div>
<label><t>Family</t></label> <label>_Family</label>
<htk-combo lot="lot" name="family"> <htk-combo lot="lot" name="family">
<db-model property="model" lot="lot"> <db-model property="model" lot="lot">
SELECT tipo_id, Tipo FROM vn2008.Tipos SELECT tipo_id, Tipo FROM vn2008.Tipos
@ -55,7 +55,7 @@
</htk-combo> </htk-combo>
</div> </div>
<div> <div>
<label><t>Store</t></label> <label>_Store</label>
<htk-combo lot="lot" name="warehouse"> <htk-combo lot="lot" name="warehouse">
<db-model property="model"> <db-model property="model">
SELECT id, name FROM vn2008.warehouse SELECT id, name FROM vn2008.warehouse
@ -64,7 +64,7 @@
</htk-combo> </htk-combo>
</div> </div>
<div> <div>
<label><t>Shelf</t></label> <label>_Shelf</label>
<htk-combo lot="lot" name="shelf"> <htk-combo lot="lot" name="shelf">
<db-model property="model"> <db-model property="model">
SELECT id, name FROM shelf SELECT id, name FROM shelf
@ -72,27 +72,27 @@
</htk-combo> </htk-combo>
</div> </div>
<div> <div>
<label><t>Name prefix</t></label> <label>_Name prefix</label>
<htk-entry lot="lot" name="namePrefix"/> <htk-entry lot="lot" name="namePrefix"/>
</div> </div>
<div> <div>
<label><t>Limit amount per item</t></label> <label>_Limit amount per item</label>
<htk-entry lot="lot" name="maxAmount"/> <htk-entry lot="lot" name="maxAmount"/>
</div> </div>
<div> <div>
<label><t>Title</t></label> <label>_Title</label>
<htk-entry lot="lot" name="reportTitle"/> <htk-entry lot="lot" name="reportTitle"/>
</div> </div>
<div> <div>
<label><t>Show packing</t></label> <label>_Show packing</label>
<htk-check lot="lot" name="showPacking"/> <htk-check lot="lot" name="showPacking"/>
</div> </div>
<div> <div>
<label><t>Stack different items</t></label> <label>_Stack different items</label>
<htk-check lot="lot" name="stack"/> <htk-check lot="lot" name="stack"/>
</div> </div>
<div> <div>
<label><t>Use ids instead of names</t></label> <label>_Use ids instead of names</label>
<htk-check lot="lot" name="useIds"/> <htk-check lot="lot" name="useIds"/>
</div> </div>
</div> </div>

View File

@ -3,7 +3,7 @@ var Gui = require ('./gui');
module.exports = new Class module.exports = new Class
({ ({
Extends: Htk.Component Extends: Vn.Component
,Properties: { ,Properties: {
gui: gui:
{ {
@ -35,15 +35,17 @@ module.exports = new Class
return; return;
var builder = new Vn.Builder (); var builder = new Vn.Builder ();
builder.signalData = this; builder.compileFile ('forms/'+ this.formInfo.path +'/ui.xml');
builder.add ('conn', this.conn);
builder.add ('hash', this.hash);
builder.loadXml ('forms/'+ this.formInfo.path +'/ui.xml');
var res = this.builder = builder.load (); var extraObjects = {
this._node = res.$('main'); conn: this.conn,
hash: this.hash
};
var scope = builder.load (this.doc, this, null, extraObjects);
this.scope = scope;
this._node = this.$('main');
var paramsLot = res.$('params'); var paramsLot = this.$('params');
if (paramsLot) if (paramsLot)
{ {
@ -51,14 +53,14 @@ module.exports = new Class
this.params = paramsLot; this.params = paramsLot;
} }
res.link (); scope.link ();
var models = res.getByTagName ('db-model'); var models = scope.getByTagName ('db-model');
for (var i = 0; i < models.length; i++) for (var i = 0; i < models.length; i++)
models[i].conn = this.conn; models[i].conn = this.conn;
var queries = res.getByTagName ('db-query'); var queries = scope.getByTagName ('db-query');
for (var i = 0; i < queries.length; i++) for (var i = 0; i < queries.length; i++)
queries[i].conn = this.conn; queries[i].conn = this.conn;
@ -66,8 +68,8 @@ module.exports = new Class
if (this.node) if (this.node)
{ {
this.gui.setForm (this.node); this.gui.setForm (this.node);
this.gui.setTitle (res.$('title')); this.gui.setTitle (scope.$('title'));
this.gui.setActions (res.$('actions')); this.gui.setActions (scope.$('actions'));
this.activate (); this.activate ();
} }
@ -82,17 +84,17 @@ module.exports = new Class
if (this.node) if (this.node)
{ {
this.deactivate (); this.deactivate ();
this.builder.unref (); this.scope.unref ();
this.gui.setTitle (null); this.gui.setTitle (null);
this.gui.setActions (null); this.gui.setActions (null);
this.gui.setForm (null); this.gui.setForm (null);
this.node = null; this.node = null;
this.params = null; this.params = null;
} }
if (this.builder) if (this.scope)
{ {
this.builder.unref (); this.scope.unref ();
this.builder = null; this.scope = null;
} }
} }

View File

@ -11,7 +11,7 @@ require ('./gui.css');
*/ */
module.exports = new Class module.exports = new Class
({ ({
Extends: Htk.Component, Extends: Vn.Component,
Properties: Properties:
{ {
/** /**
@ -54,7 +54,7 @@ module.exports = new Class
,initialize: function (props) ,initialize: function (props)
{ {
this.builderInitString (Tpl); this.loadTemplateFromString (Tpl);
this.loadingCount = 0; this.loadingCount = 0;
this.$('background').onclick = function () {}; this.$('background').onclick = function () {};

View File

@ -8,7 +8,7 @@ require ('./login.css');
*/ */
module.exports = new Class module.exports = new Class
({ ({
Extends: Htk.Component, Extends: Vn.Component,
Properties: Properties:
{ {
/** /**
@ -31,7 +31,7 @@ module.exports = new Class
,initialize: function (props) ,initialize: function (props)
{ {
this.parent (props); this.parent (props);
this.builderInitString (Tpl); this.loadTemplateFromString (Tpl);
this.$('social-bar').conn = this._conn; this.$('social-bar').conn = this._conn;

View File

@ -56,7 +56,7 @@
/* page-break-after: always;*/ /* page-break-after: always;*/
} }
/* Widgets */ /* Components */
.report .htk-grid .report .htk-grid
{ {

View File

@ -1,7 +1,7 @@
module.exports = new Class module.exports = new Class
({ ({
Extends: Htk.Component Extends: Vn.Component
,activate: function () ,activate: function ()
{ {
@ -46,12 +46,13 @@ module.exports = new Class
,renderReport: function () ,renderReport: function ()
{ {
var builder = new Vn.Builder (); var builder = new Vn.Builder ();
builder.signalData = this; builder.compileFile ('reports/'+ this.info.path +'/ui.xml');
builder.add ('hash', this.hash);
builder.add ('conn', this.conn);
builder.loadXml ('reports/'+ this.info.path +'/ui.xml');
var res = this.builderResultInit (builder); var extraObjects = {
this.body.appendChild (res.$('report')); conn: this.conn,
hash: this.hash
};
this.loadScope (builder, null, extraObjects);
this.body.appendChild (this.$('report'));
} }
}); });

View File

@ -1,7 +1,7 @@
module.exports = new Class module.exports = new Class
({ ({
Extends: Htk.Widget Extends: Vn.Component
,Tag: 'htk-social-bar' ,Tag: 'htk-social-bar'
,Properties: ,Properties:
{ {

View File

@ -1,10 +1,9 @@
var Widget = require ('./widget');
var Assistant = require ('./assistant'); var Assistant = require ('./assistant');
module.exports = new Class module.exports = new Class
({ ({
Extends: Widget Extends: Vn.Component
,Tag: 'htk-assistant-bar' ,Tag: 'htk-assistant-bar'
,Properties: ,Properties:
{ {

View File

@ -1,13 +1,11 @@
var NodeBuilder = require ('./node-builder');
/** /**
* 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.
*/ */
module.exports = new Class module.exports = new Class
({ ({
Extends: NodeBuilder Extends: Vn.NodeBuilder
,Tag: 'htk-column' ,Tag: 'htk-column'
,Properties: ,Properties:
{ {

View File

@ -1,56 +0,0 @@
var Widget = require ('./widget');
module.exports = new Class
({
Extends: Widget
,builder: null
,builderInit: function (path)
{
var builder = new Vn.Builder ();
builder.signalData = this;
builder.loadXml (path, this.doc);
this.builderResultInit (builder);
}
,builderInitString: function (xmlString)
{
var builder = new Vn.Builder ();
builder.signalData = this;
builder.loadFromString (xmlString, this.doc);
this.builderResultInit (builder);
}
,builderResultInit: function (builder)
{
var res = this.builder = builder.load ();
this._node = res.$('main');
res.link ();
return res;
}
/**
* Gets an object from the builder associated to this component.
*
* @param {string} objectId The object identifier
* @return {Object} The object, or %null if not found
*/
,$: function (id)
{
if (this.builder)
return this.builder.getById (id);
return null;
}
,_destroy: function ()
{
if (this.builder)
this.builder.unref ();
this.parent ();
}
});

View File

@ -1,12 +1,9 @@
var Widget = require ('./widget');
/** /**
* Base class for graphical fields. * Base class for graphical fields.
*/ */
module.exports = new Class module.exports = new Class
({ ({
Extends: Widget Extends: Vn.Component
,Implements: Vn.ParamIface ,Implements: Vn.ParamIface
,Tag: 'htk-field' ,Tag: 'htk-field'
,Properties: ,Properties:

View File

@ -12,7 +12,7 @@ module.exports = new Class
{ {
this._restrictFunc = x; this._restrictFunc = x;
} }
,get: function (x) ,get: function ()
{ {
return this._restrictFunc; return this._restrictFunc;
} }
@ -94,7 +94,8 @@ module.exports = new Class
for (var j = 0; j < len; j++) for (var j = 0; j < len; j++)
{ {
var td = this.createElement ('td'); var td = this.createElement ('td');
td.addEventListener ('click', this.dayClicked.bind (this, td, i*len+j)); td.addEventListener ('click',
this.dayClicked.bind (this, td, i * len + j));
tr.appendChild (td); tr.appendChild (td);
var div = this.createElement ('div'); var div = this.createElement ('div');
@ -226,7 +227,7 @@ module.exports = new Class
this.selectedCell = cellIndex; this.selectedCell = cellIndex;
} }
,putValue: function (value) ,putValue: function ()
{ {
this.goToSelectedMonth (); this.goToSelectedMonth ();
} }
@ -240,6 +241,7 @@ module.exports = new Class
this.selectCell (cellIndex); this.selectCell (cellIndex);
var newDate = new Date (this.year, this.month, cell.day); var newDate = new Date (this.year, this.month, cell.day);
this.emit ('pick', newDate);
this.valueChanged (newDate); this.valueChanged (newDate);
} }
} }

View File

@ -21,9 +21,31 @@ module.exports = new Class
return this._format; return this._format;
} }
} }
/**
* Input entry associated to the label.
*/
,for:
{
type: Vn.Component
,set: function (x)
{
this._for = x;
this.node.htmlFor = x.htmlId;
}
,get: function ()
{
return this._for;
}
}
} }
,_format: null ,_format: null
,_for: null
,appendChild: function (child)
{
this.node.appendChild (child);
}
,render: function () ,render: function ()
{ {

View File

@ -32,11 +32,17 @@ module.exports = new Class
} }
} }
,_radioGroup: null ,initialize: function (props)
{
Object.assign (this, {
_radioGroup: null
});
this.parent (props);
}
,render: function () ,render: function ()
{ {
var radio = this.doc.createElement ('input'); var radio = this.createRoot ('input');
radio.type = 'radio'; radio.type = 'radio';
radio.name = ''; radio.name = '';
radio.checked = false; radio.checked = false;

View File

@ -1,9 +1,7 @@
var Widget = require ('./widget');
module.exports = new Class module.exports = new Class
({ ({
Extends: Widget Extends: Vn.Component
,Tag: 'htk-grid' ,Tag: 'htk-grid'
,Child: 'model' ,Child: 'model'
,Properties: ,Properties:

View File

@ -3,10 +3,7 @@ require ('db/db');
require ('./style.css'); require ('./style.css');
Htk = module.exports = { Htk = module.exports = {
NodeBuilder : require ('./node-builder') Popup : require ('./popup')
,Widget : require ('./widget')
,Component : require ('./component')
,Popup : require ('./popup')
,Dialog : require ('./dialog') ,Dialog : require ('./dialog')
,Toast : require ('./toast') ,Toast : require ('./toast')
,Repeater : require ('./repeater') ,Repeater : require ('./repeater')
@ -51,4 +48,3 @@ var Fields = {
for (var field in Fields) for (var field in Fields)
Htk[field] = Fields[field]; Htk[field] = Fields[field];

View File

@ -1,9 +1,7 @@
var Widget = require ('./widget');
module.exports = new Class module.exports = new Class
({ ({
Extends: Widget Extends: Vn.Component
,Tag: 'htk-icon' ,Tag: 'htk-icon'
,Properties: ,Properties:
{ {

View File

@ -1,5 +1,4 @@
var Component = require ('./component');
var Toast = require ('./toast'); var Toast = require ('./toast');
var Tpl = require ('./image-editor.xml'); var Tpl = require ('./image-editor.xml');
@ -9,7 +8,7 @@ var Tpl = require ('./image-editor.xml');
*/ */
module.exports = new Class module.exports = new Class
({ ({
Extends: Component Extends: Vn.Component
,Properties: ,Properties:
{ {
/** /**
@ -23,7 +22,7 @@ module.exports = new Class
,initialize: function (props) ,initialize: function (props)
{ {
this.builderInitString (Tpl); this.loadTemplateFromString (Tpl);
var self = this; var self = this;
this.$('form').onsubmit = function () this.$('form').onsubmit = function ()

View File

@ -1,12 +1,9 @@
var Widget = require ('./widget');
/** /**
* Class to handle popups. * Class to handle popups.
*/ */
module.exports = new Class module.exports = new Class
({ ({
Extends: Widget Extends: Vn.Component
,Tag: 'htk-popup' ,Tag: 'htk-popup'
,Properties: ,Properties:
{ {
@ -15,7 +12,7 @@ module.exports = new Class
*/ */
child: child:
{ {
type: Widget type: Vn.Component
,set: function (x) ,set: function (x)
{ {
this._child = x; this._child = x;

View File

@ -1,9 +1,7 @@
var Widget = require ('./widget');
module.exports = new Class module.exports = new Class
({ ({
Extends: Widget Extends: Vn.Component
,Tag: 'htk-repeater' ,Tag: 'htk-repeater'
,Child: 'model' ,Child: 'model'
,Properties: ,Properties:
@ -74,6 +72,7 @@ module.exports = new Class
,_builder: null ,_builder: null
,_formId: 'form' ,_formId: 'form'
,_parentScope: null
,render: function () ,render: function ()
{ {
@ -84,14 +83,14 @@ module.exports = new Class
div.appendChild (this._container); div.appendChild (this._container);
} }
,loadXml: function (builderResult, node) ,loadXml: function (scope, node)
{ {
this.parent (builderResult, node); this.parent (scope, node);
var builder = this._builder = new Vn.Builder (); var builder = this._builder = new Vn.Builder ();
builder.setParent (builderResult); builder.compileNode (node.firstElementChild);
builder.loadXmlFromNode (node.firstElementChild);
this._parentScope = scope;
this._onModelChange (); this._onModelChange ();
} }
@ -100,9 +99,9 @@ module.exports = new Class
return this._container.childNodes[index]; return this._container.childNodes[index];
} }
,getBuilder: function (index) ,getScope: function (index)
{ {
return this._childsData[index].builder; return this._childsData[index].scope;
} }
,getForm: function (index) ,getForm: function (index)
@ -117,19 +116,21 @@ module.exports = new Class
row: index row: index
}); });
this._builder.add (this._formId, set); var extraObjects = {};
var res = this._builder.load (); extraObjects[this._formId] = set;
res.link ();
var scope = this._builder.load (this.doc, null, this._parentScope, extraObjects);
scope.link ();
this._childsData.push ({ this._childsData.push ({
builder: res, scope: scope,
set: set set: set
}); });
if (this._renderer) if (this._renderer)
this._renderer (res, set); this._renderer (scope, set);
return res.getMain (); return scope.getMain ();
} }
,_onModelChange: function () ,_onModelChange: function ()
@ -235,7 +236,7 @@ module.exports = new Class
{ {
var childData = this._childsData[index]; var childData = this._childsData[index];
childData.set.unref (); childData.set.unref ();
childData.builder.unref (); childData.scope.unref ();
} }
,_destroy: function () ,_destroy: function ()

View File

@ -1,9 +1,7 @@
var Widget = require ('./widget');
module.exports = new Class module.exports = new Class
({ ({
Extends: Widget Extends: Vn.Component
,Tag: 'htk-spinner' ,Tag: 'htk-spinner'
,_started: false ,_started: false

View File

@ -1,88 +0,0 @@
var NodeBuilder = require ('./node-builder');
var nativeEvents = {
'click' : 1
,'mousedown' : 1
,'focusout' : 1
};
module.exports = new Class
({
Extends: NodeBuilder
,Properties:
{
/**
* Main HTML node that represents the widget
*/
node:
{
type: Object
,get: function ()
{
this.renderBase ();
return this._node;
}
},
/**
* CSS classes to be appendend to the node classes.
*/
class:
{
type: String
,set: function (x)
{
this._cssClass = x;
this._refreshClass ();
}
,get: function ()
{
return this._node.className;
}
}
}
,_node: null
,initialize: function (props)
{
this.doc = document;
this.renderBase ();
this.parent (props);
}
,on: function (id, callback, instance)
{
if (nativeEvents[id])
this.node.addEventListener (id,
callback.bind (instance, this));
else
this.parent (id, callback, instance);
}
,createRoot: function (tagName)
{
return this._node = this.createElement (tagName);
}
,renderBase: function ()
{
if (this._node)
return;
this.render ();
this._refreshClass ();
}
,_refreshClass: function ()
{
if (this._node && this._cssClass)
this._node.className = this._cssClass +' '+ this._node.className;
}
,remove: function ()
{
Vn.Node.remove (this._node);
}
});

View File

@ -1,7 +1,16 @@
var VnObject = require ('./object'); var VnObject = require ('./object');
var Component = require ('./component');
var Type = require ('./type'); var Type = require ('./type');
var specialAttrs = {
id : 1,
property : 1
};
var objectAttrs = {
for : 1
};
/** /**
* Creates a object from a XML specification. * Creates a object from a XML specification.
*/ */
@ -11,91 +20,49 @@ module.exports = new Class
,_addedMap: {} ,_addedMap: {}
,_contexts: null ,_contexts: null
,add: function (id, object)
{
this._addedMap[id] = object;
}
,setParent: function (parentResult)
{
this._parentResult = parentResult;
if (parentResult && !this.signalData)
this.signalData = parentResult.builder.signalData;
}
,getMain: function (result)
{
return result.objects[this._mainContext];
}
,getById: function (result, objectId)
{
var index = this._contextMap[objectId];
if (index !== undefined)
return result.objects[index];
var object = this._addedMap[objectId];
if (object !== undefined)
return object;
if (this._parentResult)
return this._parentResult.getById (objectId);
return null;
}
,getByTagName: function (result, tagName)
{
var tags = this._tags[tagName];
if (tags)
{
var arr = new Array (tags.length);
for (var i = 0; i < tags.length; i++)
arr[i] = result.objects[tags[i]];
return arr;
}
return [];
}
/** /**
* Compiles an XML file. * Compiles an XML file.
* *
* @path String The XML path * @param {String} path The XML path
* @dstDocument Document The document used to create the nodes * @return {Boolean} %true on success, %false othersise
* @return %true on success, %false othersise
*/ */
,loadXml: function (path, dstDocument) ,compileFile: function (path)
{ {
this._path = path; this._path = path;
return this.loadFromXmlDoc (Vn.getXml (path), dstDocument); return this.compileDocument (Vn.getXml (path));
} }
,loadFromString: function (xmlString, dstDocument) /**
* Compiles an XML string.
*
* @param {String} xmlString The XML string
* @return {Boolean} %true on success, %false othersise
*/
,compileString: function (xmlString)
{ {
var parser = new DOMParser (); var parser = new DOMParser ();
var xmlDoc = parser.parseFromString (xmlString, 'text/xml'); var doc = parser.parseFromString (xmlString, 'text/xml');
return this.loadFromXmlDoc (xmlDoc, dstDocument); return this.compileDocument (doc);
} }
,loadFromXmlDoc: function (xmlDoc, dstDocument) /**
* Compiles a XML document.
*
* @param {Document} doc The DOM document
* @return {Boolean} %true on success, %false othersise
*/
,compileDocument: function (doc)
{ {
if (!xmlDoc) if (!doc)
return false; return false;
this._compileInit (dstDocument); this._compileInit ();
var docElement = xmlDoc.documentElement; var docElement = doc.documentElement;
if (docElement.tagName !== 'vn') if (docElement.tagName !== 'vn')
{ {
this._showError ('Malformed XML'); this._showError ('The toplevel tag should be named \'vn\'');
this._contexts = null; this._contexts = null;
return false; return false;
} }
@ -113,116 +80,81 @@ module.exports = new Class
/** /**
* Compiles a single DOM node. * Compiles a single DOM node.
* *
* @path Node The DOM node * @param {Node} path The DOM node
* @dstDocument Document The document used to create the nodes * @return {Boolean} %true on success, %false othersise
* @return %true on success, %false othersise
*/ */
,loadXmlFromNode: function (node, dstDocument) ,compileNode: function (node)
{ {
this._compileInit (dstDocument); this._compileInit ();
this._mainContext = this._compileNode (node).id; this._mainContext = this._compileNode (node).id;
this._compileEnd (); this._compileEnd ();
return true; return true;
} }
,load: function () /**
* Creates a new scope from a compiled XML tree.
*
* @param {Document} dstDocument The document used to create the nodes
* @param {Object} signalData The object where to bind methods
* @param {Scope} parentScope The parent scope or %null for no parent
* @return {Scope} The created scope
*/
,load: function (dstDocument, signalData, parentScope, extraObjects)
{ {
if (this._contexts === null) if (this._contexts === null)
return null; return null;
this._doc = dstDocument || document;
var contexts = this._contexts; var contexts = this._contexts;
var len = contexts.length; var len = contexts.length;
var objects = new Array (len); var objects = new Array (len);
var scope = new Scope (this, objects, signalData, parentScope, extraObjects)
for (var i = 0; i < len; i++) for (var i = 0; i < len; i++)
{ {
var context = contexts[i]; var context = contexts[i];
if (context.tagName) if (context.tagName)
objects[i] = this.elementInstantiate (context); objects[i] = this.elementInstantiate (context, scope);
else if (context.klass) else if (context.klass)
objects[i] = this.objectInstantiate (context); objects[i] = this.objectInstantiate (context, scope);
else else
objects[i] = this.textInstantiate (context); objects[i] = this.textInstantiate (context, scope);
} }
return new BuilderResult (this, objects); return scope;
} }
,link: function (result) ,_compileInit: function ()
{
var objects = result.objects;
for (var i = this._links.length - 1; i >= 0; i--)
{
var l = this._links[i];
var addedObject = this._addedMap[l.objectId];
if (addedObject)
{
if (l.prop)
objects[l.context.id][l.prop] = addedObject;
else
objects[l.context.id].appendChild (addedObject);
}
else
this._showError ('Referenced unexistent object with id \'%s\'',
l.objectId);
}
var contexts = this._contexts;
for (var i = 0; i < contexts.length; i++)
{
var context = contexts[i];
var object = objects[i];
if (context.tagName)
this.elementLink (context, object, objects, result);
else if (context.klass)
this.objectLink (context, object, objects, result);
}
}
,_compileInit: function (dstDocument)
{ {
this._path = null; this._path = null;
this._tags = {}; this._tags = {};
this._contexts = []; this._contexts = [];
this._contextMap = {}; this._contextMap = {};
this._links = []; this._objectLinks = [];
this._mainContext = null; this._mainContext = null;
this._doc = dstDocument ? dstDocument : document;
} }
,_compileEnd: function () ,_compileEnd: function ()
{ {
for (var i = this._links.length - 1; i >= 0; i--) var links = this._objectLinks;
for (var i = links.length - 1; i >= 0; i--)
{ {
var l = this._links[i]; var link = links[i];
var contextId = this._contextMap[l.objectId]; var context = link.context;
var contextId = this._contextMap[link.objectId];
if (contextId != undefined) if (contextId == undefined)
{ continue;
if (l.prop)
l.context.objectProps[l.prop] = contextId;
else
l.context.childs.push (contextId);
this._links.splice (i, 1); if (link.prop)
} context.objectProps[link.prop] = contextId;
else else
{ context.childs.push (contextId);
var object = this._addedMap[l.objectId];
if (!object && this._parentResult) links.splice (i, 1);
object = this._parentResult.getById (l.objectId);
if (object)
{
l.context.props[l.prop] = object;
this._links.splice (i, 1);
}
}
} }
} }
@ -230,8 +162,9 @@ module.exports = new Class
{ {
var context = null; var context = null;
var tagName = null; var tagName = null;
var isElement = node.nodeType === Node.ELEMENT_NODE;
if (node.nodeType === Node.ELEMENT_NODE) if (isElement)
tagName = node.tagName.toLowerCase (); tagName = node.tagName.toLowerCase ();
else if (node.nodeType !== Node.TEXT_NODE else if (node.nodeType !== Node.TEXT_NODE
|| /^[\n\r\t]*$/.test (node.textContent)) || /^[\n\r\t]*$/.test (node.textContent))
@ -244,12 +177,15 @@ module.exports = new Class
context.id = this._contexts.length; context.id = this._contexts.length;
if (tagName) if (isElement)
{ {
var nodeId = node.getAttribute ('id'); var nodeId = node.getAttribute ('id');
if (nodeId) if (nodeId)
{
this._contextMap[nodeId] = context.id; this._contextMap[nodeId] = context.id;
context.nodeId = nodeId;
}
var tags = this._tags[tagName]; var tags = this._tags[tagName];
@ -263,24 +199,52 @@ module.exports = new Class
return context; return context;
} }
/** ,link: function (scope)
* Creates a text node context.
*/
,textCompile: function (node, tagName)
{ {
if (!tagName) var objects = scope.objects;
var text = node.textContent; var links = this._objectLinks;
else if (tagName === 't')
var text = _(node.firstChild.textContent);
else
return null;
return {text: text}; for (var i = links.length - 1; i >= 0; i--)
} {
var link = links[i];
var object = objects[link.context.id];
var objectRef = scope.$(link.objectId);
,textInstantiate: function (context) if (objectRef == null)
{ {
return this._doc.createTextNode (context.text); this._showError ('Referenced unexistent object with id \'%s\'',
link.objectId);
continue;
}
if (link.prop)
object[link.prop] = objectRef;
else
object.appendChild (objectRef);
}
var contexts = this._contexts;
for (var i = 0; i < contexts.length; i++)
{
var context = contexts[i];
var object = objects[i];
if (context.tagName)
this.elementLink (context, object, objects, scope);
else if (context.klass)
this.objectLink (context, object, objects, scope);
}
for (var i = 0; i < contexts.length; i++)
{
var context = contexts[i];
var object = objects[i];
if (context.tagName)
this.elementConnect (context, object, objects, scope);
else if (context.klass)
this.objectConnect (context, object, objects, scope);
}
} }
/** /**
@ -295,6 +259,7 @@ module.exports = new Class
var props = {}; var props = {};
var objectProps = {}; var objectProps = {};
var funcProps = {};
var childs = []; var childs = [];
var events = {}; var events = {};
@ -302,6 +267,7 @@ module.exports = new Class
klass: klass, klass: klass,
props: props, props: props,
objectProps: objectProps, objectProps: objectProps,
funcProps: funcProps,
childs: childs, childs: childs,
events: events, events: events,
custom: null custom: null
@ -315,13 +281,8 @@ module.exports = new Class
var value = a[i].nodeValue; var value = a[i].nodeValue;
if (this._isEvent (attribute)) if (this._isEvent (attribute))
{ events[attribute.substr (3)] = value;
var handler = this._getMethod (value) else if (!specialAttrs[attribute])
if (handler)
events[attribute.substr (3)] = handler;
}
else if (!/^(id|property)$/.test (attribute))
{ {
this.propCompile (context, klass, props, this.propCompile (context, klass, props,
node, attribute, value); node, attribute, value);
@ -342,7 +303,7 @@ module.exports = new Class
if (childTagName === 'pointer') if (childTagName === 'pointer')
{ {
this._addLink (context, null, child.getAttribute ('object')); this.objectAddLink (context, null, child.getAttribute ('object'));
} }
else if (childTagName === 'custom') else if (childTagName === 'custom')
{ {
@ -388,6 +349,8 @@ module.exports = new Class
return; return;
} }
var propError = false;
switch (propInfo.type) switch (propInfo.type)
{ {
case null: case null:
@ -403,8 +366,7 @@ module.exports = new Class
newValue = this._translateValue (value); newValue = this._translateValue (value);
break; break;
case Function: case Function:
var method = this._getMethod (value); context.funcProps[propName] = value;
newValue = method ? method.bind (this.signalData) : null;
break; break;
case Type: case Type:
newValue = window[value]; newValue = window[value];
@ -414,26 +376,41 @@ module.exports = new Class
newValue = propInfo.enumType[value]; newValue = propInfo.enumType[value];
else if (propInfo.type instanceof Function) else if (propInfo.type instanceof Function)
isLink = true; isLink = true;
else
propError = true;
} }
if (isLink) if (isLink)
this._addLink (context, propName, value); this.objectAddLink (context, propName, value);
else if (newValue !== null && newValue !== undefined) else if (newValue != null)
props[propName] = newValue; props[propName] = newValue;
else else if (propError)
this._showError ('Attribute \'%s\' invalid for tag \'%s\'', this._showError ('Attribute \'%s\' invalid for tag \'%s\'',
attribute, node.tagName); attribute, node.tagName);
} }
,objectInstantiate: function (context) ,objectAddLink: function (context, prop, objectId)
{ {
return new context.klass (); this._objectLinks.push ({
context: context
,prop: prop
,objectId: objectId
});
} }
,objectLink: function (context, object, objects, res) ,objectInstantiate: function (context, scope)
{ {
var object = new context.klass ();
object.setProperties (context.props); object.setProperties (context.props);
if (context.nodeId && object instanceof Component)
object.htmlId = scope.getHtmlId (context.nodeId);
return object;
}
,objectLink: function (context, object, objects, scope)
{
var objectProps = context.objectProps; var objectProps = context.objectProps;
for (var prop in objectProps) for (var prop in objectProps)
object[prop] = objects[objectProps[prop]]; object[prop] = objects[objectProps[prop]];
@ -442,12 +419,29 @@ module.exports = new Class
for (var i = 0; i < childs.length; i++) for (var i = 0; i < childs.length; i++)
object.appendChild (objects[childs[i]]); object.appendChild (objects[childs[i]]);
if (context.custom)
object.loadXml (scope, context.custom);
}
,objectConnect: function (context, object, objects, scope)
{
var funcProps = context.funcProps;
for (var prop in funcProps)
{
var method = scope.getMethod (funcProps[prop], true);
if (method)
object[prop] = method;
}
var events = context.events; var events = context.events;
for (var event in events) for (var event in events)
object.on (event, events[event], this.signalData); {
var method = scope.getMethod (events[event]);
if (context.custom) if (method)
object.loadXml (res, context.custom); object.on (event, method, scope.signalData);
}
} }
/** /**
@ -455,10 +449,10 @@ module.exports = new Class
*/ */
,elementCompile: function (node, tagName) ,elementCompile: function (node, tagName)
{ {
var attributes = {}; var props = {};
var objectProps = {};
var childs = []; var childs = [];
var events = {}; var events = {};
var handler;
var a = node.attributes; var a = node.attributes;
@ -468,14 +462,11 @@ module.exports = new Class
var value = a[i].nodeValue; var value = a[i].nodeValue;
if (this._isEvent (attribute)) if (this._isEvent (attribute))
{ events[attribute.substr (3)] = value;
var handler = this._getMethod (value); else if (objectAttrs[attribute])
objectProps[attribute] = value;
if (handler) else if (!specialAttrs[attribute])
events[attribute.substr (3)] = handler; props[attribute] = this._translateValue (value);
}
else if (attribute !== 'id')
attributes[attribute] = this._translateValue (value);
} }
var childContext; var childContext;
@ -484,42 +475,94 @@ module.exports = new Class
if (childNodes) if (childNodes)
for (var i = 0; i < childNodes.length; i++) for (var i = 0; i < childNodes.length; i++)
if (childContext = this._compileNode (childNodes[i])) if (childContext = this._compileNode (childNodes[i]))
childs.push (childContext.id); childs.push (childContext.id);
return { return {
tagName: tagName, tagName: tagName,
attributes: attributes, props: props,
objectProps: objectProps,
childs: childs, childs: childs,
events: events events: events
}; };
} }
,elementInstantiate: function (context) ,elementInstantiate: function (context, scope)
{ {
return this._doc.createElement (context.tagName); var object = this._doc.createElement (context.tagName);
var props = context.props;
for (var prop in props)
object.setAttribute (prop, props[prop]);
if (context.nodeId)
object.setAttribute ('id', scope.getHtmlId (context.nodeId));
return object;
} }
,elementLink: function (context, object, objects) ,elementLink: function (context, object, objects, scope)
{ {
var attributes = context.attributes; var props = context.objectProps;
for (var attribute in attributes) for (var prop in props)
object.setAttribute (attribute, attributes[attribute]); {
var objectValue = scope.$(props[prop]);
var htmlId;
if (objectValue instanceof Component)
htmlId = objectValue.htmlId;
if (objectValue instanceof Node)
htmlId = objectValue.id;
object.setAttribute (prop, htmlId);
}
var childs = context.childs; var childs = context.childs;
for (var i = 0; i < childs.length; i++) for (var i = 0; i < childs.length; i++)
{ {
var child = objects[childs[i]]; var child = objects[childs[i]];
if (child instanceof Htk.Widget) if (child instanceof Component)
child = child.node; child = child.node;
if (child instanceof Node) if (child instanceof Node)
object.appendChild (child); object.appendChild (child);
} }
}
,elementConnect: function (context, object, objects, scope)
{
var events = context.events; var events = context.events;
for (var event in events) for (var event in events)
object.addEventListener (event, {
events[event].bind (this.signalData)); var method = scope.getMethod (events[event], true);
if (method)
object.addEventListener (event, method);
}
}
/**
* Creates a text node context.
*/
,textCompile: function (node, tagName)
{
if (!tagName)
{
var text = node.textContent;
if (/^[\s]*\\?_.*/.test (text))
text = _(text.trim ().substr (1));
}
else if (tagName === 't')
var text = _(node.firstChild.textContent);
else
return null;
return {text: text};
}
,textInstantiate: function (context)
{
return this._doc.createTextNode (context.text);
} }
,_showError: function (error) ,_showError: function (error)
@ -533,15 +576,6 @@ module.exports = new Class
console.warn.apply (console, logArgs); console.warn.apply (console, logArgs);
} }
,_addLink: function (context, prop, objectId)
{
this._links.push ({
context: context
,prop: prop
,objectId: objectId
});
}
,_translateValue: function (value) ,_translateValue: function (value)
{ {
var chr = value.charAt (0); var chr = value.charAt (0);
@ -554,19 +588,6 @@ module.exports = new Class
return value; return value;
} }
,_getMethod: function (value)
{
if (this.signalData)
var method = this.signalData[value];
else
var method = window[value];
if (method === undefined)
this._showError ('Function \'%s\' not found', value);
return method;
}
,_isEvent: function (attribute) ,_isEvent: function (attribute)
{ {
return /^on-\w+/.test (attribute); return /^on-\w+/.test (attribute);
@ -576,16 +597,54 @@ module.exports = new Class
{ {
return token.charAt(1).toUpperCase (); return token.charAt(1).toUpperCase ();
} }
,getMain: function (result)
{
return result.objects[this._mainContext];
}
,getById: function (objectId)
{
return this._contextMap[objectId];
}
,getByTagName: function (result, tagName)
{
var tags = this._tags[tagName];
if (tags)
{
var arr = new Array (tags.length);
for (var i = 0; i < tags.length; i++)
arr[i] = result.objects[tags[i]];
return arr;
}
return [];
}
}); });
var BuilderResult = new Class var scopeUid = 0;
var Scope = new Class
({ ({
Extends: VnObject Extends: VnObject
,initialize: function (builder, objects) ,initialize: function (builder, objects, signalData, parentScope, extraObjects)
{ {
this.builder = builder; this.builder = builder;
this.objects = objects; this.objects = objects;
this.signalData = signalData;
this.parentScope = parentScope;
this.uid = ++scopeUid;
this.extraObjects = extraObjects;
if (!signalData && parentScope)
this.signalData = parentScope.signalData;
this.parent ();
} }
,getMain: function () ,getMain: function ()
@ -593,14 +652,37 @@ var BuilderResult = new Class
return this.builder.getMain (this); return this.builder.getMain (this);
} }
,$: function (objectId) /**
* Fetchs an element by it's identifier.
*
* @param {String} id The node identifier
*/
,$: function (id)
{ {
return this.builder.getById (this, objectId); var object;
var index = this.builder.getById (id);
if (index !== undefined)
object = this.objects[index];
else
{
object = this.extraObjects[id];
if (object === undefined && this.parentScope)
object = this.parentScope.getById (id);
}
return object ? object : null;
} }
,getById: function (objectId) /**
* Fetchs an element by it's identifier.
*
* @param {String} id The node identifier
*/
,getById: function (id)
{ {
return this.builder.getById (this, objectId); return this.$(id);
} }
,getByTagName: function (tagName) ,getByTagName: function (tagName)
@ -613,15 +695,40 @@ var BuilderResult = new Class
this.builder.link (this); this.builder.link (this);
} }
,getMethod: function (value, binded)
{
if (this.signalData)
{
var method = this.signalData[value];
if (method && binded)
method = method.bind (this.signalData);
}
else
var method = window[value];
if (method === undefined)
this.builder._showError ('Function \'%s\' not found', value);
return method;
}
,getHtmlId: function (nodeId)
{
return 'vn-'+ this.uid +'-'+ nodeId;
}
,_destroy: function () ,_destroy: function ()
{ {
var objects = this.objects; var objects = this.objects;
for (var i = objects.length; i--;) for (var i = objects.length; i--;)
if (objects[i] instanceof VnObject) if (objects[i] instanceof VnObject)
{
objects[i].unref (); objects[i].unref ();
objects[i].disconnectByInstance (this.builder.signalData);
}
this.parent (); this.parent ();
} }
}); });

157
js/vn/component.js Normal file
View File

@ -0,0 +1,157 @@
var NodeBuilder = require ('./node-builder');
var nativeEvents = {
click : 1
,mousedown : 1
,focusout : 1
};
module.exports = new Class
({
Extends: NodeBuilder
,Properties:
{
/**
* Main HTML node that represents the component
*/
node:
{
type: Object
,get: function ()
{
this.renderBase ();
return this._node;
}
},
/**
* CSS classes to be appendend to the node classes.
*/
class:
{
type: String
,set: function (x)
{
this._cssClass = x;
this._refreshClass ();
}
,get: function ()
{
return this._node.className;
}
},
/**
* The HTML id of the element.
*/
htmlId:
{
type: String
,set: function (x)
{
this._htmlId = x;
if (this._node)
this._node.id = x;
}
,get: function ()
{
return this._htmlId;
}
}
}
,_node: null
,scope: null
,initialize: function (props)
{
this.doc = document;
this.renderBase ();
this.parent (props);
}
,on: function (id, callback, instance)
{
if (nativeEvents[id])
this.node.addEventListener (id,
callback.bind (instance, this));
else
this.parent (id, callback, instance);
}
,createRoot: function (tagName)
{
this._node = this.createElement (tagName);
if (this.htmlId)
this._node.id = this.htmlId;
return this._node;
}
,renderBase: function ()
{
if (this._node)
return;
this.render ();
this._refreshClass ();
}
,_refreshClass: function ()
{
if (this._node && this._cssClass)
this._node.className = this._cssClass +' '+ this._node.className;
}
,remove: function ()
{
Vn.Node.remove (this._node);
}
,loadTemplateFromFile: function (path)
{
var builder = new Vn.Builder ();
builder.compileFile (path);
this.loadScope (builder);
}
,loadTemplateFromString: function (xmlString)
{
var builder = new Vn.Builder ();
builder.compileString (xmlString);
this.loadScope (builder);
}
,loadScope: function (builder, parentScope, extraObjects)
{
var scope = builder.load (this.doc, this, parentScope, extraObjects);
this.scope = scope;
this._node = this.$('main');
scope.link ();
return scope;
}
/**
* Gets an object from the scope associated to this component.
*
* @param {String} id The object identifier
* @return {Object} The object, or %null if not found
*/
,$: function (id)
{
if (this.scope)
return this.scope.$(id);
return null;
}
,_destroy: function ()
{
if (this.builder)
this.builder.unref ();
this.parent ();
}
});

View File

@ -78,7 +78,10 @@ module.exports = new Class
,rowChanged: function () ,rowChanged: function ()
{ {
this._rowLock = true; this._rowLock = true;
this.params = this._model.getObject (this._row);
var row = this._model.getObject (this._row);
this.params = row != null ? row : {};
this._rowLock = false; this._rowLock = false;
} }
}); });

View File

@ -1,7 +1,9 @@
var VnObject = require ('./object');
module.exports = new Class module.exports = new Class
({ ({
Extends: Vn.Object Extends: VnObject
,doc: null ,doc: null
@ -23,4 +25,3 @@ module.exports = new Class
,render: function () {} ,render: function () {}
}); });

View File

@ -71,7 +71,7 @@ module.exports = new Class
* Called from @Vn.Builder when it finds a custom tag as a child of the * Called from @Vn.Builder when it finds a custom tag as a child of the
* element. * element.
* *
* @param {Vn.Builder} builder The builder instance * @param {Vn.Scope} scope The scope instance
* @param {Node} node The custom tag child nodes * @param {Node} node The custom tag child nodes
*/ */
,loadXml: function () {} ,loadXml: function () {}

View File

@ -28,7 +28,9 @@ Vn = module.exports = {
,Iterator : require ('./iterator') ,Iterator : require ('./iterator')
,Form : require ('./form') ,Form : require ('./form')
,Node : require ('./node') ,Node : require ('./node')
,NodeBuilder : require ('./node-builder')
,Builder : require ('./builder') ,Builder : require ('./builder')
,Component : require ('./component')
,JsonException : require ('./json-exception') ,JsonException : require ('./json-exception')
,JsonConnection : require ('./json-connection') ,JsonConnection : require ('./json-connection')

View File

@ -72,4 +72,3 @@ class App extends \Vn\Lib\App
return parent::getConfigFile (); return parent::getConfigFile ();
} }
} }

View File

@ -23,9 +23,8 @@ class DbSessionHandler implements \SessionHandlerInterface
function read ($sessionId) function read ($sessionId)
{ {
$this->db->query ('DO GET_LOCK(#, 10)', [$sessionId]);
$sessionData = $this->db->getValue ( $sessionData = $this->db->getValue (
'SELECT data FROM userSession WHERE ssid = # FOR UPDATE', [$sessionId]); 'SELECT data FROM userSession WHERE ssid = #', [$sessionId]);
return isset ($sessionData) ? $sessionData : ''; return isset ($sessionData) ? $sessionData : '';
} }
@ -37,7 +36,6 @@ class DbSessionHandler implements \SessionHandlerInterface
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
data = VALUES(data), lastUpdate = VALUES(lastUpdate)', data = VALUES(data), lastUpdate = VALUES(lastUpdate)',
[$sessionId, $sessionData]); [$sessionId, $sessionData]);
$this->db->query ('DO RELEASE_LOCK(#)', [$sessionId]);
return TRUE; return TRUE;
} }

View File

@ -286,7 +286,7 @@ abstract class Service
$version = $package->version; $version = $package->version;
} }
else else
$version = "0.0.0"; $version = '0.0.0';
apc_store ("$appName.version", $version); apc_store ("$appName.version", $version);
} }