Skip to content

Commit 26aaef0

Browse files
committed
Fix: added free seating data attribute
1 parent 6cb94da commit 26aaef0

File tree

9 files changed

+58
-26
lines changed

9 files changed

+58
-26
lines changed

src/components/workspace/elements/booth.tsx

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,28 @@ export interface IBoothProps extends IBooth {
88
className: string;
99
consumer: ISTKProps;
1010
isSelected?: boolean;
11+
element?: any;
1112
}
12-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
13-
const Booth: React.FC<IBoothProps> = forwardRef(({ id, x, y, consumer, isSelected: _, ...props }, ref: any) => {
14-
return (
15-
<rect
16-
ref={ref}
17-
id={id}
18-
x={x}
19-
y={y}
20-
width={boothSize}
21-
height={boothSize}
22-
rx={5}
23-
ry={5}
24-
{...props}
25-
className={twMerge(props.className, consumer.styles?.elements?.booth?.base?.className)}
26-
style={consumer.styles?.elements?.booth?.base?.properties}
27-
/>
28-
);
29-
});
13+
const Booth: React.FC<IBoothProps> = forwardRef(
14+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
15+
({ id, x, y, consumer, isSelected: _, element: __, ...props }, ref: any) => {
16+
return (
17+
<rect
18+
ref={ref}
19+
id={id}
20+
x={x}
21+
y={y}
22+
width={boothSize}
23+
height={boothSize}
24+
rx={5}
25+
ry={5}
26+
{...props}
27+
className={twMerge(props.className, consumer.styles?.elements?.booth?.base?.className)}
28+
style={consumer.styles?.elements?.booth?.base?.properties}
29+
/>
30+
);
31+
}
32+
);
3033

3134
Booth.displayName = "Booth";
3235

src/components/workspace/elements/image.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ export interface IImageProps extends IImage {
66
className?: string;
77
consumer: ISTKProps;
88
isSelected?: boolean;
9+
element?: any;
910
}
1011

1112
const Image: React.FC<IImageProps> = forwardRef(
1213
// eslint-disable-next-line @typescript-eslint/no-unused-vars
13-
({ x, y, id, href, width, height, consumer, isSelected: _, ...props }, ref: any) => {
14+
({ x, y, id, href, width, height, consumer, isSelected: _, element: __, ...props }, ref: any) => {
1415
return (
1516
<image
1617
ref={ref}

src/components/workspace/elements/polyline.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ const Polyline: React.FC<IPolylineProps> = forwardRef(
8181
...(sectionObject?.freeSeating && consumer.styles?.elements?.section?.freeSeating?.properties)
8282
}}
8383
{...{ [dataAttributes.section]: section }}
84+
{...{ [dataAttributes.sectionFreeSeating]: sectionObject?.freeSeating }}
8485
className={twMerge(
8586
props.className,
8687
consumer.styles?.elements?.shape?.base?.className,

src/components/workspace/elements/shape.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,30 @@ export interface IShapeProps extends IShape {
1717
resizable?: boolean;
1818
consumer: ISTKProps;
1919
isSelected?: boolean;
20+
element?: any;
2021
}
2122

2223
const Shape: React.FC<IShapeProps> = forwardRef(
2324
(
24-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
25-
{ x, y, id, name, width, height, rx, resizable, className, stroke, color, consumer, isSelected: _, ...props },
25+
{
26+
x,
27+
y,
28+
id,
29+
name,
30+
width,
31+
height,
32+
rx,
33+
resizable,
34+
className,
35+
stroke,
36+
color,
37+
consumer,
38+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
39+
isSelected: _,
40+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
41+
element: __,
42+
...props
43+
},
2644
ref: any
2745
) => {
2846
if (name === "RectangleHorizontal") {

src/components/workspace/elements/text.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface ITextProps extends IText {
1010
consumer: ISTKProps;
1111
onClick: (e: any) => void;
1212
isSelected?: boolean;
13+
element?: any;
1314
}
1415

1516
const Text: React.FC<ITextProps> = forwardRef(
@@ -28,6 +29,8 @@ const Text: React.FC<ITextProps> = forwardRef(
2829
onClick,
2930
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3031
isSelected: _,
32+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
33+
element: __,
3134
...props
3235
},
3336
ref: any

src/components/workspace/elements/utils.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ export const showPreOffsetElements = () => {
106106
const seats = d3Extended.selectAll(`[${dataAttributes.elementType}="${ElementType.Seat}"]`);
107107
if (seats.size() && +seats?.style("opacity") !== 0) {
108108
const booths = d3Extended.selectAll(`[${dataAttributes.elementType}="${ElementType.Booth}"]`);
109-
const sections = d3Extended.selectAll(`[${dataAttributes.elementType}="${ElementType.Polyline}"]`);
109+
const sections = d3Extended.selectAll(
110+
`[${dataAttributes.elementType}="${ElementType.Polyline}"][${dataAttributes.section}]`
111+
);
110112
const elementsEmbracingOffset = d3Extended.selectAll(`[${dataAttributes.embraceOffset}="true"]`);
111113
seats.forEach(hideSeat);
112114
booths.forEach((booth) => {
@@ -128,15 +130,17 @@ export const showPostOffsetElements = () => {
128130
const seats = d3Extended.selectAll(`[${dataAttributes.elementType}="${ElementType.Seat}"]`);
129131
if (seats.size() && +seats.style("opacity") !== 1) {
130132
const booths = d3Extended.selectAll(`[${dataAttributes.elementType}="${ElementType.Booth}"]`);
131-
const sections = d3Extended.selectAll(`[${dataAttributes.elementType}="${ElementType.Polyline}"]`);
133+
const sections = d3Extended.selectAll(
134+
`[${dataAttributes.elementType}="${ElementType.Polyline}"][${dataAttributes.section}]`
135+
);
132136
const elementsEmbracingOffset = d3Extended.selectAll(`[${dataAttributes.embraceOffset}="true"]`);
133137
seats.forEach(showSeat);
134138
booths.forEach((booth) => {
135139
booth.style("opacity", 1);
136140
booth.style("pointer-events", "all");
137141
});
138142
sections.forEach((section) => {
139-
if (section.attr(dataAttributes.section)) {
143+
if (section.attr(dataAttributes.sectionFreeSeating) !== "true") {
140144
section.style("opacity", 0);
141145
section.style("pointer-events", "none");
142146
}

src/constants/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const dataAttributes = {
2929
category: "data-category",
3030
status: "data-status",
3131
section: "data-section",
32+
sectionFreeSeating: "data-section-free-seating",
3233
visibilityOffset: "data-seat-visibility-offset",
3334
embraceOffset: "data-embrace-offset"
3435
};

src/styles/index.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
@tailwind base;
66
@tailwind components;
7-
@tailwind utilities;
7+
@tailwind utilities;

src/utils/transformer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ export const domTextToJSON = () => {
3737
fontSize: +text.attr("font-size"),
3838
fontWeight: +text.attr("font-weight"),
3939
letterSpacing: +text.attr("letter-spacing"),
40-
color: rgbToHex(text.style("stroke")) || text.attr("stroke")
40+
color: rgbToHex(text.style("stroke")) || text.attr("stroke"),
41+
embraceOffset: text.attr(dataAttributes.embraceOffset)
4142
};
4243
});
4344
};

0 commit comments

Comments
 (0)