From c0dbf793babfde3abfefe07435c3eabb54649669 Mon Sep 17 00:00:00 2001 From: Wesley Cho Date: Sat, 3 Oct 2015 09:32:10 -0700 Subject: [PATCH] fix(buttons): re-expose ButtonsController - Re-expose `ButtonsController` with deprecation message Closes #4526 --- src/buttons/buttons.js | 12 ++++++++++-- src/buttons/test/buttons.spec.js | 11 +++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/buttons/buttons.js b/src/buttons/buttons.js index e895e0d305..9477e32317 100644 --- a/src/buttons/buttons.js +++ b/src/buttons/buttons.js @@ -104,10 +104,18 @@ angular.module('ui.bootstrap.buttons') .value('$buttonsSuppressWarning', false) + .controller('ButtonsController', ['$controller', '$log', '$buttonsSuppressWarning', function($controller, $log, $buttonsSuppressWarning) { + if (!$buttonsSuppressWarning) { + $log.warn('ButtonsController is now deprecated. Use UibButtonsController instead.'); + } + + angular.extend(this, $controller('UibButtonsController')); + }]) + .directive('btnRadio', ['$log', '$buttonsSuppressWarning', function($log, $buttonsSuppressWarning) { return { require: ['btnRadio', 'ngModel'], - controller: 'UibButtonsController', + controller: 'ButtonsController', controllerAs: 'buttons', link: function(scope, element, attrs, ctrls) { if (!$buttonsSuppressWarning) { @@ -145,7 +153,7 @@ angular.module('ui.bootstrap.buttons') .directive('btnCheckbox', ['$document', '$log', '$buttonsSuppressWarning', function($document, $log, $buttonsSuppressWarning) { return { require: ['btnCheckbox', 'ngModel'], - controller: 'UibButtonsController', + controller: 'ButtonsController', controllerAs: 'button', link: function(scope, element, attrs, ctrls) { if (!$buttonsSuppressWarning) { diff --git a/src/buttons/test/buttons.spec.js b/src/buttons/test/buttons.spec.js index ff041957be..1634e08687 100644 --- a/src/buttons/test/buttons.spec.js +++ b/src/buttons/test/buttons.spec.js @@ -371,9 +371,12 @@ describe('buttons deprecation', function() { element = $compile('')($rootScope); $rootScope.$digest(); - expect($log.warn.calls.count()).toBe(3); - expect($log.warn.calls.argsFor(0)).toEqual(['btn-checkbox is now deprecated. Use uib-btn-checkbox instead.']); - expect($log.warn.calls.argsFor(1)).toEqual(['btn-radio is now deprecated. Use uib-btn-radio instead.']); - expect($log.warn.calls.argsFor(2)).toEqual(['btn-radio is now deprecated. Use uib-btn-radio instead.']); + expect($log.warn.calls.count()).toBe(6); + expect($log.warn.calls.argsFor(0)).toEqual(['ButtonsController is now deprecated. Use UibButtonsController instead.']); + expect($log.warn.calls.argsFor(1)).toEqual(['btn-checkbox is now deprecated. Use uib-btn-checkbox instead.']); + expect($log.warn.calls.argsFor(2)).toEqual(['ButtonsController is now deprecated. Use UibButtonsController instead.']); + expect($log.warn.calls.argsFor(3)).toEqual(['btn-radio is now deprecated. Use uib-btn-radio instead.']); + expect($log.warn.calls.argsFor(4)).toEqual(['ButtonsController is now deprecated. Use UibButtonsController instead.']); + expect($log.warn.calls.argsFor(5)).toEqual(['btn-radio is now deprecated. Use uib-btn-radio instead.']); })); });