Skip to content
Snippets Groups Projects
Commit ac699d78 authored by Ankitha Shetty's avatar Ankitha Shetty Committed by Yas Naoi
Browse files

Issue #3404519 by nakamurarts, ankithashetty, yas: Refactor to native...

Issue #3404519 by nakamurarts, ankithashetty, yas: Refactor to native JavaScript from jQuery (k8s_cost_block.js)
parent b6d0593f
No related branches found
No related tags found
1 merge request!2116Issue #3404519: Refactor to native JavaScript from jQuery (k8s_cost_block.js)
(function ($) { (function () {
'use strict'; 'use strict';
$('button[name=apply]').click(function () { for (const apply_button of document.querySelectorAll('.simple-datatable .form-inline .button[name="apply"]')) {
let $parent = $(this).parent('.form-inline'); const form_inline = apply_button.closest('.form-inline');
if ($parent.length === 0 || $parent.parents('.panel').length === 0) { const block_id = form_inline.closest('.simple-datatable').id;
return; if (!block_id) {
continue;
} }
let block_id = $parent.parents('.panel').attr('id');
let params = (new URL(location)).searchParams; apply_button.addEventListener('click', function () {
let param_arr = []; const url = new URL(location.href);
$parent.find('select').each(function () { form_inline.querySelectorAll('select').forEach(function (select) {
let name = $(this).attr('name'); url.searchParams.set(block_id + '[' + select.name + ']', select.value);
params.set(block_id + '[' + name + ']', $(this).val()); });
location.href = url.href;
}); });
}
if (Array.from(params).length === 0) { })();
return;
}
let url = location.href;
if (url.indexOf('?') !== -1) {
url = url.substr(0, url.indexOf('?'));
}
location = url + '?' + params.toString();
});
})(jQuery);
...@@ -54,8 +54,6 @@ k8s_cost_block: ...@@ -54,8 +54,6 @@ k8s_cost_block:
version: 5.x-dev version: 5.x-dev
js: js:
js/k8s_cost_block.js: {} js/k8s_cost_block.js: {}
dependencies:
- core/jquery
k8s_project_costs_chart: k8s_project_costs_chart:
version: 5.x-dev version: 5.x-dev
...@@ -79,8 +77,6 @@ k8s_all_resources: ...@@ -79,8 +77,6 @@ k8s_all_resources:
version: 5.x-dev version: 5.x-dev
js: js:
js/k8s_all_resources.js: {} js/k8s_all_resources.js: {}
dependencies:
- core/jquery
k8s_refresh_resource_trigger: k8s_refresh_resource_trigger:
version: 5.x-dev version: 5.x-dev
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment