Fix: Pagination bug with filters payload (#3747)

* Removes the last operators value

* Moved removing the last operator to the payload generator

* Update app/javascript/dashboard/helper/filterQueryGenerator.js

This makes sure the last operator is never sent to the request

Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com>

* Fixed the test specs

* Fixed the intendation and added comments

Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com>
This commit is contained in:
Fayaz Ahmed 2022-01-17 20:35:53 +05:30 committed by GitHub
parent 4398734bdf
commit 6deb3764dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 5 deletions

View file

@ -192,7 +192,6 @@ export default {
'setConversationFilters',
JSON.parse(JSON.stringify(this.appliedFilters))
);
this.appliedFilters[this.appliedFilters.length - 1].query_operator = null;
this.$emit('applyFilter', this.appliedFilters);
},
resetFilter(index, currentFilter) {

View file

@ -11,7 +11,10 @@ const generatePayload = data => {
}
return item;
});
// For every query added, the query_operator is set default to and so the
// last query will have an extra query_operator, this would break the api.
// Setting this to null for all query payload
payload[payload.length - 1].query_operator = undefined;
return { payload };
};

View file

@ -31,7 +31,7 @@ const testData = [
attribute_key: 'id',
filter_operator: 'equal_to',
values: 'This is a test',
query_operator: null,
query_operator: 'or',
},
];
@ -53,7 +53,6 @@ const finalResult = {
attribute_key: 'id',
filter_operator: 'equal_to',
values: ['This is a test'],
query_operator: null,
},
],
};

View file

@ -160,7 +160,6 @@ export default {
'contacts/setContactFilters',
JSON.parse(JSON.stringify(this.appliedFilters))
);
this.appliedFilters[this.appliedFilters.length - 1].query_operator = null;
this.$emit('applyFilter', this.appliedFilters);
},
resetFilter(index, currentFilter) {