Commit f8d35629 authored by alexandre's avatar alexandre

duplicate scores

parent 6ec6a3ab
......@@ -612,6 +612,8 @@ window.W = window.W || {};
triggers: {
'click .save': 'save',
'click .delete': 'delete',
'click .duplicate': 'duplicate',
'blur #title': 'editTextProperty',
'blur #stage_set': 'editTextProperty',
'click .mode': 'setEdit',
......@@ -655,6 +657,33 @@ window.W = window.W || {};
this.model.save();
},
onDelete: function(view, event) {
console.log("ok");
var r = confirm("Vous êtes sur le point de supprimer la partition intitulée \"" + this.model.get("title") + "\". Continuer?");
if (r) {
this.model.destroy({
success: function() {
Backbone.history.navigate('/', {
trigger: true
});
}
});
}
},
onDuplicate: function(view, event) {
var newModel = this.model.clone();
newModel.save({
title: newModel.get("title") + " (copy)",
}, {
success: function() {
Backbone.history.navigate('/' + newModel.id, {
trigger: true
});
}
});
},
onRender: function() {
var mainline = this.model.get("mainline");
......@@ -762,13 +791,42 @@ window.W = window.W || {};
W.ListItemView = Backbone.Marionette.View.extend({
tagName: 'li',
template: '#list-item-template'
template: '#list-item-template',
triggers: {
"click .delete": "delete",
"click .duplicate": "duplicate"
},
onDelete: function(view, event) {
console.log("ok");
var r = confirm("Vous êtes sur le point de supprimer la partition intitulée \"" + this.model.get("title") + "\". Continuer?");
if (r) {
this.model.destroy();
}
},
onDuplicate: function(view, event) {
var newModel = this.model.clone();
newModel.save({
title: newModel.get("title") + " (copy)",
}, {
success: function() {
Backbone.history.navigate('/' + newModel.id, {
trigger: true
});
}
});
}
});
W.ListView = Backbone.Marionette.CollectionView.extend({
tagName: 'ol',
collection: W.ScoreCollection,
childView: W.ListItemView,
initialize: function(options) {
......@@ -793,7 +851,7 @@ window.W = window.W || {};
title: title
}, {
success: function() {
Backbone.history.navigate('/' + myModel.id + '/edit/', {
Backbone.history.navigate('/' + myModel.id, {
trigger: true
});
}
......
<a href="<%= id %>"><%= title %></a> <a href="#" class="delete">(X)</a>
<a href="<%= id %>"><%= title %></a> (<a href="#" class="delete">supprimer</a>, <a href="#" class="duplicate">dupliquer</a>)
......@@ -6,6 +6,7 @@
</div>
<button class="save">Enregistrer</button>
<button class="delete">Supprimer</button>
<button class="duplicate">Dupliquer</button>
<button class="deplieTout">Tout déplier</button>
<div class="choix_mode">
<button class="mode_vue">Vue</button>
......
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