mirror of
https://github.com/lukevella/rallly.git
synced 2025-08-06 09:59:00 +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
6
public/js/controllers/account.controller.js
Normal file
6
public/js/controllers/account.controller.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
angular.module('rallly')
|
||||
.controller('AccountCtrl', function($scope, ConfirmModal){
|
||||
$scope.showNotice = function(){
|
||||
|
||||
}
|
||||
})
|
18
public/js/controllers/deletion.controller.js
Normal file
18
public/js/controllers/deletion.controller.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
angular.module('rallly')
|
||||
.controller('DeletionCtrl', function($state, Notification, Event){
|
||||
Event.destroy({id : $state.params.id, code :$state.params.code}, function(){
|
||||
var notification = new Notification({
|
||||
title : 'Event deleted',
|
||||
message : 'This event has been deleted',
|
||||
type : 'success',
|
||||
timeout : 5000
|
||||
});
|
||||
}, function(e){
|
||||
var notification = new Notification({
|
||||
title : 'Deletion Failed',
|
||||
message : 'The event could not be deleted. Make sure that it exists and that the url is correct',
|
||||
type : 'error'
|
||||
});
|
||||
});
|
||||
$state.go('event', { id : $state.params.id });
|
||||
});
|
|
@ -1,5 +1,5 @@
|
|||
angular.module('rallly')
|
||||
.controller('EditEventCtrl', function($scope, $http, $state, $timeout, Event, ConfirmModal, Title){
|
||||
.controller('EditEventCtrl', function($scope, $http, $state, $timeout, Event, ConfirmModal, Notification, Title){
|
||||
var id = $state.params.id
|
||||
$scope.event = Event.get({id:id}, function(data){
|
||||
Title.set("Edit: " + $scope.event.title);
|
||||
|
@ -9,7 +9,6 @@ angular.module('rallly')
|
|||
});
|
||||
$scope.undoChanges = function(){
|
||||
$scope.event = angular.copy($scope.master);
|
||||
resetDates();
|
||||
}
|
||||
$scope.didChange = function(){
|
||||
return JSON.stringify($scope.master) != JSON.stringify($scope.event);
|
||||
|
@ -35,10 +34,10 @@ angular.module('rallly')
|
|||
update();
|
||||
}
|
||||
} else {
|
||||
var modal = new ConfirmModal({
|
||||
title : 'Not so fast!',
|
||||
var notification = new Notification({
|
||||
title : 'Not so fast',
|
||||
message : 'Make sure you fill in all the required fields and try again.',
|
||||
cancelText : 'OK'
|
||||
type : 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -47,19 +46,12 @@ angular.module('rallly')
|
|||
id : id
|
||||
}, $scope.event,
|
||||
function(){
|
||||
var modal = new ConfirmModal({
|
||||
title : 'Event Updated',
|
||||
message : 'Your changes have been saved successfully!',
|
||||
confirmText : 'Back to Event Page',
|
||||
cancelText : 'Stay here',
|
||||
confirm : function(){
|
||||
$state.go('event',{id : $scope.event._id});
|
||||
}
|
||||
var notification = new Notification({
|
||||
title : 'Changes Saved',
|
||||
message : 'Your changes have been saved successfully.',
|
||||
type : 'success'
|
||||
});
|
||||
$scope.master = angular.copy($scope.event);
|
||||
$scope.didSave = $timeout(function(){
|
||||
$scope.didSave = false;
|
||||
}, 2000);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
angular.module('rallly')
|
||||
.controller('EventCtrl', function($scope, $http, $state, Title, Event){
|
||||
.controller('EventCtrl', function($scope, $http, $state, Title, Event, ConfirmModal){
|
||||
var id = $state.params.id;
|
||||
$scope.participant = {};
|
||||
$scope.event = Event.get({id:id}, function(data){
|
||||
Title.set($scope.event.title);
|
||||
$scope.eventUrl = $state.href('event', {
|
||||
|
@ -13,73 +12,36 @@ angular.module('rallly')
|
|||
$state.go('notfound');
|
||||
});
|
||||
|
||||
$scope.openEvent = function(){
|
||||
$scope.event.isClosed = false;
|
||||
Event.update({
|
||||
id : id
|
||||
}, $scope.event,
|
||||
function(){
|
||||
var modal = new ConfirmModal({
|
||||
title : 'Event Open',
|
||||
message : 'People can vote and comment on this event.',
|
||||
cancelText : 'OK',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$scope.closeEvent = function(){
|
||||
$scope.event.isClosed = true;
|
||||
Event.update({
|
||||
id : id
|
||||
}, $scope.event,
|
||||
function(){
|
||||
var modal = new ConfirmModal({
|
||||
title : 'Event Closed',
|
||||
message : 'People can no longer vote or comment on this event.',
|
||||
cancelText : 'OK',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$scope.editEvent = function(){
|
||||
$state.go('editevent', { id : $scope.event._id });
|
||||
}
|
||||
|
||||
})
|
||||
.directive('poll', function(Event, Participant, ConfirmModal){
|
||||
return {
|
||||
restrict : 'A',
|
||||
templateUrl : 'templates/directives/poll.html',
|
||||
scope : {
|
||||
'event' : '=',
|
||||
'participant' : '='
|
||||
},
|
||||
link : function(scope, el, attrs){
|
||||
scope.defaults = [];
|
||||
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;
|
||||
});
|
||||
}
|
||||
});
|
||||
modal.show();
|
||||
}
|
||||
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(participant){
|
||||
if (scope.formnew.$valid){
|
||||
var participant = new Participant(participant);
|
||||
participant.$save({id:scope.event._id}, function(event){
|
||||
scope.event = event;
|
||||
scope.participant = {};
|
||||
});
|
||||
scope.formnew.$setPristine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,17 +1,9 @@
|
|||
angular.module('rallly')
|
||||
.controller('NewEventCtrl', function($scope, $http, $state, Event, ConfirmModal){
|
||||
.controller('NewEventCtrl', function($scope, $http, $state, Event, ConfirmModal, Notification){
|
||||
|
||||
$scope.title = "Schedule a New Event";
|
||||
$scope.description = "Fill in the form below to create your event and share it with your friends and colleagues.";
|
||||
|
||||
var showModal = function(title, message){
|
||||
var modal = new ConfirmModal({
|
||||
title : title || 'Not so fast!',
|
||||
message : message || 'Make sure you fill in all the required fields and try again.',
|
||||
cancelText : 'OK'
|
||||
});
|
||||
}
|
||||
|
||||
$scope.submit = function(){
|
||||
if ($scope.form.$valid){
|
||||
$http.post('/api/event', $scope.event)
|
||||
|
@ -24,10 +16,18 @@ angular.module('rallly')
|
|||
});
|
||||
})
|
||||
.error(function(){
|
||||
showModal('Uh oh!', 'There was an error creating your event. Please try again later.');
|
||||
var modal = new ConfirmModal({
|
||||
title : 'Uh oh!',
|
||||
message : 'There was an error creating your event. Please try again later.',
|
||||
cancelText : 'OK'
|
||||
});
|
||||
});
|
||||
} else {
|
||||
showModal();
|
||||
var notification = new Notification({
|
||||
title : 'Not so fast',
|
||||
message : 'Make sure you fill in all the required fields and try again.',
|
||||
type : 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
19
public/js/controllers/verification.controller.js
Normal file
19
public/js/controllers/verification.controller.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
angular.module('rallly')
|
||||
.controller('VerificationCtrl', function(Event, Notification, $state){
|
||||
Event.verify({id : $state.params.id, code :$state.params.code}, function(){
|
||||
var notification = new Notification({
|
||||
title : 'Email Verified',
|
||||
message : 'Your email has been verified. You will now be able to receive email notifications for this event',
|
||||
type : 'success',
|
||||
timeout : 5000
|
||||
});
|
||||
}, function(e){
|
||||
var notification = new Notification({
|
||||
title : 'Verification Failed',
|
||||
message : 'Your verification code has expired.',
|
||||
type : 'error'
|
||||
});
|
||||
});
|
||||
$state.go('event', { id : $state.params.id });
|
||||
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue