define(['dashboard/dashboard'], function (dashboard) { dashboard.controller('DashboardSavedQuotes', ['$scope', '$state', '$http', '$mdDialog', 'Helpers', function ($scope, $state, $http, $mdDialog, Helpers) { $scope.getResumeAmendmentUrl = function () { return '/quote/?quoteType=amendment&amendmentType=Resume&referenceNumber=' + $scope.Dashboard.Policy.PolicyNumber; }; $scope.RemoveSavedQuote = function (ev, quote) { var confirm = RemoveDialog(ev); $mdDialog.show(confirm).then(function () { hideQuote(quote); }); }; $scope.GetSavedQuotes = function () { $scope.DashboardPost('/DashboardSavedQuotes/GetSavedQuotes') .then(function (data) { $scope.Dashboard.Policy.SavedQuotes = data.data; }); }; $scope.GetSavedQuotes(); var RemoveDialog = function (ev, message) { return $mdDialog.confirm() .title('Are you sure?') .content(message || 'If you remove this item, you will not be able to undo it.') .ok('Remove') .cancel('Cancel') .disableParentScroll(false) .targetEvent(ev); }; var removeSavedQuote = function (quote) { var index = $scope.Dashboard.Policy.SavedQuotes.indexOf(quote); if (index > -1) $scope.Dashboard.Policy.SavedQuotes.splice(index, 1); } var hideQuote = function (quote) { $scope.DashboardPost('DashboardSavedQuotes/HideQuote?QuoteID=' + quote.ReferenceNumberDisplay).then(function (data) { removeSavedQuote(quote); }, function (data) { }); } }]); });