Skip to content

Commit 9ca00fd

Browse files
committed
Made tiny CS fixes on app.js and draggable.ts
1 parent f61b719 commit 9ca00fd

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

assets/js/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import '../css/app.css';
22
import * as Highcharts from "highcharts";
3-
import {draggable} from './draggable';
3+
import './draggable';
44

55
global.Highcharts = Highcharts;

assets/js/draggable.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@ const sortable = new Sortable(document.querySelectorAll('.draggable_container'),
77
draggable: '.draggable'
88
});
99

10-
sortable.on('sortable:stop', (event) => {
11-
const draggedInputs = document.querySelectorAll('.draggable_container .draggable input');
12-
draggedInputs.forEach((input: Element, index: number) => {
13-
if (input.hasAttribute('name')) {
14-
let name = input.getAttribute('name') || '';
15-
if (!name.match(/\[\d+]/)) {
16-
// No DOM modification if attribute was removed already.
17-
return;
10+
sortable.on('sortable:stop', () => {
11+
document
12+
.querySelectorAll('.draggable_container .draggable input')
13+
.forEach((input: Element, index: number) => {
14+
if (input.hasAttribute('name')) {
15+
let name = input.getAttribute('name') || '';
16+
if (!name.match(/\[\d+]/)) {
17+
// No DOM modification if attribute was already removed.
18+
return;
19+
}
20+
input.setAttribute('name', name.replace(/\[\d+]/g, '['+index+']'));
1821
}
19-
input.setAttribute('name', name.replace(/\[\d+]/g, '['+index+']'));
20-
}
21-
});
22+
})
23+
;
2224
});

0 commit comments

Comments
 (0)