mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-16 16:05:33 +02:00
New Features
- added notifications - added toggle switches - added delete feature - added email verification
This commit is contained in:
parent
e61ef151f6
commit
1b20a11bba
91 changed files with 6859 additions and 2756 deletions
41
public/js/directives/discussion.directive.js
Normal file
41
public/js/directives/discussion.directive.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
27
public/js/directives/dropdown.directive.js
Normal file
27
public/js/directives/dropdown.directive.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
angular.module('rallly')
|
||||
.directive('dropdown', function($document){
|
||||
return {
|
||||
restrict : 'A',
|
||||
link : function(scope, el, attrs){
|
||||
el.addClass('dropdown');
|
||||
scope.open = false;
|
||||
|
||||
var clickHandler = function(event){
|
||||
var isClickedElementChildOfPopup = el.find(event.target).length > 0;
|
||||
if (isClickedElementChildOfPopup) return;
|
||||
scope.toggle();
|
||||
}
|
||||
|
||||
scope.toggle = function(){
|
||||
scope.open = !scope.open;
|
||||
if (scope.open){
|
||||
el.addClass('open');
|
||||
$document.bind('click', clickHandler);
|
||||
} else {
|
||||
el.removeClass('open');
|
||||
$document.unbind('click', clickHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
|
@ -1,5 +1,7 @@
|
|||
angular.module('rallly')
|
||||
.service('FormHelper', function(){
|
||||
this.emailRegexString = '^([\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4})?$';
|
||||
this.emailRegex = new RegExp(this.emailRegexString);
|
||||
this.prettyError = function(errors, field){
|
||||
if (errors.required) return field + " is required";
|
||||
if (errors.pattern) return field + " is invalid" ;
|
||||
|
@ -17,7 +19,7 @@ angular.module('rallly')
|
|||
link : function(scope, el, attrs) {
|
||||
scope.errors = {};
|
||||
|
||||
scope.emailRegex = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
|
||||
scope.emailRegex = FormHelper.emailRegex;
|
||||
|
||||
scope.$watchCollection('form.name.$error',function(errors){
|
||||
scope.errors.name = FormHelper.prettyError(errors, "Name");
|
||||
|
@ -59,12 +61,54 @@ angular.module('rallly')
|
|||
templateUrl : 'templates/directives/eventForm/dateForm.html'
|
||||
}
|
||||
})
|
||||
.directive('participantsForm', function(){
|
||||
.directive('participantsForm', function(FormHelper){
|
||||
return {
|
||||
scope : {
|
||||
event : '=',
|
||||
form : '='
|
||||
},
|
||||
templateUrl : 'templates/directives/eventForm/participantsForm.html'
|
||||
templateUrl : 'templates/directives/eventForm/participantsForm.html',
|
||||
link : function(scope, el, attrs){
|
||||
scope.emailRegex = FormHelper.emailRegexString;
|
||||
}
|
||||
}
|
||||
})
|
||||
.directive('settingsForm', function(Event){
|
||||
return {
|
||||
scope : {
|
||||
event : '=',
|
||||
form : '='
|
||||
},
|
||||
templateUrl : 'templates/directives/eventForm/settingsForm.html',
|
||||
link : function(scope, el, attrs){
|
||||
scope.deleteEvent = function(){
|
||||
Event.delete({'id' : scope.event._id}, function(){
|
||||
console.log('delete');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.directive('switchToggle', function(){
|
||||
return {
|
||||
scope : {
|
||||
model : '=ngModel'
|
||||
},
|
||||
require : 'ngModel',
|
||||
link : function(scope, el, attrs, ngModel) {
|
||||
el.addClass('switch-toggle');
|
||||
var setClass = function(){
|
||||
if (scope.model ^ typeof(attrs.invert) !== 'undefined'){
|
||||
el.addClass('active');
|
||||
} else {
|
||||
el.removeClass('active');
|
||||
}
|
||||
}
|
||||
scope.$watch('model', setClass);
|
||||
el.bind('click', function(e){
|
||||
scope.model = !scope.model;
|
||||
ngModel.$setViewValue(scope.model, e);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
65
public/js/directives/poll.directive.js
Normal file
65
public/js/directives/poll.directive.js
Normal file
|
@ -0,0 +1,65 @@
|
|||
angular.module('rallly')
|
||||
.directive('poll', function(Participant, ConfirmModal){
|
||||
return {
|
||||
restrict : 'A',
|
||||
templateUrl : 'templates/directives/poll.html',
|
||||
scope : {
|
||||
'event' : '='
|
||||
},
|
||||
link : function(scope, el, attrs){
|
||||
scope.defaults = [];
|
||||
scope.participant = {};
|
||||
var datesCount = [];
|
||||
scope.delete = function(participant){
|
||||
var modal = new ConfirmModal({
|
||||
title : 'Delete ' + participant.name + '?',
|
||||
message : 'Are you sure you want to remove '+participant.name+' from the poll?',
|
||||
confirmText : 'Yes - delete',
|
||||
cancelText : 'No - nevermind',
|
||||
isDestructive : true,
|
||||
confirm : function(){
|
||||
Participant.remove({ id : scope.event._id , pid : participant._id }, function(event){
|
||||
scope.event = event;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
scope.isTopDate = function(index){
|
||||
var count = datesCount[index];
|
||||
for (var i = 0; i < datesCount.length; i++){
|
||||
if (datesCount[i] > count) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
scope.selectedDate = function(index){
|
||||
datesCount[index] = 0;
|
||||
for (var i = 0; i < scope.event.participants.length; i++){
|
||||
if (scope.event.participants[i].dates[index]) datesCount[index]++;
|
||||
}
|
||||
return datesCount[index];
|
||||
}
|
||||
scope.update = function(participant){
|
||||
Participant.update({
|
||||
id : scope.event._id,
|
||||
pid : participant._id
|
||||
}, participant);
|
||||
}
|
||||
scope.edit = function(participant){
|
||||
scope.defaults[scope.event.participants.indexOf(participant)] = angular.copy(participant);
|
||||
}
|
||||
scope.cancel = function(index){
|
||||
scope.event.participants[index] = scope.defaults[index];
|
||||
}
|
||||
scope.save = function(){
|
||||
if (scope.formnew.$valid){
|
||||
var participant = new Participant(scope.participant);
|
||||
participant.$save({id:scope.event._id}, function(event){
|
||||
scope.event = event;
|
||||
scope.participant = {};
|
||||
});
|
||||
scope.formnew.$setPristine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue