diff --git wordcamp.org/public_html/wp-content/plugins/camptix-attendance/addons/assets/attendance-ui.js wordcamp.org/public_html/wp-content/plugins/camptix-attendance/addons/assets/attendance-ui.js
index 150c37a3b..8a86f1e0e 100644
|
|
jQuery(document).ready(function($){ |
14 | 14 | camptix.models.Attendee = Backbone.Model.extend({ |
15 | 15 | defaults: function() { |
16 | 16 | return { |
| 17 | id: null, |
17 | 18 | status: false, |
| 19 | sort: 'firstName', |
18 | 20 | avatar: '', |
19 | | name: '', |
| 21 | firstName: '', |
| 22 | lastName: '' |
20 | 23 | } |
21 | 24 | }, |
22 | 25 | |
… |
… |
jQuery(document).ready(function($){ |
162 | 165 | * Render the attendee list item. |
163 | 166 | */ |
164 | 167 | render: function() { |
165 | | this.$el.html( this.template( this.model.toJSON() ) ); |
| 168 | var attendeeData = _.extend( this.model.toJSON(), { sort: this.controller.filterSettings.sort } ); |
| 169 | this.$el.html( this.template( attendeeData ) ); |
166 | 170 | return this; |
167 | 171 | }, |
168 | 172 | |
… |
… |
jQuery(document).ready(function($){ |
317 | 321 | |
318 | 322 | events: { |
319 | 323 | 'fastClick .close': 'close', |
| 324 | 'fastClick .filter-sort li': 'toggleSort', |
320 | 325 | 'fastClick .filter-attendance li': 'toggleAttendance', |
321 | 326 | 'fastClick .filter-tickets li': 'toggleTickets' |
322 | 327 | }, |
… |
… |
jQuery(document).ready(function($){ |
368 | 373 | this.render(); |
369 | 374 | this.controller.trigger( 'filter', this.filterSettings ); |
370 | 375 | }, |
| 376 | |
| 377 | /** |
| 378 | * Toggle sort order for tickets list |
| 379 | */ |
| 380 | toggleSort: function( event ) { |
| 381 | var sortOrder = $( event.target ).data( 'sort' ); |
| 382 | this.filterSettings.sort = sortOrder; |
| 383 | this.render(); |
| 384 | |
| 385 | this.controller.trigger( 'filter', this.filterSettings ); |
| 386 | } |
371 | 387 | }); |
372 | 388 | |
373 | 389 | /** |
… |
… |
jQuery(document).ready(function($){ |
382 | 398 | events: { |
383 | 399 | 'fastClick .dashicons-menu': 'menu', |
384 | 400 | 'fastClick .submenu .search': 'searchView', |
| 401 | 'fastClick .submenu .sort': 'sortView', |
385 | 402 | 'fastClick .submenu .refresh': 'refresh', |
386 | 403 | 'fastClick .submenu .filter': 'filterView' |
387 | 404 | }, |
… |
… |
jQuery(document).ready(function($){ |
398 | 415 | this.filterSettings = { |
399 | 416 | 'attendance': 'none', |
400 | 417 | 'tickets': _camptixAttendanceTickets, |
401 | | 'search': '' |
| 418 | 'search': '', |
| 419 | 'sort': 'firstName' |
402 | 420 | }; |
403 | 421 | |
404 | 422 | this.render(); |
… |
… |
jQuery(document).ready(function($){ |
434 | 452 | options = {}; |
435 | 453 | |
436 | 454 | // Dispose of the current collection and cache it for later use. |
437 | | if ( 'undefined' != typeof this.collection ) { |
| 455 | if ( 'undefined' !== typeof this.collection ) { |
438 | 456 | this.collection.off( null, null, this ); |
439 | 457 | this.cache.push( this.collection ); |
440 | 458 | } |
diff --git wordcamp.org/public_html/wp-content/plugins/camptix-attendance/addons/attendance-ui.php wordcamp.org/public_html/wp-content/plugins/camptix-attendance/addons/attendance-ui.php
index 15b1ea915..9dc53fb95 100644
|
|
$camptix_options = $camptix->get_options(); |
19 | 19 | _camptixAttendanceTickets = [ <?php echo esc_js( implode( ', ', array_map( 'absint', wp_list_pluck( $camptix_tickets, 'ID' ) ) ) ); ?> ]; |
20 | 20 | </script> |
21 | 21 | |
22 | | <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" /> |
| 22 | <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" /> |
23 | 23 | <meta name="referrer" content="never" /> |
24 | 24 | </head> |
25 | 25 | <body> |
26 | 26 | <script id="tmpl-attendee" type="text/template"> |
27 | 27 | <div class="spinner-container"><span class="spinner"></span></div> |
28 | 28 | <a href="#" class="status toggle <# if ( data.status ) { #> yes <# } #>"><div class="dashicons dashicons-admin-users"></div></a> |
29 | | <span class="name"> |
30 | | {{ data.name }} |
31 | | </span> |
| 29 | |
| 30 | <span class="name"> |
| 31 | <# if ( 'lastName' == data.sort ) { #> |
| 32 | {{ data.lastName }}, {{ data.firstName }} |
| 33 | <# } else { #> |
| 34 | {{ data.firstName }} {{ data.lastName }} |
| 35 | <# } #> |
| 36 | </span> |
32 | 37 | </script> |
33 | 38 | |
34 | 39 | <script id="tmpl-attendee-toggle" type="text/template"> |
35 | 40 | <img src="{{ data.avatar }}" /> |
36 | | <p>Did <strong>{{ data.name }}</strong> attend <?php echo esc_html( $camptix_options['event_name'] ); ?>?</p> |
| 41 | <p>Did <strong>{{ data.firstName }} {{ data.lastName }}</strong> attend <?php echo esc_html( $camptix_options['event_name'] ); ?>?</p> |
37 | 42 | |
38 | 43 | <div class="yes-no-container"> |
39 | 44 | <a href="#" class="yes">Yes</a> |
… |
… |
$camptix_options = $camptix->get_options(); |
51 | 56 | <a href="#" class="dashicons dashicons-menu"></a> |
52 | 57 | <div class="submenu"> |
53 | 58 | <a href="#" class="search">Search</a> |
54 | | <a href="#" class="filter">Filter</a> |
| 59 | <a href="#" class="filter">Sort & Filter</a> |
55 | 60 | <a href="#" class="refresh">Refresh</a> |
56 | 61 | </div> |
57 | 62 | </div> |
… |
… |
$camptix_options = $camptix->get_options(); |
78 | 83 | <script id="tmpl-attendee-filter" type="text/template"> |
79 | 84 | <a href="#" class="close dashicons dashicons-no"></a> |
80 | 85 | <div class="wrapper"> |
81 | | <h1>Filters</h1> |
| 86 | <h1>Sort & Filter</h1> |
| 87 | |
| 88 | <h1 class="section-title">Sort Attendees By</h1> |
| 89 | <ul class="filter-sort section-controls"> |
| 90 | <li data-sort="firstName" <# if ( data.sort == 'firstName' ) { #> class="selected" <# } #> >First Name</li> |
| 91 | <li data-sort="lastName" <# if ( data.sort == 'lastName' ) { #> class="selected" <# } #> >Last Name</li> |
| 92 | <li data-sort="orderDate" <# if ( data.sort == 'orderDate' ) { #> class="selected" <# } #> >Order Date</li> |
| 93 | </ul> |
82 | 94 | |
83 | 95 | <h1 class="section-title">Attendance</h1> |
84 | 96 | <ul class="filter-attendance section-controls"> |
diff --git wordcamp.org/public_html/wp-content/plugins/camptix-attendance/addons/attendance.php wordcamp.org/public_html/wp-content/plugins/camptix-attendance/addons/attendance.php
index 9707106be..90bfac115 100644
|
|
class CampTix_Attendance extends CampTix_Addon { |
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
73 | | * Synchronize an attendee model. |
| 73 | * Synchronize a single attendee model. |
74 | 74 | * |
75 | 75 | * Sets are removes the attended flag for a given camptix_id. |
76 | 76 | */ |
… |
… |
class CampTix_Attendance extends CampTix_Addon { |
113 | 113 | $ticket_ids = wp_list_pluck( $this->get_tickets(), 'ID' ); |
114 | 114 | |
115 | 115 | $query_args = array( |
116 | | 'post_type' => 'tix_attendee', |
117 | | 'post_status' => 'publish', |
118 | | 'orderby' => 'title', |
119 | | 'order' => 'ASC', |
120 | | 'paged' => $paged, |
| 116 | 'post_type' => 'tix_attendee', |
| 117 | 'post_status' => 'publish', |
| 118 | 'orderby' => 'title', |
| 119 | 'order' => 'ASC', |
| 120 | 'paged' => $paged, |
121 | 121 | 'posts_per_page' => 50, |
122 | | 'meta_query' => '', |
| 122 | 'meta_query' => '', |
123 | 123 | ); |
124 | 124 | |
| 125 | /** |
| 126 | * Sort Attendee Posts |
| 127 | */ |
| 128 | if ( ! empty( $_REQUEST['camptix_filters']['sort'] ) ) { |
| 129 | switch ( $_REQUEST['camptix_filters']['sort'] ) { |
| 130 | case 'lastName': |
| 131 | $query_args['orderby'] = 'meta_value'; |
| 132 | $query_args['meta_key'] = 'tix_last_name'; |
| 133 | break; |
| 134 | case 'orderDate': |
| 135 | $query_args['orderby'] = 'date'; |
| 136 | $query_args['order'] = 'DESC'; |
| 137 | break; |
| 138 | case 'firstName': |
| 139 | default: |
| 140 | // each $attendee->post_title is already First Lastname |
| 141 | break; |
| 142 | } |
| 143 | |
| 144 | unset( $_REQUEST['camptix_filters']['sort'] ); |
| 145 | } |
| 146 | |
125 | 147 | $filters = array(); |
126 | 148 | if ( ! empty( $_REQUEST['camptix_filters'] ) ) |
127 | 149 | $filters = (array) $_REQUEST['camptix_filters']; |
… |
… |
class CampTix_Attendance extends CampTix_Addon { |
170 | 192 | * with an AJAX method. |
171 | 193 | */ |
172 | 194 | public function _make_object( $attendee ) { |
173 | | $attendee = get_post( $attendee ); |
| 195 | $attendee = get_post( $attendee ); |
174 | 196 | |
175 | 197 | $first_name = get_post_meta( $attendee->ID, 'tix_first_name', true ); |
176 | | $last_name = get_post_meta( $attendee->ID, 'tix_last_name', true ); |
| 198 | $last_name = get_post_meta( $attendee->ID, 'tix_last_name', true ); |
177 | 199 | $avatar_url = sprintf( 'https://secure.gravatar.com/avatar/%s?s=160', md5( get_post_meta( $attendee->ID, 'tix_email', true ) ) ); |
178 | 200 | $avatar_url = add_query_arg( 'd', 'https://secure.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=160', $avatar_url ); |
179 | 201 | |
… |
… |
class CampTix_Attendance extends CampTix_Addon { |
181 | 203 | |
182 | 204 | return array( |
183 | 205 | 'id' => $attendee->ID, |
184 | | 'name' => sprintf( '%s %s', $first_name, $last_name ), |
| 206 | 'firstName' => $first_name, |
| 207 | 'lastName' => $last_name, |
185 | 208 | 'avatar' => esc_url_raw( $avatar_url ), |
186 | 209 | 'status' => $status, |
187 | 210 | ); |
… |
… |
class CampTix_Attendance extends CampTix_Addon { |
249 | 272 | */ |
250 | 273 | public function setup_sections( $sections ) { |
251 | 274 | $sections['attendance-ui'] = esc_html__( 'Attendance UI', 'wordcamporg' ); |
| 275 | |
252 | 276 | return $sections; |
253 | 277 | } |
254 | 278 | |
… |
… |
class CampTix_Attendance extends CampTix_Addon { |
313 | 337 | } |
314 | 338 | |
315 | 339 | /** |
316 | | * Get CampTix Tickets |
| 340 | * Get CampTix Tickets (not to be confused with Attendees) |
317 | 341 | * |
318 | 342 | * Returns an array of published tickets registered with CampTix. |
319 | 343 | */ |