Commit 0cbfa759 authored by Nicolas's avatar Nicolas

Merge branch 'master' of gitlab.constantvzw.org:osp/work.w

parents 81409100 e52c1a77
......@@ -11,7 +11,10 @@ window.W = window.W || {};
var router = new W.ScoreRouter();
/** Starts the URL handling framework */
Backbone.history.start();
Backbone.history.start({
pushState: true,
root: '/playground/score/'
});
}
});
})();
......@@ -6,6 +6,13 @@ window.W = window.W || {};
(function(undefined) {
'use strict';
W.ScoreCollection = Backbone.Collection.extend({
url: '/api/scores/',
model: W.ScoreModel
});
W.LineCollection = Backbone.Collection.extend({
model: W.LineModel
});
......
......@@ -7,12 +7,18 @@ window.W = window.W || {};
'use strict';
W.ScoreController = {
editScore: function(id) {
var params = {}
if (id) {params.id = id}
var myBaseView = new W.BaseView(params);
scoreList: function() {
var myListView = new W.ScoreListView();
myListView.render();
},
scoreCreate: function() {
var myBaseView = new W.BaseView();
myBaseView.render();
},
scoreView: function(id) {
},
scoreEdit: function(id) {
var myBaseView = new W.BaseView({id: id});
myBaseView.render();
}
};
......
......@@ -10,7 +10,10 @@ window.W = window.W || {};
controller: W.ScoreController,
appRoutes: {
'(:id)': 'editScore',
'': 'scoreList',
'create/': 'scoreCreate',
'(:id)/edit/': 'scoreEdit',
'(:id)/view/': 'scoreView',
},
});
})();
......@@ -577,4 +577,66 @@ window.W = window.W || {};
});
}
});
W.ListItemView = Backbone.Marionette.View.extend({
tagName: 'li',
template: '#list-item-template'
});
W.ListView = Backbone.Marionette.CollectionView.extend({
tagName: 'ol',
collection: W.ScoreCollection,
childView: W.ListItemView,
initialize: function(options) {
this.listenTo(this.collection, 'sync', this.render);
},
});
W.CreateView = Backbone.Marionette.View.extend({
template: '#create-template',
triggers: {
'submit .create-form': 'create'
},
onCreate: function(event) {
var title = this.$el.find('[name="title"]').val();
var myModel = new W.ScoreModel();
myModel.save({title: title}, {success: function() {
Backbone.history.navigate('/' + myModel.id + '/edit/', {trigger: true});
}});
},
});
W.ScoreListView = Backbone.Marionette.View.extend({
el: "body",
template: '#score-list-template',
regions: {
list: '#list',
create: '#create'
},
onRender: function() {
var scoreCollection = new W.ScoreCollection();
var myListView = new W.ListView({collection: scoreCollection});
var myCreateView = new W.CreateView();
var that = this;
myListView.collection.fetch({
success: function() {
that.showChildView('list', myListView);
that.showChildView('create', myCreateView);
}
});
}
});
})();
......@@ -11,6 +11,26 @@
<link rel="stylesheet" href="http://meyerweb.com/eric/tools/css/reset/reset.css">
<link rel="stylesheet" href="{% static 'playground/css/styles.css' %}">
<script id="score-list-template" type="text/template">
<div id="list"></div>
<div id="create"></div>
</script>
<script id="create-template" type="text/template">
<form class="create-form" action="" method="post">
<input type="text" name="title" placeholder="title" required>
<input type="submit" name="submit" value="create">
</form>
</script>
<script id="list-item-template" type="text/template">
<a href="<%= id %>/edit/"><%= title %></a>
</script>
<script id="score-edit-template" type="text/template">
ici le template pour lire les partitions
</script>
<script id="score-template" type="text/template">
<header>
<div class="home"><a href="../">index</a></div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment