Commit 4eac9336 authored by gijs's avatar gijs

Fixes to the score form. When axis are marked alternative when they were not...

Fixes to the score form. When axis are marked alternative when they were not all children will be marked contingent
parent 9ed9f047
......@@ -176,6 +176,12 @@ button, submit, reset {
margin-top: .15em;
}
select:disabled, input:disabled {
color: var(--button-color-disabled) !important;
border-color: var(--button-color-disabled) !important;
opacity: .75;
}
button:hover, submit:hover, reset:hover { background: var(--background-color-button); }
button:active, submit:active, reset:active {
......@@ -759,7 +765,7 @@ li.axis { position: relative; }
.score__line {
padding-top: var(--axis-padding);
padding-bottom: var(--axis-padding);
/* padding-bottom: var(--axis-padding); */
}
.axis-row {
......@@ -1060,7 +1066,8 @@ li + li .alt-symbol { display: none; }
background: var(--row-color);
}
.sublines__metadata[data-alternative="1"] > .tag {
.sublines__metadata[data-alternative="1"] > .tag,
.sublines__metadata[data-show-tag="false"] > .tag {
visibility: hidden;
}
......@@ -1363,14 +1370,17 @@ li + li .alt-symbol { display: none; }
========================================================================== */
.axis-edit-form {
position: relative;
border-width: 2px;
position: absolute;
top: 3.5em;
border-width: 3px;
border-style: solid;
background: var(--background-color);
box-shadow: 8px 8px 1px var(--background-color);
margin-bottom: 1em;
margin-top: .75em;
padding: .5em;
min-width: 550px;
z-index: 3;
}
/* subaxis colors, according to the level of nesting */
......
......@@ -694,9 +694,9 @@ window.W = window.W || {};
events: {
'render': 'onRender',
'keydown': 'keydown',
'click @ui.extraFields legend': 'toggleExtraFields',
'click @ui.submit': 'submit',
'change [name="aspect"]': 'toggleAspect',
'click @ui.submit': 'submit'
},
triggers: {
......@@ -704,6 +704,18 @@ window.W = window.W || {};
'click @ui.link': 'form:makeLink'
},
keydown: function (e) {
if (e.keyCode == 27) {
e.preventDefault();
this.trigger('form:close');
}
if (e.keyCode == 13 && e.target.tagName != 'TEXTAREA') {
e.preventDefault();
this.submit();
}
},
templateContext: function () {
return {
aspectChoices: ["duratif", "itératif", "sémelfactif"],
......@@ -758,8 +770,6 @@ window.W = window.W || {};
},
onRender: function () {
this.toggleAspect();
this.renderAlternative();
this.renderBoucle();
this.renderAttachment(this.model.get('attachment'));
......@@ -802,15 +812,6 @@ window.W = window.W || {};
});
},
/**
* Check whether the aspect checkbox is checked, dis- / enable subfields
*/
toggleAspect: function (e) {
if (e) e.stopImmediatePropagation();
var active = this.isChecked('aspect');
this.field('aspect-value').prop('disabled', !active);
},
/**
* Return input field with name
*/
......@@ -849,8 +850,10 @@ window.W = window.W || {};
},
submit: function (e) {
e.stopImmediatePropagation();
e.preventDefault();
if (e) {
e.stopImmediatePropagation();
e.preventDefault();
}
// Todo: merge boucle and alternative into one value / datatype:
// null | [number, number]
......@@ -866,7 +869,7 @@ window.W = window.W || {};
'contingent': this.isChecked('contingent'),
'boucle': this.getChildView('boucle').value(),
'alternative': this.getChildView('alternative').value(),
'aspect': (this.isChecked('aspect')) ? this.fieldVal('aspect-value') : null,
'aspect': this.fieldVal('aspect-value'),
'commandement': this.fieldVal('commandement'),
'destination': this.fieldVal('destination'),
'code': this.fieldVal('code'),
......@@ -948,7 +951,7 @@ window.W = window.W || {};
alternativeChoices: ["inclusive", "exclusive"],
tagChoices: tags,
hasIndications: this.hasIndications(),
showTag: this.showTag(),
showTag: (this.showTag()) ? 'true' : 'false',
rangeType: rangeType,
isLink: (this.link) ? true : false,
hasSublines: hasSublines,
......@@ -1156,21 +1159,15 @@ window.W = window.W || {};
* in exclusive alternative.
*/
showTag: function () {
var parent = this.model.get('parent');
if (parent) {
var parent_alternative = parent.get('alternative');
var sublineCount = parent.get('sublines').models.length;
var sublines = this.model.get('sublines');
if ((parent_alternative
&& parent_alternative.type === rangeType.exact
&& parent_alternative.value === 1)
|| (sublineCount === 1)) {
if (sublines && sublines.length > 1) {
var alternative = this.model.get('alternative');
if (alternative && alternative.type === rangeType.exact) {
return false;
}
else {
return true;
}
return true;
}
return false;
......@@ -1215,6 +1212,14 @@ window.W = window.W || {};
this.model.addSubLine();
}
// The line wasn't alternative. Set all children to contingent
if (!this.model.get('alternative')) {
var sublines = this.model.get('sublines');
for(var i=0;i < sublines.length; i++) {
sublines.at(i).set('contingent', true)
}
}
this.expand();
}
......@@ -1315,7 +1320,9 @@ window.W = window.W || {};
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.get('parent').get('sublines').remove([this.model]);
var parent = this.model.get('parent');
parent.get('sublines').remove([this.model]);
parent.trigger('change');
// As models have id's Backbone tries to make a servercall to remove the item.
// this.model.destroy();
}
......@@ -1666,8 +1673,10 @@ window.W = window.W || {};
},
submit: function (e) {
e.stopImmediatePropagation();
e.preventDefault();
if (e) {
e.stopImmediatePropagation();
e.preventDefault();
}
// Cast tag value into a list
var tags = this.fieldVal('tags').trim();
......
<label><span class="label-text"><%- t('Titre') %></span><input type="text" name="title" ></label>
<label class="inline"><span class="label-text"><%- t('Pièce-jointe') %></span><input type="file" name="file" ></label>
<button class="inline">Switch to file link</button>
\ No newline at end of file
<label>
<span class="label-text"><%- t('Pièce-jointe') %></span>
<input type="text" name="title" placeholder="<%- t('Titre') %>" ></label>
</label>
<label>
<span class="label-text"></span>
<input type="file" name="file" class="inline">
<button class="inline"><%- t('Switch to link to external file') </button>
</label>
\ No newline at end of file
<label><span class="label-text"><%- t('Titre') %></span><input type="text" name="title" ></label>
<label class="inline"><span class="label-text"><%- t('Pièce-jointe') %></span><input type="text" name="url" ></label>
<button class="inline">Switch to file upload</button>
<label>
<span class="label-text"><%- t('Pièce-jointe') %></span>
<input type="text" name="title" placeholder="<%- t('Titre') %>" >
</label>
<label class="inline">
<span class="label-text"></span>
<input type="text" name="url" placeholder="URL">
<button class="inline"><%- t('Switch to file upload') %></button>
</label>
<label>
<span class="label-text"><%- t('Titre') %></span>
<input type="text" name="title" value="<%- title %>" />
</label>
<label class="inline">
<span class="label-text"><%- t('Pièce-jointe') %></span>
<a href="<%- attachment %>">Link</a>
</label>
<button class="inline">supprimer</delete>
\ No newline at end of file
<input type="text" name="title" value="<%- title %>" />
<button class="inline">supprimer</button>
</label>
\ No newline at end of file
......@@ -25,7 +25,8 @@
<label><span class="label-text js-help" data-href="#terme"><%- t('Terme') %></span>
<input type="text" name="terme" value="<%- terme %>">
</label>
</fieldset>
<fieldset>
<!-- boucle [subview] -->
<section data-name="boucle"></section>
......@@ -33,13 +34,11 @@
<section data-name="alternative"></section>
<!-- aspect -->
<section class="fieldgroup toggable">
<label class="inline">
<input type="checkbox" name="aspect" <% if (aspect) { %>checked<% } %>>
<%- t('aspect') %>
</label>
<section class="fieldgroup">
<label class="inline">
<span class="label-text"><%- t('aspect') %></span>
<select name="aspect-value">
<option value="" <% if (!aspect) { %>selected<% } %>><%- t('aucun') %></option>
<% _.each(aspectChoices, function(a) {%>
<option value="<%= a %>" <% if (aspect==a) { %>selected<% } %>><%= a %></option>
<% }); %>
......@@ -58,10 +57,12 @@
<input type="checkbox" name="module" <% if (module_) { %>checked<% } %>>
<%- t('axe modulé') %>
</label>
</fieldset>
<fieldset>
<!-- attachments -->
<section data-name="attachment"></section>
</fieldset>
<fieldset>
<!-- actant -->
<label><span class="label-text"><%- t('Actant') %></span>
<input type="text" name="actant" value="<%- actant %>">
......
......@@ -99,8 +99,8 @@
<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>
<div class="sublines__metadata" data-show-tag="<%- showTag %>" data-tag="<%- sublineTag %>" <%= (sublineAlternative != "") ? 'data-alternative="' + sublineAlternative + '"' : '' %>>
<span class="tag" data-tag="<%- sublineTag %>" data-show-tag="<%- showTag %>"></span>
<% if (sublineAlternative != "") { %>
<span class="alternative"><%- sublineAlternative %></span>
<% } %>
......
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