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

Issue #3404519 by nakamurarts, yas: Refactor to native JavaScript from jQuery (k8s_cost_block.js)

parent a8e0e612
No related branches found
No related tags found
No related merge requests found
(function ($) {
(function () {
'use strict';
$('button[name=apply]').click(function () {
let $parent = $(this).parent('.form-inline');
if ($parent.length === 0 || $parent.parents('.panel').length === 0) {
return;
for (const apply_button of document.querySelectorAll('.simple-datatable .form-inline .button[name="apply"]')) {
const form_inline = apply_button.closest('.form-inline');
const block_id = form_inline.closest('.simple-datatable').id;
if (!block_id) {
continue;
}
let block_id = $parent.parents('.panel').attr('id');
let params = (new URL(location)).searchParams;
let param_arr = [];
$parent.find('select').each(function () {
let name = $(this).attr('name');
params.set(block_id + '[' + name + ']', $(this).val());
apply_button.addEventListener('click', function () {
const url = new URL(location.href);
form_inline.querySelectorAll('select').forEach(function (select) {
url.searchParams.set(block_id + '[' + select.name + ']', select.value);
});
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:
version: 6.x-dev
js:
js/k8s_cost_block.js: {}
dependencies:
- core/jquery
k8s_project_costs_chart:
version: 6.x-dev
......@@ -79,8 +77,6 @@ k8s_all_resources:
version: 6.x-dev
js:
js/k8s_all_resources.js: {}
dependencies:
- core/jquery
k8s_refresh_resource_trigger:
version: 6.x-dev
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment