@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,182 @@
1
+ /*
2
+ * $project.fileName
3
+ * https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
4
+ */
5
+
6
+
7
+ import BlockModel from "./block.model";
8
+ import ModelBase from "./model.base";
9
+ import {SeatItem} from "../svg/stage/blocks/block-item/seat/seat-item.index";
10
+
11
+ export default class SeatModel extends ModelBase {
12
+ private _id: any;
13
+ private _x: number;
14
+ private _y: number;
15
+ private _title?: string;
16
+ private _selected: boolean;
17
+
18
+ private _color: string;
19
+ private _block: BlockModel;
20
+ private _salable: boolean;
21
+ private _note: string;
22
+
23
+ private _tags: Array<string>;
24
+ private _tag_index: any = {};
25
+
26
+ private _custom_data: any;
27
+
28
+ private _svg: SeatItem;
29
+
30
+ // public item_type: string = "Seat";
31
+
32
+
33
+ constructor(item: any) {
34
+ super();
35
+ this.id = item.id;
36
+ this.x = item.x;
37
+ this.y = item.y;
38
+ this.title = item.title || null;
39
+ this.color = item.color || null;
40
+ this.block = item.block;
41
+ this.note = item.note || null;
42
+ this.salable = item.salable === false ? item.salable : true;
43
+ this.selected = item.selected || false;
44
+ this.tags = item.tags || [];
45
+ this.custom_data = item.custom_data || {};
46
+ this._tag_index = {};
47
+ }
48
+
49
+ public selectedToggle(): boolean {
50
+ this.selected = this.selected !== true;
51
+ return this.selected;
52
+ }
53
+
54
+ get x(): number {
55
+ return this._x;
56
+ }
57
+
58
+ set x(value: number) {
59
+ this._x = value;
60
+ }
61
+
62
+ get y(): number {
63
+ return this._y;
64
+ }
65
+
66
+ set y(value: number) {
67
+ this._y = value;
68
+ }
69
+
70
+ get title(): string {
71
+ return this._title;
72
+ }
73
+
74
+ set title(value: string) {
75
+ this._title = value;
76
+ }
77
+
78
+ get selected(): boolean {
79
+ return this._selected;
80
+ }
81
+
82
+ set selected(value: boolean) {
83
+ this._selected = value;
84
+ }
85
+
86
+ get color(): string {
87
+ return this._color;
88
+ }
89
+
90
+ set color(value: string) {
91
+ this._color = value;
92
+ }
93
+
94
+ get block(): BlockModel {
95
+ return this._block;
96
+ }
97
+
98
+ set block(value: BlockModel) {
99
+ this._block = value;
100
+ }
101
+
102
+ get salable(): boolean {
103
+ return this._salable;
104
+ }
105
+
106
+ set salable(value: boolean) {
107
+ this._salable = value;
108
+ }
109
+
110
+ get note(): string {
111
+ return this._note;
112
+ }
113
+
114
+ set note(value: string) {
115
+ this._note = value;
116
+ }
117
+
118
+ get id(): any {
119
+ return this._id;
120
+ }
121
+
122
+ set id(value: any) {
123
+ this._id = value;
124
+ }
125
+
126
+
127
+ get tags(): Array<string> {
128
+ return this._tags;
129
+ }
130
+
131
+ set tags(value: Array<string>) {
132
+ this._tags = value;
133
+ }
134
+
135
+ get svg(): SeatItem {
136
+ return this._svg;
137
+ }
138
+
139
+ set svg(value: SeatItem) {
140
+ this._svg = value;
141
+ }
142
+
143
+ public addTag(tag: string) {
144
+ if (!this._tag_index[tag]) {
145
+ this._tag_index[tag] = true;
146
+ this.tags.push(tag);
147
+ }
148
+ }
149
+
150
+ public removeTags(tag: string) {
151
+
152
+ }
153
+
154
+ get tag_index(): any {
155
+ return this._tag_index;
156
+ }
157
+
158
+ set tag_index(value: any) {
159
+ this._tag_index = value;
160
+ }
161
+
162
+
163
+ get custom_data(): any {
164
+ return this._custom_data;
165
+ }
166
+
167
+ set custom_data(value: any) {
168
+ this._custom_data = value;
169
+ }
170
+
171
+ public toJson() {
172
+ return {
173
+ id: this.id,
174
+ x: this.x,
175
+ y: this.y,
176
+ salable: this.salable,
177
+ note: this.note,
178
+ color: this.color,
179
+ block: this.block.toJson()
180
+ }
181
+ }
182
+ }
@@ -0,0 +1,56 @@
1
+ /*
2
+ * $project.fileName
3
+ * https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
4
+ */
5
+
6
+ import {SeatMapCanvas} from "../canvas.index";
7
+ import {isArray} from "rxjs/internal/util/isArray";
8
+
9
+
10
+ export interface EventObject {
11
+ type: string,
12
+ fn: any
13
+ }
14
+
15
+ export default class EventManager {
16
+ private _events: Array<EventObject>;
17
+
18
+
19
+ constructor(private _self: SeatMapCanvas) {
20
+ this._events = [];
21
+ }
22
+
23
+ addEventListener(type: string | any, fn: any): this {
24
+ if (isArray(type)) {
25
+ for (let i = 0; i < type.length; i++) {
26
+ this._events.push({
27
+ type: type[i],
28
+ fn: fn
29
+ });
30
+ }
31
+ } else {
32
+ this._events.push({
33
+ type: type,
34
+ fn: fn
35
+ });
36
+ }
37
+
38
+ return this;
39
+ }
40
+
41
+ dispatch(type: string, data: any): this {
42
+ this._events
43
+ .filter((event: EventObject) => event.type === type)
44
+ .map((event: EventObject) => event.fn(data));
45
+ return this;
46
+ }
47
+
48
+
49
+ get events(): Array<EventObject> {
50
+ return this._events;
51
+ }
52
+
53
+ set events(value: Array<EventObject>) {
54
+ this._events = value;
55
+ }
56
+ }
@@ -0,0 +1,28 @@
1
+ /*
2
+ * $project.fileName
3
+ * https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
4
+ */
5
+
6
+
7
+ import {dom} from "../../decorators";
8
+ import SvgBase from "./../svg.base";
9
+ import LegendItem from "./legend.item";
10
+
11
+ @dom({
12
+ tag: "circle",
13
+ class: "legend-circle",
14
+ autoGenerate: false
15
+ })
16
+ export default class LegendCircle extends SvgBase {
17
+
18
+
19
+ constructor(public parent: LegendItem) {
20
+ super(parent);
21
+ this.attr("r", this.global.config.legend_style.radius);
22
+ this.attr("fill", this.parent.legend_data.color);
23
+ }
24
+
25
+ update() {
26
+
27
+ }
28
+ }
@@ -0,0 +1,50 @@
1
+ /*
2
+ * $project.fileName
3
+ * https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
4
+ */
5
+
6
+
7
+ import {dom} from "../../decorators";
8
+ import SvgBase from "./../svg.base";
9
+ import Legend from "../legend";
10
+ import LegendCircle from "./legend.circle";
11
+ import LegendTitle from "./legend.title";
12
+ import LegendModel from "../../models/legend.model";
13
+
14
+ @dom({
15
+ tag: "g",
16
+ class: "legend-item",
17
+ autoGenerate: false
18
+ })
19
+ export default class LegendItem extends SvgBase {
20
+
21
+ public circle: LegendCircle;
22
+ public title: LegendTitle;
23
+
24
+ constructor(public parent: Legend, public legend_data: LegendModel) {
25
+ super(parent);
26
+
27
+ }
28
+
29
+ update() {
30
+
31
+ this.circle = new LegendCircle(this);
32
+ this.addChild(this.circle);
33
+
34
+ this.title = new LegendTitle(this);
35
+ this.addChild(this.title);
36
+
37
+ this.updateChilds();
38
+
39
+ this.title.node.text(this.legend_data.title);
40
+
41
+ let x = 0;
42
+ let y = this.child_index * this.global.config.legend_style.padding;
43
+
44
+ this.node.attr("transform", "translate(" + [x, y] + ")")
45
+
46
+
47
+ }
48
+
49
+
50
+ }
@@ -0,0 +1,27 @@
1
+ /*
2
+ * $project.fileName
3
+ * https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
4
+ */
5
+
6
+
7
+ import {dom} from "../../decorators";
8
+ import SvgBase from "./../svg.base";
9
+ import LegendItem from "./legend.item";
10
+
11
+ @dom({
12
+ tag: "text",
13
+ class: "legend-title",
14
+ autoGenerate: false
15
+ })
16
+ export default class LegendTitle extends SvgBase {
17
+
18
+
19
+ constructor(public parent: LegendItem) {
20
+ super(parent);
21
+ this.attr("x", this.global.config.legend_style.radius * 1.5);
22
+ }
23
+
24
+ update() {
25
+
26
+ }
27
+ }
@@ -0,0 +1,55 @@
1
+ /*
2
+ * $project.fileName
3
+ * https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
4
+ */
5
+
6
+
7
+ import {dom} from "../decorators";
8
+ import SvgBase from "./svg.base";
9
+ import Svg from "./svg.index";
10
+ import LegendItem from "./legend/legend.item";
11
+
12
+ @dom({
13
+ tag: "g",
14
+ class: "legend",
15
+ autoGenerate: false
16
+ })
17
+ export default class Legend extends SvgBase {
18
+
19
+
20
+ constructor(public parent: Svg) {
21
+ super(parent);
22
+ }
23
+
24
+ update() {
25
+
26
+ let legend_data: Array<any> = [];
27
+
28
+ legend_data.push({
29
+ title: this.global.config.lang.non_selectable,
30
+ color: this.global.config.seat_style.not_salable
31
+ });
32
+ legend_data.push({
33
+ title: this.global.config.lang.selectable,
34
+ color: this.global.config.seat_style.color
35
+ });
36
+ legend_data.push({
37
+ title: this.global.config.lang.your_selection,
38
+ color: this.global.config.seat_style.selected
39
+ });
40
+
41
+ for (let i = 0; i < legend_data.length; i++) {
42
+ let legend: LegendItem = new LegendItem(this, legend_data[i]);
43
+ this.addChild(legend);
44
+ }
45
+
46
+ this.updateChilds()
47
+ }
48
+
49
+ afterGenerate() {
50
+
51
+ let x = this.global.config.legend_style.radius * 2;
52
+ let y = 150 - (this.global.config.legend_style.padding * this.getChildCount());
53
+ this.node.attr("transform", "translate(" + [x, y] + ")");
54
+ }
55
+ }
@@ -0,0 +1,51 @@
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
+
12
+ @dom({
13
+ tag: "g",
14
+ class: "bounds",
15
+ autoGenerate: false
16
+ })
17
+ export default class BlockBounds extends SvgBase {
18
+
19
+ public bound1: BoundItem;
20
+ public bound2: BoundItem;
21
+
22
+ constructor(public parent: Block, public item: BlockModel) {
23
+ super(parent);
24
+ return this;
25
+ }
26
+
27
+ update(): this {
28
+
29
+ // add Border Bounds container
30
+ this.bound1 = new BoundItem(this, this.item);
31
+ this.bound1.attr("fill", this.parent.item.border_color);
32
+ this.bound1.attr("stroke-width", 70);
33
+ this.bound1.attr("stroke", this.parent.item.border_color);
34
+ this.bound1.classed("block-hull-border");
35
+
36
+ // add Border Bounds container
37
+ this.bound2 = new BoundItem(this, this.item);
38
+ this.bound2.attr("fill", this.item.color);
39
+ this.bound2.attr("stroke-width", 60);
40
+ this.bound2.attr("stroke", this.item.color);
41
+ this.bound2.classed("block-hull");
42
+
43
+
44
+ this.addChild(this.bound1);
45
+ this.addChild(this.bound2);
46
+
47
+ this.updateChilds();
48
+
49
+ return this;
50
+ }
51
+ }
@@ -0,0 +1,173 @@
1
+ /*
2
+ * $project.fileName
3
+ * https://github.com/seatmap/canvas Copyright 2018 Ali Sait TEKE
4
+ */
5
+
6
+ import {mouse as d3Mouse} from 'd3-selection'
7
+
8
+ import BlocksManager from "../blocks.index";
9
+ import SvgBase from "../../../svg.base";
10
+ import {dom} from "../../../../decorators/dom";
11
+ import BlockModel from "../../../../models/block.model";
12
+ import Seats from "./block-item.seats.index";
13
+ import BlockInfo from "./block-item.info.index";
14
+ import BlockBounds from "./block-item.bounds";
15
+ import {EventType, SeatAction, ZoomLevel} from "../../../../enums/global";
16
+ import BlockMask from "./block-item.mask";
17
+ import Labels from "./block-item.labels.index";
18
+ import SeatModel from "../../../../models/seat.model";
19
+
20
+
21
+ @dom({
22
+ tag: "g",
23
+ class: "block",
24
+ autoGenerate: false
25
+ })
26
+ export default class Block extends SvgBase {
27
+
28
+
29
+ public seats: Seats;
30
+ public labels: Labels;
31
+ public info: BlockInfo;
32
+ public mask: BlockMask;
33
+ public bounds: BlockBounds;
34
+
35
+ public center_position: any = {
36
+ x: null,
37
+ y: null
38
+ };
39
+ public top_position: any = {
40
+ x: null,
41
+ y: null
42
+ };
43
+
44
+ constructor(public parent: BlocksManager, public item: BlockModel) {
45
+ super(parent);
46
+ this.attr("id", item.id);
47
+ this.attr("opacity", 0);
48
+ this.global.eventManager.addEventListener(EventType.ZOOM_LEVEL_CHANGE, (levelObject: any) => {
49
+ if (levelObject.level === ZoomLevel.VENUE) {
50
+ this.mask.blockLevelMask.show();
51
+ this.mask.seatLevelMask.show();
52
+ this.seats.resetSeatsColors(false);
53
+ this.infosToCenter();
54
+ } else if (levelObject.level === ZoomLevel.BLOCK) {
55
+ this.mask.blockLevelMask.hide();
56
+ this.mask.seatLevelMask.show();
57
+ this.infosToTop();
58
+ } else if (levelObject.level === ZoomLevel.SEAT) {
59
+ this.mask.blockLevelMask.hide();
60
+ this.mask.seatLevelMask.hide();
61
+ this.seats.resetSeatsColors(false);
62
+ this.infosToTop();
63
+ }
64
+ });
65
+
66
+ this.global.eventManager.addEventListener(EventType.MULTI_SELECT_ENABLE,()=>{
67
+ this.seats.resetSeatsColors(false);
68
+ });
69
+ this.global.eventManager.addEventListener(EventType.MULTI_SELECT_DISABLE,()=>{
70
+ this.seats.resetSeatsColors(false);
71
+ });
72
+
73
+
74
+ // grid search
75
+ this.global.eventManager.addEventListener(EventType.MOUSEMOVE_BLOCK, (block_item: Block) => {
76
+
77
+ if (!this.parent.parent.searchCircle.is_enable) return;
78
+ if (this.global.multi_select) return;
79
+ let cor = d3Mouse(this.parent.parent.blocks.node.node());
80
+ let gap = this.global.config.zoom_focus_circle_radius;
81
+
82
+ if (this.global.zoomManager.zoomLevel === ZoomLevel.BLOCK) {
83
+ for (let i = 0; i < block_item.seats.getSeatsCount(); i++) {
84
+ let _seat = block_item.seats.getSeatByIndex(i);
85
+ let _item: SeatModel = _seat.item;
86
+
87
+
88
+ let color = _seat.getColor();
89
+ if (_seat.isSelected()) {
90
+ color = _seat.getColor(SeatAction.SELECT);
91
+ } else {
92
+ if ((_item.x - gap < cor[0] && _item.x + gap > cor[0]) && (_item.y - gap < cor[1] && _item.y + gap > cor[1])) {
93
+ color = _seat.getColor(SeatAction.FOCUS);
94
+ }
95
+ _seat.setColor(color);
96
+ }
97
+
98
+
99
+ }
100
+ }
101
+ });
102
+
103
+ // grid search
104
+ // this.global.eventManager.addEventListener(EventType.TOUCHSTART_BLOCK, (block_item: Block) => {
105
+ // console.log(block_item);
106
+ // });
107
+
108
+ this.parent.node.on("mouseleave.seats", () => {
109
+ this.seats.resetSeatsColors(false);
110
+ });
111
+
112
+ return this;
113
+ }
114
+
115
+
116
+ public update() {
117
+
118
+ // add Block Bounds container
119
+ this.bounds = new BlockBounds(this, this.item);
120
+ this.addChild(this.bounds);
121
+
122
+
123
+ // add Seat container
124
+ this.seats = new Seats(this, this.item);
125
+ this.addChild(this.seats);
126
+
127
+
128
+ // add Labels container
129
+ this.labels = new Labels(this, this.item);
130
+ this.addChild(this.labels);
131
+
132
+
133
+ // add Block Info container
134
+ this.mask = new BlockMask(this, this.item);
135
+ this.addChild(this.mask);
136
+
137
+
138
+ this.info = new BlockInfo(this, this.item);
139
+ this.addChild(this.info);
140
+
141
+
142
+ this.center_position.x = ((this.item.bounds[1][0] - this.item.bounds[2][0]) / 2) + this.item.bounds[2][0];
143
+ this.center_position.y = ((this.item.bounds[0][1] - this.item.bounds[1][1]) / 2) + this.item.bounds[1][1];
144
+
145
+ this.top_position.x = this.center_position.x;
146
+ this.top_position.y = (this.item.bounds[1][1] - 50);
147
+
148
+
149
+ // update childs
150
+ this.updateChilds();
151
+
152
+
153
+ this.infosToCenter();
154
+
155
+ this.node.interrupt().transition().duration(this.global.config.animation_speed).attr("opacity", 1);
156
+
157
+
158
+ return this;
159
+ }
160
+
161
+ public infosToTop() {
162
+ if (this.info.node && this.top_position.x)
163
+ this.info.node.interrupt().transition().duration(this.global.config.animation_speed).attr("transform", "translate(" + this.top_position.x + "," + this.top_position.y + ")").attr("opacity", 1).attr("font-size", 14).attr("fill", "#ffffff");
164
+ }
165
+
166
+ public infosToCenter() {
167
+ if (this.info.node && this.center_position.x)
168
+ this.info.node.interrupt().transition().duration(this.global.config.animation_speed).attr("transform", "translate(" + this.center_position.x + "," + this.center_position.y + ")").attr("opacity", 1).attr("font-size", 28).attr("fill", "#ffffff");
169
+
170
+ }
171
+
172
+
173
+ }
@@ -0,0 +1,38 @@
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 {BlockTitle} from "./info/title";
11
+
12
+ @dom({
13
+ tag: "g",
14
+ class: "info",
15
+ autoGenerate: false
16
+ })
17
+ export default class BlockInfo extends SvgBase {
18
+
19
+ public title: BlockTitle;
20
+
21
+
22
+ constructor(public parent: Block, public item: BlockModel) {
23
+ super(parent);
24
+ this.attr("opacity", 0);
25
+ let x = ((this.item.bounds[1][0] - this.item.bounds[2][0]) / 2) + this.item.bounds[2][0];
26
+ let y = ((this.item.bounds[0][1] - this.item.bounds[1][1]) / 2) + this.item.bounds[1][1];
27
+ this.attr("transform", "translate(" + [x, y] + ")");
28
+ return this;
29
+ }
30
+
31
+ update(): this {
32
+ this.title = new BlockTitle(this);
33
+ this.addChild(this.title);
34
+ this.updateChilds();
35
+ this.title.node.text(this.parent.item.title);
36
+ return this;
37
+ }
38
+ }
@@ -0,0 +1,41 @@
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 BlockModel from "../../../../models/block.model";
11
+ import {LabelItem} from "./label/label-item.index";
12
+ import LabelModel from "../../../../models/label.model";
13
+
14
+
15
+ @dom({
16
+ tag: "g",
17
+ class: "labels",
18
+ autoGenerate: false
19
+ })
20
+ export default class Labels extends SvgBase {
21
+
22
+ constructor(public parent: Block, public item: BlockModel) {
23
+ super(parent);
24
+ return this;
25
+ }
26
+
27
+ update(): this {
28
+ // add seat items in blockItem container
29
+ this.item.labels.map((label: LabelModel) => {
30
+ this.addChild(new LabelItem(this, label))
31
+ });
32
+ this.updateChilds();
33
+ return this;
34
+ }
35
+
36
+ // Getting labels method
37
+ // ex: seatmap.stage.blocks.getBlock(2).seats.getSeat("1-1")
38
+ public getLabels(): Array<LabelItem> {
39
+ return this.child_items;
40
+ }
41
+ }