Skip to content

Commit

Permalink
correção de busca simples
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusmirandaalmeida committed Nov 6, 2017
1 parent 7e81749 commit aac1159
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gumga-query-filter-ng",
"version": "1.11.0",
"version": "1.11.1",
"description": "Gumga Query Filter",
"main": "./src/index.js",
"authors": [
Expand Down
9 changes: 6 additions & 3 deletions dist/gumga-query-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,13 @@ function Search($q, $timeout, $compile, $interpolate) {
});

result.forEach(function (field, index) {
var criteria = new Criteria(field, getComparisonOperatorByType(field), param == undefined || param == null ? '' : param);
if (ctrl.mapFields[field].type == 'number') {
var criteria = null;
if (param != undefined && param != null) {
criteria = new Criteria(field, getComparisonOperatorByType(field), param == undefined || param == null ? '' : param);
}
if (ctrl.mapFields[field].type == 'number' && param != undefined && param != null) {
criteria = new Criteria(field, getComparisonOperatorByType(field), param == undefined || param == null ? 0 : Number(param));
} else if (ctrl.mapFields[field].type == 'date') {
} else if (ctrl.mapFields[field].type == 'date' && param) {
criteria = new Criteria(field, getComparisonOperatorByType(field), param == undefined || param == null ? new Date() : new Date(param));
} else if (ctrl.mapFields[field].type == 'string') {
criteria.setFieldFunction('%s');
Expand Down
2 changes: 1 addition & 1 deletion dist/gumga-query-filter.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gumga-query-filter-ng",
"version": "1.11.0",
"version": "1.11.1",
"description": "Gumga Query Filter",
"main": "./src/index.js",
"directories": {
Expand Down
2 changes: 1 addition & 1 deletion src/factory/hql-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ function HQLFactory($filter){
}else if(querys[i].query.attribute.type == 'boolean') {
query = new GQuery(null, new Criteria(querys[i].query.attribute.field, querys[i].query.condition.key, querys[i].query.value === 'true'));
} else if(querys[i].query.attribute.type == 'number') {
query = new GQuery(null, new Criteria(querys[i].query.attribute.field, querys[i].query.condition.key, Number(querys[i].query.value)));
query = new GQuery(null, new Criteria(querys[i].query.attribute.field, querys[i].query.condition.key, Number(querys[i].query.value)));
} else {
query = new GQuery(null, new Criteria(querys[i].query.attribute.field, querys[i].query.condition.key, querys[i].query.value));
}
Expand Down
12 changes: 8 additions & 4 deletions src/query/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,13 @@
})

result.forEach((field, index) => {
let criteria = new Criteria(field, getComparisonOperatorByType(field), param == undefined || param == null ? '' : param);
if(ctrl.mapFields[field].type == 'number') {
let criteria = null;
if(param != undefined && param != null){
criteria = new Criteria(field, getComparisonOperatorByType(field), param == undefined || param == null ? '' : param);
}
if(ctrl.mapFields[field].type == 'number' && param != undefined && param != null) {
criteria = new Criteria(field, getComparisonOperatorByType(field), param == undefined || param == null ? 0 : Number(param));
} else if(ctrl.mapFields[field].type == 'date') {
} else if(ctrl.mapFields[field].type == 'date' && param) {
criteria = new Criteria(field, getComparisonOperatorByType(field), param == undefined || param == null ? new Date() : new Date(param));
} else if(ctrl.mapFields[field].type == 'string') {
criteria.setFieldFunction('%s');
Expand All @@ -207,11 +210,12 @@
}
}

if(index == 0){
if(index == 0){
query = new GQuery(criteria);
}else{
query = query.or(criteria);
}

});

innerJoins.forEach(function(innerJoin) {
Expand Down

0 comments on commit aac1159

Please sign in to comment.