mirror of
https://github.com/lukevella/rallly.git
synced 2025-04-30 02:36:30 +02:00
Canceling Changes
This commit is contained in:
parent
aff8ee6124
commit
10c035e359
10 changed files with 47 additions and 16 deletions
|
@ -19,6 +19,7 @@ exports.show = function(req, res, next){
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.update = function(req, res){
|
exports.update = function(req, res){
|
||||||
|
req.body.updated = Date.now();
|
||||||
Event.update({ '_id' : req.params.id }, req.body, function(){
|
Event.update({ '_id' : req.params.id }, req.body, function(){
|
||||||
return res.status(204).end();
|
return res.status(204).end();
|
||||||
});
|
});
|
||||||
|
@ -29,6 +30,7 @@ exports.createParticipant = function(req, res, next){
|
||||||
var participant = req.body;
|
var participant = req.body;
|
||||||
Event.findById(eventId, function(err, event){
|
Event.findById(eventId, function(err, event){
|
||||||
if (err) return handleError(res, err);
|
if (err) return handleError(res, err);
|
||||||
|
event.updated = Date.now();
|
||||||
event.participants.push(participant);
|
event.participants.push(participant);
|
||||||
event.save(function(err, event){
|
event.save(function(err, event){
|
||||||
if (err) return next(err);
|
if (err) return next(err);
|
||||||
|
@ -42,6 +44,7 @@ exports.deleteParticipant = function(req, res, next){
|
||||||
var participantId = req.params.pid;
|
var participantId = req.params.pid;
|
||||||
Event.findById(eventId, function(err, event){
|
Event.findById(eventId, function(err, event){
|
||||||
if (err) return handleError(res, err);
|
if (err) return handleError(res, err);
|
||||||
|
event.updated = Date.now();
|
||||||
event.participants.pull({ '_id' : participantId });
|
event.participants.pull({ '_id' : participantId });
|
||||||
event.save(function(err, event){
|
event.save(function(err, event){
|
||||||
res.json(event);
|
res.json(event);
|
||||||
|
|
|
@ -10,6 +10,14 @@ var EventSchema = new Schema({
|
||||||
name : String,
|
name : String,
|
||||||
email : String
|
email : String
|
||||||
},
|
},
|
||||||
|
created : {
|
||||||
|
type : Date,
|
||||||
|
default : Date.now
|
||||||
|
},
|
||||||
|
updated : {
|
||||||
|
type : Date,
|
||||||
|
default : Date.now
|
||||||
|
},
|
||||||
title : String,
|
title : String,
|
||||||
dates : [Date],
|
dates : [Date],
|
||||||
emails : [String],
|
emails : [String],
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -2,20 +2,25 @@ angular.module('rallly')
|
||||||
.controller('EventCtrl', function($scope, $http, $state, Event, Participant){
|
.controller('EventCtrl', function($scope, $http, $state, Event, Participant){
|
||||||
var id = $state.params.id;
|
var id = $state.params.id;
|
||||||
$scope.event = Event.get({id:id});
|
$scope.event = Event.get({id:id});
|
||||||
$scope.deleteParticipant = function(participant){
|
$scope.delete = function(participant){
|
||||||
if (confirm("Are you sure you want to remove "+participant.name+"?")){
|
if (confirm("Are you sure you want to remove "+participant.name+"?")){
|
||||||
Participant.remove({ id : id , pid : participant._id }, function(event){
|
Participant.remove({ id : id , pid : participant._id }, function(event){
|
||||||
$scope.event = event;
|
$scope.event = event;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$scope.edit = function(index){
|
$scope.defaults = [];
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.update = function(participant){
|
$scope.update = function(participant){
|
||||||
Event.update({'_id':$scope.event.id}, $scope.event);
|
Event.update({'_id':$scope.event.id}, $scope.event);
|
||||||
}
|
}
|
||||||
|
$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){
|
$scope.save = function(participant){
|
||||||
var participant = new Participant(participant);
|
var participant = new Participant(participant);
|
||||||
|
|
|
@ -95,10 +95,10 @@
|
||||||
}
|
}
|
||||||
&.active {
|
&.active {
|
||||||
background:white;
|
background:white;
|
||||||
color: $red-clr;
|
color: $primary-clr;
|
||||||
&:after {
|
&:after {
|
||||||
opacity:1;
|
opacity:1;
|
||||||
background: rgba($red-clr,0.1);
|
background: rgba($primary-clr,0.1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&:active {
|
&:active {
|
||||||
|
|
|
@ -22,10 +22,14 @@
|
||||||
padding: em(10px);
|
padding: em(10px);
|
||||||
border-bottom:1px solid #ddd;
|
border-bottom:1px solid #ddd;
|
||||||
}
|
}
|
||||||
|
.event-poll-name {
|
||||||
|
padding: em(6px) em(11px);
|
||||||
|
display:inline-block;
|
||||||
|
}
|
||||||
.event-poll-user {
|
.event-poll-user {
|
||||||
text-align:left;
|
text-align:left;
|
||||||
font-size: em(14px);
|
font-size: em(14px);
|
||||||
padding: em(15px) em(10px);
|
padding: em(12px) em(10px);
|
||||||
img {
|
img {
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +43,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.event-poll-input {
|
||||||
|
padding:0;
|
||||||
|
}
|
||||||
.event-poll-participants {
|
.event-poll-participants {
|
||||||
text-align:left;
|
text-align:left;
|
||||||
padding:0 em(10px);
|
padding:0 em(10px);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
.form-success-url {
|
.form-success-url {
|
||||||
font-size: em(36px);
|
font-size: em(36px);
|
||||||
text-align:center;
|
text-align:center;
|
||||||
|
padding: em(10px);
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
border: 1px solid #eee;
|
border: 1px solid #eee;
|
||||||
color: $text-clr;
|
color: $text-clr;
|
||||||
|
|
|
@ -5,6 +5,12 @@
|
||||||
<li class="event-created-by">
|
<li class="event-created-by">
|
||||||
Created by <a href="{{event.creator.email}}">{{event.creator.name}}</a>
|
Created by <a href="{{event.creator.email}}">{{event.creator.name}}</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
Created on {{event.created | date : 'short'}}
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Last updated {{event.updated | date : 'short'}}
|
||||||
|
</li>
|
||||||
<li ng-show="event.location" class="event-location">
|
<li ng-show="event.location" class="event-location">
|
||||||
{{event.location}}
|
{{event.location}}
|
||||||
</li>
|
</li>
|
||||||
|
@ -37,7 +43,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th width="160">
|
||||||
|
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -47,7 +53,7 @@
|
||||||
<td class="event-poll-user">
|
<td class="event-poll-user">
|
||||||
<img src="/images/user_gray@2x.png" width="11" />
|
<img src="/images/user_gray@2x.png" width="11" />
|
||||||
<input type="text" class="form-control" ng-model="participant.name" ng-show="editMode" value="participant.name"/>
|
<input type="text" class="form-control" ng-model="participant.name" ng-show="editMode" value="participant.name"/>
|
||||||
<span ng-hide="editMode">{{participant.name}}</span>
|
<span ng-hide="editMode" class="event-poll-name">{{participant.name}}</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="center" ng-repeat="date in event.dates">
|
<td class="center" ng-repeat="date in event.dates">
|
||||||
<img src="/images/tick@2x.png" width="16" ng-hide="editMode" ng-if="participant.dates[$index]" />
|
<img src="/images/tick@2x.png" width="16" ng-hide="editMode" ng-if="participant.dates[$index]" />
|
||||||
|
@ -55,9 +61,10 @@
|
||||||
<input ng-model="participant.dates[$index]" ng-show="editMode" ng-false-value="false" type="checkbox" />
|
<input ng-model="participant.dates[$index]" ng-show="editMode" ng-false-value="false" type="checkbox" />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a ng-hide="editMode" href="javascript:" ng-click="editMode = true; edit($index)" class="btn btn-primary">Edit</a>
|
<a ng-hide="editMode" href="javascript:" ng-click="editMode = true; edit(participant)" class="btn-primary">Edit</a>
|
||||||
<a ng-show="editMode" href="javascript:" ng-click="editMode = false; update(participant)" class="btn btn-primary">Save</a>
|
<a ng-hide="editMode" href="javascript:" ng-click="delete(participant)" class="btn-primary">Delete</a>
|
||||||
|
<a ng-show="editMode" href="javascript:" ng-click="editMode = false; update(participant)" class="btn-primary">Save</a>
|
||||||
|
<a ng-show="editMode" href="javascript:" ng-click="editMode = false; cancel($index)" class="btn-primary">Cancel</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="event-poll-input">
|
<tr class="event-poll-input">
|
||||||
|
|
Loading…
Add table
Reference in a new issue