Skip to content

Commit

Permalink
Fix multi column selector selectColumn() method logic, improve relati…
Browse files Browse the repository at this point in the history
…on item content component
  • Loading branch information
glpierce committed Apr 4, 2024
1 parent bc31a48 commit 1c0d1a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,14 @@ export default function MultiColumnSelector({

const selectColumn = (column: InferredSchemaColumn) => {
if (
selected.find(
(selectedCol: InferredSchemaColumn) =>
selectedCol.name === column.name &&
selectedCol.table === column.table &&
_.isEqual(selectedCol.relation, column.relation),
selected.find((selectedCol: InferredSchemaColumn) =>
_.isEqual(selectedCol, column),
)
) {
setSelected([
...selected.filter(
(selectedCol: InferredSchemaColumn) =>
selectedCol.name !== column.name &&
selectedCol.table !== column.table &&
!_.isEqual(selectedCol.relation, column.relation),
!_.isEqual(selectedCol, column),
),
]);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ export default function RelationItemContent({
}: {
item: RelationItem | null;
}) {
function getRelationIcon(item: RelationItem) {
function getRelationIcon(item: RelationItem): IconName {
switch (item.relation.type) {
case "one_to_one":
return "one-to-one";
case "many_to_many":
return "many-to-many";
return "many-to-many" as IconName;
case "one_to_many":
if (item.relation.table_1 === item.originTable.id) {
return "one-to-many";
return "one-to-many" as IconName;
} else {
return "many-to-one";
return "many-to-one" as IconName;
}
case "one_to_one":
default:
return "one-to-one" as IconName;
}
}

Expand Down Expand Up @@ -65,7 +66,7 @@ export default function RelationItemContent({
<Text className="font-normal text-md">{originKey}</Text>
</div>
</Tag>
<Icon icon={getRelationIcon(item) as IconName} color="gray" />
<Icon icon={getRelationIcon(item)} color="gray" />
<Tag
className="py-1 "
minimal
Expand Down

0 comments on commit 1c0d1a4

Please sign in to comment.