feat: Add the ability to save filters for contact (#3791)
This commit is contained in:
@@ -18,13 +18,18 @@ export const getters = {
|
||||
getCustomViews(_state) {
|
||||
return _state.records;
|
||||
},
|
||||
getCustomViewsByFilterType: _state => filterType => {
|
||||
return _state.records.filter(record => record.filter_type === filterType);
|
||||
},
|
||||
};
|
||||
|
||||
export const actions = {
|
||||
get: async function getCustomViews({ commit }) {
|
||||
get: async function getCustomViews({ commit }, filterType) {
|
||||
commit(types.SET_CUSTOM_VIEW_UI_FLAG, { isFetching: true });
|
||||
try {
|
||||
const response = await CustomViewsAPI.getCustomViews();
|
||||
const response = await CustomViewsAPI.getCustomViewsByFilterType(
|
||||
filterType
|
||||
);
|
||||
commit(types.SET_CUSTOM_VIEW, response.data);
|
||||
} catch (error) {
|
||||
// Ignore error
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export default [
|
||||
{
|
||||
name: 'Custom view',
|
||||
filter_type: 'conversation',
|
||||
filter_type: 0,
|
||||
query: {
|
||||
payload: [
|
||||
{
|
||||
@@ -21,20 +21,14 @@ export default [
|
||||
},
|
||||
{
|
||||
name: 'Custom view 1',
|
||||
filter_type: 'conversation',
|
||||
filter_type: 1,
|
||||
query: {
|
||||
payload: [
|
||||
{
|
||||
attribute_key: 'browser_language',
|
||||
attribute_key: 'name',
|
||||
filter_operator: 'equal_to',
|
||||
values: ['eng'],
|
||||
query_operator: 'or',
|
||||
},
|
||||
{
|
||||
attribute_key: 'campaign_id',
|
||||
filter_operator: 'equal_to',
|
||||
values: [15],
|
||||
query_operator: 'and',
|
||||
values: ['john doe'],
|
||||
query_operator: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -7,7 +7,7 @@ describe('#getters', () => {
|
||||
expect(getters.getCustomViews(state)).toEqual([
|
||||
{
|
||||
name: 'Custom view',
|
||||
filter_type: 'conversation',
|
||||
filter_type: 0,
|
||||
query: {
|
||||
payload: [
|
||||
{
|
||||
@@ -27,20 +27,34 @@ describe('#getters', () => {
|
||||
},
|
||||
{
|
||||
name: 'Custom view 1',
|
||||
filter_type: 'conversation',
|
||||
filter_type: 1,
|
||||
query: {
|
||||
payload: [
|
||||
{
|
||||
attribute_key: 'browser_language',
|
||||
attribute_key: 'name',
|
||||
filter_operator: 'equal_to',
|
||||
values: ['eng'],
|
||||
query_operator: 'or',
|
||||
values: ['john doe'],
|
||||
query_operator: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('getCustomViewsByFilterType', () => {
|
||||
const state = { records: customViewList };
|
||||
expect(getters.getCustomViewsByFilterType(state)(1)).toEqual([
|
||||
{
|
||||
name: 'Custom view 1',
|
||||
filter_type: 1,
|
||||
query: {
|
||||
payload: [
|
||||
{
|
||||
attribute_key: 'campaign_id',
|
||||
attribute_key: 'name',
|
||||
filter_operator: 'equal_to',
|
||||
values: [15],
|
||||
query_operator: 'and',
|
||||
values: ['john doe'],
|
||||
query_operator: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user