...
 
Commits (3)
This diff is collapsed.
......@@ -952,7 +952,9 @@ window.W = window.W || {};
rangeType: rangeType,
isLink: (this.link) ? true : false,
hasSublines: hasSublines,
hasAttachment: hasAttachment
hasAttachment: hasAttachment,
sublineAlternative: this.getAltSymbol(),
sublineTag: (hasSublines) ? this.model.get('sublines').first().get('tag') : ''
}
},
......@@ -962,7 +964,9 @@ window.W = window.W || {};
},
regions: {
tree: { el: '.sublines'
tree: {
el: '.sublines',
replaceElement: true
},
form: {
......@@ -1062,6 +1066,25 @@ window.W = window.W || {};
},
getAltSymbol: function () {
var alternative = this.model.get("alternative");
if (alternative) {
if (alternative.type === rangeType.undetermined) {
return "indéterminé";
} else if (alternative.type === rangeType.exact) {
return alternative.value;
} else if (alternative.type === rangeType.minimal) {
return alternative.value + "+";
} else if (alternative.type === rangeType.range) {
return alternative.value[0] + "-" + alternative.value[1];
}
}
return "";
},
/**
* Adapter function between old and new alternative field
* temporary
......@@ -1253,10 +1276,11 @@ window.W = window.W || {};
// Triggered by a subline view beeing relocated
relocateChild: function (event, model, index) {
if (valid_move(model, this.model)) {
model.get("parent").get("sublines").remove(model);
var previous_parent = model.get("parent");
previous_parent.get("sublines").remove(model);
this.model.get("sublines").add(model, { at: index });
this.render();
previous_parent.trigger('change');
this.model.trigger('change');
this.trigger('change');
var alts;
......@@ -1396,6 +1420,7 @@ window.W = window.W || {};
this.$el.attr("data-module", this.model.get("module_"));
this.$el.attr("data-contingent", this.model.get("contingent"));
this.$el.attr("data-id", this.model.get("id"));
this.$el.attr("id", this.model.get("id"));
var sublines = this.model.get("sublines");
......@@ -1404,6 +1429,8 @@ window.W = window.W || {};
var sublinesView = new W.TreeView({ collection: sublines });
this.$el.attr("data-sublines", "true");
this.showChildView('tree', sublinesView);
} else {
this.$el.attr("data-sublines", "false");
}
this.renderAttachmentView();
......@@ -1471,8 +1498,8 @@ window.W = window.W || {};
});
W.TreeView = Marionette.CollectionView.extend({
template: '#node-tree-template',
childViewContainer: 'ol',
className: 'sublines',
tagName: 'ol',
initialize: function () {
this.listenTo(this.collection, 'change:tag', this.updateTag);
......@@ -1960,7 +1987,6 @@ window.W = window.W || {};
return true;
},
relocate: function (_, ui) {
/*
* When the sort action is over:
......
......@@ -97,9 +97,16 @@
</span>
<form></form>
<div class="sublines__metadata__wrapper">
<div class="sublines__metadata" data-tag="<%- sublineTag %>" <%= (sublineAlternative != "") ? 'data-alternative="' + sublineAlternative + '"' : '' %>>
<span class="tag" data-tag="<%- sublineTag %>"></span>
<% if (sublineAlternative != "") { %>
<span class="alternative"><%- sublineAlternative %></span>
<% } %>
</div>
</div>
</header>
<% if (sublines.length) { %>
<section class="sublines"></section>
<% } %>
<ol class="sublines"></ol>
{% endspaceless %}