Commit 17e8459b authored by alexandre's avatar alexandre
Browse files

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

parents e6543bfe 2a69cd79
......@@ -339,6 +339,14 @@ li li li li li li .axis-title { color: rgb(144,103,167); }
li li li li li li li .axis-title { color: rgb(171,104, 87); }
li li li li li li li li .axis-title { color: rgb(204,194, 16); }
li form { color: rgb(114,147,203); }
li li form { color: rgb(225,151, 76); }
li li li form { color: rgb(132,186, 91); }
li li li li form { color: rgb(211, 94, 96); }
li li li li li form { color: rgb(128,133,133); }
li li li li li li form { color: rgb(144,103,167); }
li li li li li li li form { color: rgb(171,104, 87); }
li li li li li li li li form { color: rgb(204,194, 16); }
/* axe contingent : le nom de l’axe est barré */
/* .axis-title-view + ol li[data-contingent="true"] > .axis-title > .axis-title-edit { */
......@@ -426,6 +434,14 @@ li li li li li li li li .axis-title { color: rgb(204,194, 16); }
top: 0px;
}
.axis-inline-title-form {
display: inline-block;
}
.axis-inline-title-form [data-name="close"] {
margin-left: 3em;
}
li + li > .axis-title #alt_symbole { display: none; }
input[type="text"] {
......
......@@ -309,6 +309,52 @@ window.W = window.W || {};
}
});
W.NodeInlineTitleForm = Backbone.Marionette.View.extend({
tagName: 'form',
className: 'axis-inline-title-form',
template: '#node-inline-form-template',
ui: {
'title': '[name="axis-inline-title"]',
'extraFields': '[name="axis-inline-title"]',
'submit': '[name="submit"]',
'close': '[data-name="close"]',
},
events: {
'submit': 'submit',
'keyup @ui.title': 'keyup',
'click @ui.submit': 'submit',
'click @ui.close': 'close',
},
onAttach: function () {
this.ui.title.select();
},
keyup: function (e) {
if (e.keyCode == 27) {
this.close();
}
},
close: function (e) {
this.trigger('inlinetitleform:close');
},
submit: function (e) {
e.stopImmediatePropagation();
e.preventDefault();
// Todo: merge boucle and alternative into one value / datatype:
// null | [number, number]
const data = this.ui.title.val().trim();
this.trigger('inlinetitleform:submit', data);
}
});
/**
* Detail page views
*/
......@@ -353,12 +399,18 @@ window.W = window.W || {};
form: {
el: 'form',
replaceElement: true
},
inlineTitleForm: {
el: '.axis-inline-title-form',
replaceElement: true
}
},
events: {
'dblclick @ui.title': 'toggleLineDblClick',
'click [name="toggle"]': 'toggleLine',
'click @ui.title': 'toggleClick',
'click @ui.titleSpan': 'titleClick',
'click [name="toggle"]': 'toggle',
'click [name="edit"]': 'toggleForm',
'click [name="add"]': 'addLine',
'click [name="delete"]': 'delete',
......@@ -370,6 +422,8 @@ window.W = window.W || {};
childViewEvents: {
'form:submit': 'update',
'form:close': 'toggleForm',
'inlinetitleform:submit': 'updateTitle',
'inlinetitleform:close': 'closeInlineForm'
},
childViewTriggers: {
......@@ -528,6 +582,28 @@ window.W = window.W || {};
}
},
showInlineForm: function () {
const form = new W.NodeInlineTitleForm({ model: this.model });
this.showChildView('inlineTitleForm', form);
this.ui.titleSpan.hide();
},
closeInlineForm: function () {
this.getRegion('inlineTitleForm').reset();
this.ui.titleSpan.show();
},
updateTitle: function (title) {
const changes = this.model.changedAttributes({ 'title': title });
if (changes) {
this.model.set('title', title);
this.trigger('change');
} else {
this.closeInlineForm();
}
},
// Triggered by jquery nested sortable when the item is
relocate: function (event, ui) {
var parentItem = this.$el.parent().closest("li");
......@@ -565,23 +641,35 @@ window.W = window.W || {};
// Todo: insert check to see whether there is more than one subline ?
e.stopImmediatePropagation();
// Todo: check cross-consistency of axis
var r = confirm("vous êtes sur le point de supprimer l’axe " + this.model.get('title') + " et tous ses sous-axes. Continuer?");
var r = confirm("Vous êtes sur le point de supprimer l’axe " + this.model.get('title') + " et tous ses sous-axes. Continuer?");
if (r) {
this.trigger('change');
this.model.destroy();
}
},
toggleLineDblClick: function (e) {
if (e.target == this.ui.title.get(0)
titleClick: function (e) {
e.stopImmediatePropagation();
e.preventDefault();
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) {
console.log('edit inline', 'alt: ', e.altKey, 'ctrl: ', e.ctrlKey, 'meta: ', e.metaKey, 'shift: ', e.shiftKey);
this.showInlineForm();
} else {
this.toggle();
}
},
toggleClick: function (e) {
if (e && e.target == this.ui.title.get(0)
|| e.target == this.ui.titleSpan.get(0)) {
e.stopImmediatePropagation();
e.preventDefault();
return this.toggleLine();
return this.toggle(e);
}
},
toggleLine: function (e) {
toggle: function (e) {
if (e) {
e.stopImmediatePropagation();
e.preventDefault();
......
......@@ -39,6 +39,10 @@
{% include "playground/underscore/node-form.mtpl" %}
</script>
<script id="node-inline-form-template" type="text/template">
{% include "playground/underscore/node-inline-form.mtpl" %}
</script>
<!-- Perhaps remove -->
<script id="rangefield-template" type="text/template">
{% include "playground/underscore/rangefield.mtpl" %}
......@@ -79,4 +83,4 @@
<script src="{% static 'playground/js/main.js' %}"></script>
</body>
</html>
</html>
\ No newline at end of file
<input type="text" name="axis-inline-title" value="<%- title %>" />
<input type="button" name="submit" value="save" />
<a data-name="close">cancel</a>
\ No newline at end of file
......@@ -34,6 +34,8 @@
<!-- More visible aleternative, bullet: &#8729; -->
</span>
<span class="axis-inline-title-form"></span>
<% if (adresse) { %>
<span class="adresse">
@<%= adresse %>
......@@ -105,17 +107,17 @@
</span>
<section class="axis-actions">
<button name="edit" title="Modifier ce axe">🖉</button>
<button name="add" title="Ajoute sous-axe">+</button>
<button name="delete" title="Efface ce axe (et sous-axes)">x</button>
<button name="edit" title="Modifier cet axe">🖉</button>
<button name="add" title="Ajoute un sous-axe">+</button>
<button name="delete" title="Supprimer cet axe (et tous ses sous-axes)">x</button>
<% if (sublines.length) { %>
<button name="toggle"></button>
<% } %>
</section>
<form></form>
</div>
<form></form>
<% if (sublines.length) { %>
<ol></ol>
<% } %>
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