From aab3a7bd63c1a20c9561b629bfaf0690a2841728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 20 Jul 2017 19:36:14 +0200 Subject: [PATCH] Wizard: Support to prevent the "settings updated" dialog Subwizards might actually intentionally want to update stuff through the settings API, let's allow that. --- .../static/js/app/viewmodels/wizard.js | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/octoprint/static/js/app/viewmodels/wizard.js b/src/octoprint/static/js/app/viewmodels/wizard.js index 5bdccede..a1370215 100644 --- a/src/octoprint/static/js/app/viewmodels/wizard.js +++ b/src/octoprint/static/js/app/viewmodels/wizard.js @@ -192,9 +192,25 @@ $(function() { self.onSettingsPreventRefresh = function() { if (!self.finishing && self.isDialogActive() && hasDataChanged(self.settingsViewModel.getLocalData(), self.settingsViewModel.lastReceivedSettings)) { + var preventSettingsRefreshDialog = false; + callViewModels(allViewModels, "onWizardPreventSettingsRefreshDialog", function(method) { + // if any of our methods returns that it wants to prevent the dialog + // we'll need to set preventSettingsRefreshDialog to true + // + // order is important here - the method call needs to happen + // first, or it won't happen after the flag has been + // set once due to the || making further evaluation unnecessary + // then + preventSettingsRefreshDialog = (method() === true) || preventSettingsRefreshDialog; + }); + // we have local changes, show update dialog - self.settingsViewModel.settingsUpdatedDialog.modal("show"); - return true; + if (preventSettingsRefreshDialog) { + return false; + } else { + self.settingsViewModel.settingsUpdatedDialog.modal("show"); + return true; + } } return false;