limit military units - skip removed data

This commit is contained in:
Azgaar 2021-10-11 16:47:32 +03:00
parent f5065f0771
commit e7d95924e0
2 changed files with 9 additions and 5 deletions

View file

@ -1310,16 +1310,19 @@ div.slider .ui-slider-handle {
scrollbar-width: thin; scrollbar-width: thin;
} }
#alertMessage::-webkit-scrollbar,
.table::-webkit-scrollbar { .table::-webkit-scrollbar {
width: 6px; width: 6px;
background-color: transparent; background-color: transparent;
} }
#alertMessage::-webkit-scrollbar-thumb,
.table::-webkit-scrollbar-thumb { .table::-webkit-scrollbar-thumb {
background-color: #aaa; background-color: #aaa;
border-radius: 6px; border-radius: 6px;
} }
#alertMessage::-webkit-scrollbar-thumb:hover,
.table::-webkit-scrollbar-thumb:hover { .table::-webkit-scrollbar-thumb:hover {
background: #666; background: #666;
} }

View file

@ -319,14 +319,15 @@ function overviewMilitary() {
const value = el.dataset.value; const value = el.dataset.value;
const initial = value ? value.split(",").map(v => +v) : []; const initial = value ? value.split(",").map(v => +v) : [];
const lines = data.slice(1).map( const filtered = data.filter(datum => datum.i && !datum.removed);
const lines = filtered.map(
({i, name, fullName, color}) => ({i, name, fullName, color}) =>
`<tr data-tip="${name}"><td><span style="color:${color}">⬤</span></td> `<tr data-tip="${name}"><td><span style="color:${color}">⬤</span></td>
<td><input id="el${i}" type="checkbox" class="checkbox" ${!initial.length || initial.includes(i) ? "checked" : ""} > <td><input data-i="${i}" id="el${i}" type="checkbox" class="checkbox" ${!initial.length || initial.includes(i) ? "checked" : ""} >
<label for="el${i}" class="checkbox-label">${fullName || name}</label> <label for="el${i}" class="checkbox-label">${fullName || name}</label>
</td></tr>` </td></tr>`
); );
alertMessage.innerHTML = `<b>Limit unit by ${type}:</b><div style="margin-top:.3em" class="table"><table><tbody>${lines.join("")}</tbody></table></div>`; alertMessage.innerHTML = `<b>Limit unit by ${type}:</b><table style="margin-top:.3em"><tbody>${lines.join("")}</tbody></table>`;
$("#alert").dialog({ $("#alert").dialog({
width: fitContent(), width: fitContent(),
@ -337,8 +338,8 @@ function overviewMilitary() {
}, },
Apply: function () { Apply: function () {
const inputs = Array.from(alertMessage.querySelectorAll("input")); const inputs = Array.from(alertMessage.querySelectorAll("input"));
const selected = inputs.reduce((acc, input, index) => { const selected = inputs.reduce((acc, input) => {
if (input.checked) acc.push(index + 1); if (input.checked) acc.push(input.dataset.i);
return acc; return acc;
}, []); }, []);