Skip to content

Commit 46ad360

Browse files
feat: reorder kanban columns (#1699)
* kaban header options * gql codegn * moveColumn hook refactor * BoardColumnContext addition * saved board columns state * db call hook update * lint fix * state change first db call second * handleMoveTableColumn call * codegen lint fix * useMoveViewColumns hook * useBoardColumns db call addition * boardColumns state change from BoardHeader --------- Co-authored-by: Charles Bochet <[email protected]>
1 parent 1e716bf commit 46ad360

18 files changed

+456
-107
lines changed

front/src/generated/graphql.tsx

+189
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,177 @@ export type CompanyWhereUniqueInput = {
899899
id?: InputMaybe<Scalars['String']>;
900900
};
901901

902+
export enum Currency {
903+
Aed = 'AED',
904+
Afn = 'AFN',
905+
All = 'ALL',
906+
Amd = 'AMD',
907+
Ang = 'ANG',
908+
Aoa = 'AOA',
909+
Ars = 'ARS',
910+
Aud = 'AUD',
911+
Awg = 'AWG',
912+
Azn = 'AZN',
913+
Bam = 'BAM',
914+
Bbd = 'BBD',
915+
Bdt = 'BDT',
916+
Bgn = 'BGN',
917+
Bhd = 'BHD',
918+
Bif = 'BIF',
919+
Bmd = 'BMD',
920+
Bnd = 'BND',
921+
Bob = 'BOB',
922+
Bov = 'BOV',
923+
Brl = 'BRL',
924+
Bsd = 'BSD',
925+
Btn = 'BTN',
926+
Bwp = 'BWP',
927+
Byn = 'BYN',
928+
Bzd = 'BZD',
929+
Cad = 'CAD',
930+
Cdf = 'CDF',
931+
Chf = 'CHF',
932+
Clf = 'CLF',
933+
Clp = 'CLP',
934+
Cny = 'CNY',
935+
Cop = 'COP',
936+
Cou = 'COU',
937+
Crc = 'CRC',
938+
Cuc = 'CUC',
939+
Cup = 'CUP',
940+
Cve = 'CVE',
941+
Czk = 'CZK',
942+
Djf = 'DJF',
943+
Dkk = 'DKK',
944+
Dop = 'DOP',
945+
Dzd = 'DZD',
946+
Egp = 'EGP',
947+
Ern = 'ERN',
948+
Etb = 'ETB',
949+
Eur = 'EUR',
950+
Fjd = 'FJD',
951+
Fkp = 'FKP',
952+
Gbp = 'GBP',
953+
Gel = 'GEL',
954+
Ghs = 'GHS',
955+
Gip = 'GIP',
956+
Gmd = 'GMD',
957+
Gnf = 'GNF',
958+
Gtq = 'GTQ',
959+
Gyd = 'GYD',
960+
Hkd = 'HKD',
961+
Hnl = 'HNL',
962+
Hrk = 'HRK',
963+
Htg = 'HTG',
964+
Huf = 'HUF',
965+
Idr = 'IDR',
966+
Ils = 'ILS',
967+
Inr = 'INR',
968+
Iqd = 'IQD',
969+
Irr = 'IRR',
970+
Isk = 'ISK',
971+
Jmd = 'JMD',
972+
Jod = 'JOD',
973+
Jpy = 'JPY',
974+
Kes = 'KES',
975+
Kgs = 'KGS',
976+
Khr = 'KHR',
977+
Kmf = 'KMF',
978+
Kpw = 'KPW',
979+
Krw = 'KRW',
980+
Kwd = 'KWD',
981+
Kyd = 'KYD',
982+
Kzt = 'KZT',
983+
Lak = 'LAK',
984+
Lbp = 'LBP',
985+
Lkr = 'LKR',
986+
Lrd = 'LRD',
987+
Lsl = 'LSL',
988+
Lyd = 'LYD',
989+
Mad = 'MAD',
990+
Mdl = 'MDL',
991+
Mga = 'MGA',
992+
Mkd = 'MKD',
993+
Mmk = 'MMK',
994+
Mnt = 'MNT',
995+
Mop = 'MOP',
996+
Mro = 'MRO',
997+
Mru = 'MRU',
998+
Mur = 'MUR',
999+
Mvr = 'MVR',
1000+
Mwk = 'MWK',
1001+
Mxn = 'MXN',
1002+
Mxv = 'MXV',
1003+
Myr = 'MYR',
1004+
Mzn = 'MZN',
1005+
Nad = 'NAD',
1006+
Ngn = 'NGN',
1007+
Nio = 'NIO',
1008+
Nok = 'NOK',
1009+
Npr = 'NPR',
1010+
Nzd = 'NZD',
1011+
Omr = 'OMR',
1012+
Pab = 'PAB',
1013+
Pen = 'PEN',
1014+
Pgk = 'PGK',
1015+
Php = 'PHP',
1016+
Pkr = 'PKR',
1017+
Pln = 'PLN',
1018+
Pyg = 'PYG',
1019+
Qar = 'QAR',
1020+
Ron = 'RON',
1021+
Rsd = 'RSD',
1022+
Rub = 'RUB',
1023+
Rwf = 'RWF',
1024+
Sar = 'SAR',
1025+
Sbd = 'SBD',
1026+
Scr = 'SCR',
1027+
Sdd = 'SDD',
1028+
Sdg = 'SDG',
1029+
Sek = 'SEK',
1030+
Sgd = 'SGD',
1031+
Shp = 'SHP',
1032+
Sll = 'SLL',
1033+
Sos = 'SOS',
1034+
Srd = 'SRD',
1035+
Ssp = 'SSP',
1036+
Std = 'STD',
1037+
Stn = 'STN',
1038+
Svc = 'SVC',
1039+
Syp = 'SYP',
1040+
Szl = 'SZL',
1041+
Thb = 'THB',
1042+
Tjs = 'TJS',
1043+
Tmm = 'TMM',
1044+
Tmt = 'TMT',
1045+
Tnd = 'TND',
1046+
Top = 'TOP',
1047+
Try = 'TRY',
1048+
Ttd = 'TTD',
1049+
Twd = 'TWD',
1050+
Tzs = 'TZS',
1051+
Uah = 'UAH',
1052+
Ugx = 'UGX',
1053+
Usd = 'USD',
1054+
Uyu = 'UYU',
1055+
Uzs = 'UZS',
1056+
Vef = 'VEF',
1057+
Ves = 'VES',
1058+
Vnd = 'VND',
1059+
Vuv = 'VUV',
1060+
Wst = 'WST',
1061+
Xaf = 'XAF',
1062+
Xcd = 'XCD',
1063+
Xof = 'XOF',
1064+
Xpf = 'XPF',
1065+
Xsu = 'XSU',
1066+
Xua = 'XUA',
1067+
Yer = 'YER',
1068+
Zar = 'ZAR',
1069+
Zmw = 'ZMW',
1070+
Zwl = 'ZWL'
1071+
}
1072+
9021073
export type DateTimeFilter = {
9031074
equals?: InputMaybe<Scalars['DateTime']>;
9041075
gt?: InputMaybe<Scalars['DateTime']>;
@@ -942,6 +1113,13 @@ export type EnumColorSchemeFilter = {
9421113
notIn?: InputMaybe<Array<ColorScheme>>;
9431114
};
9441115

1116+
export type EnumCurrencyFilter = {
1117+
equals?: InputMaybe<Currency>;
1118+
in?: InputMaybe<Array<Currency>>;
1119+
not?: InputMaybe<NestedEnumCurrencyFilter>;
1120+
notIn?: InputMaybe<Array<Currency>>;
1121+
};
1122+
9451123
export type EnumPipelineProgressableTypeFilter = {
9461124
equals?: InputMaybe<PipelineProgressableType>;
9471125
in?: InputMaybe<Array<PipelineProgressableType>>;
@@ -1492,6 +1670,13 @@ export type NestedEnumColorSchemeFilter = {
14921670
notIn?: InputMaybe<Array<ColorScheme>>;
14931671
};
14941672

1673+
export type NestedEnumCurrencyFilter = {
1674+
equals?: InputMaybe<Currency>;
1675+
in?: InputMaybe<Array<Currency>>;
1676+
not?: InputMaybe<NestedEnumCurrencyFilter>;
1677+
notIn?: InputMaybe<Array<Currency>>;
1678+
};
1679+
14951680
export type NestedEnumPipelineProgressableTypeFilter = {
14961681
equals?: InputMaybe<PipelineProgressableType>;
14971682
in?: InputMaybe<Array<PipelineProgressableType>>;
@@ -1795,6 +1980,7 @@ export type PersonWhereUniqueInput = {
17951980
export type Pipeline = {
17961981
__typename?: 'Pipeline';
17971982
createdAt: Scalars['DateTime'];
1983+
currency: Currency;
17981984
icon: Scalars['String'];
17991985
id: Scalars['ID'];
18001986
name: Scalars['String'];
@@ -1814,6 +2000,7 @@ export type PipelineCreateNestedOneWithoutPipelineStagesInput = {
18142000

18152001
export type PipelineOrderByWithRelationInput = {
18162002
createdAt?: InputMaybe<SortOrder>;
2003+
currency?: InputMaybe<SortOrder>;
18172004
icon?: InputMaybe<SortOrder>;
18182005
id?: InputMaybe<SortOrder>;
18192006
name?: InputMaybe<SortOrder>;
@@ -2000,6 +2187,7 @@ export type PipelineRelationFilter = {
20002187

20012188
export enum PipelineScalarFieldEnum {
20022189
CreatedAt = 'createdAt',
2190+
Currency = 'currency',
20032191
DeletedAt = 'deletedAt',
20042192
Icon = 'icon',
20052193
Id = 'id',
@@ -2141,6 +2329,7 @@ export type PipelineWhereInput = {
21412329
NOT?: InputMaybe<Array<PipelineWhereInput>>;
21422330
OR?: InputMaybe<Array<PipelineWhereInput>>;
21432331
createdAt?: InputMaybe<DateTimeFilter>;
2332+
currency?: InputMaybe<EnumCurrencyFilter>;
21442333
icon?: InputMaybe<StringFilter>;
21452334
id?: InputMaybe<StringFilter>;
21462335
name?: InputMaybe<StringFilter>;

front/src/modules/companies/components/NewCompanyProgressButton.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useCallback, useContext, useState } from 'react';
22

33
import { NewButton } from '@/ui/board/components/NewButton';
4-
import { BoardColumnIdContext } from '@/ui/board/contexts/BoardColumnIdContext';
4+
import { BoardColumnContext } from '@/ui/board/contexts/BoardColumnContext';
55
import { SingleEntitySelect } from '@/ui/input/relation-picker/components/SingleEntitySelect';
66
import { relationPickerSearchFilterScopedState } from '@/ui/input/relation-picker/states/relationPickerSearchFilterScopedState';
77
import { RelationPickerHotkeyScope } from '@/ui/input/relation-picker/types/RelationPickerHotkeyScope';
@@ -14,7 +14,9 @@ import { useFilteredSearchCompanyQuery } from '../hooks/useFilteredSearchCompany
1414

1515
export const NewCompanyProgressButton = () => {
1616
const [isCreatingCard, setIsCreatingCard] = useState(false);
17-
const pipelineStageId = useContext(BoardColumnIdContext);
17+
const column = useContext(BoardColumnContext);
18+
19+
const pipelineStageId = column?.columnDefinition.id || '';
1820

1921
const { enqueueSnackBar } = useSnackBar();
2022

front/src/modules/companies/hooks/useUpdateCompanyBoardColumns.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useRecoilCallback } from 'recoil';
33
import { currentPipelineState } from '@/pipeline/states/currentPipelineState';
44
import { boardCardIdsByColumnIdFamilyState } from '@/ui/board/states/boardCardIdsByColumnIdFamilyState';
55
import { boardColumnsState } from '@/ui/board/states/boardColumnsState';
6+
import { savedBoardColumnsState } from '@/ui/board/states/savedBoardColumnsState';
67
import { BoardColumnDefinition } from '@/ui/board/types/BoardColumnDefinition';
78
import { genericEntitiesFamilyState } from '@/ui/editable-field/states/genericEntitiesFamilyState';
89
import { isThemeColor } from '@/ui/theme/utils/castStringAsThemeColor';
@@ -114,11 +115,10 @@ export const useUpdateCompanyBoard = () =>
114115
index: pipelineStage.index ?? 0,
115116
};
116117
});
117-
118-
if (!isDeeplyEqual(currentBoardColumns, newBoardColumns)) {
118+
if (currentBoardColumns.length === 0) {
119119
set(boardColumnsState, newBoardColumns);
120+
set(savedBoardColumnsState, newBoardColumns);
120121
}
121-
122122
for (const boardColumn of newBoardColumns) {
123123
const boardCardIds = pipelineProgresses
124124
.filter(

front/src/modules/ui/board/components/BoardColumn.tsx

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import React from 'react';
1+
import React, { useContext } from 'react';
22
import styled from '@emotion/styled';
33

44
import { Tag } from '@/ui/tag/components/Tag';
5-
import { ThemeColor } from '@/ui/theme/constants/colors';
65
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
76

7+
import { BoardColumnContext } from '../contexts/BoardColumnContext';
88
import { BoardColumnHotkeyScope } from '../types/BoardColumnHotkeyScope';
99

1010
import { BoardColumnMenu } from './BoardColumnMenu';
@@ -53,28 +53,24 @@ const StyledNumChildren = styled.div`
5353
`;
5454

5555
export type BoardColumnProps = {
56-
color?: ThemeColor;
57-
title: string;
5856
onDelete?: (id: string) => void;
5957
onTitleEdit: (title: string, color: string) => void;
6058
totalAmount?: number;
6159
children: React.ReactNode;
62-
isFirstColumn: boolean;
6360
numChildren: number;
6461
stageId: string;
6562
};
6663

6764
export const BoardColumn = ({
68-
color,
69-
title,
7065
onDelete,
7166
onTitleEdit,
7267
totalAmount,
7368
children,
74-
isFirstColumn,
7569
numChildren,
7670
stageId,
7771
}: BoardColumnProps) => {
72+
const boardColumn = useContext(BoardColumnContext);
73+
7874
const [isBoardColumnMenuOpen, setIsBoardColumnMenuOpen] =
7975
React.useState(false);
8076

@@ -95,10 +91,18 @@ export const BoardColumn = ({
9591
setIsBoardColumnMenuOpen(false);
9692
};
9793

94+
if (!boardColumn) return <></>;
95+
96+
const { isFirstColumn, columnDefinition } = boardColumn;
97+
9898
return (
9999
<StyledColumn isFirstColumn={isFirstColumn}>
100-
<StyledHeader onClick={handleTitleClick}>
101-
<Tag color={color ?? 'gray'} text={title} />
100+
<StyledHeader>
101+
<Tag
102+
onClick={handleTitleClick}
103+
color={columnDefinition.colorCode ?? 'gray'}
104+
text={columnDefinition.title}
105+
/>
102106
{!!totalAmount && <StyledAmount>${totalAmount}</StyledAmount>}
103107
<StyledNumChildren>{numChildren}</StyledNumChildren>
104108
</StyledHeader>
@@ -107,8 +111,6 @@ export const BoardColumn = ({
107111
onClose={handleClose}
108112
onDelete={onDelete}
109113
onTitleEdit={onTitleEdit}
110-
title={title}
111-
color={color ?? 'gray'}
112114
stageId={stageId}
113115
/>
114116
)}

0 commit comments

Comments
 (0)