feat: display record identifier field as first column in table (#3788)
* feat: display record identifier field as first column in table & forbid hiding and moving record identifier column Closes #3303 * refactor: add availableTableColumnKeysSelectorScopeMap * feat: show plus icon button for label identifier column and dropdown menu for other columns * fix: use label identifier field value in RecordShowPage title * refactor: remove availableColumnKeys selector * refactor: review - compute label identifier logic in mapViewFieldsToColumnDefinitions + remove selectors * fix: several fixes * fix: fix board fields isVisible * fix: fix board fields reordering * fix: more board fields fixes * fix: fix hiddenTableColumnsSelectorScopeMap
This commit is contained in:
13
packages/twenty-front/src/utils/array/groupArrayItemsBy.ts
Normal file
13
packages/twenty-front/src/utils/array/groupArrayItemsBy.ts
Normal file
@ -0,0 +1,13 @@
|
||||
export const groupArrayItemsBy = <Item, Key extends string>(
|
||||
array: Item[],
|
||||
computeGroupKey: (item: Item) => Key,
|
||||
) =>
|
||||
array.reduce<Partial<Record<Key, Item[]>>>((result, item) => {
|
||||
const groupKey = computeGroupKey(item);
|
||||
const previousGroup = result[groupKey] || [];
|
||||
|
||||
return {
|
||||
...result,
|
||||
[groupKey]: [...previousGroup, item],
|
||||
};
|
||||
}, {});
|
||||
@ -0,0 +1,4 @@
|
||||
export const mapArrayToObject = <ArrayItem>(
|
||||
array: ArrayItem[],
|
||||
computeItemKey: (item: ArrayItem) => string,
|
||||
) => Object.fromEntries(array.map((item) => [computeItemKey(item), item]));
|
||||
14
packages/twenty-front/src/utils/array/moveArrayItem.ts
Normal file
14
packages/twenty-front/src/utils/array/moveArrayItem.ts
Normal file
@ -0,0 +1,14 @@
|
||||
export const moveArrayItem = <Item>(
|
||||
array: Item[],
|
||||
{ fromIndex, toIndex }: { fromIndex: number; toIndex: number },
|
||||
) => {
|
||||
if (!(fromIndex in array) || !(toIndex in array) || fromIndex === toIndex) {
|
||||
return array;
|
||||
}
|
||||
|
||||
const arrayWithMovedItem = [...array];
|
||||
const [itemToMove] = arrayWithMovedItem.splice(fromIndex, 1);
|
||||
arrayWithMovedItem.splice(toIndex, 0, itemToMove);
|
||||
|
||||
return arrayWithMovedItem;
|
||||
};
|
||||
Reference in New Issue
Block a user