@alisaitteke/seatmap-canvas 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/.eslintrc.json +15 -0
  2. package/.github/FUNDING.yml +4 -0
  3. package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
  4. package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  5. package/.github/workflows/codeql-analysis.yml +29 -0
  6. package/.github/workflows/npm-publish-packages.yml +35 -0
  7. package/.github/workflows/webpack.yml +22 -0
  8. package/AUTHORS +3 -0
  9. package/LICENSE +21 -0
  10. package/README.md +160 -0
  11. package/SECURITY.md +21 -0
  12. package/_config.yml +1 -0
  13. package/assets/banner_ui.png +0 -0
  14. package/assets/bn.jpg +0 -0
  15. package/assets/logo.jpg +0 -0
  16. package/assets/logo_small.jpg +0 -0
  17. package/assets/zoom_out.svg +11 -0
  18. package/examples/basic/bootstrap.min.css +7 -0
  19. package/examples/basic/index.html +201 -0
  20. package/examples/basic/jquery.min.js +2 -0
  21. package/examples/data/data.json +70007 -0
  22. package/examples/data/small.json +1307 -0
  23. package/examples/data/tiny.json +119 -0
  24. package/examples/old/index.html +262 -0
  25. package/package.json +59 -0
  26. package/src/lib/canvas.index.ts +122 -0
  27. package/src/lib/config.ts +11 -0
  28. package/src/lib/decorators/dom.ts +40 -0
  29. package/src/lib/decorators/index.ts +6 -0
  30. package/src/lib/dev.tools.ts +18 -0
  31. package/src/lib/enums/global.ts +67 -0
  32. package/src/lib/models/block.model.ts +170 -0
  33. package/src/lib/models/coordinate.model.ts +43 -0
  34. package/src/lib/models/data.model.ts +105 -0
  35. package/src/lib/models/defaults.model.ts +125 -0
  36. package/src/lib/models/global.model.ts +24 -0
  37. package/src/lib/models/label.model.ts +58 -0
  38. package/src/lib/models/legend.model.ts +56 -0
  39. package/src/lib/models/model.base.ts +32 -0
  40. package/src/lib/models/seat.model.ts +182 -0
  41. package/src/lib/svg/event.manager.ts +56 -0
  42. package/src/lib/svg/legend/legend.circle.ts +28 -0
  43. package/src/lib/svg/legend/legend.item.ts +50 -0
  44. package/src/lib/svg/legend/legend.title.ts +27 -0
  45. package/src/lib/svg/legend.ts +55 -0
  46. package/src/lib/svg/stage/blocks/block-item/block-item.bounds.ts +51 -0
  47. package/src/lib/svg/stage/blocks/block-item/block-item.index.ts +173 -0
  48. package/src/lib/svg/stage/blocks/block-item/block-item.info.index.ts +38 -0
  49. package/src/lib/svg/stage/blocks/block-item/block-item.labels.index.ts +41 -0
  50. package/src/lib/svg/stage/blocks/block-item/block-item.mask.ts +67 -0
  51. package/src/lib/svg/stage/blocks/block-item/block-item.seats.index.ts +81 -0
  52. package/src/lib/svg/stage/blocks/block-item/bound/bound-item.index.ts +43 -0
  53. package/src/lib/svg/stage/blocks/block-item/info/title.ts +30 -0
  54. package/src/lib/svg/stage/blocks/block-item/label/label-item.circle.ts +27 -0
  55. package/src/lib/svg/stage/blocks/block-item/label/label-item.index.ts +46 -0
  56. package/src/lib/svg/stage/blocks/block-item/label/label-item.title.ts +27 -0
  57. package/src/lib/svg/stage/blocks/block-item/seat/seat-item.check.ts +45 -0
  58. package/src/lib/svg/stage/blocks/block-item/seat/seat-item.circle.ts +30 -0
  59. package/src/lib/svg/stage/blocks/block-item/seat/seat-item.index.ts +159 -0
  60. package/src/lib/svg/stage/blocks/block-item/seat/seat-item.title.ts +27 -0
  61. package/src/lib/svg/stage/blocks/blocks.index.ts +68 -0
  62. package/src/lib/svg/stage/blocks.search-circle.ts +86 -0
  63. package/src/lib/svg/stage/multi-select/rect.ts +36 -0
  64. package/src/lib/svg/stage/multi-select.ts +107 -0
  65. package/src/lib/svg/stage/search-circle/circle.ts +37 -0
  66. package/src/lib/svg/stage/stage.index.ts +41 -0
  67. package/src/lib/svg/svg.base.ts +217 -0
  68. package/src/lib/svg/svg.index.ts +76 -0
  69. package/src/lib/svg/tooltip/rect.ts +66 -0
  70. package/src/lib/svg/tooltip/title.ts +57 -0
  71. package/src/lib/svg/tooltip.ts +92 -0
  72. package/src/lib/svg/zoom-out.bg.ts +35 -0
  73. package/src/lib/svg/zoom.manager.ts +440 -0
  74. package/src/lib/window.manager.ts +40 -0
  75. package/src/scss/lib.scss +10 -0
  76. package/src/scss/style.scss +221 -0
  77. package/tsconfig.json +28 -0
  78. package/webpack.environments/development.js +58 -0
  79. package/webpack.environments/production.js +52 -0
@@ -0,0 +1,67 @@
1
+ /*
2
+ * $project.fileName
3
+ * https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
4
+ */
5
+
6
+ import SvgBase from "../../../svg.base";
7
+ import {dom} from "../../../../decorators/dom";
8
+ import BlockModel from "../../../../models/block.model";
9
+ import Block from "./block-item.index";
10
+ import {BoundItem} from "./bound/bound-item.index";
11
+ import {EventType} from "../../../../enums/global";
12
+
13
+ @dom({
14
+ tag: "g",
15
+ class: "masks",
16
+ autoGenerate: false
17
+ })
18
+ export default class BlockMask extends SvgBase {
19
+
20
+ public blockLevelMask: BoundItem;
21
+ public seatLevelMask: BoundItem;
22
+
23
+ constructor(public parent: Block, public item: BlockModel) {
24
+ super(parent);
25
+
26
+ this.global.eventManager.addEventListener(EventType.BOUND_CLICK, (bound: BoundItem) => {
27
+ if(this.global.multi_select)return;
28
+ let _block = bound.parent.parent.item;
29
+ if (bound.hasTag("block-level")) {
30
+ parent.global.zoomManager.zoomToBlock(_block.id);
31
+ } else if (bound.hasTag("seat-level")) {
32
+ parent.global.zoomManager.zoomToSelection();
33
+ }
34
+ });
35
+
36
+
37
+ return this;
38
+ }
39
+
40
+ update(): this {
41
+
42
+ // add Border Bounds container
43
+ this.seatLevelMask = new BoundItem(this, this.item);
44
+ this.seatLevelMask.attr("fill", this.item.color);
45
+ this.seatLevelMask.attr("stroke-width", 59);
46
+ this.seatLevelMask.attr("stroke", this.item.color);
47
+ this.seatLevelMask.tags.push("seat-level");
48
+ this.seatLevelMask.classed("seat-level-mask");
49
+
50
+
51
+ // add Border Bounds container
52
+ this.blockLevelMask = new BoundItem(this, this.item);
53
+ this.blockLevelMask.attr("fill", this.item.color);
54
+ this.blockLevelMask.attr("stroke-width", 59);
55
+ this.blockLevelMask.attr("stroke", this.item.color);
56
+ this.blockLevelMask.tags.push("block-level");
57
+ this.blockLevelMask.classed("block-level-mask");
58
+
59
+ this.addChild(this.seatLevelMask);
60
+ this.addChild(this.blockLevelMask);
61
+
62
+
63
+ this.updateChilds();
64
+
65
+ return this;
66
+ }
67
+ }
@@ -0,0 +1,81 @@
1
+ /*
2
+ * $project.fileName
3
+ * https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
4
+ */
5
+
6
+
7
+ import SvgBase from "../../../svg.base";
8
+ import {dom} from "../../../../decorators/dom";
9
+ import Block from "./block-item.index";
10
+ import SeatModel from "../../../../models/seat.model";
11
+ import {SeatItem} from "./seat/seat-item.index";
12
+ import BlockModel from "../../../../models/block.model";
13
+ import {EventType, SeatAction} from "../../../../enums/global";
14
+
15
+
16
+ @dom({
17
+ tag: "g",
18
+ class: "seats",
19
+ autoGenerate: false
20
+ })
21
+ export default class Seats extends SvgBase {
22
+
23
+ constructor(public parent: Block, public item: BlockModel) {
24
+ super(parent);
25
+
26
+ this.global.eventManager.addEventListener(EventType.MOUSEENTER_SEAT, (seat: SeatItem) => {
27
+ if (this.global.multi_select) return;
28
+ seat.setColor(seat.getColor(SeatAction.HOVER));
29
+ //this.global.zoomManager.zoomDisable();
30
+ });
31
+ this.global.eventManager.addEventListener(EventType.MOUSELEAVE_SEAT, (seat: SeatItem) => {
32
+ seat.setColor(seat.getColor());
33
+ //this.global.zoomManager.zoomEnable();
34
+ });
35
+
36
+ return this;
37
+ }
38
+
39
+ update(): this {
40
+ // add seat items in blockItem container
41
+ this.item.seats.forEach((seat: SeatModel) => {
42
+ this.addChild(new SeatItem(this, seat), {id: seat.id})
43
+ });
44
+ this.updateChilds();
45
+ return this;
46
+ }
47
+
48
+ // Getting seat method
49
+ // ex: seatmap.stage.blocks.getBlock(2).seats.getSeat("1-1")
50
+ public getSeat(id: any): SeatItem {
51
+ return this.child_items.find((seat: SeatItem) => seat.item.id == id);
52
+ }
53
+
54
+ // Getting seats method
55
+ // ex: seatmap.stage.blocks.getBlock(2).seats.getSeat("1-1")
56
+ public getSeats(): Array<SeatItem> {
57
+ return this.child_items;
58
+ }
59
+
60
+ public getSeatsCount(): number {
61
+ return this.child_items.length;
62
+ }
63
+
64
+ public getSeatByIndex(index: number): SeatItem {
65
+ return this.child_items[index];
66
+ }
67
+
68
+ public resetSeatsColors(animation: boolean = false) {
69
+ for (let i = 0; i < this.getSeatsCount(); i++) {
70
+ let _seat = this.getSeatByIndex(i);
71
+ let _item: SeatModel = _seat.item;
72
+
73
+ let color = _seat.getColor();
74
+
75
+ if (!_seat.isSelected() && _seat.isSalable()) {
76
+ color = _seat.getColor(SeatAction.LEAVE);
77
+ _seat.setColor(color, animation);
78
+ }
79
+ }
80
+ }
81
+ }
@@ -0,0 +1,43 @@
1
+ /*
2
+ * $project.fileName
3
+ * https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
4
+ */
5
+
6
+
7
+ import SvgBase from "../../../../svg.base";
8
+ import {dom} from "../../../../../decorators/dom";
9
+ import BlockBounds from "../block-item.bounds";
10
+ import BlockModel from "../../../../../models/block.model";
11
+ import BlockMask from "../block-item.mask";
12
+
13
+
14
+ @dom({
15
+ tag: "path",
16
+ class: "bound",
17
+ autoGenerate: false
18
+ })
19
+ export class BoundItem extends SvgBase {
20
+
21
+
22
+ constructor(public parent: BlockBounds|BlockMask, public item: BlockModel) {
23
+ super(parent);
24
+ }
25
+
26
+ show(){
27
+ this.node.classed("bound-hide",false);
28
+ }
29
+
30
+ hide(){
31
+ this.node.classed("bound-hide",true);
32
+ }
33
+
34
+ update(): this {
35
+ this.updateChilds();
36
+ this.node
37
+ .datum(this.item.bounds)
38
+ .attr("d", function (d: any) {
39
+ return "M" + d.join("L") + "Z";
40
+ });
41
+ return this;
42
+ }
43
+ }
@@ -0,0 +1,30 @@
1
+ /*
2
+ * $project.fileName
3
+ * https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
4
+ */
5
+
6
+
7
+ import SvgBase from "../../../../svg.base";
8
+ import {dom} from "../../../../../decorators/dom";
9
+ import BlockInfo from "../block-item.info.index";
10
+
11
+
12
+ @dom({
13
+ tag: "text",
14
+ class: "title",
15
+ autoGenerate: false
16
+ })
17
+ export class BlockTitle extends SvgBase {
18
+
19
+
20
+ constructor(public parent: BlockInfo) {
21
+ super(parent);
22
+ this.attr("fill",this.global.config.block_style.title_color);
23
+
24
+ }
25
+
26
+
27
+ update(): this {
28
+ return this;
29
+ }
30
+ }
@@ -0,0 +1,27 @@
1
+ /*
2
+ * $project.fileName
3
+ * https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
4
+ */
5
+
6
+ import SvgBase from "../../../../svg.base";
7
+ import {dom} from "../../../../../decorators/dom";
8
+ import {LabelItem} from "./label-item.index";
9
+
10
+ @dom({
11
+ tag: "circle",
12
+ class: "label-circle",
13
+ autoGenerate: false
14
+ })
15
+ export class LabelItemCircle extends SvgBase {
16
+
17
+ constructor(public parent: LabelItem) {
18
+ super(parent);
19
+ this.attr("r", this.global.config.label_style.radius);
20
+ this.attr("fill", this.global.config.label_style.bg);
21
+ return this;
22
+ }
23
+
24
+ update(): this {
25
+ return this;
26
+ }
27
+ }
@@ -0,0 +1,46 @@
1
+ /*
2
+ * $project.fileName
3
+ * https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
4
+ */
5
+
6
+
7
+ import SvgBase from "../../../../svg.base";
8
+ import {dom} from "../../../../../decorators/dom";
9
+ import {LabelItemCircle} from "./label-item.circle";
10
+ import {CoordinateModel} from "../../../../../models/coordinate.model";
11
+ import Labels from "../block-item.labels.index";
12
+ import LabelModel from "../../../../../models/label.model";
13
+ import {LabelItemTitle} from "./label-item.title";
14
+
15
+
16
+ @dom({
17
+ tag: "g",
18
+ class: "label",
19
+ autoGenerate: false
20
+ })
21
+ export class LabelItem extends SvgBase {
22
+
23
+ public circle: LabelItemCircle;
24
+ public coordinates: CoordinateModel;
25
+
26
+ constructor(public parent: Labels, public item: LabelModel) {
27
+ super(parent);
28
+ this.coordinates = new CoordinateModel(item);
29
+ this.attr("transform", "translate(" + this.coordinates.toArray() + ")");
30
+ return this;
31
+ }
32
+
33
+
34
+ update(): this {
35
+ this.circle = new LabelItemCircle(this);
36
+ this.addChild(this.circle);
37
+
38
+ this.circle = new LabelItemTitle(this);
39
+ this.addChild(this.circle);
40
+
41
+ this.updateChilds();
42
+
43
+ this.circle.node.text(this.item.title);
44
+ return this;
45
+ }
46
+ }
@@ -0,0 +1,27 @@
1
+ /*
2
+ * $project.fileName
3
+ * https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
4
+ */
5
+
6
+ import SvgBase from "../../../../svg.base";
7
+ import {dom} from "../../../../../decorators/dom";
8
+ import {LabelItem} from "./label-item.index";
9
+
10
+ @dom({
11
+ tag: "text",
12
+ class: "label-text",
13
+ autoGenerate: false
14
+ })
15
+ export class LabelItemTitle extends SvgBase {
16
+
17
+ constructor(public parent: LabelItem) {
18
+ super(parent);
19
+ this.attr("fill", this.global.config.label_style.color);
20
+ this.attr("font-size", this.global.config.label_style.font_size);
21
+ return this;
22
+ }
23
+
24
+ update(): this {
25
+ return this;
26
+ }
27
+ }
@@ -0,0 +1,45 @@
1
+ /*
2
+ * $project.fileName
3
+ * https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
4
+ */
5
+
6
+ import SvgBase from "../../../../svg.base";
7
+ import {dom} from "../../../../../decorators/dom";
8
+ import {SeatItem} from "./seat-item.index";
9
+
10
+ @dom({
11
+ tag: "path",
12
+ class: "seat-check",
13
+ autoGenerate: false
14
+ })
15
+ export class SeatItemCheck extends SvgBase {
16
+
17
+ constructor(public parent: SeatItem) {
18
+ super(parent);
19
+ this.attr("d", "M12.9,953.7l-6.3,6.5l-2.9-2.5l-2.1,2.4l4.1,3.5l1.1,1l1.1-1.1l7.3-7.6L12.9,953.7L12.9,953.7z");
20
+ this.attr("fill", this.global.config.seat_style.check_color);
21
+ this.attr("transform", "translate(-8,-959.36218)");
22
+ this.attr("pointer-events", "none");
23
+ this.attr("display", "none");
24
+
25
+ return this;
26
+ }
27
+
28
+ update(): this {
29
+ return this;
30
+ }
31
+
32
+ afterGenerate() {
33
+ this.node.style("pointer-events", "none");
34
+ }
35
+
36
+ show():this {
37
+ this.node.attr("display", "block");
38
+ return this;
39
+ }
40
+
41
+ hide():this {
42
+ this.node.attr("display", "none");
43
+ return this;
44
+ }
45
+ }
@@ -0,0 +1,30 @@
1
+ /*
2
+ * $project.fileName
3
+ * https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
4
+ */
5
+
6
+ import SvgBase from "../../../../svg.base";
7
+ import {dom} from "../../../../../decorators/dom";
8
+ import {SeatItem} from "./seat-item.index";
9
+
10
+ @dom({
11
+ tag: "circle",
12
+ class: "seat-circle",
13
+ autoGenerate: false
14
+ })
15
+ export class SeatItemCircle extends SvgBase {
16
+
17
+ constructor(public parent: SeatItem) {
18
+ super(parent);
19
+ this.attr("block-id", parent.item.block.id);
20
+ this.attr("r", this.global.config.seat_style.radius);
21
+ this.attr("fill", this.global.config.seat_style.color);
22
+ this.attr("stroke", "rgba(0,0,0,0.3)");
23
+ this.attr("stroke-width", 1);
24
+ return this;
25
+ }
26
+
27
+ update(): this {
28
+ return this;
29
+ }
30
+ }
@@ -0,0 +1,159 @@
1
+ /*
2
+ * $project.fileName
3
+ * https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
4
+ */
5
+
6
+
7
+ import SvgBase from "../../../../svg.base";
8
+ import {dom} from "../../../../../decorators/dom";
9
+ import SeatModel from "../../../../../models/seat.model";
10
+ import Seats from "../block-item.seats.index";
11
+ import {SeatItemCircle} from "./seat-item.circle";
12
+ import {CoordinateModel} from "../../../../../models/coordinate.model";
13
+ import {SeatItemTitle} from "./seat-item.title";
14
+ import {SeatAction} from "../../../../../enums/global";
15
+ import {SeatItemCheck} from "./seat-item.check";
16
+
17
+
18
+ @dom({
19
+ tag: "g",
20
+ class: "seat",
21
+ autoGenerate: false
22
+ })
23
+ export class SeatItem extends SvgBase {
24
+
25
+ public circle: SeatItemCircle;
26
+ public title: SeatItemTitle;
27
+ public coordinates: CoordinateModel;
28
+ public check: SeatItemCheck;
29
+
30
+ constructor(public parent: Seats, public item: SeatModel) {
31
+ super(parent);
32
+ this.coordinates = new CoordinateModel(item);
33
+ this.attr("transform", "translate(" + this.coordinates.toArray() + ")");
34
+ this.item.svg = this;
35
+ return this;
36
+ }
37
+
38
+ public setColor(color: string, animation: boolean = false): this {
39
+ if (animation) {
40
+ this.circle.node.transition().duration(this.global.config.animation_speed).attr("fill", color);
41
+ } else {
42
+ this.circle.node.attr("fill", color);
43
+ }
44
+
45
+ return this;
46
+ }
47
+
48
+ public updateColor(color: string = null): this {
49
+ this.setColor(this.getColor());
50
+ return this;
51
+ }
52
+
53
+ public select(color: string = null): this {
54
+ this.item.selected = true;
55
+ this.node.classed("selected", true);
56
+ this.circle.node.attr("fill", this.global.config.seat_style.selected);
57
+ this.check.show();
58
+ return this;
59
+ }
60
+
61
+ public unSelect(): this {
62
+ this.item.selected = false;
63
+ this.node.classed("selected", false);
64
+ this.circle.node.attr("fill", this.global.config.seat_style.color);
65
+ this.check.hide();
66
+ return this;
67
+ }
68
+
69
+ public isSelected(): Boolean {
70
+ return this.item.selected;
71
+ }
72
+
73
+ public isSalable(): Boolean {
74
+ return this.item.salable;
75
+ }
76
+
77
+ public hover() {
78
+ this.setColor(this.global.config.seat_style.hover);
79
+ }
80
+
81
+ public blur() {
82
+ this.setColor(this.getColor());
83
+ }
84
+
85
+ public getColor(action: SeatAction = null): string {
86
+
87
+ if (this.isSalable()) {
88
+
89
+ if (action == SeatAction.FOCUS) {
90
+ if (this.isSelected()) {
91
+ return this.global.config.seat_style.focus_out;
92
+ } else {
93
+ return this.global.config.seat_style.focus;
94
+ }
95
+
96
+ } else if (action == SeatAction.HOVER) {
97
+ if (this.isSelected()) {
98
+ return this.global.config.seat_style.selected;
99
+ } else {
100
+ return this.global.config.seat_style.hover;
101
+ }
102
+ }
103
+ else if (action == SeatAction.LEAVE) {
104
+ if (this.isSelected()) {
105
+ return this.global.config.seat_style.selected;
106
+ } else {
107
+ return this.global.config.seat_style.color;
108
+ }
109
+ }
110
+ else if (action == SeatAction.SELECT) {
111
+ if (this.isSelected()) {
112
+ return this.global.config.seat_style.selected;
113
+ } else {
114
+ return this.global.config.seat_style.selected;
115
+ }
116
+ } else {
117
+ if (this.isSelected()) {
118
+ return this.global.config.seat_style.selected;
119
+ } else {
120
+ return this.global.config.seat_style.color;
121
+ }
122
+ }
123
+
124
+ } else {
125
+ return this.global.config.seat_style.not_salable;
126
+ }
127
+
128
+ }
129
+
130
+ update(): this {
131
+ this.circle = new SeatItemCircle(this);
132
+ this.addChild(this.circle);
133
+
134
+
135
+ this.check = new SeatItemCheck(this).addTo(this);
136
+
137
+
138
+
139
+ // this.title = new SeatItemTitle(this);
140
+ // this.addChild(this.title);
141
+
142
+
143
+ this.updateChilds();
144
+
145
+ //this.title.node.text(this.item.title);
146
+
147
+ return this;
148
+ }
149
+
150
+ afterGenerate(){
151
+ this.setColor(this.getColor());
152
+ if(this.item.selected){
153
+ this.check.show()
154
+ }else{
155
+ this.check.hide()
156
+ }
157
+
158
+ }
159
+ }
@@ -0,0 +1,27 @@
1
+ /*
2
+ * $project.fileName
3
+ * https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
4
+ */
5
+
6
+ import SvgBase from "../../../../svg.base";
7
+ import {dom} from "../../../../../decorators/dom";
8
+ import {SeatItem} from "./seat-item.index";
9
+
10
+ @dom({
11
+ tag: "text",
12
+ class: "label-text",
13
+ autoGenerate: false
14
+ })
15
+ export class SeatItemTitle extends SvgBase {
16
+
17
+ constructor(public parent: SeatItem) {
18
+ super(parent);
19
+ this.attr("fill", this.global.config.label_style.color);
20
+ this.attr("font-size", 10);
21
+ return this;
22
+ }
23
+
24
+ update(): this {
25
+ return this;
26
+ }
27
+ }
@@ -0,0 +1,68 @@
1
+ /*
2
+ * blocks.ts
3
+ * https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
4
+ */
5
+
6
+ import {polygonHull} from 'd3-polygon'
7
+
8
+ import StageManager from "../stage.index";
9
+ import Block from "./block-item/block-item.index";
10
+ import SvgBase from "../../svg.base";
11
+ import {dom} from "../../../decorators/dom";
12
+ import SeatModel from "../../../models/seat.model";
13
+ import {SeatItem} from "./block-item/seat/seat-item.index";
14
+ import BlockModel from "../../../models/block.model";
15
+ import LabelModel from "../../../models/label.model";
16
+
17
+ @dom({
18
+ tag: "g",
19
+ class: "blocks",
20
+ autoGenerate: false
21
+ })
22
+ export default class Blocks extends SvgBase {
23
+
24
+ public seats: Array<SeatItem>;
25
+
26
+
27
+ constructor(public parent: StageManager) {
28
+ super(parent);
29
+ return this;
30
+ }
31
+
32
+ public update(): this {
33
+ this.clear();
34
+ this.global.data.getBlocks().map((block_item: BlockModel) => {
35
+ let _blockItem = new Block(this, block_item);
36
+ let _seats = block_item.seats;
37
+
38
+
39
+ // algorithm problem fixed
40
+ if (_seats && _seats.length) {
41
+ _seats[0].y += 0.0001;
42
+ _seats[0].x += 0.0001;
43
+ }
44
+
45
+ let bound_items: Array<any> = _seats.map((item: SeatModel) => [item.x, item.y]).concat(block_item.labels.map((item: LabelModel) => [item.x, item.y]));
46
+ let _bounds = polygonHull(bound_items);
47
+ block_item.bounds = _bounds;
48
+
49
+ this.addChild(_blockItem);
50
+ });
51
+ this.updateChilds();
52
+ this.seats = this.node.selectAll(".seat");
53
+
54
+ return this;
55
+ }
56
+
57
+ public getBlock(id: any): Block {
58
+ return this.getBlocks().find((block: Block) => block.item.id == id);
59
+ }
60
+
61
+ public getBlocks(): Array<Block> {
62
+ return this.getChilds(Block.name);
63
+ }
64
+
65
+ public center() {
66
+
67
+ }
68
+ }