mirror of
https://github.com/lukevella/rallly.git
synced 2025-06-03 03:01:52 +02:00
First Commit
This commit is contained in:
commit
2630cc237a
527 changed files with 104273 additions and 0 deletions
18
public/js/controllers/event.controller.js
Normal file
18
public/js/controllers/event.controller.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
angular.module('rallly')
|
||||
.controller('EventCtrl', function($scope, $http, $state, Event, Participant){
|
||||
|
||||
var id = $state.params.id;
|
||||
$scope.event = Event.get({id:id});
|
||||
$scope.deleteParticipant = function(pid){
|
||||
Participant.remove({ id : id , pid : pid }, function(event){
|
||||
$scope.event = event;
|
||||
});
|
||||
}
|
||||
$scope.save = function(participant){
|
||||
var participant = new Participant(participant);
|
||||
participant.$save({id:id}, function(event){
|
||||
$scope.event = event;
|
||||
$scope.participant = {};
|
||||
});
|
||||
}
|
||||
});
|
65
public/js/controllers/newevent.controller.js
Normal file
65
public/js/controllers/newevent.controller.js
Normal file
|
@ -0,0 +1,65 @@
|
|||
angular.module('rallly')
|
||||
.controller('NewEventCtrl', function($scope, $http, $state){
|
||||
$scope.event = {};
|
||||
$scope.templates = {
|
||||
modal : 'templates/modal.html'
|
||||
};
|
||||
$scope.submit = function(){
|
||||
$http.post('/api/event', $scope.event)
|
||||
.success(function(event, status, headers, config){
|
||||
$scope.event = event;
|
||||
$scope.eventUrl = $state.href('event', {
|
||||
id: $scope.event._id
|
||||
}, {
|
||||
absolute : true
|
||||
});
|
||||
// $state.go('event',{id : data.event._id});
|
||||
})
|
||||
.error(function(data, status, headers, config){
|
||||
$scope.errors = data.errors;
|
||||
console.log(data.errors);
|
||||
})
|
||||
}
|
||||
$scope.clearDates = null
|
||||
})
|
||||
.directive('datepicker', function(){
|
||||
return {
|
||||
restrict : 'A',
|
||||
require : 'ngModel',
|
||||
link : function(scope, el, attrs, ngModel){
|
||||
$(el).datepicker({
|
||||
multidate : true,
|
||||
todayHighlight: true,
|
||||
format : 'dd/mm/yyyy'
|
||||
})
|
||||
.on('changeDate', function(e){
|
||||
var dates = e.dates;
|
||||
dates.sort(function(a, b){
|
||||
if (a.getTime() > b.getTime()) return true;
|
||||
return false;
|
||||
});
|
||||
ngModel.$setViewValue(dates, e);
|
||||
});
|
||||
|
||||
scope.clearDates = function(){
|
||||
$(el).datepicker('setDate', null)
|
||||
};
|
||||
scope.unsetDate = function(date){
|
||||
$(el).datepicker('setDates', scope.event.dates.filter(function(el){
|
||||
return el != date;
|
||||
}));
|
||||
};
|
||||
}
|
||||
}
|
||||
})
|
||||
.directive('rallly-error', function(){
|
||||
return {
|
||||
restrict : 'A',
|
||||
scope: {
|
||||
'message': '='
|
||||
},
|
||||
controller : function($scope){
|
||||
console.log($scope.message);
|
||||
}
|
||||
}
|
||||
});
|
30
public/js/main.js
Normal file
30
public/js/main.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
angular.module('rallly', ['ui.router','ngResource','ngFx'])
|
||||
.config(function($stateProvider, $urlRouterProvider, $locationProvider){
|
||||
$locationProvider.html5Mode(true);
|
||||
$urlRouterProvider.otherwise("/notfound")
|
||||
$stateProvider
|
||||
.state('index',{
|
||||
url : '/',
|
||||
templateUrl : 'templates/new.html',
|
||||
controller : 'NewEventCtrl'
|
||||
})
|
||||
.state('about', {
|
||||
url : '/about',
|
||||
templateUrl : 'templates/about.html'
|
||||
})
|
||||
.state('notfound', {
|
||||
url : '/notfound',
|
||||
templateUrl : 'templates/notfound.html'
|
||||
})
|
||||
.state('event',{
|
||||
url : '/:id',
|
||||
templateUrl : 'templates/event.html',
|
||||
controller : 'EventCtrl'
|
||||
})
|
||||
})
|
||||
.factory('Event', function($resource){
|
||||
return $resource('/api/event/:id', { id : '@_id' });
|
||||
})
|
||||
.factory('Participant', function($resource){
|
||||
return $resource('/api/event/:id/participant/:pid', { id: '@_id', pid : '@pid'});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue