Commit 805a7b9e authored by gijs's avatar gijs
Browse files

Added 'emergency' export. Also switched the performance author and score author.

parent c88677ec
......@@ -13,6 +13,8 @@ body {
}
#sidebar {
flex: auto 0 0;
padding: 2em;
width: 300px;
......@@ -22,7 +24,7 @@ body {
}
#main-area {
flex: 1;
flex: auto 1 1;
display: flex;
flex-direction: column;
}
......
......@@ -58,6 +58,22 @@ window.W = window.W || {};
+ ':' + d.getMinutes();
}
// https://stackoverflow.com/questions/2897619/using-html5-javascript-to-generate-and-save-a-file#4551467
function download(filename, text) {
var a = document.createElement('a');
a.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
a.setAttribute('download', filename);
if (document.createEvent) {
var event = document.createEvent('MouseEvents');
event.initEvent('click', true, true);
a.dispatchEvent(event);
}
else {
a.click();
}
}
/**
* Instantiate with at least a label.
*/
......@@ -941,7 +957,7 @@ window.W = window.W || {};
},
onChangeScoreType: function (e) {
if (parseInt(this.fieldVal('score_type')) === 1) {
if (parseInt(this.fieldVal('score_type')) === 2) {
this.field('performance_author').prop('disabled', true);
} else {
this.field('performance_author').prop('disabled', false);
......@@ -952,8 +968,6 @@ window.W = window.W || {};
e.stopImmediatePropagation();
e.preventDefault();
console.log(this.getChildView('effectif').value());
var data = {
title: this.fieldVal('title'),
score_type: parseInt(this.fieldVal('score_type')),
......@@ -1009,7 +1023,8 @@ window.W = window.W || {};
'click .duplicate': 'duplicate',
'click .unfold': 'unfold',
'click .fold': 'fold',
'change @ui.expandLevel': 'expandUntill'
'change @ui.expandLevel': 'expandUntill',
'click [data-name="export"]': 'downloadAsJSON'
},
childViewEvents: {
......@@ -1182,6 +1197,10 @@ window.W = window.W || {};
onBeforeDestroy: function () {
$(window).off('beforeunload');
},
downloadAsJSON: function () {
download(this.model.get('title') + '-export.json', JSON.stringify(this.model.toJSON()));
}
});
......
......@@ -24,7 +24,7 @@
<!-- Performance author -->
<label>
<span class="label-text">Auteur de la perfomance:</span>
<input type="text" name="performance_author" value="<%= performance_author %>" <%= (score_type === 1) ? 'disabled' : '' %>>
<input type="text" name="performance_author" value="<%= performance_author %>" <%= (score_type === 2) ? 'disabled' : '' %>>
</label>
<!-- description -->
......
......@@ -33,14 +33,14 @@
} %>
</dd>
<% } %>
<% if (performance_author) { %>
<dt>Auteur de la performance</dt>
<dd><%= performance_author %></dd>
<% } %>
<% if (score_author && (score_type === 2 || score_type === 3)) { %>
<% if (score_author) { %>
<dt>Auteur de la partition</dt>
<dd><%= score_author %></dd>
<% } %>
<% if (performance_author && (score_type === 1 || score_type === 3)) { %>
<dt>Auteur de la performance</dt>
<dd><%= performance_author %></dd>
<% } %>
<% if (presentation) { %>
<dt>Présentation</dt>
<dd><%= presentation %></dd>
......@@ -80,6 +80,8 @@
<% } %>
</dl>
<button data-name="export">Export / back-up</button>
<form></form>
</header>
......
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