From c54afefa103cd385de4df6c3b9519e35ecd6a42e Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Sun, 23 Nov 2014 18:33:26 -0800 Subject: [PATCH 1/1] CRM-15578 - crmMailing2 - When ID of new mailing is established, update navbar. --- js/angular-crmMailing2.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/js/angular-crmMailing2.js b/js/angular-crmMailing2.js index 1495fc78ea..a9dd27f52a 100644 --- a/js/angular-crmMailing2.js +++ b/js/angular-crmMailing2.js @@ -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; @@ -77,6 +77,17 @@ 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 ( -- 2.25.1