-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
58 lines (48 loc) · 1.19 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
window.App = Ember.Application.create({
});
App.Movie = DS.Model.extend({
title: DS.attr('string')
});
App.Router.map(function() {
this.resource('movies');
this.resource('movie', { path: '/movies/:movie_id' });
});
App.MoviesRoute = Ember.Route.extend({
model: function() {
return this.store.findAll('movie');
}
});
App.MoviesController = Ember.ArrayController.extend({
movieName: null,
actions: {
createMovie: function() {
var newMovie = this.store.createRecord('movie', {
title: this.get('movieName')
});
this.set('movieName', '');
newMovie.save();
}
}
});
App.MovieController = Ember.ObjectController.extend({
actions: {
editTitle: function() {
var newTitle = prompt("Enter new title");
var movie = this.get('model');
movie.set('title', newTitle);
movie.save();
},
deleteMovie: function() {
var controller = this;
var movie = this.get('model');
movie.deleteRecord();
movie.save().then(function() {
controller.transitionToRoute('movies');
});
}
}
});
App.ApplicationAdapter = DS.Neo4jAdapter.extend({
});
App.ApplicationSerializer = DS.Neo4jSerializer.extend({
});