controller to add new event
This commit is contained in:
parent
0db7feb547
commit
bd5e73f62b
5 changed files with 51 additions and 10 deletions
|
@ -1,16 +1,24 @@
|
|||
<div class="container-fluid">
|
||||
<form ng-model="eventdetails" ng-submit="save()">
|
||||
<div class="input-group input-group-lg">
|
||||
<span class="input-group-addon" id="basic-addon1">Title</span>
|
||||
<input type="text" class="form-control" placeholder="Title" aria-describedby="basic-addon-2" value="{{event.title}}">
|
||||
<input type="text" class="form-control" placeholder="Title" aria-describedby="basic-addon-2" value="{{event.title}}" ng-model="event.title" ng-required="1">
|
||||
</div>
|
||||
|
||||
<div class="input-group top5">
|
||||
<span class="input-group-addon" id="basic-addon1">Short description</span>
|
||||
<input type="text" class="form-control" placeholder="The event in one sentence" aria-describedby="basic-addon1" value="{{event['short-description']}}" ng-model="event['short-description']">
|
||||
</div>
|
||||
|
||||
<div class="input-group top5">
|
||||
<span class="input-group-addon" id="basic-addon1">Begin time</span>
|
||||
<input type="text" class="form-control" placeholder="Date and time" aria-describedby="basic-addon1" value="{{event['begin-datetime']}}">
|
||||
<input type="text" class="form-control" placeholder="Date and time" aria-describedby="basic-addon1" value="{{event['begin-datetime']}}" ng-model="event['begin-datetime']">
|
||||
</div>
|
||||
|
||||
<div class="input-group top5">
|
||||
<span class="input-group-addon" id="basic-addon1">End time</span>
|
||||
<input type="text" class="form-control" placeholder="Date and time" aria-describedby="basic-addon1" value="{{event['end-datetime']}}">
|
||||
<input type="text" class="form-control" placeholder="Date and time" aria-describedby="basic-addon1" value="{{event['end-datetime']}}" ng-model="event['begin-endtime']">
|
||||
</div>
|
||||
<input type="submit" style="position: absolute; left: -9999px; width: 1px; height: 1px;"/>
|
||||
</form>
|
||||
</div>
|
||||
|
|
17
angular_app/js/app.js
vendored
17
angular_app/js/app.js
vendored
|
@ -4,6 +4,19 @@ var eventManApp = angular.module('eventManApp', [
|
|||
'eventManControllers'
|
||||
]);
|
||||
|
||||
eventManApp.directive('ngEnter', function () {
|
||||
return function (scope, element, attrs) {
|
||||
element.bind("keydown keypress", function (event) {
|
||||
if(event.which === 13) {
|
||||
scope.$apply(function (){
|
||||
scope.$eval(attrs.ngEnter);
|
||||
});
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
eventManApp.config(['$routeProvider',
|
||||
function($routeProvider) {
|
||||
$routeProvider.
|
||||
|
@ -11,7 +24,7 @@ eventManApp.config(['$routeProvider',
|
|||
templateUrl: 'persons-list.html',
|
||||
controller: 'PersonsListCtrl'
|
||||
}).
|
||||
when('/persons/:personID', {
|
||||
when('/persons/:id', {
|
||||
templateUrl: 'person-detail.html',
|
||||
controller: 'PersonDetailsCtrl'
|
||||
}).
|
||||
|
@ -19,7 +32,7 @@ eventManApp.config(['$routeProvider',
|
|||
templateUrl: 'events-list.html',
|
||||
controller: 'EventsListCtrl'
|
||||
}).
|
||||
when('/events/:eventID', {
|
||||
when('/events/:id', {
|
||||
templateUrl: 'event-detail.html',
|
||||
controller: 'EventDetailsCtrl'
|
||||
}).
|
||||
|
|
11
angular_app/js/controllers.js
vendored
11
angular_app/js/controllers.js
vendored
|
@ -22,7 +22,16 @@ eventManControllers.controller('EventsListCtrl', ['$scope', 'Event',
|
|||
|
||||
eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', '$routeParams',
|
||||
function ($scope, Event, $routeParams) {
|
||||
$scope.event = Event.get($routeParams);
|
||||
if ($routeParams.id) {
|
||||
$scope.event = Event.get($routeParams);
|
||||
}
|
||||
$scope.save = function() {
|
||||
if ($scope.event.id === undefined) {
|
||||
Event.save($scope.event);
|
||||
} else {
|
||||
Event.update($scope.event);
|
||||
}
|
||||
};
|
||||
}]
|
||||
);
|
||||
|
||||
|
|
9
angular_app/js/services.js
vendored
9
angular_app/js/services.js
vendored
|
@ -2,14 +2,15 @@ var eventManServices = angular.module('eventManServices', ['ngResource']);
|
|||
|
||||
eventManServices.factory('Event', ['$resource',
|
||||
function($resource) {
|
||||
return $resource('events/:eventID', {eventID: '@eventID'}, {
|
||||
return $resource('events/:id', {id: '@id'}, {
|
||||
all: {
|
||||
method: 'GET',
|
||||
isArray:true,
|
||||
isArray: true,
|
||||
transformResponse: function(data, headers) {
|
||||
return angular.fromJson(data).events;
|
||||
}
|
||||
}
|
||||
},
|
||||
update: {method: 'PUT'}
|
||||
});
|
||||
}]
|
||||
);
|
||||
|
@ -17,7 +18,7 @@ eventManServices.factory('Event', ['$resource',
|
|||
|
||||
eventManServices.factory('Person', ['$resource',
|
||||
function($resource) {
|
||||
return $resource('persons/:personID', {personID: '@personID'}, {
|
||||
return $resource('persons/:id', {id: '@id'}, {
|
||||
all: {
|
||||
method: 'GET',
|
||||
isArray:true,
|
||||
|
|
|
@ -79,6 +79,16 @@ class EventsHandler(BaseHandler):
|
|||
return
|
||||
self.write({'events': MOCKUP_EVENTS.values()})
|
||||
|
||||
@gen.coroutine
|
||||
def post(self, id_=None, **kwargs):
|
||||
data = self.request.body
|
||||
print 'aaaaaa', id_, data
|
||||
|
||||
@gen.coroutine
|
||||
def put(self, id_=None, **kwargs):
|
||||
data = self.request.body
|
||||
print 'aaaaaaa put', id_, data
|
||||
|
||||
|
||||
def main():
|
||||
define("port", default=5242, help="run on the given port", type=int)
|
||||
|
|
Loading…
Reference in a new issue