Keep "Load and print" button enabled when file is selected

Some users get confused by having to use the blue "Print" button in
the state panel for consecutive prints of the same model, let's solve
this once and for all.
This commit is contained in:
Gina Häußge 2017-04-12 19:04:45 +02:00
parent 0f6edabea3
commit 2a7cebfe55
2 changed files with 18 additions and 8 deletions

View file

@ -395,14 +395,21 @@ $(function() {
}
};
self.loadFile = function(file, printAfterLoad) {
if (!file) {
self.loadFile = function(data, printAfterLoad) {
if (!data) {
return;
}
var withinPrintDimensions = self.evaluatePrintDimensions(file, true);
var print = printAfterLoad && withinPrintDimensions;
OctoPrint.files.select(file.origin, file.path, print);
if (printAfterLoad && self.listHelper.isSelected(data) && self.enablePrint(data)) {
// file was already selected, just start the print job
OctoPrint.job.start();
} else {
// select file, start print job (if requested and within dimensions)
var withinPrintDimensions = self.evaluatePrintDimensions(data, true);
var print = printAfterLoad && withinPrintDimensions;
OctoPrint.files.select(data.origin, data.path, print);
}
};
self.removeFile = function(file, event) {
@ -545,8 +552,11 @@ $(function() {
};
self.enableSelect = function(data, printAfterSelect) {
var isLoadActionPossible = self.loginState.isUser() && self.isOperational() && !(self.isPrinting() || self.isPaused() || self.isLoading());
return isLoadActionPossible && !self.listHelper.isSelected(data);
return self.enablePrint(data) && !self.listHelper.isSelected(data);
};
self.enablePrint = function(data) {
return self.loginState.isUser() && self.isOperational() && !(self.isPrinting() || self.isPaused() || self.isLoading());
};
self.enableSlicing = function(data) {

View file

@ -21,7 +21,7 @@
<a class="btn btn-mini" data-bind="attr: {href: $root.downloadLink($data)}, css: {disabled: !$root.downloadLink($data)}" title="{{ _('Download') }}"><i class="icon-download-alt"></i></a>
<div class="btn btn-mini" data-bind="click: function(data, event) { if ($root.enableRemove($data)) { $root.removeFile($data, event); } else { return; } }, css: {disabled: !$root.enableRemove($data)}" title="{{ _('Remove') }}"><i class="icon-trash"></i></div>
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableSelect($data)) { $root.loadFile($data, false); } else { return; } }, css: {disabled: !$root.enableSelect($data)}" title="{{ _('Load') }}"><i class="icon-folder-open"></i></div>
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableSelect($data)) { $root.loadFile($data, true); } else { return; } }, css: {disabled: !$root.enableSelect($data)}" title="{{ _('Load and Print') }}"><i class="icon-print"></i></div>
<div class="btn btn-mini" data-bind="click: function() { if ($root.enablePrint($data)) { $root.loadFile($data, true); } else { return; } }, css: {disabled: !$root.enablePrint($data)}" title="{{ _('Load and Print') }}"><i class="icon-print"></i></div>
</div>
</script>