Skip to content

Commit

Permalink
remove unnecessary number of cards in group prop
Browse files Browse the repository at this point in the history
  • Loading branch information
Georges-GNM committed Jan 29, 2025
1 parent 562054c commit 3f25f08
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 18 deletions.
3 changes: 0 additions & 3 deletions fronts-client/src/components/FrontsEdit/Collection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ class CollectionContext extends React.Component<ConnectedCollectionContextProps>
isUneditable={isUneditable}
groupId={group.uuid}
groupName={group.name ? group.name : ''}
//todo: numberOfCards can probably just be got by the card array
numberOfCardsInGroup={group.cards.length}
groupsIds={groupsIds}
onMove={handleMove}
onDrop={handleInsert}
Expand Down Expand Up @@ -200,7 +198,6 @@ class CollectionContext extends React.Component<ConnectedCollectionContextProps>
isUneditable={isUneditable}
cardId={card.uuid}
groupName={group.name ? group.name : ''}
numberOfCardsInGroup={group.cards.length}
groupsIds={groupsIds}
onMove={handleMove}
onDrop={handleInsert}
Expand Down
4 changes: 2 additions & 2 deletions fronts-client/src/components/FrontsEdit/FrontContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class FrontContent extends React.Component<FrontProps, FrontState> {
}

public handleMove = (move: Move<TCard>) => {
const numberOfArticlesAlreadyInGroup = move.to.numberOfCardsInGroup;
const numberOfArticlesAlreadyInGroup = move.to.cards?.length;

// if we are inserting an article into any group that is not the splash, then we just insert
if (move.to.groupName !== 'splash') {
Expand Down Expand Up @@ -262,7 +262,7 @@ class FrontContent extends React.Component<FrontProps, FrontState> {
};

public handleInsert = (e: React.DragEvent, to: PosSpec) => {
const numberOfArticlesAlreadyInGroup = to.numberOfCardsInGroup;
const numberOfArticlesAlreadyInGroup = to.cards?.length;

// if we are inserting an article into any group that is not the splash, then we just insert
if (to.groupName !== 'splash') {
Expand Down
3 changes: 0 additions & 3 deletions fronts-client/src/components/clipboard/CardLevel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ interface OuterProps {
dropMessage?: string;
cardTypeAllowList?: CardTypes[];
groupName?: string;
numberOfCardsInGroup?: number;
groupsIds?: string[];
}

Expand Down Expand Up @@ -53,15 +52,13 @@ const CardLevel = ({
dropMessage,
cardTypeAllowList,
groupName,
numberOfCardsInGroup,
groupsIds,
}: Props) => (
<CardTypeLevel
arr={supporting || []}
parentType="card"
parentId={cardId}
groupName={groupName}
numberOfCardsInGroup={numberOfCardsInGroup}
groupsIds={groupsIds}
onMove={onMove}
onDrop={onDrop}
Expand Down
3 changes: 0 additions & 3 deletions fronts-client/src/components/clipboard/GroupLevel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ interface OuterProps {
onDrop: DropHandler;
isUneditable?: boolean;
groupName: string;
numberOfCardsInGroup: number;
groupsIds: string[];
}

Expand Down Expand Up @@ -64,15 +63,13 @@ const GroupLevel = ({
onDrop,
isUneditable,
groupName,
numberOfCardsInGroup,
groupsIds,
}: Props) => (
<CardTypeLevel
arr={cards}
parentType="group"
parentId={groupId}
groupName={groupName}
numberOfCardsInGroup={numberOfCardsInGroup}
groupsIds={groupsIds}
onMove={onMove}
onDrop={onDrop}
Expand Down
3 changes: 0 additions & 3 deletions fronts-client/src/lib/dnd/Level.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ interface PosSpec {
id: string;
index: number;
groupName?: string;
numberOfCardsInGroup?: number;
groupsIds?: string[];
cards?: any[];
}
Expand Down Expand Up @@ -61,7 +60,6 @@ export interface LevelProps<T> {
parentId: string;
parentType: string;
groupName?: string;
numberOfCardsInGroup?: number;
groupsIds?: string[];
type: string;
getDropType?: (item: T) => string;
Expand Down Expand Up @@ -186,7 +184,6 @@ class Level<T> extends React.Component<Props<T>, State> {
type: this.props.parentType,
id: this.props.parentId,
groupName: this.props.groupName,
numberOfCardsInGroup: this.props.numberOfCardsInGroup,
groupsIds: this.props.groupsIds,
cards: this.props.arr,
};
Expand Down
3 changes: 0 additions & 3 deletions fronts-client/src/lib/dnd/__tests__/dnd.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ describe('Curation', () => {
groupsIds: undefined,
id: '2',
index: 1,
numberOfCardsInGroup: undefined,
type: 'a',
},
});
Expand Down Expand Up @@ -178,7 +177,6 @@ describe('Curation', () => {
groupsIds: undefined,
id: '2',
index: 0,
numberOfCardsInGroup: undefined,
type: 'a',
},
});
Expand Down Expand Up @@ -295,7 +293,6 @@ describe('Curation', () => {
groupsIds: undefined,
id: '2',
index: 1,
numberOfCardsInGroup: undefined,
type: 'a',
});
});
Expand Down
1 change: 0 additions & 1 deletion fronts-client/src/util/collectionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export type InsertDropType = keyof typeof dropToCardMap;
const dropToCard = (e: React.DragEvent): MappableDropType | null => {
for (const [type, fn] of Object.entries(dropToCardMap)) {
const data = e.dataTransfer.getData(type);

if (data) {
return fn(data);
}
Expand Down

0 comments on commit 3f25f08

Please sign in to comment.