Commit 7fab61cc authored by alexandre's avatar alexandre

Now you can delete partitions

parent f516669e
......@@ -86,15 +86,17 @@ window.W = window.W || {};
relocateChild: function(event, model, index) {
model.get("parent").get("sublines").remove(model);
this.model.get("sublines").add(model, {at: index});
this.model.get("sublines").add(model, {
at: index
});
console.log("relocate", model.get("parent").get("alternative_mode"));
var alts;
if(model.get("parent").get("alternative_mode")){
if (model.get("parent").get("alternative_mode")) {
alts = "V" + model.get("parent").get('alternative_n') + "-" + model.get("parent").get('alternative_p');
if(model.get("parent").get("alternative_mode") == "exclusive"){
alts = "V"+model.get("parent").get('alternative_p');
if (model.get("parent").get("alternative_mode") == "exclusive") {
alts = "V" + model.get("parent").get('alternative_p');
}
model.set('alternative_symbole',alts);
model.set('alternative_symbole', alts);
}
return false;
},
......@@ -231,7 +233,9 @@ window.W = window.W || {};
});
var num = alt_p;
//exception: si la condition est alt p et alt n = 1 il faut un sous-axe de plus pour définir l'axe
if(alt_p == 1){num++;}
if (alt_p == 1) {
num++;
}
this.addLinesAlternative(num, alt_symbole);
alt_div.hide();
this.render();
......@@ -307,7 +311,7 @@ window.W = window.W || {};
editTimeSequence: function(e) {
if(W.edit_mode){
if (W.edit_mode) {
var $target = $(e.target);
var boucle_div = $target.parent().parent().find('.boucle-infos');
boucle_div.show();
......@@ -412,10 +416,10 @@ window.W = window.W || {};
var title = "Sous axe " + incr;
var title2 = "Sous axe " + (incr + 1);
var alts = '';
if(this.model.get("alternative_mode")){
if (this.model.get("alternative_mode")) {
alts = "V" + this.model.get('alternative_n') + "-" + this.model.get('alternative_p');
if(this.model.get("alternative_mode") == "exclusive"){
alts = "V"+this.model.get('alternative_p');
if (this.model.get("alternative_mode") == "exclusive") {
alts = "V" + this.model.get('alternative_p');
}
}
if (sublines.length == 0) {
......@@ -427,7 +431,7 @@ window.W = window.W || {};
} else {
sublines.add({
title: title,
alternative_symbole : alts
alternative_symbole: alts
});
}
......@@ -552,11 +556,11 @@ window.W = window.W || {};
//console.log(this.$el);
if (!hasparent) {
this.$el.find(".el_tag").addClass("invis_root");
}else if(hasparent.get("alternative_mode") == "exclusive"){
} else if (hasparent.get("alternative_mode") == "exclusive") {
console.log("exclusive");
this.$el.find(".tag").removeClass("vis");
this.$el.find(".tag").addClass("invis");
}else{
} else {
this.$el.find(".tag").removeClass("invis");
this.$el.find(".tag").addClass("vis");
}
......@@ -611,6 +615,7 @@ window.W = window.W || {};
triggers: {
'click .save': 'save',
'click .delete': 'delete',
'blur #title': 'editTextProperty',
'blur #stage_set': 'editTextProperty',
'click .mode': 'setEdit',
......@@ -654,6 +659,20 @@ 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
});
}
});
}
},
onRender: function() {
var mainline = this.model.get("mainline");
......@@ -761,7 +780,20 @@ window.W = window.W || {};
W.ListItemView = Backbone.Marionette.View.extend({
tagName: 'li',
template: '#list-item-template'
template: '#list-item-template',
triggers: {
"click .delete": "delete"
},
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();
}
}
});
......@@ -792,7 +824,7 @@ window.W = window.W || {};
title: title
}, {
success: function() {
Backbone.history.navigate('/' + myModel.id + '/edit/', {
Backbone.history.navigate('/' + myModel.id + '/', {
trigger: true
});
}
......
......@@ -24,7 +24,7 @@
</script>
<script id="list-item-template" type="text/template">
<a href="<%= id %>"><%= title %></a>
<a href="<%= id %>"><%= title %></a> <a href="#" class="delete">(X)</a>
</script>
<script id="score-edit-template" type="text/template">
......@@ -37,6 +37,7 @@
<h1 contenteditable="true" id="title"><%- title %></h1>
<div contenteditable="true" id="stage_set" ><%= stage_set %></div>
<button class="save">Enregistrer</button>
<button class="delete">Supprimer</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