0
1
Fork 0

Tags Alpha v2

This commit is contained in:
Juan Ferrer Toribio 2017-11-21 12:50:55 +01:00
parent 857e46ce4d
commit 23715816ce
3 changed files with 71 additions and 78 deletions

View File

@ -1,5 +1,7 @@
(function () { (function () {
var maxFilters = 5;
var View = { var View = {
LIST: 0, LIST: 0,
GRID: 1 GRID: 1
@ -82,7 +84,6 @@ Hedera.Catalog = new Class
icon: 'view-list', icon: 'view-list',
tip: _('List view') tip: _('List view')
}); });
this.view = View.GRID;
var className = 'grid-view'; var className = 'grid-view';
} }
else else
@ -91,10 +92,10 @@ Hedera.Catalog = new Class
icon: 'view-grid', icon: 'view-grid',
tip: _('Grid view') tip: _('Grid view')
}); });
this.view = View.LIST;
var className = 'list-view'; var className = 'list-view';
} }
this.view = view;
var node = this.$.gridView.node; var node = this.$.gridView.node;
node.className = className; node.className = className;
localStorage.setItem ('hederaView', this.view); localStorage.setItem ('hederaView', this.view);
@ -102,8 +103,8 @@ Hedera.Catalog = new Class
,onSwitchViewClick: function () ,onSwitchViewClick: function ()
{ {
this.setView (this.view === View.LIST ? this.setView (this.view === View.GRID ?
View.GRID : View.LIST); View.LIST : View.GRID);
} }
,onBasketReady: function (form) ,onBasketReady: function (form)
@ -139,8 +140,14 @@ Hedera.Catalog = new Class
this.$.items.query = this.buildQuery ('CALL catalogGetItems ()'); this.$.items.query = this.buildQuery ('CALL catalogGetItems ()');
this.$.items.refresh (); this.$.items.refresh ();
var tagsQuery = this.buildQuery ('CALL catalogGetTags ()'); var nTags = maxFilters - this.nFilters;
if (nTags > 0)
{
var tagsQuery = this.buildQuery (
'CALL catalogGetTags (#nTags)', {nTags: nTags});
this.conn.execQuery (tagsQuery, this.onTagsReady.bind (this)); this.conn.execQuery (tagsQuery, this.onTagsReady.bind (this));
}
this.hideMenu (); this.hideMenu ();
} }
@ -154,7 +161,6 @@ Hedera.Catalog = new Class
{ {
this.$.filters.style.display = show ? 'block' : 'none'; this.$.filters.style.display = show ? 'block' : 'none';
this.$.categoryMsg.style.display = show ? 'none' : 'block'; this.$.categoryMsg.style.display = show ? 'none' : 'block';
this.$.order.style.display = show ? 'block' : 'none';
} }
,onRemoveFiltersClick: function () ,onRemoveFiltersClick: function ()
@ -164,6 +170,7 @@ Hedera.Catalog = new Class
} }
,filters: {} ,filters: {}
,nFilters: 0
,buildQuery: function (query, params, excludeTag) ,buildQuery: function (query, params, excludeTag)
{ {
@ -342,9 +349,11 @@ Hedera.Catalog = new Class
{ {
this.$.currentFilters.removeChild (filter); this.$.currentFilters.removeChild (filter);
delete this.filters[tagId]; delete this.filters[tagId];
this.nFilters--;
} }
else if (this.filters[tagId] === undefined) else if (this.filters[tagId] === undefined)
{ {
this.nFilters++;
this.filters[tagId] = filterData; this.filters[tagId] = filterData;
this.$.suggestedFilters.removeChild (filter); this.$.suggestedFilters.removeChild (filter);
this.$.currentFilters.appendChild (filter); this.$.currentFilters.appendChild (filter);

View File

@ -48,33 +48,6 @@
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
} }
.right-panel .filter
{
padding: 1em 1.8em;
}
.right-panel .filters,
.right-panel .order
{
display: none;
}
.right-panel .category-msg
{
margin-top: 1em;
}
.right-panel .category-msg > h1
{
font-weight: normal;
text-align: center;
padding: 2.5em 0;
color: #777;
}
.right-panel h2
{
font-weight: normal;
padding: .4em 0;
color: #777;
font-size: 1.1em;
}
.right-panel .categories .right-panel .categories
{ {
width: 95%; width: 95%;
@ -93,13 +66,20 @@
padding: 0; padding: 0;
width: 100%; width: 100%;
} }
.right-panel .vn-filter, .right-panel .category-msg
.right-panel select
{ {
margin: 0 auto; margin-top: 1em;
margin-bottom: .7em; }
width: 90%; .right-panel .category-msg > h1
display: block; {
font-weight: normal;
text-align: center;
padding: 2.5em 0;
color: #777;
}
.right-panel .filters
{
display: none;
} }
.right-panel .filters > button .right-panel .filters > button
{ {
@ -107,6 +87,13 @@
margin: 0 auto; margin: 0 auto;
margin-top: 1em; margin-top: 1em;
} }
.right-panel .filters label
{
font-size: .9em;
color: #666;
padding-top: .7em;
display: block;
}
/* Items */ /* Items */

View File

@ -65,10 +65,10 @@
<db-model <db-model
property="model" property="model"
lot="card-lot"> lot="card-lot">
SELECT a.description, o.str origin SELECT i.description, o.name origin
FROM vn2008.Articles a FROM vn.item i
LEFT JOIN vn_locale.origin_view o ON o.origin_id = a.id_origen LEFT JOIN vn.originL10n o ON o.id = i.originFk
WHERE a.Id_Article = #item WHERE i.id = #item
</db-model> </db-model>
</db-form> </db-form>
<db-model <db-model
@ -193,19 +193,17 @@
<div class="clear"/> <div class="clear"/>
</div> </div>
</div> </div>
<div id="order" class="order"> <div id="category-msg" class="category-msg">
<h2>_Order by</h2> <h1>_Choose a category</h1>
</div>
<div id="filters" class="filters">
<div>
<label>_Order by</label>
<htk-combo <htk-combo
id="order-by" id="order-by"
on-change="onOrderChange" on-change="onOrderChange"
value="relevancy" value="relevancy"
not-null="true"/> not-null="true"/>
</div>
<div id="category-msg" class="category-msg">
<h1>_Choose a category</h1>
</div>
<div id="filters" class="filters">
<h2>_Filter by</h2>
<label>_Family</label> <label>_Family</label>
<htk-combo <htk-combo
id="type" id="type"
@ -217,20 +215,19 @@
property="model" property="model"
lot="params" lot="params"
result-index="1"> result-index="1">
CALL item_available (); CALL itemGetAvailable;
SELECT DISTINCT t.id, l.name SELECT DISTINCT t.id, l.name
FROM vn.itemType t FROM vn.itemType t
JOIN vn.item i ON i.typeFk = t.id JOIN vn.item i ON i.typeFk = t.id
JOIN tmp.item_available a ON a.item_id = i.id JOIN tmp.itemAvailable a ON a.id = i.id
JOIN vn.itemTypeL10n l ON l.id = t.id JOIN vn.itemTypeL10n l ON l.id = t.id
WHERE t.categoryFk = #category WHERE t.categoryFk = #category
ORDER BY name ORDER BY name
</db-model> </db-model>
</htk-combo> </htk-combo>
<div id="current-filters">
</div>
<div id="suggested-filters">
</div> </div>
<div id="current-filters"/>
<div id="suggested-filters"/>
<button on-click="onRemoveFiltersClick" class="thin"> <button on-click="onRemoveFiltersClick" class="thin">
_Remove filters _Remove filters
</button> </button>