mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 03:57:52 +00:00
feat: Custom attribute sidebar list UX improvements (#9070)
--------- Co-authored-by: Pranav <pranav@chatwoot.com> Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
@@ -29,33 +29,6 @@ export default {
|
||||
conversationId() {
|
||||
return this.currentChat.id;
|
||||
},
|
||||
|
||||
filteredAttributes() {
|
||||
return Object.keys(this.customAttributes).map(key => {
|
||||
const item = this.attributes.find(
|
||||
attribute => attribute.attribute_key === key
|
||||
);
|
||||
if (item) {
|
||||
return {
|
||||
...item,
|
||||
value: this.customAttributes[key],
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
...item,
|
||||
value: this.customAttributes[key],
|
||||
attribute_description: key,
|
||||
attribute_display_name: key,
|
||||
attribute_display_type: this.attributeDisplayType(
|
||||
this.customAttributes[key]
|
||||
),
|
||||
attribute_key: key,
|
||||
attribute_model: this.attributeType,
|
||||
id: Math.random(),
|
||||
};
|
||||
});
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
isAttributeNumber(attributeValue) {
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
export default [
|
||||
{
|
||||
attribute_description: 'Product name',
|
||||
attribute_display_name: 'Product name',
|
||||
attribute_display_type: 'text',
|
||||
attribute_key: 'product_name',
|
||||
attribute_model: 'conversation_attribute',
|
||||
created_at: '2021-09-03T10:45:09.587Z',
|
||||
default_value: null,
|
||||
id: 6,
|
||||
updated_at: '2021-09-22T10:40:42.511Z',
|
||||
},
|
||||
{
|
||||
attribute_description: 'Product identifier',
|
||||
attribute_display_name: 'Product id',
|
||||
attribute_display_type: 'number',
|
||||
attribute_key: 'product_id',
|
||||
attribute_model: 'conversation_attribute',
|
||||
created_at: '2021-09-16T13:06:47.329Z',
|
||||
default_value: null,
|
||||
icon: 'fluent-calculator',
|
||||
id: 10,
|
||||
updated_at: '2021-09-22T10:42:25.873Z',
|
||||
value: 2021,
|
||||
},
|
||||
];
|
||||
@@ -1,7 +1,6 @@
|
||||
import { shallowMount, createLocalVue } from '@vue/test-utils';
|
||||
import attributeMixin from '../attributeMixin';
|
||||
import Vuex from 'vuex';
|
||||
import attributeFixtures from './attributeFixtures';
|
||||
|
||||
const localVue = createLocalVue();
|
||||
localVue.use(Vuex);
|
||||
@@ -41,43 +40,6 @@ describe('attributeMixin', () => {
|
||||
expect(wrapper.vm.conversationId).toEqual(7165);
|
||||
});
|
||||
|
||||
it('returns filtered attributes from conversation custom attributes', () => {
|
||||
const Component = {
|
||||
render() {},
|
||||
title: 'TestComponent',
|
||||
mixins: [attributeMixin],
|
||||
computed: {
|
||||
attributes() {
|
||||
return attributeFixtures;
|
||||
},
|
||||
contact() {
|
||||
return {
|
||||
id: 7165,
|
||||
custom_attributes: {
|
||||
product_id: 2021,
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
||||
const wrapper = shallowMount(Component, { store, localVue });
|
||||
expect(wrapper.vm.filteredAttributes).toEqual([
|
||||
{
|
||||
attribute_description: 'Product identifier',
|
||||
attribute_display_name: 'Product id',
|
||||
attribute_display_type: 'number',
|
||||
attribute_key: 'product_id',
|
||||
attribute_model: 'conversation_attribute',
|
||||
created_at: '2021-09-16T13:06:47.329Z',
|
||||
default_value: null,
|
||||
icon: 'fluent-calculator',
|
||||
id: 10,
|
||||
updated_at: '2021-09-22T10:42:25.873Z',
|
||||
value: 2021,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('return display type if attribute passed', () => {
|
||||
const Component = {
|
||||
render() {},
|
||||
|
||||
Reference in New Issue
Block a user