@@ -13,8 +13,6 @@ import {
13
13
verticalListSortingStrategy ,
14
14
} from "@dnd-kit/sortable" ;
15
15
import { CSS } from "@dnd-kit/utilities" ;
16
- import { KeyboardArrowDown } from "@mui/icons-material" ;
17
- import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp" ;
18
16
import {
19
17
Button ,
20
18
Dialog ,
@@ -37,7 +35,6 @@ import {
37
35
isDupName ,
38
36
saveTreeData ,
39
37
} from "./mainPageSettingsUtils" ;
40
- import { set } from "lodash" ;
41
38
42
39
function validRegex ( value : string ) {
43
40
try {
@@ -172,31 +169,6 @@ export default function SettingsModal({
172
169
setTreeData ( treeData . filter ( ( node ) => node . name !== name ) ) ;
173
170
}
174
171
175
- function moveItem ( name : string , direction : "up" | "down" ) {
176
- const group = treeData . find ( ( node ) => node . name === name ) ! ;
177
- const index =
178
- orderBy === "display" ? group . displayPriority : group . filterPriority ;
179
- const swapWithIndex = index + ( direction === "down" ? 1 : - 1 ) ;
180
-
181
- if ( swapWithIndex < 0 || swapWithIndex >= treeData . length ) {
182
- return ;
183
- }
184
- const swapWith = treeData . find (
185
- ( node ) =>
186
- ( orderBy === "display" ? node . displayPriority : node . filterPriority ) ===
187
- swapWithIndex
188
- ) ;
189
-
190
- if ( orderBy == "display" ) {
191
- group . displayPriority = swapWithIndex ;
192
- swapWith ! . displayPriority = index ;
193
- } else {
194
- group . filterPriority = swapWithIndex ;
195
- swapWith ! . filterPriority = index ;
196
- }
197
- setTreeData ( [ ...treeData ] ) ;
198
- }
199
-
200
172
function setItem ( name : string , newName : string , regex : string ) {
201
173
setTreeData (
202
174
treeData . map ( ( node ) => {
@@ -222,7 +194,13 @@ export default function SettingsModal({
222
194
} ;
223
195
224
196
return (
225
- < ListItem ref = { setNodeRef } style = { style } { ...attributes } { ...listeners } id = { data . name } >
197
+ < ListItem
198
+ ref = { setNodeRef }
199
+ style = { style }
200
+ { ...attributes }
201
+ { ...listeners }
202
+ id = { data . name }
203
+ >
226
204
< ListItemButton >
227
205
< Stack
228
206
direction = "row"
@@ -237,12 +215,6 @@ export default function SettingsModal({
237
215
< Typography > { data . regex . source } </ Typography >
238
216
</ Stack >
239
217
< Stack direction = "row" alignItems = { "center" } >
240
- < Button onClick = { ( ) => moveItem ( data . name , "up" ) } >
241
- < KeyboardArrowUpIcon />
242
- </ Button >
243
- < Button onClick = { ( ) => moveItem ( data . name , "down" ) } >
244
- < KeyboardArrowDown />
245
- </ Button >
246
218
< EditSectionDialog
247
219
treeData = { treeData }
248
220
name = { data . name }
@@ -257,15 +229,12 @@ export default function SettingsModal({
257
229
} ) ;
258
230
function handleDragEnd ( event : any ) {
259
231
const { active, over } = event ;
260
- const priority = orderBy === "display" ? "displayPriority" : "filterPriority" ;
261
- console . log ( active . id , over . id ) ;
262
- treeDataOrdered . forEach ( ( node ) => {
263
- console . log ( node . name , node [ priority ] ) ;
264
- } )
265
-
266
- const oldIndex = treeData . find ( ( node ) => node . name === active . id ) ! [ priority ] ;
232
+ const priority =
233
+ orderBy === "display" ? "displayPriority" : "filterPriority" ;
234
+ const oldIndex = treeData . find ( ( node ) => node . name === active . id ) ! [
235
+ priority
236
+ ] ;
267
237
const newIndex = treeData . find ( ( node ) => node . name === over . id ) ! [ priority ] ;
268
- console . log ( newIndex , oldIndex ) ;
269
238
if ( oldIndex < newIndex ) {
270
239
setTreeData (
271
240
treeData . map ( ( node ) => {
@@ -277,7 +246,7 @@ export default function SettingsModal({
277
246
} else if ( oldIndex <= node [ priority ] && node [ priority ] <= newIndex ) {
278
247
return {
279
248
...node ,
280
- [ orderBy ] : node [ priority ] - 1 ,
249
+ [ priority ] : node [ priority ] - 1 ,
281
250
} ;
282
251
}
283
252
return node ;
@@ -302,13 +271,6 @@ export default function SettingsModal({
302
271
} )
303
272
) ;
304
273
}
305
- // if (active.id !== over.id) {
306
- // setItems((items) => {
307
- // const oldIndex = items.indexOf(active.id);
308
- // const newIndex = items.indexOf(over.id);
309
-
310
- // });
311
- // }
312
274
}
313
275
return (
314
276
< Dialog
@@ -317,7 +279,7 @@ export default function SettingsModal({
317
279
maxWidth = "xl"
318
280
onClose = { handleClose }
319
281
onClick = { ( e ) => e . stopPropagation ( ) }
320
- style = { { zIndex : 3000 } }
282
+ style = { { zIndex : 400000 } }
321
283
>
322
284
< Stack
323
285
spacing = { 2 }
@@ -367,7 +329,7 @@ export default function SettingsModal({
367
329
strategy = { verticalListSortingStrategy }
368
330
>
369
331
{ treeDataOrdered . map ( ( id ) => (
370
- < Node key = { id . name } data = { id } />
332
+ < Node key = { id . name } data = { id } />
371
333
) ) }
372
334
</ SortableContext >
373
335
</ DndContext >
0 commit comments