Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const FilterByText: FilterByTextType = ({ setFilter, reload, customFields, setCu
<Box display='flex' flexDirection='row' marginBlockStart='x8' {...props}>
<Box display='flex' mie='x8' flexGrow={1} flexDirection='column'>
<Label mb='x4'>{t('Tags')}</Label>
<EETagsComponent value={tags} handler={handleTags} />
<EETagsComponent value={tags} handler={handleTags} viewAll />
</Box>
</Box>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function RoomEdit({ room, visitor, reload, reloadInfo, onClose }: RoomEditProps)
</Field>

<Field>
<Tags tags={tagsField.value} handler={tagsField.onChange} />
<Tags tags={tagsField.value} handler={tagsField.onChange} department={room.departmentId} />
</Field>

{SlaPoliciesSelect && !!slaPolicies?.length && (
Expand Down
17 changes: 10 additions & 7 deletions apps/meteor/ee/client/hooks/useTagsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ import { RecordList } from '../../../client/lib/lists/RecordList';
type TagsListOptions = {
filter: string;
department?: string;
viewAll?: boolean;
};

export const useTagsList = (
options: TagsListOptions,
): {
type UseTagsListResult = {
itemsList: RecordList<ILivechatTagRecord>;
initialItemCount: number;
reload: () => void;
loadMoreItems: (start: number, end: number) => void;
} => {
};

export const useTagsList = (options: TagsListOptions): UseTagsListResult => {
const { viewAll, department, filter } = options;
const [itemsList, setItemsList] = useState(() => new RecordList<ILivechatTagRecord>());
const reload = useCallback(() => setItemsList(new RecordList<ILivechatTagRecord>()), []);

Expand All @@ -31,10 +33,11 @@ export const useTagsList = (
const fetchData = useCallback(
async (start, end) => {
const { tags, total } = await getTags({
text: options.filter,
text: filter,
offset: start,
count: end + start,
...(options.department && { department: options.department }),
...(viewAll && { viewAll: 'true' }),
...(department && { department }),
});
return {
items: tags.map((tag: any) => {
Expand All @@ -46,7 +49,7 @@ export const useTagsList = (
itemCount: total,
};
},
[getTags, options.filter, options.department],
[getTags, filter, viewAll, department],
);

const { loadMoreItems, initialItemCount } = useScrollableRecordList(itemsList, fetchData, 25);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ import { AsyncStatePhase } from '../../../../client/hooks/useAsyncState';
import { useTagsList } from '../../hooks/useTagsList';

const AutoCompleteTagMultiple = (props) => {
const { value, onlyMyTags = false, onChange = () => {}, department } = props;
const { value, onlyMyTags = false, onChange = () => {}, department, viewAll = false } = props;

const t = useTranslation();
const [tagsFilter, setTagsFilter] = useState('');

const debouncedTagsFilter = useDebouncedValue(tagsFilter, 500);

const { itemsList: tagsList, loadMoreItems: loadMoreTags } = useTagsList(
useMemo(() => ({ filter: debouncedTagsFilter, onlyMyTags, department }), [debouncedTagsFilter, onlyMyTags, department]),
useMemo(
() => ({ filter: debouncedTagsFilter, onlyMyTags, department, viewAll }),
[debouncedTagsFilter, onlyMyTags, department, viewAll],
),
);

const { phase: tagsPhase, items: tagsItems, itemCount: tagsTotal } = useRecordList(tagsList);
Expand Down
6 changes: 4 additions & 2 deletions apps/meteor/ee/client/omnichannel/tags/CurrentChatTags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import React from 'react';

import AutoCompleteTagsMultiple from './AutoCompleteTagsMultiple';

const CurrentChatTags: FC<{ value: Array<string>; handler: () => void; department?: string }> = ({ value, handler, department }) => (
<AutoCompleteTagsMultiple onChange={handler} value={value} department={department} />
type CurrentChatTagsProps = { value: Array<string>; handler: () => void; department?: string; viewAll?: boolean };

const CurrentChatTags: FC<CurrentChatTagsProps> = ({ value, handler, department, viewAll }) => (
<AutoCompleteTagsMultiple onChange={handler} value={value} department={department} viewAll={viewAll} />
);

export default CurrentChatTags;