diff --git a/.codeclimate.yml b/.codeclimate.yml index f26021240..6b9e1a78f 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -22,6 +22,9 @@ checks: enabled: true config: threshold: 300 + method-lines: + config: + threshold: 50 exclude_patterns: - 'spec/' - '**/specs/' @@ -44,3 +47,4 @@ exclude_patterns: - 'app/javascript/shared/constants/countries.js' - 'app/javascript/dashboard/components/widgets/conversation/advancedFilterItems/languages.js' - 'app/javascript/dashboard/routes/dashboard/contacts/contactFilterItems/index.js' + - 'app/javascript/dashboard/components/widgets/FilterInput/FilterOperatorTypes.js' diff --git a/app/javascript/dashboard/components/ChatList.vue b/app/javascript/dashboard/components/ChatList.vue index 4b951a705..a1651c534 100644 --- a/app/javascript/dashboard/components/ChatList.vue +++ b/app/javascript/dashboard/components/ChatList.vue @@ -129,7 +129,7 @@ > diff --git a/app/javascript/dashboard/components/ui/DateTimePicker.vue b/app/javascript/dashboard/components/ui/DateTimePicker.vue index 4507edf78..979136695 100644 --- a/app/javascript/dashboard/components/ui/DateTimePicker.vue +++ b/app/javascript/dashboard/components/ui/DateTimePicker.vue @@ -30,7 +30,7 @@ export default { }, value: { type: Date, - default: () => [], + default: [], }, }, diff --git a/app/javascript/dashboard/components/widgets/FilterInput/FilterOperatorTypes.js b/app/javascript/dashboard/components/widgets/FilterInput/FilterOperatorTypes.js new file mode 100644 index 000000000..9e9e3a844 --- /dev/null +++ b/app/javascript/dashboard/components/widgets/FilterInput/FilterOperatorTypes.js @@ -0,0 +1,75 @@ +export const OPERATOR_TYPES_1 = [ + { + value: 'equal_to', + label: 'Equal to', + }, + { + value: 'not_equal_to', + label: 'Not equal to', + }, +]; + +export const OPERATOR_TYPES_2 = [ + { + value: 'equal_to', + label: 'Equal to', + }, + { + value: 'not_equal_to', + label: 'Not equal to', + }, + { + value: 'is_present', + label: 'Is present', + }, + { + value: 'is_not_present', + label: 'Is not present', + }, +]; + +export const OPERATOR_TYPES_3 = [ + { + value: 'equal_to', + label: 'Equal to', + }, + { + value: 'not_equal_to', + label: 'Not equal to', + }, + { + value: 'contains', + label: 'Contains', + }, + { + value: 'does_not_contain', + label: 'Does not contain', + }, +]; + +export const OPERATOR_TYPES_4 = [ + { + value: 'equal_to', + label: 'Equal to', + }, + { + value: 'not_equal_to', + label: 'Not equal to', + }, + { + value: 'is_present', + label: 'Is present', + }, + { + value: 'is_not_present', + label: 'Is not present', + }, + { + value: 'is_greater_than', + label: 'Is greater than', + }, + { + value: 'is_lesser_than', + label: 'Is lesser than', + }, +]; diff --git a/app/javascript/dashboard/components/widgets/FilterInput.vue b/app/javascript/dashboard/components/widgets/FilterInput/Index.vue similarity index 85% rename from app/javascript/dashboard/components/widgets/FilterInput.vue rename to app/javascript/dashboard/components/widgets/FilterInput/Index.vue index e0d0ea3b6..a64425393 100644 --- a/app/javascript/dashboard/components/widgets/FilterInput.vue +++ b/app/javascript/dashboard/components/widgets/FilterInput/Index.vue @@ -3,6 +3,27 @@
+ +
[], + }, }, computed: { attributeKey: { diff --git a/app/javascript/dashboard/components/widgets/conversation/ConversationAdvancedFilter.vue b/app/javascript/dashboard/components/widgets/conversation/ConversationAdvancedFilter.vue index acf7f3cfd..de65bb042 100644 --- a/app/javascript/dashboard/components/widgets/conversation/ConversationAdvancedFilter.vue +++ b/app/javascript/dashboard/components/widgets/conversation/ConversationAdvancedFilter.vue @@ -9,12 +9,13 @@ v-for="(filter, i) in appliedFilters" :key="i" v-model="appliedFilters[i]" - :filter-attributes="filterAttributes" + :filter-groups="filterGroups" :input-type="getInputType(appliedFilters[i].attribute_key)" :operators="getOperators(appliedFilters[i].attribute_key)" :dropdown-values="getDropdownValues(appliedFilters[i].attribute_key)" :show-query-operator="i !== appliedFilters.length - 1" :show-user-input="showUserInput(appliedFilters[i].filter_operator)" + :grouped-filters="true" :v="$v.appliedFilters.$each[i]" @resetFilter="resetFilter(i, appliedFilters[i])" @removeFilter="removeFilter(i)" @@ -48,22 +49,24 @@ diff --git a/app/javascript/shared/mixins/specs/filterFixtures.js b/app/javascript/shared/mixins/specs/filterFixtures.js new file mode 100644 index 000000000..6bacc4456 --- /dev/null +++ b/app/javascript/shared/mixins/specs/filterFixtures.js @@ -0,0 +1,29 @@ +export const filterGroups = [ + { + name: 'Standard Filters', + attributes: [ + { key: 'status', name: 'Status' }, + { key: 'assignee_id', name: 'Assignee Name' }, + { key: 'inbox_id', name: 'Inbox Name' }, + { key: 'team_id', name: 'Team Name' }, + { key: 'display_id', name: 'Conversation Identifier' }, + { key: 'campaign_id', name: 'Campaign Name' }, + { key: 'labels', name: 'Labels' }, + ], + }, + { + name: 'Additional Filters', + attributes: [ + { key: 'browser_language', name: 'Browser Language' }, + { key: 'country_code', name: 'Country Name' }, + { key: 'referer', name: 'Referer link' }, + ], + }, + { + name: 'Custom Attributes', + attributes: [ + { key: 'signed_up_at', name: 'Signed Up At' }, + { key: 'test', name: 'Test' }, + ], + }, +]; diff --git a/app/javascript/shared/mixins/specs/filterMixin.spec.js b/app/javascript/shared/mixins/specs/filterMixin.spec.js new file mode 100644 index 000000000..94fe95ea7 --- /dev/null +++ b/app/javascript/shared/mixins/specs/filterMixin.spec.js @@ -0,0 +1,13 @@ +import filterMixin from '../filterMixin'; +import { shallowMount } from '@vue/test-utils'; +import MockComponent from './MockComponent.vue'; + +describe('Test mixin function', () => { + const wrapper = shallowMount(MockComponent, { + mixins: [filterMixin], + }); + + it('should return proper value from bool', () => { + expect(wrapper.vm.setFilterAttributes).toBeTruthy(); + }); +});