CRM-15578 - crmMailing2 - When ID of new mailing is established, update navbar.
authorTim Otten <totten@civicrm.org>
Mon, 24 Nov 2014 02:33:26 +0000 (18:33 -0800)
committerTim Otten <totten@civicrm.org>
Mon, 24 Nov 2014 02:33:26 +0000 (18:33 -0800)
js/angular-crmMailing2.js

index 1495fc78ea94f4d8220d38505930f5faf48d04f0..a9dd27f52a71437c6d07eece660b97a5f7c4fae9 100644 (file)
@@ -55,7 +55,7 @@
     });
   });
 
-  crmMailing2.controller('EditMailingCtrl', function EditMailingCtrl($scope, selectedMail) {
+  crmMailing2.controller('EditMailingCtrl', function EditMailingCtrl($scope, selectedMail, $location) {
     $scope.mailing = selectedMail;
     $scope.crmMailingConst = CRM.crmMailing;
 
         scheduled: 'false'
       });
     };
+
+    // Transition URL "/mailing2/new" => "/mailing2/123" as soon as ID is known
+    $scope.$watch('mailing.id', function(newValue, oldValue) {
+      if (newValue && newValue != oldValue) {
+        var parts = $location.path().split('/'); // e.g. "/mailing2/new" or "/mailing2/123/wizard"
+        parts[2] = newValue;
+        $location.path(parts.join('/'));
+        $location.replace();
+        // FIXME: Angular unnecessarily refreshes UI
+      }
+    });
   });
 
   // Controller for the edit-recipients fields (