@stratusjs/angular 0.8.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,11 +49,12 @@ import {RefreshInterface} from '../core/refresh.interface'
49
49
  // Services
50
50
  import {BackendService} from '../backend.service'
51
51
  import {Registry} from '@stratusjs/angularjs/services/registry'
52
- import {cookie} from '@stratusjs/core/environment'
53
52
 
54
53
  // Core Classes
55
54
  import {EventManager} from '@stratusjs/core/events/eventManager'
56
55
  import {EventBase} from '@stratusjs/core/events/eventBase'
56
+ import {cookie} from '@stratusjs/core/environment'
57
+ import {isJSON} from '@stratusjs/core/misc'
57
58
 
58
59
  // AngularJS Classes
59
60
  import {
@@ -196,7 +197,6 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
196
197
  expandDelay = 1000
197
198
  dropData: DropData = null
198
199
  cdkDropListSortingDisabled = true
199
- dropDebug = false
200
200
 
201
201
  // Tree Specific
202
202
  tree: Node[]
@@ -210,6 +210,10 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
210
210
  // hasChild = (index: number, node: any) => this.getChildren(node).length > 0
211
211
  // hasChild = (index: number, node: any) => node.children && node.children.length > 0
212
212
 
213
+ // User Settings
214
+ isBorder = false
215
+ isDebug = false
216
+
213
217
  constructor(
214
218
  public iconRegistry: MatIconRegistry,
215
219
  public sanitizer: DomSanitizer,
@@ -323,6 +327,16 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
323
327
  this.dropListIdMap[`${this.uid}_parent_drop_list`] = true
324
328
  this.trackDropLists()
325
329
 
330
+ // Initialize User Settings
331
+ const isBorder = cookie('tree-node-border')
332
+ if (isBorder && isJSON(isBorder)) {
333
+ this.isBorder = JSON.parse(isBorder)
334
+ }
335
+ const isDebug = cookie('tree-debug')
336
+ if (isDebug && isJSON(isDebug)) {
337
+ this.isDebug = JSON.parse(isDebug)
338
+ }
339
+
326
340
  // Mark as complete
327
341
  this.isInitialized = true
328
342
 
@@ -546,7 +560,7 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
546
560
  // return this.getIdsRecursive(this.parentItem).reverse()
547
561
  // }
548
562
 
549
- public onDragDrop(event: CdkDragDrop<any>) {
563
+ public async onDragDrop(event: CdkDragDrop<any>) {
550
564
  // ignore drops outside of the tree
551
565
  if (!event.isPointerOverContainer) {
552
566
  return
@@ -582,7 +596,7 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
582
596
  this.treeMap[_.toNumber(this.dropData.targetId)] : null
583
597
 
584
598
  // Debug Data
585
- if (cookie('env') && this.dropDebug) {
599
+ if (cookie('env') && this.isDebug) {
586
600
  console.group('onDragDrop()')
587
601
  _.forEach(
588
602
  [
@@ -602,7 +616,7 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
602
616
  // with the drop location and this attempts to correct it in these
603
617
  // specific edge cases
604
618
  if (targetDropNode && !this.nodeIsEqual(parentNode, targetDropNode)) {
605
- if (cookie('env') && this.dropDebug) {
619
+ if (cookie('env') && this.isDebug) {
606
620
  console.log(`target drop node differs: ${targetDropNode.id} -> ${targetDropNode.model.get('name')}`)
607
621
  console.log('target drop node is the same as target node:', targetNode.id === targetDropNode.id)
608
622
  }
@@ -619,7 +633,7 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
619
633
  break
620
634
  }
621
635
  }
622
- if (cookie('env') && this.dropDebug) {
636
+ if (cookie('env') && this.isDebug) {
623
637
  console.log('target drop node selected:', parentNode ? `${parentNode.id} -> ${parentNode.model.get('name')}` : 'none')
624
638
  }
625
639
  }
@@ -648,7 +662,7 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
648
662
  targetNode.model.set('nestParent', this.buildNodePatch(parentNode))
649
663
 
650
664
  // Display debug data
651
- if (cookie('env') && this.dropDebug) {
665
+ if (cookie('env') && this.isDebug) {
652
666
  console.log(`new parent: ${targetNode.model.get('nestParent.name') || null}`)
653
667
  }
654
668
  }
@@ -668,7 +682,7 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
668
682
  if (this.dropData.action === 'after') {
669
683
  targetDropIndex++
670
684
  }
671
- if (cookie('env') && this.dropDebug) {
685
+ if (cookie('env') && this.isDebug) {
672
686
  console.log('index change (drop node):', `${event.previousIndex} -> ${targetDropIndex}`)
673
687
  }
674
688
  break
@@ -688,14 +702,13 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
688
702
  node.model.set('priority', priority++)
689
703
  })
690
704
  // Display debug data
691
- if (cookie('env') && this.dropDebug) {
705
+ if (cookie('env') && this.isDebug) {
692
706
  console.log('new priority:', targetNode.model.get('priority'))
693
707
  }
694
708
  }
695
709
 
696
710
  // Close Debug Group
697
- if (cookie('env') && this.dropDebug) {
698
- console.log(`new parent: ${targetNode.model.get('nestParent.name') || null}`)
711
+ if (cookie('env') && this.isDebug) {
699
712
  console.groupEnd()
700
713
  }
701
714
 
@@ -716,17 +729,20 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
716
729
  // })
717
730
 
718
731
  // Start XHR
719
- targetNode.model.save()
732
+ await targetNode.model.save()
720
733
 
721
734
  // Enable Listeners
722
735
  this.unsettled = false
723
736
 
737
+ // Refresh UI
738
+ // await this.refresh()
739
+
724
740
  // update pipe
725
- // this.subscriber.next(tree)
741
+ // this.subscriber.next(this.dataRef())
726
742
  // this.ref.detectChanges()
727
743
 
728
744
  // propagate change
729
- // this.collection.throttleTrigger('change')
745
+ this.collection.throttleTrigger('change')
730
746
  }
731
747
 
732
748
  // private canBeDropped(event: CdkDragDrop<any, any>): boolean {