Improved delete request transaction

This commit is contained in:
Luke Vella 2015-01-26 15:35:08 +01:00
parent 1b20a11bba
commit 59caf01443
15 changed files with 18 additions and 10343 deletions

View file

@ -27,6 +27,7 @@ exports.create = function(req, res, next){
var event = req.body;
event.__private = {
'verificationCode' : getRandomString(),
'unsubscribeCode' : getRandomString(),
'deleteCode' : getRandomString()
}
Event.create(req.body, function(err, event){

View file

@ -55,7 +55,8 @@ var EventSchema = new Schema({
},
__private : {
verificationCode : String,
deleteCode : String,
unsubscribeCode : String,
deleteCode : String
}
});

View file

@ -20,7 +20,6 @@
"bootstrap-datepicker": "~1.3.0",
"angular-ui-router": "~0.2.13",
"angular-resource": "~1.3.6",
"ngFx": "~1.0.5",
"angular-modal": "~0.4.0",
"jquery": "~2.1.3",
"angular-hotkeys": "~0.2.2",

File diff suppressed because one or more lines are too long

View file

@ -73,7 +73,7 @@ angular.module('rallly')
}
}
})
.directive('settingsForm', function(Event){
.directive('settingsForm', function(Event, ConfirmModal){
return {
scope : {
event : '=',
@ -82,8 +82,14 @@ angular.module('rallly')
templateUrl : 'templates/directives/eventForm/settingsForm.html',
link : function(scope, el, attrs){
scope.deleteEvent = function(){
if (scope.deleteRequestSent) return;
Event.delete({'id' : scope.event._id}, function(){
console.log('delete');
scope.deleteRequestSent = true;
var modal = new ConfirmModal({
title : 'Delete Request Sent',
message : 'An email has been sent to the creator of this event with instructions to delete it.',
cancelText : 'OK'
});
});
}
}

View file

@ -1,4 +1,4 @@
angular.module('rallly', ['ui.router','ngResource','ngFx','btford.modal','ngTagsInput','ngAnimate'])
angular.module('rallly', ['ui.router','ngResource','btford.modal','ngTagsInput','ngAnimate'])
.config(function($stateProvider, $urlRouterProvider, $locationProvider){
$locationProvider.html5Mode(true);
$urlRouterProvider.otherwise("/notfound")

View file

@ -3,7 +3,7 @@ $templateCache.put("templates/confirmmodal.html","<div class=\"rl-modal-overlay\
$templateCache.put("templates/editevent.html","<div ng-show=\"event._id\">\n <div class=\"box\">\n\n <div class=\"box-title\">Edit Event</div>\n <div class=\"box-description\">\n You can makes changes to your existing event by changing the fields in the form below.\n </div>\n\n <form novalidate name=\"form\" ng-submit=\"submit()\">\n\n <section class=\"box-section\" user-form form=\"form\" event=\"event\">\n\n </section>\n\n <section class=\"box-section\" event-form form=\"form\" event=\"event\">\n\n </section>\n <section class=\"box-section\" date-form form=\"form\" event=\"event\">\n\n </section>\n\n <section class=\"box-section\" settings-form form=\"form\" event=\"event\">\n\n </section>\n\n <div class=\"box-controls box-bottom-sticky\">\n <button type=\"submit\" ng-show=\"didChange()\" class=\"btn btn-primary\" ng-class=\"{disabled : !didChange()}\">\n Save Changes\n </button>\n <button type=\"button\" ng-click=\"undoChanges()\" class=\"btn\" ng-show=\"didChange()\">Undo Changes</button>\n <a href=\"/{{event._id}}\" class=\"btn\" ng-hide=\"didChange()\">Done</a>\n </div>\n\n </form>\n\n </div>\n\n</div>\n");
$templateCache.put("templates/event.html","<div ng-show=\"event._id && !event.isDeleted\">\n <div class=\"box \">\n <div class=\"event-header\">\n <div class=\"avatar\">\n <img src=\"/images/eventicon.png\" width=\"32\" />\n </div>\n <div class=\"details\">\n <div class=\"title\">\n {{event.title}}\n <span class=\"title-label danger\" ng-show=\"event.isClosed\">Poll Closed</span>\n <span class=\"title-label success\" ng-hide=\"event.isClosed\">Poll Open</span>\n </div>\n <div class=\"subtitle\">\n Created by <a href=\"mailto:{{event.creator.email}}\">{{event.creator.name}}</a> &bull; {{event.created | elapsed}}\n </div>\n </div>\n <div class=\"actions\">\n <button class=\"btn\" ng-click=\"editEvent()\">Edit Event</button>\n </div>\n </div>\n <div class=\"box-side-sticky event-description\" ng-show=\"event.description\">{{event.description}}</div>\n <div class=\"box-bottom-sticky event-location\" ng-show=\"event.location\">\n <img src=\"/images/location.png\" width=\"18\" /><a href=\"http://google.com/maps?q={{event.location}}\" target=\"_blank\">{{event.location}}</a>\n </div>\n\n </div>\n <div class=\"box box-x-scroll\">\n <div poll event=\"event\" class=\"poll\">\n </div>\n </div>\n\n <div class=\"box\" ng-hide=\"event.comments.length == 0 && event.isClosed\">\n <div class=\"box-title\">\n Discussion\n </div>\n <div class=\"box-description\">\n You can discuss the event with your friends by leaving a comment below.\n </div>\n <div discussion event=\"event\">\n\n </div>\n </div>\n</div>\n");
$templateCache.put("templates/home.html","<div class=\"page-placeholder\">\n <div class=\"image\">\n <img src=\"/images/mark_large.png\" width=\"67\" />\n </div>\n <div class=\"title\">\n Schedule an Event\n </div>\n <div class=\"content\">\n Want to host an event but cant decide on a date? Click on the button below to start!\n </div>\n <button ng-click=\"newEvent()\" class=\"btn\">Schedule New Event</button>\n</div>\n");
$templateCache.put("templates/newevent.html","<div ng-hide=\"eventUrl\">\n <div class=\"box\" ng-class=\"{\'animated shake\': form.$submitted && form.$invalid }\">\n\n <div class=\"box-title\">Schedule a New Event</div>\n <div class=\"box-description\">\n Fill in the form below to create your event and share it with your friends and colleagues.\n </div>\n\n <form novalidate autocomplete=\"off\" name=\"form\" ng-submit=\"submit()\">\n <section class=\"box-section\" user-form form=\"form\" event=\"event\">\n\n </section>\n\n <section class=\"box-section\" event-form form=\"form\" event=\"event\">\n\n </section>\n\n <section class=\"box-section\" date-form form=\"form\" event=\"event\">\n\n </section>\n\n <section class=\"box-section\" participants-form form=\"form\" event=\"event\">\n\n </section>\n\n <div class=\"box-controls box-bottom-sticky\">\n <button type=\"submit\" class=\"btn btn-primary\">Create Event</button>\n </div>\n\n </form>\n </div>\n</div>\n<div ng-show=\"eventUrl\" class=\"box fx-fade-up\">\n <div class=\"box-message\">\n <div class=\"main-image\">\n <img src=\"/images/success_large.png\" width=\"100\" />\n </div>\n <div class=\"title\">Event Created</div>\n <div class=\"content\">\n Your event has been created successfully! You should receive an email shortly with instructions to verify your email address.\n </div>\n <div class=\"mini-divider\">\n </div>\n <div class=\"form-group\">\n <input type=\"text\" class=\"form-control\" disabled=\"true\" value=\"{{eventUrl}}\" />\n <a href=\"{{eventUrl}}\" class=\"btn form-btn\">GO</a>\n </div>\n </div>\n</div>\n");
$templateCache.put("templates/newevent.html","<div ng-hide=\"eventUrl\">\n <div class=\"box\" ng-class=\"{\'animated shake\': form.$submitted && form.$invalid }\">\n\n <div class=\"box-title\">Schedule a New Event</div>\n <div class=\"box-description\">\n Fill in the form below to create your event and share it with your friends and colleagues.\n </div>\n\n <form novalidate autocomplete=\"off\" name=\"form\" ng-submit=\"submit()\">\n <section class=\"box-section\" user-form form=\"form\" event=\"event\">\n\n </section>\n\n <section class=\"box-section\" event-form form=\"form\" event=\"event\">\n\n </section>\n\n <section class=\"box-section\" date-form form=\"form\" event=\"event\">\n\n </section>\n\n <section class=\"box-section\" participants-form form=\"form\" event=\"event\">\n\n </section>\n\n <div class=\"box-controls box-bottom-sticky\">\n <button type=\"submit\" class=\"btn btn-primary\">Create Event</button>\n </div>\n\n </form>\n </div>\n</div>\n<div ng-show=\"eventUrl\" class=\"box\">\n <div class=\"box-message\">\n <div class=\"main-image\">\n <img src=\"/images/success_large.png\" width=\"100\" />\n </div>\n <div class=\"title\">Event Created</div>\n <div class=\"content\">\n Your event has been created successfully! You should receive an email shortly with instructions to verify your email address.\n </div>\n <div class=\"mini-divider\">\n </div>\n <div class=\"form-group\">\n <input type=\"text\" class=\"form-control\" disabled=\"true\" value=\"{{eventUrl}}\" />\n <a href=\"{{eventUrl}}\" class=\"btn form-btn\">GO</a>\n </div>\n </div>\n</div>\n");
$templateCache.put("templates/notfound.html","<h1>Error 404</h1>\n<h2>Not Found</h2>\n");
$templateCache.put("templates/notification.html","<div class=\"notification {{notification.type}}\" ng-click=\"notification.close()\">\n <div class=\"title\">\n {{notification.title}}\n </div>\n <div class=\"message\">\n {{notification.message}}\n </div>\n</div>\n");
$templateCache.put("templates/directives/discussion.html","<ul class=\"comment-thread\" ng-show=\"event.comments.length\">\n <li ng-repeat=\"comment in event.comments\" class=\"comment\">\n <div class=\"avatar-section\">\n <img src=\"/images/avatar.png\" />\n </div>\n <div class=\"comment-section\">\n <a href=\"#\" class=\"comment-delete\" ng-click=\"deleteComment(comment)\">&times;</a>\n <div class=\"meta\">\n <span class=\"name\">{{comment.author.name}}</span>\n <span class=\"time\">{{comment.created | elapsed}}</span>\n </div>\n <div class=\"content\">{{comment.content}}</div>\n </div>\n </li>\n</ul>\n<form novalidate ng-submit=\"postComment()\" name=\"commentForm\" class=\"comment-form\">\n <div class=\"avatar-section\">\n <img src=\"/images/avatar.png\" />\n </div>\n <div class=\"input-section form-group\">\n <div class=\"content-section\">\n <textarea class=\"form-control\" required ng-model=\"comment.content\" placeholder=\"Write a comment...\"></textarea>\n </div>\n <div class=\"name-section\">\n <div class=\"name-container\">\n <input type=\"text\" class=\"form-control\" required placeholder=\"Your Name\" ng-model=\"comment.author.name\" />\n <button type=\"submit\" class=\"btn\">Post Comment</button>\n <span class=\"form-error\" ng-show=\"commentForm.$submitted && commentForm.$error\">\n <img src=\"/images/error.png\" width=\"14\" /> Make sure you fill in all the fields.\n </span>\n </div>\n </div>\n </div>\n</form>\n");
@ -11,5 +11,5 @@ $templateCache.put("templates/directives/poll.html","<div class=\"poll-header\">
$templateCache.put("templates/directives/eventForm/dateForm.html","<div class=\"section-details\">\n <div class=\"section-title\">Choose Dates</div>\n <ul class=\"daticon-list\">\n <li ng-repeat=\"date in event.dates\">\n <div class=\"daticon\">\n <div class=\"dow\">\n {{date | date: \'EEE\'}}\n </div>\n <div class=\"day\">\n {{date | date: \'d\'}}\n </div>\n <div class=\"month\">\n {{date | date : \'MMM\'}}\n </div>\n <span class=\"delete\" ng-click=\"datepicker.unsetDate(date)\"></span>\n </div>\n </li>\n </ul>\n</div>\n<div class=\"section-main\">\n <div class=\"form-row\">\n <div class=\"form-group\">\n <label for=\"email\">Calendar</label>\n <span class=\"form-error\" ng-show=\"(form.datepicker.$dirty || form.$submitted) && form.datepicker.$error.required\">\n <img src=\"/images/error.png\" width=\"14\" /> You need to select a few dates\n </span>\n <div datepicker required name=\"datepicker\" control=\"datepicker\" ng-model=\"event.dates\">\n\n </div>\n </div>\n </div>\n</div>\n");
$templateCache.put("templates/directives/eventForm/eventForm.html","<div class=\"section-details\">\n <div class=\"section-title\">Event Details</div>\n</div>\n<div class=\"section-main\">\n <div class=\"form-row\">\n <div class=\"form-col\">\n <div class=\"form-group\">\n <label for=\"title\">Title</label>\n <span class=\"form-error\" ng-show=\"(form.title.$touched || form.$submitted) && errors.title\">\n <img src=\"/images/error.png\" width=\"14\" /> {{errors.title}}\n </span>\n <input id=\"title\" name=\"title\" ng-maxlength=\"30\" required ng-model=\"event.title\" type=\"text\" placeholder=\"Monthly Meetup...\" class=\"form-control extend\"/>\n </div>\n </div>\n <div class=\"form-col\">\n <div class=\"form-group optional\">\n <label for=\"location\">Location</label>\n <span class=\"form-error\" ng-show=\"(form.location.$touched || form.$submitted) && errors.location\">\n <img src=\"/images/error.png\" width=\"14\" /> {{errors.location}}\n </span>\n <input id=\"location\" name=\"location\" ng-model=\"event.location\" ng-maxlength=\"50\" type=\"text\" placeholder=\"Rick\'s Cafe...\" class=\"form-control extend\"/>\n </div>\n </div>\n </div>\n <div class=\"form-row\">\n <div class=\"form-group optional\">\n <label for=\"description\" >Description</label>\n <textarea id=\"description\" name=\"description\" ng-model=\"event.description\" placeholder=\"Enter Description...\" class=\"form-control extend\"></textarea>\n </div>\n </div>\n</div>\n");
$templateCache.put("templates/directives/eventForm/participantsForm.html","<div class=\"section-details\">\n <div class=\"section-title\">Invite Participants</div>\n</div>\n<div class=\"section-main\">\n <div class=\"form-row\">\n <div class=\"form-group optional\">\n <label>Participant\'s Emails</label>\n <tags-input max-length=\"50\" allowed-tags-pattern=\"{{emailRegex}}\" display-property=\"email\" ng-model=\"event.emails\" placeholder=\"Add an Email\" type=\"email\" autocomplete=\"off\"></tags-input>\n </div>\n </div>\n</div>\n</section>\n");
$templateCache.put("templates/directives/eventForm/settingsForm.html","<div class=\"section-details\">\n <div class=\"section-title\">Settings</div>\n</div>\n<div class=\"section-main\">\n <div class=\"switch-row\">\n <div class=\"switch-details\">\n <div class=\"title\">\n Poll Status\n </div>\n <div class=\"description\">\n Let people vote on the poll.\n </div>\n </div>\n <div class=\"switch\">\n <div class=\"switch-value\">\n {{event.isClosed ? \'Closed\' : \'Open\' }}\n </div>\n <div switch-toggle ng-model=\"event.isClosed\" invert>\n </div>\n </div>\n </div>\n <div class=\"switch-row\">\n <div class=\"switch-details\">\n <div class=\"title\">\n Notifications\n </div>\n <div class=\"description\">\n Send email notifications to the creator of this event.\n </div>\n </div>\n <div class=\"switch\">\n <div class=\"switch-value\">\n {{event.creator.allowNotifications ? \'Enabled\' : \'Disabled\' }}\n </div>\n <div switch-toggle ng-model=\"event.creator.allowNotifications\">\n </div>\n </div>\n </div>\n <div class=\"switch-row\">\n <div class=\"switch-details\">\n <div class=\"title\">\n Delete Event\n </div>\n <div class=\"description\">\n Once you delete an event it will no longer be accessible.\n </div>\n </div>\n <div class=\"switch\">\n <button type=\"button\" ng-click=\"deleteEvent()\" class=\"btn danger\">Delete Event</button>\n </div>\n </div>\n</div>\n</section>\n");
$templateCache.put("templates/directives/eventForm/settingsForm.html","<div class=\"section-details\">\n <div class=\"section-title\">Settings</div>\n</div>\n<div class=\"section-main\">\n <div class=\"switch-row\">\n <div class=\"switch-details\">\n <div class=\"title\">\n Poll Status\n </div>\n <div class=\"description\">\n Let people vote on the poll.\n </div>\n </div>\n <div class=\"switch\">\n <div class=\"switch-value\">\n {{event.isClosed ? \'Closed\' : \'Open\' }}\n </div>\n <div switch-toggle ng-model=\"event.isClosed\" invert>\n </div>\n </div>\n </div>\n <div class=\"switch-row\">\n <div class=\"switch-details\">\n <div class=\"title\">\n Notifications\n </div>\n <div class=\"description\">\n Send email notifications to the creator of this event.\n </div>\n </div>\n <div class=\"switch\">\n <div class=\"switch-value\">\n {{event.creator.allowNotifications ? \'Enabled\' : \'Disabled\' }}\n </div>\n <div switch-toggle ng-model=\"event.creator.allowNotifications\">\n </div>\n </div>\n </div>\n <div class=\"switch-row\">\n <div class=\"switch-details\">\n <div class=\"title\">\n Delete Event\n </div>\n <div class=\"description\">\n Once you delete an event it will no longer be accessible.\n </div>\n </div>\n <div class=\"switch\">\n <button type=\"button\" ng-click=\"deleteEvent()\" class=\"btn\" ng-class=\"{danger : !deleteRequestSent, disabled : deleteRequestSent}\">{{deleteRequestSent ? \'Request Sent\' : \'Delete Event\' }}</button>\n </div>\n </div>\n</div>\n</section>\n");
$templateCache.put("templates/directives/eventForm/userForm.html","<div class=\"section-details\">\n <div class=\"section-title\">Your Details</div>\n</div>\n<div class=\"section-main\">\n <div class=\"form-row\">\n <div class=\"form-col\">\n <div class=\"form-group\">\n <label for=\"name\">Name</label>\n <span class=\"form-error\" ng-show=\"(form.name.$touched || form.$submitted) && errors.name\">\n <img src=\"/images/error.png\" width=\"14\" /> {{errors.name}}\n </span>\n <input id=\"name\" name=\"name\" ng-maxlength=\"30\" required ng-model=\"event.creator.name\" type=\"text\" placeholder=\"John Doe...\" class=\"form-control extend\"/>\n </div>\n </div>\n <div class=\"form-col\">\n <div class=\"form-group\">\n <label for=\"email\">Email</label>\n <span class=\"form-error\" ng-show=\"(form.email.$touched || form.$submitted) && errors.email\">\n <img src=\"/images/error.png\" width=\"14\" /> {{errors.email}}\n </span>\n <input type=\"email\" id=\"email\" name=\"email\" ng-pattern=\"emailRegex\" required ng-model=\"event.creator.email\" placeholder=\"john.doe@email.com...\" class=\"form-control extend\"/>\n </div>\n </div>\n </div>\n</div>\n");}]);

View file

@ -46,7 +46,7 @@
</div>
</div>
<div class="switch">
<button type="button" ng-click="deleteEvent()" class="btn danger">Delete Event</button>
<button type="button" ng-click="deleteEvent()" class="btn" ng-class="{danger : !deleteRequestSent, disabled : deleteRequestSent}">{{deleteRequestSent ? 'Request Sent' : 'Delete Event' }}</button>
</div>
</div>
</div>

View file

@ -30,7 +30,7 @@
</form>
</div>
</div>
<div ng-show="eventUrl" class="box fx-fade-up">
<div ng-show="eventUrl" class="box">
<div class="box-message">
<div class="main-image">
<img src="/images/success_large.png" width="100" />

View file

@ -1,59 +0,0 @@
{
"name": "ngAnimations.js",
"version": "1.0.5",
"homepage": "https://hendrixer.github.io",
"authors": [
"Hendrixer"
],
"description": "A conversion of animate.css into angular ngAnimate javaScript.",
"main": "dist/ngFx.js",
"keywords": [
"angular",
"ngAnimate",
"animate",
"animations"
],
"license": "MIT",
"ignore": [
".*",
"node_modules",
"bower_components",
"src",
"README.md",
"features",
"demoApp",
"index.html",
"animationList.txt",
"easingList.txt",
"Gulpfile.js",
"bower.json",
".gitignore",
"package.json",
"coverage",
"karma.conf.js",
"specs"
],
"dependencies": {
"angular": "~1.3.0"
},
"devDependencies": {
"angular-mocks": "~1.3.0",
"angular-animate": "~1.3.0",
"gsap": "~1.11.6",
"angular-bootstrap": "~0.11.0",
"angular-ui-router": "~0.2.10"
},
"resolutions": {
"angular": "~1.3.0"
},
"_release": "1.0.5",
"_resolution": {
"type": "version",
"tag": "v1.0.5",
"commit": "1801b9f102d724f3240e5d1128b7859b5c82175f"
},
"_source": "git://github.com/Hendrixer/ngFx.git",
"_target": "~1.0.5",
"_originalSource": "ngFx",
"_direct": true
}

View file

@ -1,13 +0,0 @@
#ngFx Change Log
##1.0 (11 Jul 2014)
+ ###Bug Fixes
* ```fx-trigger``` will now emit ```leave``` animations
* Rid of console logs :)
* Add demoApp to visually inspect animations for development
+ ###Features
* Concat ```ngAnimate``` and ```TweenMax``` into one file
+ ###Breaking changes
* You no longer use ```fx.animations``` in your modules, you must now use ```ngFx```, so ... ```angular.module("app", ["ngFx"])```
* You no longer have to include ```ngAnimate``` or ```GSAP```
* ngFx is now regestered on bower as ```ngFx```, ```bower install ngFx```

View file

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2014 Scott Moss
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,49 +0,0 @@
{
"name": "ngAnimations.js",
"version": "1.0.4",
"homepage": "https://hendrixer.github.io",
"authors": [
"Hendrixer"
],
"description": "A conversion of animate.css into angular ngAnimate javaScript.",
"main": "dist/ngFx.js",
"keywords": [
"angular",
"ngAnimate",
"animate",
"animations"
],
"license": "MIT",
"ignore": [
".*",
"node_modules",
"bower_components",
"src",
"README.md",
"features",
"demoApp",
"index.html",
"animationList.txt",
"easingList.txt",
"Gulpfile.js",
"bower.json",
".gitignore",
"package.json",
"coverage",
"karma.conf.js",
"specs"
],
"dependencies": {
"angular": "~1.3.0"
},
"devDependencies": {
"angular-mocks": "~1.3.0",
"angular-animate": "~1.3.0",
"gsap": "~1.11.6",
"angular-bootstrap": "~0.11.0",
"angular-ui-router": "~0.2.10"
},
"resolutions": {
"angular": "~1.3.0"
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long