mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
Move member modal controller to own file
This commit is contained in:
@@ -73,6 +73,7 @@ module.exports = function(config) {
|
|||||||
"website/public/js/directives/when-scrolled.directive.js",
|
"website/public/js/directives/when-scrolled.directive.js",
|
||||||
|
|
||||||
"website/public/js/controllers/authCtrl.js",
|
"website/public/js/controllers/authCtrl.js",
|
||||||
|
"website/public/js/controllers/memberModalCtrl.js",
|
||||||
"website/public/js/controllers/menuCtrl.js",
|
"website/public/js/controllers/menuCtrl.js",
|
||||||
"website/public/js/controllers/notificationCtrl.js",
|
"website/public/js/controllers/notificationCtrl.js",
|
||||||
"website/public/js/controllers/rootCtrl.js",
|
"website/public/js/controllers/rootCtrl.js",
|
||||||
|
|||||||
@@ -159,70 +159,6 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
|
|||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.controller("MemberModalCtrl", ['$scope', '$rootScope', 'Members', 'Shared', '$http', 'Notification', 'Groups', 'Chat', '$controller', 'Stats',
|
|
||||||
function($scope, $rootScope, Members, Shared, $http, Notification, Groups, Chat, $controller, Stats) {
|
|
||||||
|
|
||||||
$controller('RootCtrl', {$scope: $scope});
|
|
||||||
|
|
||||||
$scope.timestamp = function(timestamp){
|
|
||||||
return moment(timestamp).format($rootScope.User.user.preferences.dateFormat.toUpperCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.statCalc = Stats;
|
|
||||||
|
|
||||||
// We watch Members.selectedMember because it's asynchronously set, so would be a hassle to handle updates here
|
|
||||||
$scope.$watch( function() { return Members.selectedMember; }, function (member) {
|
|
||||||
if(member) {
|
|
||||||
member.petCount = Shared.countPets($rootScope.countExists(member.items.pets), member.items.pets);
|
|
||||||
member.mountCount = Shared.countMounts($rootScope.countExists(member.items.mounts), member.items.mounts);
|
|
||||||
$scope.profile = member;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.sendPrivateMessage = function(uuid, message){
|
|
||||||
// Don't do anything if the user somehow gets here without a message.
|
|
||||||
if (!message) return;
|
|
||||||
|
|
||||||
$http.post('/api/v2/members/'+uuid+'/message',{message:message}).success(function(){
|
|
||||||
Notification.text(window.env.t('messageSentAlert'));
|
|
||||||
$rootScope.User.sync();
|
|
||||||
$scope.$close();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.gift = {
|
|
||||||
type: 'gems',
|
|
||||||
gems: {amount:0, fromBalance:true},
|
|
||||||
subscription: {key:''},
|
|
||||||
message:''
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.sendGift = function(uuid, gift){
|
|
||||||
$http.post('/api/v2/members/'+uuid+'/gift', gift).success(function(){
|
|
||||||
Notification.text('Gift sent!')
|
|
||||||
$rootScope.User.sync();
|
|
||||||
$scope.$close();
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.reportAbuse = function(reporter, message, groupId) {
|
|
||||||
message.flags[reporter._id] = true;
|
|
||||||
Chat.utils.flagChatMessage({gid: groupId, messageId: message.id}, undefined, function(data){
|
|
||||||
Notification.text(window.env.t('abuseReported'));
|
|
||||||
$scope.$close();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.clearFlagCount = function(message, groupId) {
|
|
||||||
Chat.utils.clearFlagCount({gid: groupId, messageId: message.id}, undefined, function(data){
|
|
||||||
message.flagCount = 0;
|
|
||||||
Notification.text("Flags cleared");
|
|
||||||
$scope.$close();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
])
|
|
||||||
|
|
||||||
.controller('AutocompleteCtrl', ['$scope', '$timeout', 'Groups', 'User', 'InputCaret', function ($scope,$timeout,Groups,User,InputCaret) {
|
.controller('AutocompleteCtrl', ['$scope', '$timeout', 'Groups', 'User', 'InputCaret', function ($scope,$timeout,Groups,User,InputCaret) {
|
||||||
$scope.clearUserlist = function() {
|
$scope.clearUserlist = function() {
|
||||||
$scope.response = [];
|
$scope.response = [];
|
||||||
|
|||||||
66
website/public/js/controllers/memberModalCtrl.js
Normal file
66
website/public/js/controllers/memberModalCtrl.js
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
habitrpg
|
||||||
|
.controller("MemberModalCtrl", ['$scope', '$rootScope', 'Members', 'Shared', '$http', 'Notification', 'Groups', 'Chat', '$controller', 'Stats',
|
||||||
|
function($scope, $rootScope, Members, Shared, $http, Notification, Groups, Chat, $controller, Stats) {
|
||||||
|
|
||||||
|
$controller('RootCtrl', {$scope: $scope});
|
||||||
|
|
||||||
|
$scope.timestamp = function(timestamp){
|
||||||
|
return moment(timestamp).format($rootScope.User.user.preferences.dateFormat.toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.statCalc = Stats;
|
||||||
|
|
||||||
|
// We watch Members.selectedMember because it's asynchronously set, so would be a hassle to handle updates here
|
||||||
|
$scope.$watch( function() { return Members.selectedMember; }, function (member) {
|
||||||
|
if(member) {
|
||||||
|
member.petCount = Shared.countPets($rootScope.countExists(member.items.pets), member.items.pets);
|
||||||
|
member.mountCount = Shared.countMounts($rootScope.countExists(member.items.mounts), member.items.mounts);
|
||||||
|
$scope.profile = member;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.sendPrivateMessage = function(uuid, message){
|
||||||
|
// Don't do anything if the user somehow gets here without a message.
|
||||||
|
if (!message) return;
|
||||||
|
|
||||||
|
$http.post('/api/v2/members/'+uuid+'/message',{message:message}).success(function(){
|
||||||
|
Notification.text(window.env.t('messageSentAlert'));
|
||||||
|
$rootScope.User.sync();
|
||||||
|
$scope.$close();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.gift = {
|
||||||
|
type: 'gems',
|
||||||
|
gems: {amount:0, fromBalance:true},
|
||||||
|
subscription: {key:''},
|
||||||
|
message:''
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.sendGift = function(uuid, gift){
|
||||||
|
$http.post('/api/v2/members/'+uuid+'/gift', gift).success(function(){
|
||||||
|
Notification.text('Gift sent!')
|
||||||
|
$rootScope.User.sync();
|
||||||
|
$scope.$close();
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.reportAbuse = function(reporter, message, groupId) {
|
||||||
|
message.flags[reporter._id] = true;
|
||||||
|
Chat.utils.flagChatMessage({gid: groupId, messageId: message.id}, undefined, function(data){
|
||||||
|
Notification.text(window.env.t('abuseReported'));
|
||||||
|
$scope.$close();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.clearFlagCount = function(message, groupId) {
|
||||||
|
Chat.utils.clearFlagCount({gid: groupId, messageId: message.id}, undefined, function(data){
|
||||||
|
message.flagCount = 0;
|
||||||
|
Notification.text("Flags cleared");
|
||||||
|
$scope.$close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
@@ -71,6 +71,7 @@
|
|||||||
|
|
||||||
"js/controllers/authCtrl.js",
|
"js/controllers/authCtrl.js",
|
||||||
"js/controllers/menuCtrl.js",
|
"js/controllers/menuCtrl.js",
|
||||||
|
"js/controllers/memberModalCtrl.js",
|
||||||
"js/controllers/notificationCtrl.js",
|
"js/controllers/notificationCtrl.js",
|
||||||
"js/controllers/rootCtrl.js",
|
"js/controllers/rootCtrl.js",
|
||||||
"js/controllers/settingsCtrl.js",
|
"js/controllers/settingsCtrl.js",
|
||||||
|
|||||||
Reference in New Issue
Block a user