From 5079e7e891c2999db4fb01976e46da65772eb29f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 9 Sep 2019 12:54:03 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Clear=20user=20management=20dial?= =?UTF-8?q?ogs=20on=20close?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../static/js/app/viewmodels/users.js | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/octoprint/static/js/app/viewmodels/users.js b/src/octoprint/static/js/app/viewmodels/users.js index 14aa3840e..11658e161 100644 --- a/src/octoprint/static/js/app/viewmodels/users.js +++ b/src/octoprint/static/js/app/viewmodels/users.js @@ -38,25 +38,28 @@ $(function() { self.changePasswordDialog = undefined; self.currentUser.subscribe(function(newValue) { - if (newValue === undefined) { - self.editorUsername(undefined); - self.editorAdmin(undefined); - self.editorActive(undefined); - self.editorApikey(undefined); - } else { + self.resetEditUser(); + if (newValue !== undefined) { self.editorUsername(newValue.name); self.editorAdmin(newValue.admin); self.editorActive(newValue.active); self.editorApikey(newValue.apikey); } - self.editorPassword(undefined); - self.editorRepeatedPassword(undefined); }); self.editorPasswordMismatch = ko.pureComputed(function() { return self.editorPassword() !== self.editorRepeatedPassword(); }); + self.resetEditUser = function() { + self.editorUsername(undefined); + self.editorAdmin(undefined); + self.editorActive(undefined); + self.editorApikey(undefined); + self.editorPassword(undefined); + self.editorRepeatedPassword(undefined); + }; + self.requestData = function() { if (!CONFIG_ACCESS_CONTROL) return; if (!self.loginState.isAdmin()) return; @@ -178,8 +181,19 @@ $(function() { self.onStartup = function() { self.addUserDialog = $("#settings-usersDialogAddUser"); + self.addUserDialog.on("hidden", function() { + self.resetEditUser(); + }); + self.editUserDialog = $("#settings-usersDialogEditUser"); + self.editUserDialog.on("hidden", function() { + self.resetEditUser(); + }); + self.changePasswordDialog = $("#settings-usersDialogChangePassword"); + self.changePasswordDialog.on("hidden", function() { + self.resetEditUser(); + }); }; //~~ API calls