#1136 item.buscador Avanzado añadir campo visible y isActive
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
This commit is contained in:
parent
7dd08dc6e5
commit
9ef3eac480
|
@ -33,6 +33,16 @@ module.exports = Self => {
|
|||
type: 'Integer',
|
||||
description: 'Type id',
|
||||
http: {source: 'query'}
|
||||
}, {
|
||||
arg: 'hasVisible',
|
||||
type: 'Boolean',
|
||||
description: 'Whether the the item has o not visible',
|
||||
http: {source: 'query'}
|
||||
}, {
|
||||
arg: 'isActive',
|
||||
type: 'Boolean',
|
||||
description: 'Whether the the item is o not active',
|
||||
http: {source: 'query'}
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
|
@ -45,7 +55,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.filter = async(ctx, filter, tags) => {
|
||||
Self.filter = async(ctx, filter) => {
|
||||
let conn = Self.dataSource.connector;
|
||||
|
||||
let where = buildFilter(ctx.args, (param, value) => {
|
||||
|
@ -62,15 +72,23 @@ module.exports = Self => {
|
|||
return {'ic.id': value};
|
||||
case 'typeFk':
|
||||
return {'t.id': value};
|
||||
case 'isActive':
|
||||
return {'i.isActive': value};
|
||||
}
|
||||
});
|
||||
|
||||
filter = mergeFilters(ctx.args.filter, {where});
|
||||
|
||||
let stmt = new ParameterizedSQL(
|
||||
let stmts = [];
|
||||
let stmt;
|
||||
if (ctx.args.hasVisible === true)
|
||||
stmts.push('CALL cache.visible_refresh(@visibleCalc, true, 1)');
|
||||
|
||||
stmt = new ParameterizedSQL(
|
||||
`SELECT i.id, i.image, i.name, i.description,
|
||||
i.size, i.tag5, i.value5, i.tag6, i.value6,
|
||||
i.tag7, i.value7, i.tag8, i.value8, i.isActive,
|
||||
i.tag7, i.value7, i.tag8, i.value8,
|
||||
i.tag9, i.value9, i.tag10, i.value10, i.isActive,
|
||||
t.name type, u.nickname userNickname,
|
||||
t.name type, u.id userId,
|
||||
intr.description AS intrastat, i.stems,
|
||||
|
@ -90,6 +108,14 @@ module.exports = Self => {
|
|||
LEFT JOIN vn.buy b ON b.id = lb.buy_id`
|
||||
);
|
||||
|
||||
if (ctx.args.hasVisible === true) {
|
||||
let joinAvailable = new ParameterizedSQL(
|
||||
`JOIN cache.visible v
|
||||
ON v.item_id = i.id AND v.calc_id = @visibleCalc`
|
||||
);
|
||||
stmt.merge(joinAvailable);
|
||||
}
|
||||
|
||||
if (ctx.args.tags) {
|
||||
let i = 1;
|
||||
for (let tag of ctx.args.tags) {
|
||||
|
@ -104,6 +130,10 @@ module.exports = Self => {
|
|||
}
|
||||
}
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
return Self.rawStmt(stmt);
|
||||
let itemsIndex = stmts.push(stmt) - 1;
|
||||
|
||||
let sql = ParameterizedSQL.join(stmts, ';');
|
||||
let result = await conn.executeStmt(sql);
|
||||
return itemsIndex === 0 ? result : result[itemsIndex];
|
||||
};
|
||||
};
|
||||
|
|
|
@ -3,10 +3,39 @@
|
|||
<vn-auto>
|
||||
<section
|
||||
class="inline-tag ellipsize"
|
||||
ng-class="::{empty: !fetchedTag.value}"
|
||||
ng-repeat="fetchedTag in $ctrl.tags track by $index"
|
||||
title="{{::fetchedTag.name}}: {{::fetchedTag.value}}">
|
||||
{{::fetchedTag.value}}
|
||||
ng-class="::{empty: !$ctrl.item.value5}"
|
||||
title="{{::$ctrl.item.tag5}}: {{::$ctrl.item.value5}}">
|
||||
{{::$ctrl.item.value5}}
|
||||
</section>
|
||||
<section
|
||||
class="inline-tag ellipsize"
|
||||
ng-class="::{empty: !$ctrl.item.value6}"
|
||||
title="{{::$ctrl.item.tag6}}: {{::$ctrl.item.value6}}">
|
||||
{{::$ctrl.item.value6}}
|
||||
</section>
|
||||
<section
|
||||
class="inline-tag ellipsize"
|
||||
ng-class="::{empty: !$ctrl.item.value7}"
|
||||
title="{{::$ctrl.item.tag7}}: {{::$ctrl.item.value7}}">
|
||||
{{::$ctrl.item.value7}}
|
||||
</section>
|
||||
<section
|
||||
class="inline-tag ellipsize"
|
||||
ng-class="::{empty: !$ctrl.item.value8}"
|
||||
title="{{::$ctrl.item.tag8}}: {{::$ctrl.item.value8}}">
|
||||
{{::$ctrl.item.value8}}
|
||||
</section>
|
||||
<section
|
||||
class="inline-tag ellipsize"
|
||||
ng-class="::{empty: !$ctrl.item.value9}"
|
||||
title="{{::$ctrl.item.tag9}}: {{::$ctrl.item.value9}}">
|
||||
{{::$ctrl.item.value9}}
|
||||
</section>
|
||||
<section
|
||||
class="inline-tag ellipsize"
|
||||
ng-class="::{empty: !$ctrl.item.value10}"
|
||||
title="{{::$ctrl.item.tag10}}: {{::$ctrl.item.value10}}">
|
||||
{{::$ctrl.item.value10}}
|
||||
</section>
|
||||
</vn-auto>
|
||||
</vn-horizontal>
|
|
@ -1,52 +1,8 @@
|
|||
import ngModule from '../module';
|
||||
import './style.scss';
|
||||
|
||||
export default class FetchedTags {
|
||||
set item(value) {
|
||||
if (value) {
|
||||
let tags = [];
|
||||
for (let i = 5; i < 5 + this.maxLength; i++) {
|
||||
if (value['tag' + i]) {
|
||||
let tagValue = value['value' + i];
|
||||
let tagKey = value['tag' + i];
|
||||
tags.push({name: tagKey, value: tagValue, position: i - 5});
|
||||
}
|
||||
}
|
||||
this.tags = tags;
|
||||
}
|
||||
this._item = value;
|
||||
}
|
||||
|
||||
get item() {
|
||||
return this._item;
|
||||
}
|
||||
|
||||
set tags(value) {
|
||||
if (value) {
|
||||
let organizedTags = new Array(parseInt(this.maxLength));
|
||||
for (let i = 0; i < this.maxLength; i++) {
|
||||
let organizedTag = {};
|
||||
for (let j = 0; j < value.length; j++) {
|
||||
if (value[j].position === i) {
|
||||
organizedTag.name = value[j].name;
|
||||
organizedTag.value = value[j].value;
|
||||
}
|
||||
organizedTags[i] = JSON.parse(JSON.stringify(organizedTag));
|
||||
}
|
||||
}
|
||||
this._tags = organizedTags;
|
||||
}
|
||||
}
|
||||
|
||||
get tags() {
|
||||
return this._tags;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ngModule.component('vnFetchedTags', {
|
||||
template: require('./index.html'),
|
||||
controller: FetchedTags,
|
||||
bindings: {
|
||||
maxLength: '<',
|
||||
item: '<',
|
||||
|
|
|
@ -2,7 +2,7 @@ import ngModule from '../module';
|
|||
import './style.scss';
|
||||
|
||||
class Controller {
|
||||
constructor($http, $state, $scope) {
|
||||
constructor($http, $state, $scope, $stateParams) {
|
||||
this.$http = $http;
|
||||
this.$state = $state;
|
||||
this.$ = $scope;
|
||||
|
@ -13,6 +13,14 @@ class Controller {
|
|||
id: false,
|
||||
actions: false
|
||||
};
|
||||
|
||||
if (!$stateParams.q)
|
||||
this.filter = {hasVisible: true, isActive: true};
|
||||
}
|
||||
|
||||
$postLink() {
|
||||
if (this.filter)
|
||||
this.onSearch(this.filter);
|
||||
}
|
||||
|
||||
stopEvent(event) {
|
||||
|
@ -83,7 +91,7 @@ class Controller {
|
|||
this.$.preview.show();
|
||||
}
|
||||
}
|
||||
Controller.$inject = ['$http', '$state', '$scope'];
|
||||
Controller.$inject = ['$http', '$state', '$scope', '$stateParams'];
|
||||
|
||||
ngModule.component('vnItemIndex', {
|
||||
template: require('./index.html'),
|
||||
|
|
|
@ -47,6 +47,19 @@
|
|||
model="filter.description">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-check
|
||||
vn-one
|
||||
label="With visible"
|
||||
field="filter.hasVisible">
|
||||
</vn-check>
|
||||
<vn-check
|
||||
vn-one
|
||||
label="Active"
|
||||
field="filter.isActive"
|
||||
triple-state="true">
|
||||
</vn-check>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal ng-repeat="itemTag in filter.tags">
|
||||
<vn-autocomplete
|
||||
vn-id="tag"
|
||||
|
|
Loading…
Reference in New Issue