mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-14 16:02:14 +00:00
add GET /groups/:gid, champ/elite/master tiers, chat sync button
This commit is contained in:
parent
479cd16835
commit
5113ed192a
8 changed files with 68 additions and 11 deletions
|
|
@ -26,6 +26,16 @@
|
|||
label
|
||||
margin-right:5px
|
||||
|
||||
.label-elite
|
||||
background-color: #5DF644
|
||||
color: black
|
||||
.label-champion
|
||||
background-color: #0070dd
|
||||
color: white
|
||||
.label-master
|
||||
background-color: #a335ee
|
||||
color: white
|
||||
|
||||
#market-tab
|
||||
position relative
|
||||
height 500px
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Groups', '$http', 'A
|
|||
}
|
||||
])
|
||||
|
||||
.controller('ChatCtrl', ['$scope', 'Groups', function($scope, Groups){
|
||||
.controller('ChatCtrl', ['$scope', 'Groups', 'User', function($scope, Groups, User){
|
||||
$scope._chatMessage = '';
|
||||
$scope.postChat = function(group, message){
|
||||
if (_.isEmpty(message)) return
|
||||
|
|
@ -33,6 +33,23 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Groups', '$http', 'A
|
|||
$('.chat-btn').removeClass('disabled');
|
||||
});
|
||||
}
|
||||
$scope.sync = function(group){
|
||||
group.$get();
|
||||
}
|
||||
$scope.nameTagClasses = function(message){
|
||||
if (message.contributor) {
|
||||
if (message.contributor.match(/npc/i) || message.contributor.match(/master/i)) {
|
||||
return 'label-master'; // master
|
||||
} else if (message.contributor.match(/champion/i)) {
|
||||
return 'label-champion'; // champion
|
||||
} else if (message.contributor.match(/elite/i)) {
|
||||
return 'label-success'; //elite
|
||||
}
|
||||
}
|
||||
if (message.uuid == User.user.id) {
|
||||
return 'label-inverse'; //self
|
||||
}
|
||||
}
|
||||
|
||||
}])
|
||||
|
||||
|
|
|
|||
|
|
@ -83,6 +83,28 @@ api.getGroups = function(req, res, next) {
|
|||
})
|
||||
};
|
||||
|
||||
/**
|
||||
* Get group
|
||||
*/
|
||||
api.getGroup = function(req, res, next) {
|
||||
var user = res.locals.user;
|
||||
var gid = req.params.gid;
|
||||
|
||||
Group.findById(gid).populate('members', partyFields).exec(function(err, group){
|
||||
if ( (group.type == 'guild' && group.privacy == 'private') || group.type == 'party') {
|
||||
return res.json(401, {err: "You don't have access to this group"});
|
||||
}
|
||||
// Remove self from party (see above failing `match` directive in `populate`
|
||||
if (group.type == 'party') {
|
||||
var i = _.findIndex(group.members, {_id:user._id});
|
||||
if (~i) group.members.splice(i,1);
|
||||
}
|
||||
res.json(group);
|
||||
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
api.createGroup = function(req, res, next) {
|
||||
var group = new Group(req.body);
|
||||
group.save(function(err, saved){
|
||||
|
|
|
|||
|
|
@ -51,8 +51,7 @@ router.post('/user/buy-gems', auth.auth, user.buyGems);
|
|||
/* Groups*/
|
||||
router.get('/groups', auth.auth, groups.getGroups);
|
||||
router.post('/groups', auth.auth, groups.createGroup);
|
||||
//TODO:
|
||||
//GET /groups/:gid (get group)
|
||||
router.get('/groups/:gid', auth.auth, groups.getGroup);
|
||||
//PUT /groups/:gid (edit group)
|
||||
//DELETE /groups/:gid
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
form(ng-controller='ChatCtrl', ng-submit='postChat(group,_chatMessage)')
|
||||
form(ng-submit='postChat(group,_chatMessage)')
|
||||
//FIXME ng-model makes this painfully slow! using jquery for now, which is really non-angular-like
|
||||
//textarea.span6(rows='3', ui-keypress='{13:"postChat(group,_chatMessage)"}', ng-model='_chatMessage')
|
||||
textarea.span6.chat-textarea(rows='3', ui-keypress='{13:"postChat(group,_chatMessage)"}', ng-model='_chatMessage')
|
||||
br
|
||||
input.btn.chat-btn(type='submit', value='Send Chat')
|
||||
table
|
||||
tr
|
||||
td
|
||||
input.btn.chat-btn(type='submit', value='Send Chat')
|
||||
td
|
||||
button.btn
|
||||
i(class='pull-right icon-refresh', ng-click='sync(group)', tooltip='Fetch Recent Messages')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
li(ng-repeat='message in group.chat', ng-class='{highlight: message.text.indexOf(username(user.auth,user.profile.name)) != -1}')
|
||||
span.label.chat-message(ng-class='{"label-success": message.npc, "label-inverse": message.contributor, "label-info": message.uuid == user.id}', tooltip='{{message.contributor}}{{message.npc}}')
|
||||
span.label.chat-message(class='{{nameTagClasses(message)}}', tooltip='{{message.contributor}}{{message.npc}}')
|
||||
| {{message.user}}
|
||||
span
|
||||
span(ng-bind-html="message.text | linky:'_blank'") -
|
||||
|
|
|
|||
|
|
@ -99,8 +99,9 @@ a.pull-right.gem-wallet(rel='popover', data-trigger='hover', data-title='Guild B
|
|||
.arrow
|
||||
h3.popover-title {{username(_members[group.leader].auth,_members[group.leader].profile.name)}}
|
||||
.popover-content {{group.leaderMessage}}
|
||||
h3 Chat
|
||||
include ./chat-box
|
||||
div(ng-controller='ChatCtrl')
|
||||
h3 Chat
|
||||
include ./chat-box
|
||||
|
||||
ul.unstyled.tavern-chat
|
||||
include ./chat-message
|
||||
ul.unstyled.tavern-chat
|
||||
include ./chat-message
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
li
|
||||
h4
|
||||
a(target='_blank', href='http://community.habitrpg.com/forum') Community Forum
|
||||
.span8
|
||||
.span8(ng-controller='ChatCtrl')
|
||||
h3 Tavern Talk & LFG
|
||||
.row-fluid
|
||||
.span3
|
||||
|
|
|
|||
Loading…
Reference in a new issue