1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-15 14:49:09 +00:00

feat: metadata multiple select

This commit is contained in:
杨国璇
2024-08-16 18:56:41 +08:00
committed by 杨国璇
parent 0142fe448a
commit 7a47c647a2
46 changed files with 900 additions and 75 deletions

View File

@@ -5,6 +5,8 @@ import {
sortNumber,
sortCheckbox,
sortCollaborator,
sortSingleSelect,
sortMultipleSelect,
} from '../sort/sort-column';
import { MAX_GROUP_LEVEL } from '../../constants/group';
import {
@@ -45,6 +47,9 @@ const _getFormattedCellValue = (cellValue, groupby) => {
case CellType.SINGLE_SELECT: {
return cellValue || null;
}
case CellType.MULTIPLE_SELECT: {
return Array.isArray(cellValue) ? cellValue : [];
}
case CellType.COLLABORATOR: {
return Array.isArray(cellValue) ? cellValue : [];
}
@@ -98,8 +103,18 @@ const _findGroupIndex = (sCellValue, cellValue2GroupIndexMap, groupsLength) => {
const getSortedGroups = (groups, groupbys, level, collaborators = []) => {
const sortFlag = 0;
const { column, sort_type } = groupbys[level];
const { type: columnType } = column;
const { type: columnType, data: columnData } = column;
const normalizedSortType = sort_type || SORT_TYPE.UP;
let option_id_index_map = {};
if (columnType === CellType.SINGLE_SELECT || columnType === CellType.MULTIPLE_SELECT) {
const { options } = columnData || {};
if (Array.isArray(options)) {
options.forEach((option, index) => {
option_id_index_map[option.id] = index;
});
}
}
groups.sort((currGroupRow, nextGroupRow) => {
let { cell_value: currCellVal } = currGroupRow;
let { cell_value: nextCellVal } = nextGroupRow;
@@ -121,6 +136,10 @@ const getSortedGroups = (groups, groupbys, level, collaborators = []) => {
nextCollaborators = getCollaboratorsNames(nextCollaborators, collaborators);
}
sortResult = sortCollaborator(currCollaborators, nextCollaborators, normalizedSortType);
} else if (columnType === CellType.SINGLE_SELECT) {
sortResult = sortSingleSelect(currCellVal, nextCellVal, { sort_type: normalizedSortType, option_id_index_map });
} else if (columnType === CellType.MULTIPLE_SELECT) {
sortResult = sortMultipleSelect(currCellVal, nextCellVal, { sort_type: normalizedSortType, option_id_index_map });
}
return sortFlag || sortResult;
}