diff --git a/Controller/GoogleAnalyticsAJAXController.php b/Controller/GoogleAnalyticsAJAXController.php index 736852b3..e7e36c63 100644 --- a/Controller/GoogleAnalyticsAJAXController.php +++ b/Controller/GoogleAnalyticsAJAXController.php @@ -173,6 +173,7 @@ public function saveProfileAction(Request $request) { */ public function saveConfigAction(Request $request) { // get params + $configId = $request->query->get('configId'); $accountId = $request->query->get('accountId'); $propertyId = $request->query->get('propertyId'); $profileId = $request->query->get('profileId'); @@ -180,7 +181,7 @@ public function saveConfigAction(Request $request) { // edit the config $em = $this->getDoctrine()->getManager(); - $config = $em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->findFirst(); + $config = $em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->find($configId); if ($accountId && $propertyId && $profileId) { $config->setAccountId($accountId); $config->setPropertyId($propertyId); @@ -192,7 +193,7 @@ public function saveConfigAction(Request $request) { // set the config name $configHelper = $this->container->get('kunstmaan_dashboard.helper.google.analytics.config'); - $configHelper->init($config->getId()); + $configHelper->init($configId); $profile = $configHelper->getActiveProfile(); $config->setName($profile['profileName']); $config->setDisableGoals($disableGoals); @@ -252,6 +253,7 @@ public function getConfigAction(Request $request) { * @Route("/segment/add/", name="kunstmaan_dashboard_ajax_segment_add") */ public function addSegmentAction(Request $request) { + $configId = $request->query->get('configId'); $em = $this->getDoctrine()->getManager(); // create a new segment @@ -262,8 +264,7 @@ public function addSegmentAction(Request $request) { $segment->setName($name); // add the segment to the config - $analyticsConfigRepository = $em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig'); - $config = $analyticsConfigRepository->findFirst(); + $config = $em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->find($configId); $segment->setConfig($config); $segments = $config->getSegments(); $segments[] = $segment; diff --git a/Controller/GoogleAnalyticsController.php b/Controller/GoogleAnalyticsController.php index 7bc72d85..cad92615 100755 --- a/Controller/GoogleAnalyticsController.php +++ b/Controller/GoogleAnalyticsController.php @@ -143,9 +143,10 @@ public function configAction(Request $request) $params['accounts'] = $configHelper->getAccounts(); $params['segments'] = $config->getSegments(); $params['disableGoals'] = $config->getDisableGoals(); + $params['configId'] = $config->getId(); return $this->render( - 'KunstmaanDashboardBundle:GoogleAnalytics:setup.html.twig', + 'KunstmaanDashboardBundle:GoogleAnalytics:setupcontainer.html.twig', $params ); } diff --git a/Resources/public/js/setup/setup.js b/Resources/public/js/setup/setup.js index d1ab4736..1b55e97e 100644 --- a/Resources/public/js/setup/setup.js +++ b/Resources/public/js/setup/setup.js @@ -3,6 +3,7 @@ $(function () { var accountId = $('#account_id').attr('data-id'); var propertyId = $('#property_id').attr('data-id'); var profileId = $('#profile_id').attr('data-id'); + var configId = $('#config_id').attr('data-id'); $('#submit_save').click(function() { @@ -14,7 +15,7 @@ $(function () { $.ajax({ type: 'get', url: url, - data: {'profileId' : profileId, 'propertyId' : propertyId, 'accountId' : accountId, 'disableGoals' : disableGoals}, + data: {'profileId' : profileId, 'propertyId' : propertyId, 'accountId' : accountId, 'disableGoals' : disableGoals, 'configId' : configId}, success: function (data) { // get all new segments var segments = $('#segments-new').children(); @@ -36,7 +37,7 @@ $(function () { $.ajax({ type: 'get', url: url, - data: {'query' : query, 'name' : name}, + data: {'query' : query, 'name' : name, 'configId' : configId}, success: function (data) { location.reload(); } diff --git a/Resources/views/GoogleAnalytics/setup.html.twig b/Resources/views/GoogleAnalytics/setup.html.twig index 3ab673c9..40de8364 100644 --- a/Resources/views/GoogleAnalytics/setup.html.twig +++ b/Resources/views/GoogleAnalytics/setup.html.twig @@ -1,5 +1,3 @@ -{% extends 'KunstmaanAdminBundle:Default:layout.html.twig' %} - {% block header %}{% endblock %} {% block content %} @@ -61,6 +59,7 @@

{{ 'dashboard.ga.setup.segment.info' | trans }} {{ 'dashboard.ga.setup.segment.here' | trans }}.

+