mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-03 12:37:56 +00:00
fix: Edit custom views folder (#7670)
This commit is contained in:
@@ -36,6 +36,10 @@ export const getValuesName = (values, list, idKey, nameKey) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getValuesForStatus = values => {
|
||||||
|
return values.map(value => ({ id: value, name: value }));
|
||||||
|
};
|
||||||
|
|
||||||
const getValuesForLabels = (values, labels) => {
|
const getValuesForLabels = (values, labels) => {
|
||||||
const selectedLabels = labels.filter(label => values.includes(label.title));
|
const selectedLabels = labels.filter(label => values.includes(label.title));
|
||||||
return selectedLabels.map(({ title }) => ({
|
return selectedLabels.map(({ title }) => ({
|
||||||
@@ -76,6 +80,8 @@ export const getValuesForFilter = (filter, params) => {
|
|||||||
labels,
|
labels,
|
||||||
} = params;
|
} = params;
|
||||||
switch (attribute_key) {
|
switch (attribute_key) {
|
||||||
|
case 'status':
|
||||||
|
return getValuesForStatus(values);
|
||||||
case 'assignee_id':
|
case 'assignee_id':
|
||||||
return getValuesName(values, agents, 'id', 'name');
|
return getValuesName(values, agents, 'id', 'name');
|
||||||
case 'inbox_id':
|
case 'inbox_id':
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import {
|
|||||||
getAttributeInputType,
|
getAttributeInputType,
|
||||||
getInputType,
|
getInputType,
|
||||||
getValuesName,
|
getValuesName,
|
||||||
|
getValuesForStatus,
|
||||||
getValuesForFilter,
|
getValuesForFilter,
|
||||||
generateValuesForEditCustomViews,
|
generateValuesForEditCustomViews,
|
||||||
generateCustomAttributesInputType,
|
generateCustomAttributesInputType,
|
||||||
@@ -106,7 +107,33 @@ describe('customViewsHelper', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#getValuesForStatus', () => {
|
||||||
|
it('should return id and name if value is present', () => {
|
||||||
|
const values = ['open'];
|
||||||
|
expect(getValuesForStatus(values)).toEqual([
|
||||||
|
{ id: 'open', name: 'open' },
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return id and name if multiple values are present', () => {
|
||||||
|
const values = ['open', 'resolved'];
|
||||||
|
expect(getValuesForStatus(values)).toEqual([
|
||||||
|
{ id: 'open', name: 'open' },
|
||||||
|
{ id: 'resolved', name: 'resolved' },
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('#getValuesForFilter', () => {
|
describe('#getValuesForFilter', () => {
|
||||||
|
it('should return id and name if attribute_key is status', () => {
|
||||||
|
const filter = { attribute_key: 'status', values: ['open', 'resolved'] };
|
||||||
|
const params = {};
|
||||||
|
expect(getValuesForFilter(filter, params)).toEqual([
|
||||||
|
{ id: 'open', name: 'open' },
|
||||||
|
{ id: 'resolved', name: 'resolved' },
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
it('should return id and name if attribute_key is assignee_id', () => {
|
it('should return id and name if attribute_key is assignee_id', () => {
|
||||||
const filter = { attribute_key: 'assignee_id', values: [1] };
|
const filter = { attribute_key: 'assignee_id', values: [1] };
|
||||||
const params = { agents: [{ id: 1, name: 'test' }] };
|
const params = { agents: [{ id: 1, name: 'test' }] };
|
||||||
|
|||||||
Reference in New Issue
Block a user