diff --git a/front/core/components/searchbar/searchbar.js b/front/core/components/searchbar/searchbar.js
index aefa89b5b..c74146817 100644
--- a/front/core/components/searchbar/searchbar.js
+++ b/front/core/components/searchbar/searchbar.js
@@ -203,7 +203,7 @@ export default class Searchbar extends Component {
doSearch(filter, source) {
if (filter === this.filter && !this.isIndex) return;
- let promise = this.onSearch({$params: filter});
+ let promise = this.onSearch({$params: filter}, source);
promise = promise || this.$q.resolve();
promise.then(data => this.onFilter(filter, source, data));
this.toBar(filter);
@@ -259,12 +259,6 @@ export default class Searchbar extends Component {
this.filter = filter;
- if (source == 'removeBar') {
- delete params[this.toRemove];
- delete this.model.userParams[this.toRemove];
- this.model.refresh();
- }
-
if (!filter && this.model)
this.model.clear();
if (source != 'state')
@@ -279,7 +273,7 @@ export default class Searchbar extends Component {
return {id: params.$row.id};
}
- onSearch(args) {
+ onSearch(args, source) {
if (!this.model) return;
let filter = args.$params;
@@ -325,6 +319,12 @@ export default class Searchbar extends Component {
for (let param in stateFilter.tableQ)
params[param] = stateFilter.tableQ[param];
+ if (source == 'removeBar') {
+ delete params[this.toRemove];
+ delete this.model.userParams[this.toRemove];
+ delete stateFilter[this.toRemove];
+ }
+
const newParams = Object.assign(stateFilter, params);
return this.model.applyParams(newParams)
.then(() => this.model.data);
diff --git a/front/core/components/searchbar/searchbar.spec.js b/front/core/components/searchbar/searchbar.spec.js
index 9998e7a7c..2e00c2905 100644
--- a/front/core/components/searchbar/searchbar.spec.js
+++ b/front/core/components/searchbar/searchbar.spec.js
@@ -197,7 +197,7 @@ describe('Component vnSearchbar', () => {
controller.doSearch(filter, 'any');
$scope.$apply();
- expect(controller.onSearch).toHaveBeenCalledWith({$params: filter});
+ expect(controller.onSearch).toHaveBeenCalledWith({$params: filter}, 'any');
expect(controller.onFilter).toHaveBeenCalledWith(filter, 'any', undefined);
});
});
diff --git a/modules/ticket/front/main/index.html b/modules/ticket/front/main/index.html
index 82b5e58cd..e1e6c4e47 100644
--- a/modules/ticket/front/main/index.html
+++ b/modules/ticket/front/main/index.html
@@ -16,4 +16,4 @@
-
\ No newline at end of file
+
diff --git a/modules/ticket/front/main/index.js b/modules/ticket/front/main/index.js
index 3f9482fc4..c49418cfc 100644
--- a/modules/ticket/front/main/index.js
+++ b/modules/ticket/front/main/index.js
@@ -1,5 +1,6 @@
import ngModule from '../module';
import ModuleMain from 'salix/components/module-main';
+const UserError = require('vn-loopback/util/user-error');
export default class Ticket extends ModuleMain {
fetchParams($params) {
@@ -14,10 +15,19 @@ export default class Ticket extends ModuleMain {
'scopeDays'
];
+ const seachPanelParams = Object.entries($params);
+ const hasFromParam = seachPanelParams.some(subarray => subarray.length > 0 && subarray[0] === 'from');
+ const hasToParam = seachPanelParams.some(subarray => subarray.length > 0 && subarray[0] === 'to');
+
+ if ((hasFromParam && !hasToParam) || (!hasFromParam && hasToParam))
+ throw new UserError(`Date range must have 'from' and 'to'`);
+
const hasExcludedParams = excludedParams.some(param => {
return $params && $params[param] != undefined;
});
+
const hasParams = Object.entries($params).length;
+
if (!hasParams || !hasExcludedParams)
$params.scopeDays = 1;
@@ -28,7 +38,6 @@ export default class Ticket extends ModuleMain {
const to = new Date(from.getTime());
to.setDate(to.getDate() + $params.scopeDays);
to.setHours(23, 59, 59, 999);
-
Object.assign($params, {from, to});
}
diff --git a/modules/ticket/front/main/locale/es.yml b/modules/ticket/front/main/locale/es.yml
new file mode 100644
index 000000000..8db264e45
--- /dev/null
+++ b/modules/ticket/front/main/locale/es.yml
@@ -0,0 +1 @@
+Date range must have 'from' and 'to': El rango de fechas debe tener 'desde' y 'hasta'