Skip to content

Commit

Permalink
fix(ui): handle re-ordering of the services container
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmckendry committed Feb 1, 2025
1 parent 9e5ebe3 commit be1d8c3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion views/modal-add.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,16 @@ <h1>Add</h1>
<button
type="button"
class="btn-danger"
onclick="this.closest('.service-entry').remove()"
onclick="
this.closest('.service-entry').remove();
const services = document.getElementById('services-container');
const entries = services.getElementsByClassName('service-entry');
for (let i = 0; i < entries.length; i++) {
const inputs = entries[i].getElementsByTagName('input');
for (let input of inputs) {
input.name = input.name.replace(/services\[\d+\]/, `services[${i}]`);
}
}"
>
<i class="nf nf-cod-trash"></i>
</button>
Expand Down
11 changes: 10 additions & 1 deletion views/modal-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,16 @@ <h1>Edit {{.Name}}</h1>
<button
type="button"
class="btn-danger"
onclick="this.closest('.service-entry').remove()"
onclick="
this.closest('.service-entry').remove();
const services = document.getElementById('services-container');
const entries = services.getElementsByClassName('service-entry');
for (let i = 0; i < entries.length; i++) {
const inputs = entries[i].getElementsByTagName('input');
for (let input of inputs) {
input.name = input.name.replace(/services\[\d+\]/, `services[${i}]`);
}
}"
>
<i class="nf nf-cod-trash"></i>
</button>
Expand Down

0 comments on commit be1d8c3

Please sign in to comment.