Config : sécurisation comptes par défaut
This commit is contained in:
parent
98f4fa5330
commit
4ecd144593
2 changed files with 54 additions and 25 deletions
33
config.html
33
config.html
|
|
@ -46,6 +46,7 @@
|
|||
{{/form}}
|
||||
|
||||
{{:admin_header title="Configuration" custom_css="./style.css" current="module_amortization"}}
|
||||
|
||||
{{:include file="_nav.html" current="config"}}
|
||||
{{if $_GET.ok == 1}}
|
||||
<p class="block confirm">Configuration enregistrée.</p>
|
||||
|
|
@ -154,13 +155,14 @@
|
|||
}}
|
||||
</td>
|
||||
<td class="actions">
|
||||
{{:button
|
||||
label="Enlever"
|
||||
title="Enlever une ligne"
|
||||
shape="minus"
|
||||
min="1"
|
||||
name="remove_line"
|
||||
}}
|
||||
{{if ! $code|in:$config_defaut.prefixes}}
|
||||
{{:button
|
||||
label="Enlever"
|
||||
shape="minus"
|
||||
min="1"
|
||||
name="remove_line"
|
||||
}}
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
|
|
@ -187,6 +189,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{:assign unfinished_lines=$config_defaut.unfinished|map:implode:"-"|implode:","}}
|
||||
{{#foreach from=$unfinished_accounts key=code item=elem}}
|
||||
<tr>
|
||||
<td>
|
||||
|
|
@ -200,13 +203,15 @@
|
|||
}}
|
||||
</td>
|
||||
<td class="actions">
|
||||
{{:button
|
||||
label="Enlever"
|
||||
title="Enlever une ligne"
|
||||
shape="minus"
|
||||
min="1"
|
||||
name="remove_line"
|
||||
}}
|
||||
{{if $unfinished_lines|strpos:$code === false}}
|
||||
{{:button
|
||||
label="Enlever"
|
||||
title="Enlever une ligne"
|
||||
shape="minus"
|
||||
min="1"
|
||||
name="remove_line"
|
||||
}}
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
|
|
|
|||
46
scripts.js
46
scripts.js
|
|
@ -145,19 +145,21 @@ function setSelectorYear(button_names, f_years_selector)
|
|||
|
||||
// Associer au bouton « Enlever » de chaque ligne l'action de suppression de la ligne
|
||||
function initLine(row) {
|
||||
var removeBtn = row.querySelector('button[name="remove_line"]');
|
||||
removeBtn.onclick = () => {
|
||||
let count = removeBtn.closest("table").querySelectorAll('tbody tr').length;
|
||||
var min = removeBtn.getAttribute('min');
|
||||
let removeBtn = row.querySelector('button[name="remove_line"]');
|
||||
if (removeBtn != null) {
|
||||
removeBtn.onclick = () => {
|
||||
let count = removeBtn.closest("table").querySelectorAll('tbody tr').length;
|
||||
var min = removeBtn.getAttribute('min');
|
||||
|
||||
if (count <= min) {
|
||||
alert("Il n'est pas possible d'avoir moins de " + min + " ligne(s).");
|
||||
return false;
|
||||
}
|
||||
if (count <= min) {
|
||||
alert("Il n'est pas possible d'avoir moins de " + min + " ligne(s).");
|
||||
return false;
|
||||
}
|
||||
|
||||
row.parentNode.removeChild(row);
|
||||
return true;
|
||||
};
|
||||
row.parentNode.removeChild(row);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Associer au bouton « Ajouter » de chaque table l'action d'ajouter une ligne
|
||||
|
|
@ -185,6 +187,28 @@ function addLine(button, codes) {
|
|||
let lib = newNode.querySelector('.input-list span.label');
|
||||
lib.innerText = '';
|
||||
|
||||
// si besoin, ajouter le bouton de suppression
|
||||
let action_cell = newNode.querySelector('td.actions');
|
||||
let removeBtn = newNode.querySelector('button[name="remove_line"]');
|
||||
if (removeBtn == null) {
|
||||
const attributs = {
|
||||
"title" : "Enlever une ligne",
|
||||
"min": "1",
|
||||
"name": "remove_line",
|
||||
"data-icon": "➖",
|
||||
"type": "button",
|
||||
"class": "icn-btn",
|
||||
"value": "1",
|
||||
"aria-label": "Enlever une ligne"
|
||||
};
|
||||
let new_button = document.createElement("button");
|
||||
new_button.appendChild(document.createTextNode("Enlever"));
|
||||
for (let attr in attributs) {
|
||||
new_button.setAttribute(attr, attributs[attr]);
|
||||
}
|
||||
action_cell.appendChild(new_button);
|
||||
}
|
||||
|
||||
// ajouter la nouvelle ligne
|
||||
line.parentNode.appendChild(newNode);
|
||||
initLine(newNode);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue