Wallet/src/js/controllers/feedback/send.js

98 lines
3.9 KiB
JavaScript
Raw Normal View History

2016-11-01 14:21:35 -03:00
'use strict';
2016-12-22 14:45:00 -03:00
angular.module('copayApp.controllers').controller('sendController', function($scope, $state, $log, $timeout, $stateParams, $ionicNavBarDelegate, $ionicHistory, $ionicConfig, $window, gettextCatalog, popupService, configService, lodash, feedbackService, ongoingProcess, platformInfo) {
2016-11-01 14:21:35 -03:00
$scope.sendFeedback = function(feedback, goHome) {
2016-11-07 17:31:13 -03:00
var config = configService.getSync();
2016-11-07 17:31:13 -03:00
var dataSrc = {
"Email": lodash.values(config.emailFor)[0] || ' ',
"Feedback": goHome ? ' ' : feedback,
"Score": $stateParams.score || ' ',
"AppVersion": $window.version,
"Platform": ionic.Platform.platform(),
"DeviceVersion": ionic.Platform.version()
2016-11-07 17:31:13 -03:00
};
if (!goHome) ongoingProcess.set('sendingFeedback', true);
feedbackService.send(dataSrc, function(err) {
if (goHome) return;
ongoingProcess.set('sendingFeedback', false);
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Feedback could not be submitted. Please try again later.'));
return;
}
2016-11-15 17:38:48 -03:00
if (!$stateParams.score) {
popupService.showAlert(gettextCatalog.getString('Thank you!'), gettextCatalog.getString('A member of the team will review your feedback as soon as possible.'), function() {
$scope.feedback.value = '';
$ionicHistory.nextViewOptions({
disableAnimate: false,
historyRoot: true
});
$ionicHistory.goBack();
}, gettextCatalog.getString('Finish'));
2016-11-15 17:38:48 -03:00
return;
}
2016-11-16 11:16:20 -03:00
$state.go('tabs.rate.complete', {
score: $stateParams.score
});
2016-11-01 14:21:35 -03:00
});
if (goHome) $state.go('tabs.home');
2016-11-01 14:21:35 -03:00
};
$scope.$on("$ionicView.beforeLeave", function(event, data) {
$ionicConfig.views.swipeBackEnabled(true);
});
$scope.$on("$ionicView.enter", function(event, data) {
if ($scope.score)
$ionicConfig.views.swipeBackEnabled(false);
});
2016-11-15 17:38:48 -03:00
$scope.$on("$ionicView.beforeEnter", function(event, data) {
2016-12-22 14:45:00 -03:00
$scope.isCordova = platformInfo.isCordova;
2016-11-16 11:16:20 -03:00
$scope.score = (data.stateParams && data.stateParams.score) ? parseInt(data.stateParams.score) : null;
2016-11-15 17:38:48 -03:00
$scope.feedback = {};
switch ($scope.score) {
case 1:
2016-12-02 14:36:14 -03:00
$scope.reaction = "Ouch!";
2016-11-15 17:38:48 -03:00
$scope.comment = gettextCatalog.getString("There's obviously something we're doing wrong.") + ' ' + gettextCatalog.getString("How could we improve your experience?");
break;
case 2:
$scope.reaction = gettextCatalog.getString("Oh no!");
$scope.comment = gettextCatalog.getString("There's obviously something we're doing wrong.") + ' ' + gettextCatalog.getString("How could we improve your experience?");
break;
case 3:
2016-12-02 14:36:14 -03:00
$scope.reaction = "Hmm...";
2016-11-15 17:38:48 -03:00
$scope.comment = gettextCatalog.getString("We'd love to do better.") + ' ' + gettextCatalog.getString("How could we improve your experience?");
break;
case 4:
$scope.reaction = gettextCatalog.getString("Thanks!");
$scope.comment = gettextCatalog.getString("That's exciting to hear. We'd love to earn that fifth star from you how could we improve your experience?");
break;
case 5:
$scope.reaction = gettextCatalog.getString("Thank you!");
2016-11-15 16:35:30 -05:00
$scope.comment = gettextCatalog.getString("We're always looking for ways to improve BitPay.") + ' ' + gettextCatalog.getString("Is there anything we could do better?");
2016-11-15 17:38:48 -03:00
break;
default:
$scope.justFeedback = true;
2016-11-15 16:35:30 -05:00
$scope.comment = gettextCatalog.getString("We're always looking for ways to improve BitPay. How could we improve your experience?");
2016-11-15 17:38:48 -03:00
break;
}
});
$scope.$on("$ionicView.afterEnter", function() {
$scope.showForm = true;
});
2016-11-17 11:06:22 -03:00
$scope.goBack = function() {
$ionicHistory.nextViewOptions({
disableAnimate: false,
historyRoot: true
});
$ionicHistory.goBack();
};
2016-11-01 14:21:35 -03:00
});