Skip to content
Snippets Groups Projects
Commit af9ef0de authored by L N's avatar L N Committed by Yas Naoi
Browse files

Issue #3402301 by nakamurarts, yas: Refactor to native JavaScript from jQuery...

Issue #3402301 by nakamurarts, yas: Refactor to native JavaScript from jQuery (k8s_all_resources.js)
parent c6e4f7c4
No related branches found
No related tags found
1 merge request!2123Issue #3386224 by asai.noriaki, yas: Fix an issue where clicking an OpenStack...
(function ($) {
(function () {
'use strict';
let cloud_context_namespaces = drupalSettings.k8s.cloud_context_namespaces;
let updateNamespaceOptions = function (cloud_context) {
$('#edit-namespace option').each(function () {
let namespace = $(this).val();
const cloud_context_namespaces = drupalSettings.k8s.cloud_context_namespaces;
const updateNamespaceOptions = function (cloud_context) {
const namespaceOptions = document.querySelectorAll('#edit-namespace option');
namespaceOptions.forEach(function (option) {
const namespace = option.value;
// If the cloud context is any.
if (!cloud_context) {
$(this).show();
option.style.display = '';
return;
}
// If the namespace is any.
if (!namespace) {
$(this).show();
option.style.display = '';
return;
}
......@@ -23,18 +25,17 @@
if (!cloud_context_namespaces[cloud_context]
|| !cloud_context_namespaces[cloud_context][namespace]) {
$(this).hide();
if ($(this).prop('selected')) {
$(this).prop('selected', '');
}
option.style.display = 'none';
option.selected = false;
} else {
$(this).show();
option.style.display = '';
}
});
};
updateNamespaceOptions($('#edit-cloud-context').val());
$('#edit-cloud-context').change(function () {
updateNamespaceOptions($(this).val());
const cloud_context_element = document.querySelector('#edit-cloud-context');
updateNamespaceOptions(cloud_context_element.value);
cloud_context_element.addEventListener('change', function () {
updateNamespaceOptions(this.value);
});
})(jQuery);
})();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment