mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-02 11:46:03 +02:00
- added notifications - added toggle switches - added delete feature - added email verification
41 lines
1.5 KiB
JavaScript
41 lines
1.5 KiB
JavaScript
angular.module('rallly')
|
|
.directive('discussion', function($timeout, Comment, ConfirmModal){
|
|
return {
|
|
restrict : 'A',
|
|
templateUrl : 'templates/directives/discussion.html',
|
|
scope : {
|
|
'event' : '='
|
|
},
|
|
link : function(scope, el, attrs){
|
|
scope.comment = {};
|
|
var thread = angular.element('.comment-thread');
|
|
$timeout(function(){
|
|
thread.scrollTop(thread.prop('scrollHeight'));
|
|
});
|
|
scope.deleteComment = function(comment){
|
|
var modal = new ConfirmModal({
|
|
title : 'Are you sure?',
|
|
message : 'Are you sure you want to remove this comment?',
|
|
confirmText : 'Yes - delete',
|
|
cancelText : 'No - nevermind',
|
|
isDestructive : true,
|
|
confirm : function(){
|
|
Comment.remove({ id : scope.event._id , cid : comment._id }, function(event){
|
|
scope.event = event;
|
|
});
|
|
}
|
|
});
|
|
}
|
|
scope.postComment = function(){
|
|
if (scope.commentForm.$valid){
|
|
var comment = new Comment(scope.comment);
|
|
comment.$save({id:scope.event._id}, function(event){
|
|
scope.event = event;
|
|
scope.comment = {};
|
|
});
|
|
scope.commentForm.$setPristine();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|