From ea10b814d6377541ab84dc683795210aaa677edd Mon Sep 17 00:00:00 2001 From: Matt Scott Date: Mon, 10 Apr 2023 18:35:25 -0400 Subject: [PATCH] Working on implementing the jQuery Validation plugin for the authentication settings editor. --- .../js/app-authentication-settings-editor.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/powerdnsadmin/static/custom/js/app-authentication-settings-editor.js b/powerdnsadmin/static/custom/js/app-authentication-settings-editor.js index 0fa6aa2..27eac02 100644 --- a/powerdnsadmin/static/custom/js/app-authentication-settings-editor.js +++ b/powerdnsadmin/static/custom/js/app-authentication-settings-editor.js @@ -323,6 +323,26 @@ let AuthenticationSettingsModel = function (user_data, api_url, csrf_token, sele element.after(error); } }, + showErrors: function (errorMap, errorList) { + this.defaultShowErrors(); + let selectors = [ + 'input.error:not([disabled])', + 'select.error:not([disabled])', + 'textarea.error:not([disabled])', + ]; + let selector_query = selectors.join(','); + let tabs = target.find('.tab-content > *[data-tab]') + tabs.each(function (index, tab) { + tab = $(tab); + let tabId = tab.data('tab'); + let tabLink = target.find('.nav-tabs > li > a[data-tab="' + tabId + '"]'); + if (tab.find(selector_query).length > 0) { + tabLink.addClass('error'); + } else { + tabLink.removeClass('error'); + } + }); + }, rules: { local_db_enabled: 'auth_enabled', ldap_enabled: 'auth_enabled',