Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSS-2333-refactor-dashboard-javascript #871

Merged
merged 23 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0675c2a
using django template and react component
osimuka Jan 14, 2025
d23520d
using a controller to work with react components in the new dashboard
osimuka Jan 16, 2025
15a4393
Merge branch 'master' into TSS-2333-refactor-dashboard-javascript
osimuka Jan 16, 2025
3c602be
lint fix
osimuka Jan 16, 2025
58c1397
Merge branch 'TSS-2333-refactor-dashboard-javascript' of https://gith…
osimuka Jan 16, 2025
db321ff
removing Barrier Overview imports
osimuka Jan 17, 2025
08637ff
fixing clear url
osimuka Jan 17, 2025
6759603
updating logic to be more granular at the api request level
osimuka Jan 22, 2025
0b2a3c5
lint fix
osimuka Jan 22, 2025
cfc1b71
Merge branch 'master' into TSS-2333-refactor-dashboard-javascript
osimuka Jan 22, 2025
09b8493
adding charts
osimuka Jan 23, 2025
9a632c5
updating pack version for apexchart
osimuka Jan 23, 2025
4a127a6
optimising dashboard
osimuka Jan 23, 2025
a793edb
optising chart values
osimuka Jan 23, 2025
1f154a2
fixing link to search
osimuka Jan 23, 2025
d98db9f
fixing link to search
osimuka Jan 23, 2025
8d4a57c
removing the barrieroverview file
osimuka Jan 23, 2025
f7f168a
Formatting (#877)
EPedley Jan 27, 2025
88a9b95
removing commented out imports
osimuka Jan 27, 2025
fa59d5c
Merge branch 'TSS-2333-refactor-dashboard-javascript' of https://gith…
osimuka Jan 27, 2025
2b84726
fixing prettier format
osimuka Jan 28, 2025
7307e18
removing comments
osimuka Jan 28, 2025
18374a2
Merge branch 'master' into TSS-2333-refactor-dashboard-javascript
osimuka Jan 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions core/frontend/src/js/components/MultiSelect.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ma.components.MultiSelect = function (id_name) {
ma.components.MultiSelect = function (/** @type {string} */ id_name) {
const nodes = document.getElementById(id_name);

const select = nodes.querySelector(".dropdown");
Expand All @@ -9,6 +9,7 @@ ma.components.MultiSelect = function (id_name) {
.querySelectorAll("input")[1];

add_button.addEventListener("click", function () {
// @ts-ignore
if (select.value) {
additionMode();
}
Expand All @@ -19,15 +20,20 @@ ma.components.MultiSelect = function (id_name) {

const appendToList = function () {
if (selection.value) {
const new_list = JSON.parse(selection.value).map(function (e) {
return e.toString();
});
const new_list = JSON.parse(selection.value).map(
function (/** @type {{ toString: () => any; }} */ e) {
return e.toString();
},
);
// @ts-ignore
if (!new_list.includes(select.value)) {
// @ts-ignore
new_list.push(select.value);
selection.value = JSON.stringify(new_list);
}
} else {
const new_list = [];
// @ts-ignore
new_list.push(select.value);
selection.value = JSON.stringify(new_list);
}
Expand All @@ -37,12 +43,16 @@ ma.components.MultiSelect = function (id_name) {

const updateDisplay = function () {
if (selection.value) {
const selected_list = JSON.parse(selection.value).map(function (e) {
return e.toString();
});
const selected_list = JSON.parse(selection.value).map(
function (/** @type {{ toString: () => any; }} */ e) {
return e.toString();
},
);
display_list.innerHTML = "";
for (let i = 0; i < selected_list.length; i++) {
// @ts-ignore
for (let x = 0; x < select.length; x++) {
// @ts-ignore
let option = select.options[x];
if (option.value == selected_list[i]) {
let category_entry = document.createElement("li");
Expand Down Expand Up @@ -76,11 +86,13 @@ ma.components.MultiSelect = function (id_name) {
}
};

const removeItem = function (item) {
const removeItem = function (/** @type {any} */ item) {
if (selection.value) {
let selected_list = JSON.parse(selection.value).map(function (e) {
return e.toString();
});
let selected_list = JSON.parse(selection.value).map(
function (/** @type {{ toString: () => any; }} */ e) {
return e.toString();
},
);
const index = selected_list.indexOf(item);
if (index > -1) {
// only splice array when item is found
Expand Down
Loading
Loading