copy chat messages as todo

This commit is contained in:
Negue 2015-04-25 18:30:11 +02:00
parent ca3ac96d6d
commit 78dd949f20
4 changed files with 52 additions and 2 deletions

View file

@ -96,5 +96,7 @@
"abuseReported": "Thank you for reporting this violation. The moderators have been notified.",
"abuseAlreadyReported": "You have already reported this message.",
"needsText": "Please type a message.",
"needsTextPlaceholder": "Type your message here."
"needsTextPlaceholder": "Type your message here.",
"copyMessageAsToDo": "copy message as to-do",
"messageAddedAsToDo": "Message copied as to-do."
}

View file

@ -344,7 +344,21 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
});
});
}
}
};
$scope.copyToDo = function(message) {
var taskNotes = '[' + message.user + '](' + env.BASE_URL + '/static/front/#?memberId=' + message.uuid +
') wrote in [' + $scope.group.name + '](' + window.location.href + ')';
var newScope = $scope.$new();
newScope.text = message.text;
newScope.notes = taskNotes;
$rootScope.openModal('copyChatToDo',{
controller:'CopyMessageModalCtrl',
scope: newScope
});
};
$scope.sync = function(group){
group.$get();
@ -549,3 +563,20 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
}
}
])
.controller("CopyMessageModalCtrl", ['$scope', 'User', 'Notification',
function($scope, User, Notification){
$scope.saveTodo = function() {
var newTask = {
text: $scope.text,
type: 'todo',
notes: $scope.notes
};
User.user.ops.addTask({body:newTask});
Notification.text(window.env.t('messageAddedAsToDo'));
$scope.$close();
}
}
]);

View file

@ -31,6 +31,9 @@ mixin chatMessages(inbox)
|    
a(ng-click="flagChatMessage(group._id, message)", ng-if=':: user.contributor.admin || (!message.sent && user.flags.communityGuidelinesAccepted && message.uuid != user.id && message.uuid != "system")')
span.glyphicon.glyphicon-flag(tooltip="{{message.flags[user._id] ? env.t('abuseAlreadyReported') : env.t('abuseFlag')}}" ng-class='message.flags[user._id] ? "text-danger" : ""')
|    
a(ng-click="copyToDo(message)")
span.glyphicon.glyphicon-share(tooltip=env.t('copyMessageAsToDo'))
span.float-label(ng-class='::contribText(message.contributor, message.backer).length > 30 ? "long-title" : ""')
a.label.label-default.chat-message(ng-if=':: message.user', ng-class='::userLevelStyleFromLevel(message.contributor.level, message.backer.npc, style)', ng-click='clickMember(message.uuid, true)')
span.glyphicon.glyphicon-arrow-right(ng-if='::message.sent')

View file

@ -113,3 +113,17 @@ script(type='text/ng-template', id='partials/options.social.html')
.tab-content
.tab-pane.active
div(ui-view)
script(type='text/ng-template', id='modals/copyChatToDo.html')
.modal-header
h4=env.t('copyMessageAsToDo')
.modal-body
p
input.form-control(type='text',ng-model='text')
br
p
textarea.form-control(type='text',rows='5',ng-model='notes', focus-me)
.modal-footer
button.btn.btn-default(ng-click='$close()')=env.t('close')
button.btn.btn-default(ng-click='saveTodo()')=env.t('submit')