mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
Add buttons to challenge participant modal
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
describe('Challenges Controller', function() {
|
describe('Challenges Controller', function() {
|
||||||
var $rootScope, scope, user, User, ctrl, groups, notification, state;
|
var rootScope, scope, user, User, ctrl, groups, members, notification, state;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
module(function($provide) {
|
module(function($provide) {
|
||||||
@@ -15,11 +15,12 @@ describe('Challenges Controller', function() {
|
|||||||
$provide.value('User', User);
|
$provide.value('User', User);
|
||||||
});
|
});
|
||||||
|
|
||||||
inject(function($rootScope, $controller, _$state_, _Groups_, _Notification_){
|
inject(function($rootScope, $controller, _$state_, _Groups_, _Members_, _Notification_){
|
||||||
user = specHelper.newUser();
|
user = specHelper.newUser();
|
||||||
user._id = "unique-user-id";
|
user._id = "unique-user-id";
|
||||||
|
|
||||||
scope = $rootScope.$new();
|
scope = $rootScope.$new();
|
||||||
|
rootScope = $rootScope;
|
||||||
|
|
||||||
// Load RootCtrl to ensure shared behaviors are loaded
|
// Load RootCtrl to ensure shared behaviors are loaded
|
||||||
$controller('RootCtrl', {$scope: scope, User: User});
|
$controller('RootCtrl', {$scope: scope, User: User});
|
||||||
@@ -27,6 +28,7 @@ describe('Challenges Controller', function() {
|
|||||||
ctrl = $controller('ChallengesCtrl', {$scope: scope, User: User});
|
ctrl = $controller('ChallengesCtrl', {$scope: scope, User: User});
|
||||||
|
|
||||||
groups = _Groups_;
|
groups = _Groups_;
|
||||||
|
members = _Members_;
|
||||||
notification = _Notification_;
|
notification = _Notification_;
|
||||||
state = _$state_;
|
state = _$state_;
|
||||||
});
|
});
|
||||||
@@ -614,7 +616,7 @@ describe('Challenges Controller', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('User interactions', function() {
|
context('User interactions', function() {
|
||||||
describe('join', function() {
|
describe('join', function() {
|
||||||
it('calls challenge.$join', function(){
|
it('calls challenge.$join', function(){
|
||||||
var challenge = specHelper.newChallenge({
|
var challenge = specHelper.newChallenge({
|
||||||
@@ -682,4 +684,37 @@ describe('Challenges Controller', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
context('modal actions', function() {
|
||||||
|
beforeEach(function() {
|
||||||
|
sandbox.stub(members, 'selectMember');
|
||||||
|
sandbox.stub(rootScope, 'openModal');
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('sendMessageToChallengeParticipant', function() {
|
||||||
|
it('opens private-message modal', function() {
|
||||||
|
members.selectMember.yields();
|
||||||
|
scope.sendMessageToChallengeParticipant(user._id);
|
||||||
|
|
||||||
|
expect(rootScope.openModal).to.be.calledOnce;
|
||||||
|
expect(rootScope.openModal).to.be.calledWith(
|
||||||
|
'private-message',
|
||||||
|
{ controller: 'MemberModalCtrl' }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('sendGiftToChallengeParticipant', function() {
|
||||||
|
it('opens send-gift modal', function() {
|
||||||
|
members.selectMember.yields();
|
||||||
|
scope.sendGiftToChallengeParticipant(user._id);
|
||||||
|
|
||||||
|
expect(rootScope.openModal).to.be.calledOnce;
|
||||||
|
expect(rootScope.openModal).to.be.calledWith(
|
||||||
|
'send-gift',
|
||||||
|
{ controller: 'MemberModalCtrl' }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User', 'Challenges', 'Notification', '$compile', 'Groups', '$state', '$stateParams', 'Tasks',
|
habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User', 'Challenges', 'Notification', '$compile', 'Groups', '$state', '$stateParams', 'Members', 'Tasks',
|
||||||
function($rootScope, $scope, Shared, User, Challenges, Notification, $compile, Groups, $state, $stateParams, Tasks) {
|
function($rootScope, $scope, Shared, User, Challenges, Notification, $compile, Groups, $state, $stateParams, Members, Tasks) {
|
||||||
|
|
||||||
// Use presence of cid to determine whether to show a list or a single
|
// Use presence of cid to determine whether to show a list or a single
|
||||||
// challenge
|
// challenge
|
||||||
@@ -313,6 +313,18 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.sendMessageToChallengeParticipant = function(uid) {
|
||||||
|
Members.selectMember(uid, function(){
|
||||||
|
$rootScope.openModal('private-message',{controller:'MemberModalCtrl'});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.sendGiftToChallengeParticipant = function(uid) {
|
||||||
|
Members.selectMember(uid, function(){
|
||||||
|
$rootScope.openModal('send-gift',{controller:'MemberModalCtrl'})
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
function _calculateMaxPrize(gid) {
|
function _calculateMaxPrize(gid) {
|
||||||
|
|
||||||
var userBalance = User.getBalanceInGems() || 0;
|
var userBalance = User.getBalanceInGems() || 0;
|
||||||
|
|||||||
@@ -19,6 +19,13 @@ script(type='text/ng-template', id='partials/options.social.challenges.detail.me
|
|||||||
.modal-body
|
.modal-body
|
||||||
habitrpg-tasks(main=false, modal='true')
|
habitrpg-tasks(main=false, modal='true')
|
||||||
.modal-footer
|
.modal-footer
|
||||||
|
.btn-group.pull-left(role="group")
|
||||||
|
button.btn.btn-default(ng-click='clickMember(obj._id, true)')
|
||||||
|
.glyphicon.glyphicon-user
|
||||||
|
button.btn.btn-default(ng-click='sendMessageToChallengeParticipant(obj._id)')
|
||||||
|
.glyphicon.glyphicon-envelope
|
||||||
|
button.btn.btn-default(ng-click='sendGiftToChallengeParticipant(obj._id)')
|
||||||
|
.glyphicon.glyphicon-gift
|
||||||
a.btn.btn-default(ng-click='$state.go("^")')=env.t('close')
|
a.btn.btn-default(ng-click='$state.go("^")')=env.t('close')
|
||||||
|
|
||||||
script(type='text/ng-template', id='partials/options.social.challenges.detail.html')
|
script(type='text/ng-template', id='partials/options.social.challenges.detail.html')
|
||||||
|
|||||||
Reference in New Issue
Block a user