fix: display_id to id mapping not handled (#12426)
The frontend filtering didn't handle the `id` to `display_id` mapping of conversations. This PR fixes it --------- Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
This commit is contained in:
@@ -103,6 +103,12 @@ const validationError = computed(() => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const inputFieldType = computed(() => {
|
||||||
|
if (inputType.value === 'date') return 'date';
|
||||||
|
if (inputType.value === 'number') return 'number';
|
||||||
|
return 'text';
|
||||||
|
});
|
||||||
|
|
||||||
const resetModelOnAttributeKeyChange = newAttributeKey => {
|
const resetModelOnAttributeKeyChange = newAttributeKey => {
|
||||||
/**
|
/**
|
||||||
* Resets the filter values and operator when the attribute key changes. This ensures that
|
* Resets the filter values and operator when the attribute key changes. This ensures that
|
||||||
@@ -182,7 +188,7 @@ defineExpose({ validate });
|
|||||||
<Input
|
<Input
|
||||||
v-else
|
v-else
|
||||||
v-model="values"
|
v-model="values"
|
||||||
:type="inputType === 'date' ? 'date' : 'text'"
|
:type="inputFieldType"
|
||||||
class="[&>input]:h-8 [&>input]:py-1.5 [&>input]:outline-offset-0"
|
class="[&>input]:h-8 [&>input]:py-1.5 [&>input]:outline-offset-0"
|
||||||
:placeholder="t('FILTER.INPUT_PLACEHOLDER')"
|
:placeholder="t('FILTER.INPUT_PLACEHOLDER')"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -164,8 +164,8 @@ export function useConversationFilterContext() {
|
|||||||
value: CONVERSATION_ATTRIBUTES.DISPLAY_ID,
|
value: CONVERSATION_ATTRIBUTES.DISPLAY_ID,
|
||||||
attributeName: t('FILTER.ATTRIBUTES.CONVERSATION_IDENTIFIER'),
|
attributeName: t('FILTER.ATTRIBUTES.CONVERSATION_IDENTIFIER'),
|
||||||
label: t('FILTER.ATTRIBUTES.CONVERSATION_IDENTIFIER'),
|
label: t('FILTER.ATTRIBUTES.CONVERSATION_IDENTIFIER'),
|
||||||
inputType: 'plainText',
|
inputType: 'number',
|
||||||
datatype: 'number',
|
dataType: 'number',
|
||||||
filterOperators: containmentOperators.value,
|
filterOperators: containmentOperators.value,
|
||||||
attributeModel: 'standard',
|
attributeModel: 'standard',
|
||||||
},
|
},
|
||||||
@@ -179,7 +179,7 @@ export function useConversationFilterContext() {
|
|||||||
id: campaign.id,
|
id: campaign.id,
|
||||||
name: campaign.title,
|
name: campaign.title,
|
||||||
})),
|
})),
|
||||||
datatype: 'number',
|
dataType: 'number',
|
||||||
filterOperators: presenceOperators.value,
|
filterOperators: presenceOperators.value,
|
||||||
attributeModel: 'standard',
|
attributeModel: 'standard',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -55,7 +55,12 @@ const inputOutlineClass = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleInput = event => {
|
const handleInput = event => {
|
||||||
emit('update:modelValue', event.target.value);
|
let value = event.target.value;
|
||||||
|
// Convert to number if type is number and value is not empty
|
||||||
|
if (props.type === 'number' && value !== '') {
|
||||||
|
value = Number(value);
|
||||||
|
}
|
||||||
|
emit('update:modelValue', value);
|
||||||
emit('input', event);
|
emit('input', event);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -114,7 +119,7 @@ onMounted(() => {
|
|||||||
? max
|
? max
|
||||||
: undefined
|
: undefined
|
||||||
"
|
"
|
||||||
class="block w-full reset-base text-sm h-10 !px-3 !py-2.5 !mb-0 outline outline-1 border-none border-0 outline-offset-[-1px] rounded-lg bg-n-alpha-black2 file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-n-slate-10 dark:placeholder:text-n-slate-10 disabled:cursor-not-allowed disabled:opacity-50 text-n-slate-12 transition-all duration-500 ease-in-out"
|
class="block w-full reset-base text-sm h-10 !px-3 !py-2.5 !mb-0 outline outline-1 border-none border-0 outline-offset-[-1px] rounded-lg bg-n-alpha-black2 file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-n-slate-10 dark:placeholder:text-n-slate-10 disabled:cursor-not-allowed disabled:opacity-50 text-n-slate-12 transition-all duration-500 ease-in-out [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"
|
||||||
@input="handleInput"
|
@input="handleInput"
|
||||||
@focus="handleFocus"
|
@focus="handleFocus"
|
||||||
@blur="handleBlur"
|
@blur="handleBlur"
|
||||||
|
|||||||
@@ -64,11 +64,13 @@ const getValueFromConversation = (conversation, attributeKey) => {
|
|||||||
switch (attributeKey) {
|
switch (attributeKey) {
|
||||||
case 'status':
|
case 'status':
|
||||||
case 'priority':
|
case 'priority':
|
||||||
case 'display_id':
|
|
||||||
case 'labels':
|
case 'labels':
|
||||||
case 'created_at':
|
case 'created_at':
|
||||||
case 'last_activity_at':
|
case 'last_activity_at':
|
||||||
return conversation[attributeKey];
|
return conversation[attributeKey];
|
||||||
|
case 'display_id':
|
||||||
|
// Frontend uses 'id' but backend expects 'display_id'
|
||||||
|
return conversation.display_id || conversation.id;
|
||||||
case 'assignee_id':
|
case 'assignee_id':
|
||||||
return conversation.meta?.assignee?.id;
|
return conversation.meta?.assignee?.id;
|
||||||
case 'inbox_id':
|
case 'inbox_id':
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ describe('filterHelpers', () => {
|
|||||||
|
|
||||||
// Text search tests - display_id
|
// Text search tests - display_id
|
||||||
it('should match conversation with equal_to operator for display_id', () => {
|
it('should match conversation with equal_to operator for display_id', () => {
|
||||||
const conversation = { display_id: '12345' };
|
const conversation = { id: '12345' };
|
||||||
const filters = [
|
const filters = [
|
||||||
{
|
{
|
||||||
attribute_key: 'display_id',
|
attribute_key: 'display_id',
|
||||||
@@ -260,7 +260,7 @@ describe('filterHelpers', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should match conversation with contains operator for display_id', () => {
|
it('should match conversation with contains operator for display_id', () => {
|
||||||
const conversation = { display_id: '12345' };
|
const conversation = { id: '12345' };
|
||||||
const filters = [
|
const filters = [
|
||||||
{
|
{
|
||||||
attribute_key: 'display_id',
|
attribute_key: 'display_id',
|
||||||
@@ -273,7 +273,7 @@ describe('filterHelpers', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not match conversation with does_not_contain operator for display_id', () => {
|
it('should not match conversation with does_not_contain operator for display_id', () => {
|
||||||
const conversation = { display_id: '12345' };
|
const conversation = { id: '12345' };
|
||||||
const filters = [
|
const filters = [
|
||||||
{
|
{
|
||||||
attribute_key: 'display_id',
|
attribute_key: 'display_id',
|
||||||
@@ -286,7 +286,7 @@ describe('filterHelpers', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should match conversation with does_not_contain operator when value is not present', () => {
|
it('should match conversation with does_not_contain operator when value is not present', () => {
|
||||||
const conversation = { display_id: '12345' };
|
const conversation = { id: '12345' };
|
||||||
const filters = [
|
const filters = [
|
||||||
{
|
{
|
||||||
attribute_key: 'display_id',
|
attribute_key: 'display_id',
|
||||||
@@ -989,7 +989,7 @@ describe('filterHelpers', () => {
|
|||||||
|
|
||||||
it('should handle empty string values in conversation', () => {
|
it('should handle empty string values in conversation', () => {
|
||||||
const conversation = {
|
const conversation = {
|
||||||
display_id: '',
|
id: '',
|
||||||
};
|
};
|
||||||
const filters = [
|
const filters = [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user