mirror of
https://github.com/lukevella/rallly.git
synced 2025-08-01 15:39:03 +02:00
Update
- added example feature
This commit is contained in:
parent
2e6131bc7b
commit
6877e92a1d
6 changed files with 66 additions and 9 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
52
public/js/controllers/example.controller.js
Normal file
52
public/js/controllers/example.controller.js
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
angular.module('rallly')
|
||||||
|
.controller('ExampleCtrl', function($state, Event){
|
||||||
|
// Generate dates
|
||||||
|
var dates = [], date = new Date();
|
||||||
|
for (var i = 0; i < 4; i++){
|
||||||
|
dates.push(date.add(Math.ceil(Math.random() * 5)).days().toISOString());
|
||||||
|
}
|
||||||
|
// Generate Participants
|
||||||
|
var examplesNames = ['John Example', 'Jane Specimen','Mark Instance', 'Mary Case'];
|
||||||
|
var examples = [];
|
||||||
|
for (var i = 0; i < examplesNames.length; i++){
|
||||||
|
var example = { name : examplesNames[i] };
|
||||||
|
example.votes = [];
|
||||||
|
for (var j = 0; j < dates.length; j++){
|
||||||
|
var answer = Math.random()<.5;
|
||||||
|
example.votes[j] = answer;
|
||||||
|
}
|
||||||
|
examples.push(example);
|
||||||
|
}
|
||||||
|
var event = new Event({
|
||||||
|
"creator": {
|
||||||
|
"name": "John Example",
|
||||||
|
"email": "rallly@lukevella.com"
|
||||||
|
},
|
||||||
|
"title": "Lunch Meeting",
|
||||||
|
"location": "Starbucks, 901 New York Avenue",
|
||||||
|
"description": "This event has been automatically generated just for you! Feel free to try out all the different features and when you're ready, you can schedule a new event.",
|
||||||
|
"dates" : dates,
|
||||||
|
"participants" : examples,
|
||||||
|
"emails": [],
|
||||||
|
"comments" : [{
|
||||||
|
author : {
|
||||||
|
name : "John Example"
|
||||||
|
},
|
||||||
|
content : "Hey guys, this is a comment!"
|
||||||
|
}, {
|
||||||
|
author : {
|
||||||
|
name : "Mark Instance"
|
||||||
|
},
|
||||||
|
content : "Hi John... nice comment. Keep up the great work!"
|
||||||
|
}, {
|
||||||
|
author : {
|
||||||
|
name : "John Example"
|
||||||
|
},
|
||||||
|
content : "Thank you!"
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
event.$save(function(data){
|
||||||
|
|
||||||
|
$state.go('event', { id : data._id });
|
||||||
|
})
|
||||||
|
});
|
|
@ -23,8 +23,10 @@ angular.module('rallly')
|
||||||
|
|
||||||
$scope.submit = function(){
|
$scope.submit = function(){
|
||||||
if ($scope.form.$valid && $scope.page == states.length){
|
if ($scope.form.$valid && $scope.page == states.length){
|
||||||
$http.post('/api/event', $scope.event)
|
console.log(JSON.stringify($scope.event));
|
||||||
.success(function(event, status, headers, config){
|
var newEvent = new Event($scope.event);
|
||||||
|
newEvent.$save()
|
||||||
|
.then(function(event){
|
||||||
$scope.event = event;
|
$scope.event = event;
|
||||||
$scope.eventUrl = $state.href('event', {
|
$scope.eventUrl = $state.href('event', {
|
||||||
id: $scope.event._id
|
id: $scope.event._id
|
||||||
|
@ -33,8 +35,7 @@ angular.module('rallly')
|
||||||
});
|
});
|
||||||
$scope.page++;
|
$scope.page++;
|
||||||
$state.go('newevent.success');
|
$state.go('newevent.success');
|
||||||
})
|
}, function(){
|
||||||
.error(function(){
|
|
||||||
var modal = new ConfirmModal({
|
var modal = new ConfirmModal({
|
||||||
title : 'Uh oh!',
|
title : 'Uh oh!',
|
||||||
message : 'There was an error creating your event. Please try again later.',
|
message : 'There was an error creating your event. Please try again later.',
|
||||||
|
|
|
@ -15,10 +15,10 @@ angular.module('rallly')
|
||||||
var examples = [];
|
var examples = [];
|
||||||
for (var i = 0; i < examplesNames.length; i++){
|
for (var i = 0; i < examplesNames.length; i++){
|
||||||
var example = { name : examplesNames[i] };
|
var example = { name : examplesNames[i] };
|
||||||
example.dates = [];
|
example.votes = [];
|
||||||
for (var j = 0; j < event.dates.length; j++){
|
for (var j = 0; j < event.dates.length; j++){
|
||||||
var answer = Math.random()<.5;
|
var answer = Math.random()<.5;
|
||||||
example.dates[j] = answer;
|
example.votes[j] = answer;
|
||||||
}
|
}
|
||||||
examples.push(example);
|
examples.push(example);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,10 @@ angular.module('rallly', ['ui.router','ngResource','btford.modal','ngTagsInput',
|
||||||
templateUrl : 'templates/about.html',
|
templateUrl : 'templates/about.html',
|
||||||
controller : 'AboutCtrl'
|
controller : 'AboutCtrl'
|
||||||
})
|
})
|
||||||
|
.state('example', {
|
||||||
|
url : '/example',
|
||||||
|
controller : 'ExampleCtrl'
|
||||||
|
})
|
||||||
.state('notfound', {
|
.state('notfound', {
|
||||||
url : '/notfound',
|
url : '/notfound',
|
||||||
templateUrl : 'templates/notfound.html'
|
templateUrl : 'templates/notfound.html'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue