mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 23:27:26 +01:00
Add confirmation popover for Rebirth
Add confirmation popover for Fortify/Reroll Add tests for reroll and rebirth
This commit is contained in:
committed by
Blade Barringer
parent
d53ac4c66f
commit
f6f82cafc4
@@ -2,8 +2,8 @@
|
||||
|
||||
// Make user and settings available for everyone through root scope.
|
||||
habitrpg.controller('SettingsCtrl',
|
||||
['$scope', 'User', '$rootScope', '$http', 'ApiUrl', 'Guide', '$location', '$timeout', 'Content', 'Notification', 'Shared',
|
||||
function($scope, User, $rootScope, $http, ApiUrl, Guide, $location, $timeout, Content, Notification, Shared) {
|
||||
['$scope', 'User', '$rootScope', '$http', 'ApiUrl', 'Guide', '$location', '$timeout', 'Content', 'Notification', 'Shared', '$compile',
|
||||
function($scope, User, $rootScope, $http, ApiUrl, Guide, $location, $timeout, Content, Notification, Shared, $compile) {
|
||||
|
||||
// FIXME we have this re-declared everywhere, figure which is the canonical version and delete the rest
|
||||
// $scope.auth = function (id, token) {
|
||||
@@ -90,14 +90,54 @@ habitrpg.controller('SettingsCtrl',
|
||||
|
||||
$scope.availableFormats = ['MM/dd/yyyy','dd/MM/yyyy', 'yyyy/MM/dd'];
|
||||
|
||||
$scope.reroll = function(){
|
||||
User.user.ops.reroll({});
|
||||
$rootScope.$state.go('tasks');
|
||||
$scope.reroll = function(confirm){
|
||||
$scope.popoverEl.popover('destroy')
|
||||
|
||||
if (confirm) {
|
||||
User.user.ops.reroll({});
|
||||
$rootScope.$state.go('tasks');
|
||||
}
|
||||
}
|
||||
|
||||
$scope.rebirth = function(){
|
||||
User.user.ops.rebirth({});
|
||||
$rootScope.$state.go('tasks');
|
||||
$scope.clickReroll = function($event){
|
||||
$scope.popoverEl = $($event.target);
|
||||
|
||||
var html = $compile(
|
||||
'<a ng-controller="SettingsCtrl" ng-click="$close(); reroll(true)">' + window.env.t('confirm') + '</a><br/>\n<a ng-click="reroll(false)">' + window.env.t('cancel') + '</a><br/>'
|
||||
)($scope);
|
||||
|
||||
$scope.popoverEl.popover('destroy').popover({
|
||||
html: true,
|
||||
placement: 'top',
|
||||
trigger: 'manual',
|
||||
title: window.env.t('confirmFortify'),
|
||||
content: html
|
||||
}).popover('show');
|
||||
}
|
||||
|
||||
$scope.rebirth = function(confirm){
|
||||
$scope.popoverEl.popover('destroy')
|
||||
|
||||
if (confirm) {
|
||||
User.user.ops.rebirth({});
|
||||
$rootScope.$state.go('tasks');
|
||||
}
|
||||
}
|
||||
|
||||
$scope.clickRebirth = function($event){
|
||||
$scope.popoverEl = $($event.target);
|
||||
|
||||
var html = $compile(
|
||||
'<a ng-controller="SettingsCtrl" ng-click="$close(); rebirth(true)">' + window.env.t('confirm') + '</a><br/>\n<a ng-click="rebirth(false)">' + window.env.t('cancel') + '</a><br/>'
|
||||
)($scope);
|
||||
|
||||
$scope.popoverEl.popover('destroy').popover({
|
||||
html: true,
|
||||
placement: 'top',
|
||||
trigger: 'manual',
|
||||
title: window.env.t('confirmReborn'),
|
||||
content: html
|
||||
}).popover('show');
|
||||
}
|
||||
|
||||
$scope.changeUser = function(attr, updates){
|
||||
|
||||
Reference in New Issue
Block a user