質問編集履歴
14
マルチポストであることの報告
test
CHANGED
File without changes
|
test
CHANGED
@@ -547,3 +547,15 @@
|
|
547
547
|
階層構造も含めて
|
548
548
|
|
549
549
|
updatedObjectと同じ構造にしたいです...
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
-追記-
|
554
|
+
|
555
|
+
https://ja.stackoverflow.com/questions/47499/typescript-%E9%85%8D%E5%88%97%E3%81%AE%E7%89%B9%E6%AE%8A%E3%81%AA%E3%82%BD%E3%83%BC%E3%83%88
|
556
|
+
|
557
|
+
|
558
|
+
|
559
|
+
こちら、スタックオーバーフローにほとんど同じ質問をしたところ、マルチポストであるというご指摘を頂きました。
|
560
|
+
|
561
|
+
配列をソートする方法自体に関しては、スタックオーバーフローの方で回答をいただけました。
|
13
誤字修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -532,7 +532,7 @@
|
|
532
532
|
|
533
533
|
for(var i = 0; i < updatedObjectList.length; i++){
|
534
534
|
|
535
|
-
this.
|
535
|
+
this.objectList.unshift(Enumerable.asEnumerable(objectList).Where(x=>x.objectId==updatedObjectList[i].objectId).ToArray()[0])
|
536
536
|
|
537
537
|
}
|
538
538
|
|
12
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -507,3 +507,43 @@
|
|
507
507
|
|
508
508
|
|
509
509
|
data.outerRect.function is not a function とエラーが出てしまいます。
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
-追記-
|
514
|
+
|
515
|
+
|
516
|
+
|
517
|
+
そしてやはり並び替えだとうまくいきます
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
```typescript
|
522
|
+
|
523
|
+
|
524
|
+
|
525
|
+
let objectList = this.objectList
|
526
|
+
|
527
|
+
|
528
|
+
|
529
|
+
this.objectList = []
|
530
|
+
|
531
|
+
|
532
|
+
|
533
|
+
for(var i = 0; i < updatedObjectList.length; i++){
|
534
|
+
|
535
|
+
this.shapeList.unshift(Enumerable.asEnumerable(shapeList).Where(x=>x.shapeId==updatedObjectList[i].shapeId).ToArray()[0])
|
536
|
+
|
537
|
+
}
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
```
|
542
|
+
|
543
|
+
|
544
|
+
|
545
|
+
ただし、これはグループ化をしておらず、一階層目だけでオブジェクトを入れ替えているだけです。
|
546
|
+
|
547
|
+
階層構造も含めて
|
548
|
+
|
549
|
+
updatedObjectと同じ構造にしたいです...
|
11
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -422,6 +422,8 @@
|
|
422
422
|
|
423
423
|
this.data = new ImageObject(object)
|
424
424
|
|
425
|
+
//imageObjectはobjectDataをextendしている
|
426
|
+
|
425
427
|
}
|
426
428
|
|
427
429
|
}
|
10
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -438,8 +438,6 @@
|
|
438
438
|
|
439
439
|
|
440
440
|
|
441
|
-
import { InnerRect } from './rect/innerRect'
|
442
|
-
|
443
441
|
import { OuterRect } from './rect/outerRect'
|
444
442
|
|
445
443
|
|
9
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -431,3 +431,79 @@
|
|
431
431
|
}
|
432
432
|
|
433
433
|
```
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
```typescript
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
import { InnerRect } from './rect/innerRect'
|
442
|
+
|
443
|
+
import { OuterRect } from './rect/outerRect'
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
/** 挿入データ(文字とか画像とか)の状態のうち、全てのデータで共有する要素 */
|
448
|
+
|
449
|
+
export class ObjectData{
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
public objectId : number = 0
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
public objectType : string = ""
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
public name : string = ""
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
public selected : boolean = false
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
public outerRect : OuterRect = new OuterRect("string")
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
constructor(objectType : string){
|
474
|
+
|
475
|
+
this.objectType = objectType
|
476
|
+
|
477
|
+
if(objectType!=""){
|
478
|
+
|
479
|
+
this.outerRect = new OuterRect(objectType)
|
480
|
+
|
481
|
+
}
|
482
|
+
|
483
|
+
}
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
public changeState(state : { value : string , stateType : string }){
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
}
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
}
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
```
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
このようにobjectDataにも関数はありますし、outerRectにも関数があるのですが、それらが順番を変えたりすると(objectList = updatedObjectListをすると)、消えてしまいます。
|
506
|
+
|
507
|
+
|
508
|
+
|
509
|
+
data.outerRect.function is not a function とエラーが出てしまいます。
|
8
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -384,6 +384,8 @@
|
|
384
384
|
|
385
385
|
dataにプロパティで任意のプロパティを持っても、関数が渡されなかった
|
386
386
|
|
387
|
+
以下はvuexのルートモデルの一部
|
388
|
+
|
387
389
|
|
388
390
|
|
389
391
|
```typescript
|
7
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -375,3 +375,57 @@
|
|
375
375
|
linq-es2015という,typescript用のlinqモジュールも使えますので、linqを使うこともできます。
|
376
376
|
|
377
377
|
ただc#のlinqと全く同じメソッドが定義されている訳ではありません。
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
-追記-
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
dataにプロパティで任意のプロパティを持っても、関数が渡されなかった
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
```typescript
|
390
|
+
|
391
|
+
import { ImageObject } from './image/imageObject'
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
import { ObjectData } from './objectData'
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
export class Object{
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
public title : string = ""
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
public isLeaf : boolean = true
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
public data : ObjectData = new ObjectData("")
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
constructor(object : {objectType : string , objectId : number}){
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
if(object.objectType == "imageObject"){
|
420
|
+
|
421
|
+
this.data = new ImageObject(object)
|
422
|
+
|
423
|
+
}
|
424
|
+
|
425
|
+
}
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
}
|
430
|
+
|
431
|
+
```
|
6
追記修正(linq-es2015も使用可能)
test
CHANGED
File without changes
|
test
CHANGED
@@ -371,3 +371,7 @@
|
|
371
371
|
そして、子はchildrenという名前のパラメーターに入ります。
|
372
372
|
|
373
373
|
しかし、childrenに格納することに加えて、同じものを、objectListというパラメーターに格納したいです。
|
374
|
+
|
375
|
+
linq-es2015という,typescript用のlinqモジュールも使えますので、linqを使うこともできます。
|
376
|
+
|
377
|
+
ただc#のlinqと全く同じメソッドが定義されている訳ではありません。
|
5
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
少し説明が難しのですが、なるべくコードなども簡略化してみますので、読んでくだされば幸いです(T_T)
|
1
|
+
少し説明が難しいのですが、なるべくコードなども簡略化してみますので、読んでくだされば幸いです(T_T)
|
2
2
|
|
3
3
|
|
4
4
|
|
4
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
少し説明が難しのですが、
|
1
|
+
少し説明が難しのですが、なるべくコードなども簡略化してみますので、読んでくだされば幸いです(T_T)
|
2
2
|
|
3
3
|
|
4
4
|
|
3
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -102,6 +102,8 @@
|
|
102
102
|
|
103
103
|
vuexとこちらのライブラリを組み合わせる場合、上のように、getとsetを使います。
|
104
104
|
|
105
|
+
setはドラッグ&ドロップした時に呼ばれます。
|
106
|
+
|
105
107
|
|
106
108
|
|
107
109
|
set objectList(updatedObjectList) {
|
@@ -130,6 +132,8 @@
|
|
130
132
|
|
131
133
|
ここが変化し、ソートができます。
|
132
134
|
|
135
|
+
データはgetとバインドされています。
|
136
|
+
|
133
137
|
|
134
138
|
|
135
139
|
しかし、こちらのライブラリ、
|
@@ -182,7 +186,11 @@
|
|
182
186
|
|
183
187
|
objectName : "オブジェクト1",
|
184
188
|
|
185
|
-
objectList : []
|
189
|
+
objectList : [],
|
190
|
+
|
191
|
+
isLeaf : false,
|
192
|
+
|
193
|
+
children : []
|
186
194
|
|
187
195
|
},
|
188
196
|
|
@@ -192,7 +200,9 @@
|
|
192
200
|
|
193
201
|
objectName : "オブジェクト2",
|
194
202
|
|
195
|
-
objectList : []
|
203
|
+
objectList : [],
|
204
|
+
|
205
|
+
isLeaf : true
|
196
206
|
|
197
207
|
},
|
198
208
|
|
@@ -202,7 +212,11 @@
|
|
202
212
|
|
203
213
|
objectName : "オブジェクト3",
|
204
214
|
|
205
|
-
objectList : []
|
215
|
+
objectList : [],
|
216
|
+
|
217
|
+
isLeaf : false,
|
218
|
+
|
219
|
+
children : []
|
206
220
|
|
207
221
|
},
|
208
222
|
|
@@ -212,7 +226,9 @@
|
|
212
226
|
|
213
227
|
objectName : "オブジェクト4",
|
214
228
|
|
215
|
-
objectList : []
|
229
|
+
objectList : [],
|
230
|
+
|
231
|
+
isLeaf : true
|
216
232
|
|
217
233
|
},
|
218
234
|
|
@@ -222,7 +238,11 @@
|
|
222
238
|
|
223
239
|
objectName : "オブジェクト5",
|
224
240
|
|
225
|
-
objectList : []
|
241
|
+
objectList : [],
|
242
|
+
|
243
|
+
isLeaf : false,
|
244
|
+
|
245
|
+
children : []
|
226
246
|
|
227
247
|
},
|
228
248
|
|
@@ -254,7 +274,11 @@
|
|
254
274
|
|
255
275
|
objectName : "オブジェクト5",
|
256
276
|
|
257
|
-
objectList : []
|
277
|
+
objectList : [],
|
278
|
+
|
279
|
+
isLeaf : false,
|
280
|
+
|
281
|
+
children : []
|
258
282
|
|
259
283
|
},
|
260
284
|
|
@@ -276,7 +300,9 @@
|
|
276
300
|
|
277
301
|
objectName : "オブジェクト2",
|
278
302
|
|
279
|
-
objectList : []
|
303
|
+
objectList : [],
|
304
|
+
|
305
|
+
isLeaf : true
|
280
306
|
|
281
307
|
},
|
282
308
|
|
@@ -298,7 +324,9 @@
|
|
298
324
|
|
299
325
|
objectName : "オブジェクト4",
|
300
326
|
|
301
|
-
objectList : []
|
327
|
+
objectList : [],
|
328
|
+
|
329
|
+
isLeaf : true
|
302
330
|
|
303
331
|
},
|
304
332
|
|
@@ -330,9 +358,7 @@
|
|
330
358
|
|
331
359
|
|
332
360
|
|
333
|
-
|
361
|
+
親になることができるobjectは
|
334
|
-
|
335
|
-
親は
|
336
362
|
|
337
363
|
|
338
364
|
|
@@ -344,76 +370,4 @@
|
|
344
370
|
|
345
371
|
そして、子はchildrenという名前のパラメーターに入ります。
|
346
372
|
|
347
|
-
しかし、children
|
373
|
+
しかし、childrenに格納することに加えて、同じものを、objectListというパラメーターに格納したいです。
|
348
|
-
|
349
|
-
従ってソートによって
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
```typescript
|
354
|
-
|
355
|
-
let objectList = [
|
356
|
-
|
357
|
-
{
|
358
|
-
|
359
|
-
objectId : 5,
|
360
|
-
|
361
|
-
objectName : "オブジェクト5",
|
362
|
-
|
363
|
-
objectList : []
|
364
|
-
|
365
|
-
},
|
366
|
-
|
367
|
-
{
|
368
|
-
|
369
|
-
objectId : 3,
|
370
|
-
|
371
|
-
objectName : "オブジェクト3",
|
372
|
-
|
373
|
-
objectList : [
|
374
|
-
|
375
|
-
{
|
376
|
-
|
377
|
-
objectId : 2,
|
378
|
-
|
379
|
-
objectName : "オブジェクト2",
|
380
|
-
|
381
|
-
objectList : []
|
382
|
-
|
383
|
-
},
|
384
|
-
|
385
|
-
{
|
386
|
-
|
387
|
-
objectId : 1,
|
388
|
-
|
389
|
-
objectName : "オブジェクト1",
|
390
|
-
|
391
|
-
objectList : [
|
392
|
-
|
393
|
-
{
|
394
|
-
|
395
|
-
objectId : 4,
|
396
|
-
|
397
|
-
objectName : "オブジェクト4",
|
398
|
-
|
399
|
-
objectList : []
|
400
|
-
|
401
|
-
},
|
402
|
-
|
403
|
-
]
|
404
|
-
|
405
|
-
},
|
406
|
-
|
407
|
-
]
|
408
|
-
|
409
|
-
}
|
410
|
-
|
411
|
-
]
|
412
|
-
|
413
|
-
```
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
このようなものを作りたいです
|
418
|
-
|
419
|
-
※childrenやisLeafのパラメーターは特に消す必要はありません。
|
2
誤字修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -100,7 +100,7 @@
|
|
100
100
|
|
101
101
|
|
102
102
|
|
103
|
-
vuexとこちらのライブラリを組み合わせる場合、上のように、getとsetを使い
|
103
|
+
vuexとこちらのライブラリを組み合わせる場合、上のように、getとsetを使います。
|
104
104
|
|
105
105
|
|
106
106
|
|
1
重要な補足の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -264,6 +264,112 @@
|
|
264
264
|
|
265
265
|
objectName : "オブジェクト3",
|
266
266
|
|
267
|
+
objectList : [],
|
268
|
+
|
269
|
+
isLeaf : false,
|
270
|
+
|
271
|
+
children : [
|
272
|
+
|
273
|
+
{
|
274
|
+
|
275
|
+
objectId : 2,
|
276
|
+
|
277
|
+
objectName : "オブジェクト2",
|
278
|
+
|
279
|
+
objectList : []
|
280
|
+
|
281
|
+
},
|
282
|
+
|
283
|
+
{
|
284
|
+
|
285
|
+
objectId : 1,
|
286
|
+
|
287
|
+
objectName : "オブジェクト1",
|
288
|
+
|
289
|
+
objectList : [],
|
290
|
+
|
291
|
+
isLeaf : false,
|
292
|
+
|
293
|
+
children : [
|
294
|
+
|
295
|
+
{
|
296
|
+
|
297
|
+
objectId : 4,
|
298
|
+
|
299
|
+
objectName : "オブジェクト4",
|
300
|
+
|
301
|
+
objectList : []
|
302
|
+
|
303
|
+
},
|
304
|
+
|
305
|
+
]
|
306
|
+
|
307
|
+
},
|
308
|
+
|
309
|
+
]
|
310
|
+
|
311
|
+
}
|
312
|
+
|
313
|
+
]
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
```
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
だった場合、
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
objectList = updatedObjectListとするのではなく
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
"objectListをソートして、"updatedObjectListと同じ構造にするためにはどのようにすればよろしいでしょうか。
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
あと、グループ化(階層構造)にした場合、
|
334
|
+
|
335
|
+
親は
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
isLeaf : false
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
というパラメーターを持ちます。
|
344
|
+
|
345
|
+
そして、子はchildrenという名前のパラメーターに入ります。
|
346
|
+
|
347
|
+
しかし、childrenではなく、objectListというパラメーターに格納したいです。
|
348
|
+
|
349
|
+
従ってソートによって
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
```typescript
|
354
|
+
|
355
|
+
let objectList = [
|
356
|
+
|
357
|
+
{
|
358
|
+
|
359
|
+
objectId : 5,
|
360
|
+
|
361
|
+
objectName : "オブジェクト5",
|
362
|
+
|
363
|
+
objectList : []
|
364
|
+
|
365
|
+
},
|
366
|
+
|
367
|
+
{
|
368
|
+
|
369
|
+
objectId : 3,
|
370
|
+
|
371
|
+
objectName : "オブジェクト3",
|
372
|
+
|
267
373
|
objectList : [
|
268
374
|
|
269
375
|
{
|
@@ -304,18 +410,10 @@
|
|
304
410
|
|
305
411
|
]
|
306
412
|
|
307
|
-
|
308
|
-
|
309
413
|
```
|
310
414
|
|
311
415
|
|
312
416
|
|
313
|
-
|
417
|
+
このようなものを作りたいです
|
314
|
-
|
315
|
-
|
316
|
-
|
418
|
+
|
317
|
-
|
419
|
+
※childrenやisLeafのパラメーターは特に消す必要はありません。
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
"objectListをソートして、"updatedObjectListと同じ構造にするためにはどのようにすればよろしいでしょうか。
|