mirror of
https://github.com/lukevella/rallly.git
synced 2025-06-15 09:01:48 +02:00
Cleaned up some code
This commit is contained in:
parent
0e0e49dc35
commit
bcc35ffe73
3 changed files with 52 additions and 53 deletions
|
@ -11,7 +11,6 @@ angular.module('rallly')
|
|||
scope.participant = {};
|
||||
var datesCount = [];
|
||||
scope.event.$promise.then(function(event){
|
||||
console.log(event);
|
||||
var examplesNames = ['John Example', 'Jane Specimen','Mark Instance', 'Mary Case'];
|
||||
var examples = [];
|
||||
for (var i = 0; i < examplesNames.length; i++){
|
||||
|
@ -24,57 +23,57 @@ angular.module('rallly')
|
|||
examples.push(example);
|
||||
}
|
||||
scope.examples = examples;
|
||||
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].votes[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();
|
||||
}
|
||||
}
|
||||
})
|
||||
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].votes[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