Browse Source

Initially disable load/save scoria functions to guide the user to a less surprising path

main
Tissevert 8 months ago
parent
commit
0c07e74293
3 changed files with 26 additions and 20 deletions
  1. +2
    -2
      index.html
  2. +3
    -1
      js/Toolbar/Page.js
  3. +21
    -17
      js/View.js

+ 2
- 2
index.html View File

@ -14,8 +14,8 @@
<ul>
<li id="loadALTO">Charger des fichiers ALTO</li>
<li id="saveALTO" class="disabled">Exporter la page courante modifiée</li>
<li id="loadScoria">Importer des scories</li>
<li id="saveScoria">Exporter les scories</li>
<li id="loadScoria" class="disabled">Importer des scories</li>
<li id="saveScoria" class="disabled">Exporter les scories</li>
</ul>
</div><div id="help" class="menu">
<span>Aide</span>


+ 3
- 1
js/Toolbar/Page.js View File

@ -17,7 +17,9 @@ GUI.loadALTO.addEventListener('click', function() {
GUI.fileNumber.value = 0;
syncNumber();
updateNumber();
GUI.saveALTO.classList.remove('disabled');
['loadScoria', 'saveScoria', 'saveALTO'].forEach(function(elem) {
GUI[elem].classList.remove('disabled');
});
return Async.wrap();
}
)


+ 21
- 17
js/View.js View File

@ -54,20 +54,22 @@ function scale(o) {
}
function importScoria() {
Async.run(
Async.bind(
File.pick({accept:"text/csv,.csv", multiple: true}),
function(input) {
var loaders = [];
for(var i = 0; i < input.files.length; i++) {
loaders.push(File.load(input.files[i]));
}
return Async.parallel.apply(null, loaders);
},
Async.map(setFromFiles),
Async.map(refresh)
)
);
if(!GUI.loadScoria.classList.contains('disabled')) {
Async.run(
Async.bind(
File.pick({accept:"text/csv,.csv", multiple: true}),
function(input) {
var loaders = [];
for(var i = 0; i < input.files.length; i++) {
loaders.push(File.load(input.files[i]));
}
return Async.parallel.apply(null, loaders);
},
Async.map(setFromFiles),
Async.map(refresh)
)
);
}
}
function setFromFiles(files) {
@ -79,7 +81,9 @@ function setFromFiles(files) {
}
function exportScoria() {
var column = ['ID'].concat(Scoria.getScoriae());
var data = 'data:text/csv,' + encodeURIComponent(column.join('\n'));
File.save(data, 'scoria.csv');
if(!GUI.saveScoria.classList.contains('disabled')) {
var column = ['ID'].concat(Scoria.getScoriae());
var data = 'data:text/csv,' + encodeURIComponent(column.join('\n'));
File.save(data, 'scoria.csv');
}
}

Loading…
Cancel
Save