artfully_ose 1.3.0.pre3 → 1.3.0.pre4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/loading-white.gif +0 -0
  3. data/app/assets/images/seating_temp/1.jpg +0 -0
  4. data/app/assets/images/seating_temp/10.jpg +0 -0
  5. data/app/assets/images/seating_temp/11.jpg +0 -0
  6. data/app/assets/images/seating_temp/2.jpg +0 -0
  7. data/app/assets/images/seating_temp/3.jpg +0 -0
  8. data/app/assets/images/seating_temp/4.jpg +0 -0
  9. data/app/assets/images/seating_temp/5.jpg +0 -0
  10. data/app/assets/images/seating_temp/6.jpg +0 -0
  11. data/app/assets/images/seating_temp/7.jpg +0 -0
  12. data/app/assets/images/seating_temp/8.jpg +0 -0
  13. data/app/assets/images/seating_temp/9.jpg +0 -0
  14. data/app/assets/images/seating_temp/icon_43405.png +0 -0
  15. data/app/assets/images/seating_temp/icon_43405.svg +3 -0
  16. data/app/assets/images/seating_temp/icon_43405_plus.png +0 -0
  17. data/app/assets/images/seating_temp/license.txt +8 -0
  18. data/app/assets/javascripts/application.js +1 -0
  19. data/app/assets/javascripts/custom/cookies.js +27 -0
  20. data/app/assets/javascripts/custom/inline-people-search.js +4 -0
  21. data/app/assets/javascripts/custom/job-monitor.js +0 -1
  22. data/app/assets/javascripts/exchange-seat-chart.js +5 -0
  23. data/app/assets/javascripts/seat-chart.js +606 -0
  24. data/app/assets/javascripts/show-seat-chart.js +17 -0
  25. data/app/assets/javascripts/store/store-seat-chart.js +76 -0
  26. data/app/assets/javascripts/store/store.js +14 -39
  27. data/app/assets/stylesheets/application.sass +49 -1
  28. data/app/assets/stylesheets/bootstrap-overrides.css +11 -3
  29. data/app/assets/stylesheets/sass/seat-chart.sass +311 -0
  30. data/app/assets/stylesheets/sass/store.sass +73 -19
  31. data/app/assets/stylesheets/storefront.css +2 -0
  32. data/app/concerns/pdf_generation.rb +1 -15
  33. data/app/controllers/advanced_searches_controller.rb +1 -3
  34. data/app/controllers/charts_controller.rb +14 -12
  35. data/app/controllers/console_sales_controller.rb +55 -0
  36. data/app/controllers/event_calendars_controller.rb +15 -0
  37. data/app/controllers/events_controller.rb +16 -5
  38. data/app/controllers/exchanges_controller.rb +32 -9
  39. data/app/controllers/export_controller.rb +8 -0
  40. data/app/controllers/members/sessions_controller.rb +0 -2
  41. data/app/controllers/membership_comps_controller.rb +2 -1
  42. data/app/controllers/prices_controller.rb +20 -0
  43. data/app/controllers/shows_controller.rb +3 -1
  44. data/app/controllers/store/events_controller.rb +6 -5
  45. data/app/controllers/store/orders_controller.rb +11 -13
  46. data/app/controllers/store/shows_controller.rb +1 -0
  47. data/app/controllers/store/store_controller.rb +11 -0
  48. data/app/controllers/tickets_controller.rb +0 -28
  49. data/app/controllers/user_memberships_controller.rb +7 -2
  50. data/app/controllers/venues_controller.rb +9 -0
  51. data/app/helpers/artfully_ose_helper.rb +18 -4
  52. data/app/helpers/seating_helper.rb +157 -0
  53. data/app/models/assigned_chart.rb +220 -0
  54. data/app/models/cart.rb +6 -1
  55. data/app/models/chart.rb +28 -17
  56. data/app/models/database_views/item_view.rb +76 -5
  57. data/app/models/discount.rb +4 -0
  58. data/app/models/discounts/buy_one_get_one_free_discount_type.rb +1 -1
  59. data/app/models/discounts/dollars_off_tickets_discount_type.rb +5 -1
  60. data/app/models/discounts/percentage_off_tickets_discount_type.rb +8 -4
  61. data/app/models/event.rb +86 -12
  62. data/app/models/general_admission_chart.rb +51 -0
  63. data/app/models/imports/events_import.rb +1 -1
  64. data/app/models/job/show_creator.rb +3 -10
  65. data/app/models/kit.rb +11 -1
  66. data/app/models/kits/assigned_seating_kit.rb +23 -0
  67. data/app/models/member_walkup.rb +1 -1
  68. data/app/models/order_handler.rb +22 -6
  69. data/app/models/organization.rb +4 -5
  70. data/app/models/person.rb +3 -1
  71. data/app/models/sale.rb +1 -1
  72. data/app/models/seat.rb +96 -0
  73. data/app/models/section.rb +1 -3
  74. data/app/models/show.rb +10 -17
  75. data/app/models/ticket.rb +30 -6
  76. data/app/models/ticket/locker.rb +3 -2
  77. data/app/models/ticket_type.rb +12 -6
  78. data/app/models/ticket_types_seat.rb +4 -0
  79. data/app/models/venue.rb +23 -0
  80. data/app/views/advanced_searches/filters/_birthday.html.haml +1 -0
  81. data/app/views/assigned_charts/_show.html.haml +12 -0
  82. data/app/views/console_sales/_aloha.html.haml +5 -4
  83. data/app/views/console_sales/new.html.haml +9 -0
  84. data/app/views/event_calendars/index.html.haml +34 -0
  85. data/app/views/events/_menu.html.haml +2 -1
  86. data/app/views/events/_section_fields.html.haml +13 -8
  87. data/app/views/events/new.html.haml +34 -4
  88. data/app/views/events/prices.html.haml +3 -4
  89. data/app/views/events/seating.html.haml +131 -0
  90. data/app/views/exchanges/_assigned_chart.html.haml +108 -0
  91. data/app/views/exchanges/_general_admission_chart.html.haml +55 -0
  92. data/app/views/exchanges/new.html.haml +1 -55
  93. data/app/views/general_admission_charts/_show.html.haml +2 -0
  94. data/app/views/layouts/_menu.html.haml +44 -31
  95. data/app/views/layouts/storefront.html.haml +72 -30
  96. data/app/views/membership_comps/new.html.haml +1 -0
  97. data/app/views/order_mailer/confirmation_for.html.haml +5 -3
  98. data/app/views/order_mailer/confirmation_for.text.haml +1 -2
  99. data/app/views/pdfs/order.html.haml +20 -6
  100. data/app/views/seating/_actions_menu.html.haml +10 -0
  101. data/app/views/seating/_chart.html.haml +15 -0
  102. data/app/views/seating/_chart_container.html.haml +2 -0
  103. data/app/views/seating/_chart_note_display.html.haml +7 -0
  104. data/app/views/seating/_hold_seats_modal.html.haml +39 -0
  105. data/app/views/seating/_layer_menu.html.haml +23 -0
  106. data/app/views/seating/_legend.html.haml +52 -0
  107. data/app/views/seating/_modify_seats_modal.html.haml +29 -0
  108. data/app/views/seating/_ticket_type_modals.html.haml +41 -0
  109. data/app/views/shows/_seat_chart.html.haml +122 -0
  110. data/app/views/shows/_sections_table.html.haml +3 -24
  111. data/app/views/shows/_ticket_table.html.haml +4 -2
  112. data/app/views/shows/_work_with.html.haml +4 -0
  113. data/app/views/shows/new.html.haml +2 -2
  114. data/app/views/shows/show.html.haml +93 -14
  115. data/app/views/store/assigned_charts/_show.html.haml +54 -0
  116. data/app/views/store/checkouts/shopping_cart_display/_tickets.haml +13 -0
  117. data/app/views/store/donations/index.html.haml +1 -1
  118. data/app/views/store/events/calendar.html.haml +94 -11
  119. data/app/views/store/events/index.html.haml +1 -1
  120. data/app/views/store/events/show.html.haml +36 -2
  121. data/app/views/store/events/single_show.html.haml +5 -4
  122. data/app/views/store/general_admission_charts/_show.html.haml +41 -0
  123. data/app/views/store/orders/show.html.haml +17 -4
  124. data/app/views/store/shared/_donate_form.html.haml +2 -1
  125. data/app/views/store/shared/_small_donate_form.html.haml +1 -1
  126. data/app/views/store/shows/_show.html.haml +1 -39
  127. data/app/views/ticket_types/edit.html.haml +1 -1
  128. data/app/views/user_memberships/_list.html.haml +1 -1
  129. data/app/views/venues/edit.html.haml +1 -1
  130. data/app/views/venues/show.html.haml +11 -0
  131. data/config/routes.rb +27 -10
  132. data/db/migrate/20140828174357_add_type_to_chart.rb +7 -0
  133. data/db/migrate/20140828195617_create_seats.rb +16 -0
  134. data/db/migrate/20140829135426_add_venue_to_chart.rb +5 -0
  135. data/db/migrate/20140829143520_add_assigned_to_event.rb +5 -0
  136. data/db/migrate/20140904164927_add_fields_to_seat.rb +14 -0
  137. data/db/migrate/20140912170010_add_note_to_seat.rb +6 -0
  138. data/db/migrate/20140919152307_add_seats_to_ticket.rb +5 -0
  139. data/db/migrate/20140930224543_add_public_note_to_chart.rb +5 -0
  140. data/db/migrate/20141001140737_add_seat_id_index_to_tickets.rb +5 -0
  141. data/db/migrate/20141001193242_associate_hold_with_person.rb +6 -0
  142. data/db/migrate/20141021175311_create_ticket_types_seats.rb +11 -0
  143. data/db/migrate/20150106161744_migrate_charts_back_to_venues.rb +18 -0
  144. data/db/migrate/20151105085424_add_creator_to_items_view.rb +40 -0
  145. data/lib/artfully_ose/version.rb +1 -1
  146. data/spec/factories/assigned_chart_factories.rb +18 -0
  147. data/spec/factories/chart_factories.rb +4 -8
  148. data/spec/factories/kit_factories.rb +4 -0
  149. data/spec/factories/seat_factories.rb +4 -0
  150. data/spec/factories/show_factories.rb +1 -1
  151. metadata +66 -5
  152. data/app/models/ticket/foundry.rb +0 -48
  153. data/app/models/ticket/template.rb +0 -40
  154. data/app/views/store/events/_calendar.html.haml +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fbca74b3c729a037bb45f57968f80d5f307c6bf
4
- data.tar.gz: d82ddcd5912ed3aaabb3070d5fecca425f581482
3
+ metadata.gz: 35fd5cb2888a52b1977abcbf7fc915c6a9c9b2a9
4
+ data.tar.gz: c99f0198ca7d86b60fdf9588837f7b218b5e04a8
5
5
  SHA512:
6
- metadata.gz: 1df7b7aeff9f5aa8d33a9319c688b0bb71453a2f79885a04c2c39aff2da05da5459d2771769b0aff8d0e54261ddcbdf4a3cec832902766e68418c7d7134bec02
7
- data.tar.gz: df671c3cd62c19462a95c709abc93f6dec9cff3b0194646c3d1507128cd8a6f8540a490393ef9229ed4cd7dc6c7012f160e0542a2a105438ded262103b5355d7
6
+ metadata.gz: ce804301c643b5a0d22b3de1f6381fc971113a9c14b867531c261adec8446ab5f4e37bd3ae480c3766aab1fbf8950177b3a9906af445139489ede28b00448a43
7
+ data.tar.gz: 1f0cf8b9eaf06ed02680d55791a9d214fb4d248034e311fbbe47ce5a1d94ebc812a399d21ab862970972b7a1d9b9aa50a1e0e892ff5ae5a062c1a41103db8cf4
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Laag_1" x="0px" y="0px" width="100px" height="100px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve">
2
+ <path d="M85.502,74.339l-7.524,4.001l-14.612-27.48v-0.21H37.164v-6.978h19.93v-6.977h-19.93V21.941 c4.006-0.703,7.052-4.197,7.052-8.405C44.216,8.822,40.394,5,35.68,5c-4.714,0-8.536,3.822-8.536,8.536 c0,2.622,1.183,4.966,3.043,6.532v37.558h0.816v0h28.059l16.026,30.141l0.015-0.008l0.004,0.008L88.778,80.5L85.502,74.339z M40.346,88.507c-12.376,0-22.408-10.033-22.408-22.408c0-7.7,3.885-14.493,9.8-18.526v-7.956 c-9.771,4.7-16.515,14.692-16.515,26.26C11.222,81.961,24.261,95,40.346,95c11.872,0,22.084-7.105,26.619-17.294l-4.446-8.361 C60.946,80.182,51.619,88.507,40.346,88.507z"/>
3
+ </svg>
@@ -0,0 +1,8 @@
1
+ Thank you for using The Noun Project. This icon is licensed under Creative
2
+ Commons Attribution and must be attributed as:
3
+
4
+ Wheelchair by Neal Van Den Eertwegh from The Noun Project
5
+
6
+ If you have a Premium Account or have purchased a license for this icon, you
7
+ don't need to worry about attribution! We will share the profits from your
8
+ purchase with this icon's designer.
@@ -677,6 +677,7 @@ $( '#widget_type_event' ).click(function() {
677
677
  $( '#widget_type_both' ).click(function() {
678
678
  $("#preset-amount").show();
679
679
  $("#widget-event").show();
680
+
680
681
  });
681
682
 
682
683
  $( '#organization_fiscal_month' ).bind('change keydown', function() {
@@ -0,0 +1,27 @@
1
+ function createCookie(name, value, days) {
2
+ var expires;
3
+
4
+ if (days) {
5
+ var date = new Date();
6
+ date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
7
+ expires = "; expires=" + date.toGMTString();
8
+ } else {
9
+ expires = "";
10
+ }
11
+ document.cookie = escape(name) + "=" + escape(value) + expires + "; path=/";
12
+ }
13
+
14
+ function readCookie(name) {
15
+ var nameEQ = escape(name) + "=";
16
+ var ca = document.cookie.split(';');
17
+ for (var i = 0; i < ca.length; i++) {
18
+ var c = ca[i];
19
+ while (c.charAt(0) === ' ') c = c.substring(1, c.length);
20
+ if (c.indexOf(nameEQ) === 0) return unescape(c.substring(nameEQ.length, c.length));
21
+ }
22
+ return null;
23
+ }
24
+
25
+ function eraseCookie(name) {
26
+ createCookie(name, "", -1);
27
+ }
@@ -25,6 +25,9 @@ function updateSelectedPerson(personId, personFirstName, personLastName, personE
25
25
  $("input#person_first_name").val(personFirstName)
26
26
  $("input#person_last_name").val(personLastName)
27
27
  $("input#person_email").val(personEmail)
28
+
29
+ $("input.person-search").val(personFirstName + " " + personLastName)
30
+
28
31
  updateModal()
29
32
  }
30
33
 
@@ -33,6 +36,7 @@ function clearNewPersonForm() {
33
36
  $("input#person_first_name").val("")
34
37
  $("input#person_last_name").val("")
35
38
  $("input#person_email").val("")
39
+ $("input.person-search").val("")
36
40
  }
37
41
 
38
42
  $("document").ready(function(){
@@ -1,6 +1,5 @@
1
1
  $(document).ready(function () {
2
2
  var monitors = $(".remote-monitor")
3
- console.log(monitors.length)
4
3
  if (monitors.length > 0) {
5
4
  var m = $(document.createElement('div')).attr('id', 'monitorModal').addClass('modal')
6
5
  .append($(document.createElement('div')).addClass("modal-header").html("&nbsp")
@@ -0,0 +1,5 @@
1
+ // modifications to seat-chart.js which are specific to exchanges
2
+
3
+ $(document).ready(function() {
4
+
5
+ })
@@ -0,0 +1,606 @@
1
+ seatChartLayers = ["holds_layer", "notes_layer", "wheelchair_layer", "aisle_layer"]
2
+
3
+ jQuery.fn.extend({
4
+ clearHolds: function() {
5
+ this.removeClass("hold")
6
+ this.removeClass("house-hold")
7
+ this.removeClass("development-hold")
8
+ this.removeClass("tech-hold")
9
+ this.removeClass("contractual-hold")
10
+ this.removeClass("person-hold")
11
+ this.removeClass("press-hold")
12
+ this.clearHoldNote
13
+ },
14
+ addHoldNote: function(note) {
15
+ this.attr('data-hold-note', note)
16
+ },
17
+ addHoldPerson: function(person_id) {
18
+ this.attr('data-hold-person-id', person_id)
19
+ },
20
+ addTicketType: function(ticket_type_id) {
21
+ this.addClass("ticket-type-" + ticket_type_id)
22
+ },
23
+ removeTicketType: function(ticket_type_id) {
24
+ this.removeClass("ticket-type-" + ticket_type_id)
25
+ },
26
+ clearHoldNote: function(note) {
27
+ this.removeAttr('data-hold-note')
28
+ },
29
+ clearHoldPerson: function(person_id) {
30
+ this.attr('data-hold-person-id', person_id)
31
+ },
32
+ addSeatNote: function(note) {
33
+ var seatNoteDiv = $(document.createElement('div')).addClass('seat-note')
34
+ var iconDiv = $(document.createElement('i')).addClass('icon-file')
35
+ seatNoteDiv.append(iconDiv)
36
+ this.append(seatNoteDiv)
37
+ this.attr('data-seat-note', note)
38
+ },
39
+ clearSeatNote: function(note) {
40
+ this.removeAttr('data-seat-note')
41
+ },
42
+ getTicketTypeIds: function() {
43
+ ticketTypeStrings = this.attr('class')
44
+ .split(" ")
45
+ .filter(function (className)
46
+ {
47
+ return className.lastIndexOf("ticket-type-",0) === 0
48
+ })
49
+
50
+ $.each(ticketTypeStrings,
51
+ function (idx, ticketTypeString) {
52
+ ticketTypeStrings[idx] = ticketTypeString.substring(12, ticketTypeString.length)
53
+ })
54
+
55
+ return ticketTypeStrings;
56
+ }
57
+ });
58
+
59
+ function checkLayers() {
60
+
61
+ $.each(seatChartLayers, function (index, layerName) {
62
+ tagalong = readCookie(layerName)
63
+ if(tagalong) {
64
+ $("#" + layerName).prop( "checked", true ).change();
65
+ }
66
+ })
67
+ }
68
+
69
+ function updateSeatsSelected() {
70
+ var numSeatsSelected = $(".seat-selected").length
71
+ $("#seats-selected").html(numSeatsSelected)
72
+ if (numSeatsSelected == 1) {
73
+ $("#seats-selected-text").html("seat selected")
74
+ } else {
75
+ $("#seats-selected-text").html("seats selected")
76
+ }
77
+ }
78
+
79
+ $(document).ready(function() {
80
+ $('.icon-file').tooltip()
81
+ $('#show-tabs a').click(function (e) {
82
+ e.preventDefault();
83
+ $(this).tab('show');
84
+ })
85
+
86
+ /* Controls */
87
+ $(".action-button").click(function () {
88
+ $(".layers-container").hide()
89
+ $(".actions-container").toggle()
90
+ })
91
+
92
+ $(".work-with-button").click(function () {
93
+ $(".toggable-container").hide()
94
+ updateSeatsSelected()
95
+ $("#modifyMultipleSeats").modal("show")
96
+ })
97
+
98
+ $(".layers-button").click(function () {
99
+ $(".actions-container").hide()
100
+ $(".layers-container").toggle()
101
+ })
102
+
103
+ //TODO: This verbosiates a lot of the stuff with seatChartLayers
104
+ //and checkLayers() above. If the layers change, make the changes here
105
+ //and in checkLayers()
106
+ $("#holds_layer").change(function() {
107
+ if ($(this).is(':checked')) {
108
+ $(".seat-chart-layout").addClass("show-hold-layer")
109
+ enableHoldPopovers();
110
+ createCookie("holds_layer", "true")
111
+ } else {
112
+ $(".seat-chart-layout").removeClass("show-hold-layer")
113
+ disableHoldPopovers();
114
+ eraseCookie("holds_layer")
115
+ }
116
+ })
117
+
118
+ $("#wheelchair_layer").change(function() {
119
+ if ($(this).is(':checked')) {
120
+ $(".seat-chart-layout").addClass("show-wheelchair-layer")
121
+ createCookie("wheelchair_layer", "true")
122
+ } else {
123
+ $(".seat-chart-layout").removeClass("show-wheelchair-layer")
124
+ eraseCookie("wheelchair_layer")
125
+ }
126
+ })
127
+
128
+ $("#notes_layer").change(function() {
129
+ if ($(this).is(':checked')) {
130
+ $(".seat-chart-layout").addClass("show-seat-note-layer")
131
+ createCookie("notes_layer", "true")
132
+ } else {
133
+ $(".seat-chart-layout").removeClass("show-seat-note-layer")
134
+ eraseCookie("notes_layer")
135
+ }
136
+ })
137
+
138
+ $("#aisle_layer").change(function() {
139
+ if ($(this).is(':checked')) {
140
+ $(".seat-chart-layout").addClass("show-aisle-layer")
141
+ createCookie("aisle_layer", "true")
142
+ } else {
143
+ $(".seat-chart-layout").removeClass("show-aisle-layer")
144
+ eraseCookie("aisle_layer")
145
+ }
146
+ })
147
+
148
+ $(".ticket_type_layer").change(function() {
149
+ $(".ticket_type_layer").each(function () {
150
+ if ($(this).is(':checked')) {
151
+ $(".seat-chart-layout").addClass("show-ticket-type-layer")
152
+
153
+ //This allows us to break from jQuery's .each loop
154
+ return false;
155
+ } else {
156
+ $(".seat-chart-layout").removeClass("show-ticket-type-layer")
157
+ }
158
+ })
159
+
160
+ if ($(this).is(':checked')) {
161
+ $("." + $(this).attr("id")).addClass("ticket-type-on")
162
+ } else {
163
+ $("." + $(this).attr("id")).removeClass("ticket-type-on")
164
+ }
165
+ })
166
+
167
+ $("#edit-chart-note-link").click(function () {
168
+ $("#chartNoteModal").modal("show")
169
+ })
170
+
171
+ $(".add-chart-note-button").click(function () {
172
+ $("#chartNoteModal").modal("show")
173
+ })
174
+
175
+ $(".select-none-button").click(function () {
176
+ $(".seat-selected").removeClass("seat-selected")
177
+ })
178
+
179
+ $(".select-all-button").click(function () {
180
+ $(".seat-selectable").addClass("seat-selected")
181
+ })
182
+
183
+ /* Chart creator */
184
+
185
+ normalizeWidth();
186
+ makeSeatsSelectable();
187
+ checkLayers();
188
+
189
+ $(".add-row-button").click(function() {
190
+ addRow()
191
+ })
192
+
193
+ $(".add-col-button").click(function() {
194
+ addColumn();
195
+ })
196
+
197
+ $(".clear-ticket-types").click(function () {
198
+ $('.ticket-type-selected').removeClass('ticket-type-selected')
199
+ })
200
+
201
+ $(".show-ticket-type").click(function () {
202
+ $('.ticket-type-selected').removeClass('ticket-type-selected')
203
+ tt = $(this).attr("data-ticket-type-name")
204
+ $(".seat-row:nth-last-child(2) .seat").addClass("ticket-type-selected")
205
+ $(".seat-row:nth-last-child(1) .seat").addClass("ticket-type-selected")
206
+ })
207
+
208
+ $("#chart-make-available-btn").click(function () {
209
+ $(".seat-selected").each(function() {
210
+ $(this).clearHolds()
211
+ $(this).addClass("available")
212
+ $(this).html("")
213
+ })
214
+ hideSeatModal()
215
+ fireUpdate();
216
+ })
217
+
218
+ $("#chart-aisle-btn").click(function () {
219
+ $(".seat-selected").each(function() {
220
+ $(this).addClass("aisle")
221
+ $(this).html("A")
222
+ })
223
+ hideSeatModal()
224
+ fireUpdate();
225
+ })
226
+
227
+ $("#chart-wheelchair-btn").click(function () {
228
+ $(".seat-selected").each(function() {
229
+ $(this).addClass("wheelchair")
230
+ $(this).html("")
231
+ })
232
+ hideSeatModal()
233
+ fireUpdate();
234
+ })
235
+
236
+ $("#chart-wheelchair-companion-btn").click(function () {
237
+ $(".seat-selected").each(function() {
238
+ $(this).addClass("wheelchair-companion")
239
+ $(this).html("")
240
+ })
241
+ hideSeatModal()
242
+ fireUpdate();
243
+ })
244
+
245
+ $("#chart-hold-btn").click(function () {
246
+ hideSeatModal()
247
+ $("#holdSeatsModal").modal("show")
248
+ })
249
+
250
+ $("#add-seat-note-btn").click(function () {
251
+ hideSeatModal()
252
+ $("#seatNoteModal").modal("show")
253
+ })
254
+
255
+ $("#add-ticket-type").click(function () {
256
+ hideSeatModal()
257
+ $("#addTicketTypeModal").modal("show")
258
+ })
259
+
260
+ $(".add-ticket-type-btn").click(function () {
261
+ ticketTypeId = $(this).attr("data-ticket-type-id")
262
+ $(".seat-selected").each(function() {
263
+ $(this).addTicketType(ticketTypeId)
264
+ })
265
+ fireUpdate();
266
+ $("#addTicketTypeModal").modal("hide")
267
+ })
268
+
269
+ $("#remove-ticket-type").click(function () {
270
+ hideSeatModal()
271
+ $("#removeTicketTypeModal").modal("show")
272
+ })
273
+
274
+ $(".remove-ticket-type-btn").click(function () {
275
+ ticketTypeId = $(this).attr("data-ticket-type-id")
276
+ $(".seat-selected").each(function() {
277
+ $(this).removeTicketType(ticketTypeId)
278
+ })
279
+ fireUpdate();
280
+ $("#removeTicketTypeModal").modal("hide")
281
+ })
282
+
283
+ $("#seat-note-form").submit(function () {
284
+ $(".seat-selected").each(function() {
285
+ $(this).addSeatNote($("#seat-note").val())
286
+ })
287
+ fireUpdate();
288
+ $("#seatNoteModal").modal("hide")
289
+ return false;
290
+ })
291
+
292
+ $('#edit-chart-note-form').bind('ajax:beforeSend', function(){
293
+ $("#chartNoteModal").modal("hide")
294
+ showLoading();
295
+
296
+ var note = $("#assigned_chart_public_note").val()
297
+ if (note == "") {
298
+ $("#chart-note-display").hide();
299
+ } else {
300
+ $("#public-chart-note").html(note)
301
+ $("#chart-note-display").show();
302
+ }
303
+ });
304
+
305
+ $('#edit-chart-note-form').bind('ajax:success', function(){
306
+ hideLoading();
307
+ });
308
+
309
+ $('#edit-chart-note-form').bind('ajax:error', function(){
310
+ showFail();
311
+ });
312
+
313
+ $("#hold-form").submit(function () {
314
+ $(".seat-selected").each(function() {
315
+ $(this).removeClass("available")
316
+ $(this).addClass("hold")
317
+ $(this).addClass($("#hold-type").val())
318
+ $(this).addHoldNote($("#hold-note").val())
319
+ $(this).addHoldPerson($("input#person_id").val())
320
+ })
321
+ hideSeatModal()
322
+ fireUpdate();
323
+ $("#holdSeatsModal").modal("hide")
324
+ return false;
325
+ })
326
+
327
+ $("#chart-kill-btn").click(function () {
328
+ $(".seat-selected").each(function() {
329
+ $(this).removeClass()
330
+ $(this).clearHolds()
331
+ $(this).addClass("seat")
332
+ $(this).addClass("killed")
333
+ $(this).html("")
334
+ })
335
+ hideSeatModal()
336
+ fireUpdate();
337
+ })
338
+
339
+ $("#chart-delete-rows-btn").click(function () {
340
+ $(".seat-selected").each(function() {
341
+ $(this).parent().remove();
342
+ })
343
+
344
+ var rowCount = $(".seat-chart-layout .seat-row").length
345
+ if(rowCount == 0) {
346
+ $(".column-labels .col").each(function() {
347
+ $(this).remove()
348
+ })
349
+ }
350
+
351
+ labelColumns()
352
+ labelRows()
353
+ hideSeatModal()
354
+ fireUpdate();
355
+ normalizeWidth()
356
+ })
357
+
358
+ $("#chart-delete-columns-btn").click(function () {
359
+ $(".seat-selected").each(function() {
360
+ var colIndex = $(this).attr('data-col-index')
361
+ $("div[data-col-index='"+colIndex+"']").remove()
362
+ })
363
+ labelColumns()
364
+ hideSeatModal()
365
+ fireUpdate();
366
+ normalizeWidth()
367
+ })
368
+ })
369
+
370
+ function enableHoldPopovers() {
371
+ $(".seat-chart-creator .hold").popover({delay: { show: 500, hide: 2000 }});
372
+ }
373
+
374
+ function showSellSeat(seatId, seatLabel) {
375
+ $("#sell-seat-form #seat_id").val(seatId)
376
+ $("#sellSeat #seat-label").html(seatLabel)
377
+ $("#sellSeat").modal("show")
378
+ }
379
+
380
+ function disableHoldPopovers() {
381
+ }
382
+
383
+ function makeSeatsSelectable() {
384
+ $(".seat-selectable").click(function() {
385
+ $(this).toggleClass("seat-selected")
386
+ })
387
+ }
388
+
389
+ function addColumn() {
390
+ var rowCount = $(".seat-chart-layout .seat-row").length
391
+ var columnCount = $($(".seat-chart-layout .seat-row")[0]).find('.seat').length
392
+
393
+ if(columnCount == 0) {
394
+ addRow()
395
+ return;
396
+ } else if(columnCount <= 20) {
397
+ var colHeader = $(document.createElement('div')).addClass('col')
398
+ colHeader.attr("data-col-index", columnCount)
399
+ $(".seat-chart-layout .column-labels .clear").before(colHeader)
400
+
401
+ var seat = $(document.createElement('div')).addClass('seat').addClass('empty').addClass('available');
402
+ seat.attr("data-col-index", columnCount)
403
+ $(".seat-chart-layout .seat-row .clear").before(seat)
404
+ } else if (columnCount > 20) {
405
+ $(".add-col-button").attr('disabled',true);
406
+ $("#colLimitReached").modal('show')
407
+ }
408
+
409
+ labelRows()
410
+ labelColumns();
411
+
412
+ fireUpdate();
413
+ normalizeWidth();
414
+ }
415
+
416
+ function addRow() {
417
+ var rowCount = $(".seat-chart-layout .seat-row").length
418
+ var columnCount = $($(".seat-chart-layout .seat-row")[0]).find('.seat').length
419
+
420
+ if (rowCount == 0) {
421
+
422
+ var colHeader = $(document.createElement('div')).addClass('col')
423
+ colHeader.attr("data-col-index", columnCount)
424
+ $(".seat-chart-layout .column-labels .clear").before(colHeader)
425
+
426
+ var seatRow = $(document.createElement('div')).addClass('seat-row');
427
+ var rowLabel = $(document.createElement('div')).addClass('row-label');
428
+ var seat = $(document.createElement('div')).addClass('seat').addClass('empty').addClass('available');
429
+ var clear = $(document.createElement('div')).addClass('clear');
430
+ $(".seat-chart-layout").append(seatRow);
431
+ seatRow.append(rowLabel)
432
+ seatRow.append(seat)
433
+ seatRow.append(clear)
434
+ } else if (rowCount <= 20) {
435
+ var seatRow = $(document.createElement('div')).addClass('seat-row');
436
+ var rowLabel = $(document.createElement('div')).addClass('row-label');
437
+ var clear = $(document.createElement('div')).addClass('clear');
438
+ $(".seat-chart-layout").append(seatRow);
439
+ seatRow.append(rowLabel)
440
+
441
+ for(i=0; i<columnCount; i++) {
442
+ var seat = $(document.createElement('div')).addClass('seat').addClass('available').addClass('empty');
443
+ seatRow.append(seat)
444
+ }
445
+
446
+ seatRow.append(clear)
447
+ }
448
+
449
+ if(rowCount > 15) {
450
+ $(".add-row-button").attr('disabled',true);
451
+ $("#rowLimitReached").modal('show')
452
+ }
453
+
454
+ labelRows()
455
+ labelColumns();
456
+ fireUpdate();
457
+ normalizeWidth()
458
+ }
459
+
460
+ function showLoading() {
461
+ var over = '<div id="chart-overlay">' +
462
+ '<img id="chart-loading" src="/assets/loading-white.gif">' +
463
+ '</div>';
464
+ $(over).appendTo('#big-seat-chart-container');
465
+ }
466
+
467
+ function showFail() {
468
+ $("#chart-loading").remove()
469
+ var failDiv = $(document.createElement('div')).attr("id","chart-error")
470
+ failDiv.html("We're sorry, but we could not update your chart. Please reload this page and try again.")
471
+ $("#chart-overlay").append(failDiv)
472
+ }
473
+
474
+ function hideLoading() {
475
+ $("#chart-overlay").remove()
476
+ }
477
+
478
+ function fireUpdate() {
479
+ var chartId = $(".seat-chart-layout").attr('data-chart-id')
480
+ var chart = new Object();
481
+ chart.seatRows = [];
482
+ showLoading();
483
+
484
+ $(".seat-chart-creator .seat-row").each(function(index, rowEl) {
485
+ var seatRow = new Object();
486
+ seatRow.rowLabel = $(this).find(".row-label").html()
487
+ seatRow.rowIndex = index
488
+ seatRow.seats = []
489
+
490
+ $(this).find(".seat").each (function (index, seatEl) {
491
+ seatEl = $(seatEl)
492
+ var seat = new Object();
493
+ seat.available = true
494
+ seat.rowIndex = seatRow.rowIndex
495
+ seat.colIndex = index
496
+ seat.label = seatRow.rowLabel + "" + (index+1)
497
+
498
+ seat.id = seatEl.attr("data-seat-id")
499
+ seat.houseHold = seatEl.hasClass("house-hold")
500
+ seat.developmentHold = seatEl.hasClass("development-hold")
501
+ seat.techHold = seatEl.hasClass("tech-hold")
502
+ seat.contractualHold = seatEl.hasClass("contractual-hold")
503
+ seat.personHold = seatEl.hasClass("person-hold")
504
+ seat.pressHold = seatEl.hasClass("press-hold")
505
+
506
+ seat.killed = seatEl.hasClass("killed")
507
+ seat.aisle = seatEl.hasClass("aisle")
508
+ seat.wheelchair = seatEl.hasClass("wheelchair")
509
+ seat.wheelchairCompanion = seatEl.hasClass("wheelchair-companion")
510
+ seat.available = seatEl.hasClass("available")
511
+ seat.holdNote = seatEl.attr("data-hold-note")
512
+ seat.holdPersonId = seatEl.attr("data-hold-person-id")
513
+
514
+ seat.seatNote = seatEl.attr("data-seat-note")
515
+ seat.ticketTypeIds = seatEl.getTicketTypeIds();
516
+
517
+ seatRow.seats[index] = seat;
518
+
519
+ })
520
+
521
+ chart.seatRows[index] = seatRow
522
+ })
523
+
524
+ $.post( '/assigned_charts/' + chartId, {_method:'PUT', chart: JSON.stringify(chart)} )
525
+ .done(function(data) {
526
+ $("#chart").html(data)
527
+ makeSeatsSelectable();
528
+ hideLoading();
529
+ })
530
+ .fail(function() {
531
+ showFail();
532
+ })
533
+ }
534
+
535
+ //
536
+ // WIP auto chart updating
537
+ //
538
+ // function updateChart() {
539
+ // var selectedSeatIds = []
540
+ // $.each($(".seat.seat-selected"), function () { selectedSeatIds.push($(this).attr("id")) })
541
+
542
+ // var chartId = $(".seat-chart-layout").attr('data-chart-id')
543
+
544
+ // $.get('/assigned_charts/' + chartId)
545
+ // .done(function(data) {
546
+ // $("#chart").html(data)
547
+ // makeSeatsSelectable();
548
+
549
+ // var arrayLength = selectedSeatIds.length;
550
+ // for (var i = 0; i < arrayLength; i++) {
551
+ // $("#" + selectedSeatIds[i]).addClass("seat-selected")
552
+ // }
553
+ // })
554
+ // }
555
+ // setInterval(updateChart, 60000);
556
+
557
+ function updateSelectionStatus(numSelected) {
558
+ var seatText = "seats"
559
+ if (numSelected == 1) {
560
+ seatText = "seat"
561
+ }
562
+ console.log(numSelected + ' ' + seatText + ' selected')
563
+ //$("#selected-output").html(numSelected + ' ' + seatText + ' selected')
564
+ }
565
+
566
+ function scaleDown() {
567
+ $(".seat-chart-layout .seat").addClass('seat-mini')
568
+ $(".seat-chart-layout .col").addClass('col-mini')
569
+ }
570
+
571
+ function scaleUp() {
572
+ $(".seat-chart-layout .seat").removeClass('seat-mini')
573
+ $(".seat-chart-layout .col").removeClass('col-mini')
574
+ }
575
+
576
+ function normalizeWidth() {
577
+ var columnCount = $($(".seat-chart-layout .seat-row")[0]).find('.seat').length
578
+ var full = columnCount
579
+ var width = 0
580
+ if(columnCount > 15) {
581
+ width = columnCount * 30
582
+ scaleDown()
583
+ } else {
584
+ width = (columnCount * 37) + 30
585
+ scaleUp()
586
+ }
587
+ $(".seat-chart-layout").width(width);
588
+ }
589
+
590
+ function hideSeatModal(numSelected) {
591
+ $("#modifyMultipleSeats").modal("hide")
592
+ }
593
+
594
+ function labelRows() {
595
+ $(".seat-chart-layout .row-label").each(function(index, el) {
596
+ $(this).html(alphabet[index])
597
+ })
598
+ }
599
+
600
+ function labelColumns() {
601
+ $(".seat-chart-layout .column-labels .col").each(function(index, el) {
602
+ $(this).html(index+1)
603
+ })
604
+ }
605
+
606
+ var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");