mirror of
https://github.com/haiwen/seahub.git
synced 2025-04-27 11:01:14 +00:00
Fix search tags not by RGB color (#7708)
* remove search tag by RGB color * remove search tag by tag RGB color
This commit is contained in:
parent
09581a961a
commit
ee09f7b0f8
@ -8,7 +8,7 @@ import DeleteTags from './delete-tags';
|
||||
import { Utils } from '../../../../utils/utils';
|
||||
import { KeyCodes } from '../../../../constants';
|
||||
import { gettext } from '../../../../utils/constants';
|
||||
import { getTagColor, getTagId, getTagName, getTagsByNameOrColor } from '../../../../tag/utils/cell';
|
||||
import { getTagColor, getTagId, getTagName, getTagsByName } from '../../../../tag/utils/cell';
|
||||
import { getRecordIdFromRecord } from '../../../../metadata/utils/cell';
|
||||
import { SELECT_OPTION_COLORS } from '../../../../metadata/constants';
|
||||
import { getRowById } from '../../utils/table';
|
||||
@ -38,7 +38,7 @@ const TagsEditor = ({
|
||||
const editorRef = useRef(null);
|
||||
const selectItemRef = useRef(null);
|
||||
|
||||
const displayTags = useMemo(() => getTagsByNameOrColor(allTagsRef.current, searchValue), [searchValue, allTagsRef]);
|
||||
const displayTags = useMemo(() => getTagsByName(allTagsRef.current, searchValue), [searchValue, allTagsRef]);
|
||||
|
||||
const isShowCreateBtn = useMemo(() => {
|
||||
if (!canAddTag || !searchValue || !Utils.isFunction(addNewTag)) return false;
|
||||
|
@ -8,7 +8,7 @@ import { Utils } from '../../../../utils/utils';
|
||||
import { KeyCodes } from '../../../../constants';
|
||||
import { gettext } from '../../../../utils/constants';
|
||||
import { useTags } from '../../../../tag/hooks';
|
||||
import { getTagColor, getTagId, getTagName, getTagsByNameOrColor, getTagByNameOrColor } from '../../../../tag/utils/cell';
|
||||
import { getTagId, getTagName, getTagsByName, getTagByName } from '../../../../tag/utils/cell';
|
||||
import { getRecordIdFromRecord } from '../../../utils/cell';
|
||||
import { getRowById } from '../../../../components/sf-table/utils/table';
|
||||
import { SELECT_OPTION_COLORS } from '../../../constants';
|
||||
@ -55,13 +55,13 @@ const TagsEditor = forwardRef(({
|
||||
return tagsData?.rows || [];
|
||||
}, [tagsData]);
|
||||
|
||||
const displayTags = useMemo(() => getTagsByNameOrColor(tags, searchValue), [searchValue, tags]);
|
||||
const displayTags = useMemo(() => getTagsByName(tags, searchValue), [searchValue, tags]);
|
||||
const recentlyUsedTags = useMemo(() => recentlyUsed, [recentlyUsed]);
|
||||
|
||||
const isShowCreateBtn = useMemo(() => {
|
||||
if (!canAddTag) return false;
|
||||
if (!canEditData || !searchValue) return false;
|
||||
return !getTagByNameOrColor(displayTags, searchValue);
|
||||
return !getTagByName(displayTags, searchValue);
|
||||
}, [canEditData, displayTags, searchValue, canAddTag]);
|
||||
|
||||
const style = useMemo(() => {
|
||||
@ -278,8 +278,7 @@ const TagsEditor = forwardRef(({
|
||||
if (!row) return;
|
||||
const value = searchValue.toLowerCase();
|
||||
const tagName = getTagName(row).toLowerCase();
|
||||
const tagColor = getTagColor(row).toLowerCase();
|
||||
if (!tagName.includes(value) && !tagColor.includes(value)) return;
|
||||
if (!tagName.includes(value)) return;
|
||||
const nodesWithAncestors = getNodesWithAncestors(node, tree).filter(node => checkIsTreeNodeShown(getTreeNodeKey(node), searchedKeyNodeFoldedMap));
|
||||
searchedNodes = [...searchedNodes, ...nodesWithAncestors];
|
||||
});
|
||||
|
@ -41,27 +41,23 @@ export const getTagFilesCount = (tag) => {
|
||||
return Array.isArray(links) ? links.length : 0;
|
||||
};
|
||||
|
||||
export const getTagsByNameOrColor = (tags, nameOrColor) => {
|
||||
export const getTagsByName = (tags, name) => {
|
||||
if (!Array.isArray(tags) || tags.length === 0) return [];
|
||||
if (!nameOrColor) return tags;
|
||||
const value = nameOrColor.toLowerCase();
|
||||
if (!name) return tags;
|
||||
const value = name.toLowerCase();
|
||||
return tags.filter((tag) => {
|
||||
const tagName = getTagName(tag);
|
||||
if (tagName && tagName.toLowerCase().includes(value)) return true;
|
||||
const tagColor = getTagColor(tag);
|
||||
if (tagColor && tagColor.toLowerCase().includes(value)) return true;
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
export const getTagByNameOrColor = (tags, nameOrColor) => {
|
||||
export const getTagByName = (tags, name) => {
|
||||
if (!Array.isArray(tags) || tags.length === 0) return null;
|
||||
if (!nameOrColor) return null;
|
||||
if (!name) return null;
|
||||
return tags.find((tag) => {
|
||||
const tagName = getTagName(tag);
|
||||
if (tagName && tagName === nameOrColor) return true;
|
||||
const tagColor = getTagColor(tag);
|
||||
if (tagColor && tagColor === nameOrColor) return true;
|
||||
if (tagName && tagName === name) return true;
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user