From 2a7cebfe555f6ebe1a070df23a37ff6de777928c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 12 Apr 2017 19:04:45 +0200 Subject: [PATCH] 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. --- .../static/js/app/viewmodels/files.js | 24 +++++++++++++------ src/octoprint/templates/sidebar/files.jinja2 | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/octoprint/static/js/app/viewmodels/files.js b/src/octoprint/static/js/app/viewmodels/files.js index 75bb00926..6ff1fdf0e 100644 --- a/src/octoprint/static/js/app/viewmodels/files.js +++ b/src/octoprint/static/js/app/viewmodels/files.js @@ -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) { diff --git a/src/octoprint/templates/sidebar/files.jinja2 b/src/octoprint/templates/sidebar/files.jinja2 index 3fde22c9e..99b199df8 100644 --- a/src/octoprint/templates/sidebar/files.jinja2 +++ b/src/octoprint/templates/sidebar/files.jinja2 @@ -21,7 +21,7 @@
-
+