Event Locations now appear to be working.
authorChuck Scott <cscott@gaslightmedia.com>
Wed, 16 Mar 2016 14:23:45 +0000 (10:23 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Wed, 16 Mar 2016 14:23:45 +0000 (10:23 -0400)
classes/data/dataLocations.php
models/admin/events/list.php
views/admin/events/edit.html
views/admin/events/editLocation.html
views/admin/events/editSchedule.html

index 0ae6985..cd7b9e6 100644 (file)
@@ -240,18 +240,6 @@ class GlmDataEventsLocations extends GlmDataAbstract
                 'use' => 'a'
             ),
 
-            // Contact Reference - Points to Contacts add-on contacts table
-            'region' => array (
-                'field' => 'region',
-                'type' => 'pointer',
-                    'p_table' => GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . 'regions',
-                    'p_field' => 'name',
-                    'p_orderby' => 'name',
-                    'p_blank' => true,
-                //  'force_list' => true,
-                'use' => 'a'
-            ),
-
             // Contact Reference Placeholder if no Contacts Add-On (see below)
             'contact_addon_id' => array(
                 'field' => 'contact_addon_id',
index f1a77c3..92c74e8 100644 (file)
@@ -240,6 +240,18 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
                     }
                 }
 
+                // Look for location deletes
+                if (isset($_REQUEST['deleteLocation']) && count($_REQUEST['deleteLocation'] > 0)) {
+                    foreach ($_REQUEST['deleteLocation'] as $d) {
+
+                        // If this was not a new entry that was deleted (in which case it was never added)
+                        if ($d[0] != 'n') {
+                            $Locations->deleteEntry($d, true);
+                        }
+
+                    }
+                }
+
                 // Look for location data
                 if (isset($_REQUEST['locID'])) {
 
index 95ce313..a3bcab4 100644 (file)
@@ -98,6 +98,7 @@
 
             var fullCalendarLoaded = false;
             var recurrencesInited = false;
+            var locationsInited = false;
 
             /*
              * Edit area tabs
                     recurrencesInited = true;
                 }
 
+                if (table == 'glm-table-location' && !locationsInited) {
+                    initLocations();
+                    locationsInited = true;
+                }
+
                 if (table == 'glm-table-calendar' && !fullCalendarLoaded) {
                     $('#eventCalendar').fullCalendar({
         {if $haveTimes}
                     $("#newCityDialog").dialog("open");
                 });
 
+                // Delete a location
+                $('.delete-location').on( 'click', function() {
+                    locID = $(this).attr('data-id');
+                    $('#location_' + locID).remove();
+                    $('#placeLocationDeletesHere').append('<input type="hidden" name="deleteLocation[' + locID + ']" value="' + locID + '">');
+                    numbLocations--;
+                })
+
                 initMap(locID);
 
+            }
+
+            /*
+             * This is used to initialize all of the locations when the location tab is first clicked.
+             */
+            function initLocations() {
+
+                $('.location-form').each( function() {
+                    locID = $(this).attr('data-id');
+                    initLocation(locID);
+                })
 
             }
 
                     timepicker: false
                 });
 
-
                 // Delete a recurrence
-                $('.delete-new-recurrence').on( 'click', function() {
+                $('.delete-recurrence').on( 'click', function() {
                     recurID = $(this).attr('data-id');
-                    $('.recurrence_' + recurID).remove();
+                    $('#recurrence_' + recurID).remove();
                     $('#placeRecurDeletesHere').append('<input type="hidden" name="deleteRecur[' + recurID + ']" value="' + recurID + '">');
                     numbRecurrences--;
                 })
                 });
 
             }
-            
+
             function glmGeocode(locID) {
 
                 // Get all address parts
                     }
                 });
 
-                
+
             }
-            
+
         });
     </script>
 
index 9d18ce0..60278c9 100644 (file)
                 <!-- Location forms go here. -->
 {if $locations}
     {foreach $locations as $loc}
-                <tr><td colspan="2"><hr></td></tr>
-                <tr id="location_{$loc.id}" class="location_{$r.id} location-form">
+                <tr class="location_{$r.id}"><td colspan="2"><hr></td></tr>
+                <tr id="location_{$loc.id}" data-id="{$loc.id}" class="location_{$r.id} location-form">
                     <td>
                         <input type="hidden" name="locID[{$r.id}]" value="{$loc.id}">
-                        <input type="hidden" name="{$loc.id}_event" value="{$event.id}"> <!-- required to have event id with prefix -->
+                        <input type="hidden" name="{$loc.id}_event" value="{$event.fieldData.id}"> <!-- required to have event id with prefix -->
                         <table width="100%">
                             <tr>
                                 <th>Location Name:</th>
@@ -80,7 +80,7 @@
                             <tr>
                                 <th>ZIP / Postal Code:</th>
                                 <td>
-                                    <input type="text" name="{$loc.id}_zip" value="{$newLocation.zip}" class="glm-form-text-input-medium">
+                                    <input type="text" name="{$loc.id}_zip" value="{$loc.zip}" class="glm-form-text-input-medium">
                                 </td>
                             </tr>
                             <tr>
                             <tr>
                                 <th>Contact Name:</th>
                                 <td>
-                                    First: <input type="text" name="{$loc.ID}_contact_fname" value="{$loc.contact_fname}" class="glm-form-text-input-small">
-                                    Last:  <input type="text" name="{$loc.ID}_contact_lname" value="{$loc.contact_lname}" class="glm-form-text-input-small">
+                                    First: <input type="text" name="{$loc.id}_contact_fname" value="{$loc.contact_fname}" class="glm-form-text-input-small">
+                                    Last:  <input type="text" name="{$loc.id}_contact_lname" value="{$loc.contact_lname}" class="glm-form-text-input-small">
                                 </td>
                             </tr>
                             <tr>
                                 <th>Contact Phone:</th>
                                 <td>
-                                    <input type="text" name="{$loc.ID}_contact_phone" value="{$loc.contact_phone}" class="glm-form-text-input-medium">
+                                    <input type="text" name="{$loc.id}_contact_phone" value="{$loc.contact_phone}" class="glm-form-text-input-medium">
                                 </td>
                             </tr>
                             <tr>
                                 <th>Contact Email:</th>
                                 <td>
-                                    <input type="text" name="{$loc.ID}_contact_email" value="{$loc.contact_email}" class="glm-form-text-input-medium">
+                                    <input type="text" name="{$loc.id}_contact_email" value="{$loc.contact_email}" class="glm-form-text-input-medium">
                                 </td>
                             </tr>
 
                             <tr>
                                 <th>Location:</th>
                                 <td>
-                                    <input id="glmLat_{$loc.id}" name="lat" type="hidden" value="{$memberInfo.lat}">
-                                    <input id="glmLng_{$loc.id}" name="lon" type="hidden" value="{$memberInfo.lon}">
+                                    <input id="glmLat_{$loc.id}" name="{$loc.id}_lat" type="hidden" value="{$loc.lat}">
+                                    <input id="glmLng_{$loc.id}" name="{$loc.id}_lon" type="hidden" value="{$loc.lon}">
+                                    <span class="glm-right"><a id="deleteLocation_{$loc.id}" data-id="{$loc.id}" class="button button-primary glm-button glm-right delete-location">Delete Location</a></span>
                                     <div id="glm-estimate-location_{$loc.id}" class="button button-secondary">Map Location Using Above Address</div>
                                     <p>
-                                        <div id="locationMap_{$loc.id}" class="glm-map-edit-small">(map loads here)</div>
-                                        <span id="mapPosition_{$loc.id}">Lat {$newLocation.lat}, Lon {$newLocation.lon}</span>
+                                        <div id="locationMap_{$loc.id}" class="glm-map-edit">(map loads here)</div>
+                                        <span id="mapPosition_{$loc.id}">Lat {$loc.lat}, Lon {$loc.lon}</span>
                                     </p>
                                 </td>
                             </tr>
                 <tr>
                     <th>Location:</th>
                     <td>
-                        <input id="glmLat_{ newLocID }" name="lat" type="hidden" value="{$newLocation.fieldData.lat}">
-                        <input id="glmLng_{ newLocID }" name="lon" type="hidden" value="{$newLocation.fieldData.lon}">
+                        <input id="glmLat_{ newLocID }" name="{ newLocID }_lat" type="hidden" value="{$newLocation.fieldData.lat}">
+                        <input id="glmLng_{ newLocID }" name="{ newLocID }_lon" type="hidden" value="{$newLocation.fieldData.lon}">
+                        <span class="glm-right"><a id="deleteLocation_{ newLocID }" data-id="{ newLocID }" class="button button-primary glm-button glm-right delete-location">Delete Location</a></span>
                         <div id="glm-estimate-location_{ newLocID }" class="button button-secondary">Map Location Using Address</div>
                         <p>
                             <div id="locationMap_{ newLocID }" class="glm-map-edit">(map loads here)</div>
index 0530222..f93ee1a 100644 (file)
                 <!-- Recurrence forms go here. -->
 {if $recurrences}
     {foreach $recurrences as $r}
-                <tr><td colspan="2"><hr></td></tr>
+                <tr class="recurrence_{$r.id}"><td colspan="2"><hr></td></tr>
                 <tr id="recurrence_{$r.id}" class="recurrence_{$r.id} recurrence-form">
                     <td>
                         <input type="hidden" name="recurID[{$r.id}]" value="{$r.id}">
                         <input type="hidden" name="{$r.id}_event" value="{$event.fieldData.id}"> <!-- required to have event id with prefix -->
                         <input id="{$r.id}_recurUpdated" type="hidden" name="recurUpdated[{$r.id}]" value="0">
-                        <table width="100%">
-                            <tr><th></th><th>First occurrence for this schedule</th></tr>
+                        <table>
+                            <tr><th colspan="2">First occurrence for this schedule</th></tr>
                             <tr>
                                 <th>All Day Event:</th>
                                 <td>
@@ -46,8 +46,8 @@
                                     <input data-id="{$r.id}" type="text" name="{$r.id}_event_date" value="{$r.start_time.datetime}" class="glm-form-text-input-small glm-date-input recurrence-input" placeholder="Click to Select Date/Time">
                                 </td>
                             </tr>
-                
-                            <tr><th></th><th><p>Date range over which recurring event can take place</p></th></tr>
+                            <tr><td colspan="2">&nbsp;</td></tr>
+                            <tr><th colspan="2">Date range over which recurring event can take place</p></th></tr>
                             <tr>
                                 <th>From Date:</th>
                                 <td>
@@ -69,7 +69,7 @@
                             <tr>
                                 <th></th>
                                 <th>                                
-                                    <a id="deleteRecurrence_{$r.id}" data-id="{$r.id}" class="button button-primary glm-button glm-right delete-new-recurrence all_dates-checkbox">Delete this Event Schedule</a>
+                                    <a id="deleteRecurrence_{$r.id}" data-id="{$r.id}" class="button button-primary glm-button glm-right delete-recurrence all_dates-checkbox">Delete this Event Schedule</a>
                                     When the event recurrs
                                 </th>
                             </tr>
                         <input type="text" name="{ newRecurID }_event_date" value="{$newRecurrence.fieldData.start_date.date}" class="glm-form-text-input-small glm-date-input" placeholder="Click to Select Date/Time">
                     </td>
                 </tr>
-    
-                <tr><th></th><th><p>Date range over which recurring event can take place</p></th></tr>
+                <tr><td colspan="2">&nbsp;</td></tr>
+                <tr><th colspan=2">Date range over which recurring event can take place</th></tr>
                 <tr>
                     <th>From Date:</th>
                     <td>
                 <tr>
                     <th></th>
                     <th>
-                        <a id="deleteRecurrence_{ newRecurID }" data-id="{ newRecurID }" class="button button-primary glm-button glm-right delete-new-recurrence">Delete this Event Schedule</a>
+                        <a id="deleteRecurrence_{ newRecurID }" data-id="{ newRecurID }" class="button button-primary glm-button glm-right delete-recurrence">Delete this Event Schedule</a>
                         When the event recurrs
                     </th>
                 </tr>