@stratusjs/angular 0.8.0 → 0.8.1

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.
@@ -123781,13 +123781,14 @@ System.register(['@stratusjs/runtime/stratus', 'lodash', '@stratusjs/core/enviro
123781
123781
  this.expandDelay = 1000;
123782
123782
  this.dropData = null;
123783
123783
  this.cdkDropListSortingDisabled = true;
123784
- this.dropDebug = false;
123785
123784
  this.treeControl = new NestedTreeControl((node) => node.children || []);
123785
+ this.isBorder = false;
123786
+ this.isDebug = false;
123786
123787
  }
123787
123788
  ngOnInit() {
123788
123789
  this.uid = _.uniqueId(`sa_${_.snakeCase(moduleName$3)}_component_`);
123789
123790
  Stratus.Instances[this.uid] = this;
123790
- this.hydrate(this.elementRef, this.sanitizer, ["title", "uid", "isInitialized", "isDestroyed", "isStyled", "target", "targetSuffix", "id", "manifest", "decouple", "direct", "api", "urlRoot", "type", "property", "_", "Stratus", "registry", "fetched", "data", "collection", "model", "dataSub", "onChange", "subscriber", "unsettled", "svgIcons", "isSingleClick", "dblClickWait", "dropLists", "dropListIdMap", "dropListMap", "expandedNodeSet", "dragging", "expandTimeout", "expandDelay", "dropData", "cdkDropListSortingDisabled", "dropDebug", "tree", "treeMap", "metaMap", "dataSource", "treeControl", "iconRegistry", "sanitizer", "backend", "ref", "elementRef", "document", "ngOnInit", "ngOnDestroy", "refresh", "remove", "removeNode", "nodeIsEqual", "fetchData", "dataDefer", "dataRef", "trackDropLists", "setExpanded", "setExpandedClick", "setExpandedDblClick", "onDragDrop", "onDragMove", "showDragData", "clearDragData", "buildNodePatch", "getSvg", "addSvgIcon", "hydrate", "disableRefresh", "stagger", "reloading"]);
123791
+ this.hydrate(this.elementRef, this.sanitizer, ["title", "uid", "isInitialized", "isDestroyed", "isStyled", "target", "targetSuffix", "id", "manifest", "decouple", "direct", "api", "urlRoot", "type", "property", "_", "Stratus", "registry", "fetched", "data", "collection", "model", "dataSub", "onChange", "subscriber", "unsettled", "svgIcons", "isSingleClick", "dblClickWait", "dropLists", "dropListIdMap", "dropListMap", "expandedNodeSet", "dragging", "expandTimeout", "expandDelay", "dropData", "cdkDropListSortingDisabled", "tree", "treeMap", "metaMap", "dataSource", "treeControl", "isBorder", "isDebug", "iconRegistry", "sanitizer", "backend", "ref", "elementRef", "document", "ngOnInit", "ngOnDestroy", "refresh", "remove", "removeNode", "nodeIsEqual", "fetchData", "dataDefer", "dataRef", "trackDropLists", "setExpanded", "setExpandedClick", "setExpandedDblClick", "onDragDrop", "onDragMove", "showDragData", "clearDragData", "buildNodePatch", "getSvg", "addSvgIcon", "hydrate", "disableRefresh", "stagger", "reloading"]);
123791
123792
  Stratus.Internals.CssLoader(`${localDir$7}/${moduleName$3}/${moduleName$3}.component${min$6}.css`)
123792
123793
  .then(() => {
123793
123794
  this.isStyled = true;
@@ -123849,6 +123850,14 @@ System.register(['@stratusjs/runtime/stratus', 'lodash', '@stratusjs/core/enviro
123849
123850
  this.dataSub = new Observable((subscriber) => this.dataDefer(subscriber));
123850
123851
  this.dropListIdMap[`${this.uid}_parent_drop_list`] = true;
123851
123852
  this.trackDropLists();
123853
+ const isBorder = cookie('tree-node-border');
123854
+ if (isBorder && isJSON(isBorder)) {
123855
+ this.isBorder = JSON.parse(isBorder);
123856
+ }
123857
+ const isDebug = cookie('tree-debug');
123858
+ if (isDebug && isJSON(isDebug)) {
123859
+ this.isDebug = JSON.parse(isDebug);
123860
+ }
123852
123861
  this.isInitialized = true;
123853
123862
  this.refresh();
123854
123863
  }
@@ -124000,115 +124009,118 @@ System.register(['@stratusjs/runtime/stratus', 'lodash', '@stratusjs/core/enviro
124000
124009
  this.setExpanded(expanded);
124001
124010
  }
124002
124011
  onDragDrop(event) {
124003
- if (!event.isPointerOverContainer) {
124004
- return;
124005
- }
124006
- const targetNode = event.item.data;
124007
- if (!targetNode) {
124008
- return;
124009
- }
124010
- let parentNode = event.container.data;
124011
- const pastParentNode = event.previousContainer.data;
124012
- const tree = parentNode ? parentNode.children : this.dataRef();
124013
- if (!tree) {
124014
- return;
124015
- }
124016
- this.unsettled = true;
124017
- const targetDropNode = (this.dropData.targetId && this.dropData.targetId in this.treeMap) ?
124018
- this.treeMap[_.toNumber(this.dropData.targetId)] : null;
124019
- if (cookie('env') && this.dropDebug) {
124020
- console.group('onDragDrop()');
124021
- _.forEach([
124022
- `model drop: ${targetNode.model.get('name')}`,
124023
- `list shift: ${event.container.element.nativeElement.id} -> ${event.previousContainer.element.nativeElement.id}`,
124024
- `index change (event): ${event.previousIndex} -> ${event.currentIndex}`,
124025
- `current priority: ${targetNode.model.get('priority')}`,
124026
- `target drop action: ${this.dropData.action}`,
124027
- ], (message) => console.log(message));
124028
- }
124029
- if (targetDropNode && !this.nodeIsEqual(parentNode, targetDropNode)) {
124030
- if (cookie('env') && this.dropDebug) {
124031
- console.log(`target drop node differs: ${targetDropNode.id} -> ${targetDropNode.model.get('name')}`);
124032
- console.log('target drop node is the same as target node:', targetNode.id === targetDropNode.id);
124033
- }
124034
- if (targetNode.id !== targetDropNode.id) {
124035
- switch (this.dropData.action) {
124036
- case 'before':
124037
- case 'after':
124038
- const nestParentId = targetDropNode.model.get('nestParent.id');
124039
- const nestParent = (nestParentId && nestParentId in this.treeMap) ? this.treeMap[nestParentId] : null;
124040
- parentNode = nestParent;
124041
- break;
124042
- case 'inside':
124043
- parentNode = targetDropNode;
124044
- break;
124012
+ return __awaiter$8(this, void 0, void 0, function* () {
124013
+ if (!event.isPointerOverContainer) {
124014
+ return;
124015
+ }
124016
+ const targetNode = event.item.data;
124017
+ if (!targetNode) {
124018
+ return;
124019
+ }
124020
+ let parentNode = event.container.data;
124021
+ const pastParentNode = event.previousContainer.data;
124022
+ const tree = parentNode ? parentNode.children : this.dataRef();
124023
+ if (!tree) {
124024
+ return;
124025
+ }
124026
+ this.unsettled = true;
124027
+ const targetDropNode = (this.dropData.targetId && this.dropData.targetId in this.treeMap) ?
124028
+ this.treeMap[_.toNumber(this.dropData.targetId)] : null;
124029
+ if (cookie('env') && this.isDebug) {
124030
+ console.group('onDragDrop()');
124031
+ _.forEach([
124032
+ `model drop: ${targetNode.model.get('name')}`,
124033
+ `list shift: ${event.container.element.nativeElement.id} -> ${event.previousContainer.element.nativeElement.id}`,
124034
+ `index change (event): ${event.previousIndex} -> ${event.currentIndex}`,
124035
+ `current priority: ${targetNode.model.get('priority')}`,
124036
+ `target drop action: ${this.dropData.action}`,
124037
+ ], (message) => console.log(message));
124038
+ }
124039
+ if (targetDropNode && !this.nodeIsEqual(parentNode, targetDropNode)) {
124040
+ if (cookie('env') && this.isDebug) {
124041
+ console.log(`target drop node differs: ${targetDropNode.id} -> ${targetDropNode.model.get('name')}`);
124042
+ console.log('target drop node is the same as target node:', targetNode.id === targetDropNode.id);
124043
+ }
124044
+ if (targetNode.id !== targetDropNode.id) {
124045
+ switch (this.dropData.action) {
124046
+ case 'before':
124047
+ case 'after':
124048
+ const nestParentId = targetDropNode.model.get('nestParent.id');
124049
+ const nestParent = (nestParentId && nestParentId in this.treeMap) ? this.treeMap[nestParentId] : null;
124050
+ parentNode = nestParent;
124051
+ break;
124052
+ case 'inside':
124053
+ parentNode = targetDropNode;
124054
+ break;
124055
+ }
124056
+ }
124057
+ if (cookie('env') && this.isDebug) {
124058
+ console.log('target drop node selected:', parentNode ? `${parentNode.id} -> ${parentNode.model.get('name')}` : 'none');
124045
124059
  }
124046
124060
  }
124047
- if (cookie('env') && this.dropDebug) {
124048
- console.log('target drop node selected:', parentNode ? `${parentNode.id} -> ${parentNode.model.get('name')}` : 'none');
124061
+ if (!this.nodeIsEqual(parentNode, pastParentNode)) {
124062
+ if (parentNode) {
124063
+ switch (this.dropData.action) {
124064
+ case 'before':
124065
+ case 'after':
124066
+ let targetIndex = parentNode.children.findIndex((n) => n.id === targetNode.id);
124067
+ if (this.dropData.action === 'after') {
124068
+ targetIndex++;
124069
+ }
124070
+ parentNode.children.splice(targetIndex, 0, targetNode);
124071
+ break;
124072
+ case 'inside':
124073
+ parentNode.children.push(targetNode);
124074
+ break;
124075
+ }
124076
+ parentNode.meta.expanded = true;
124077
+ }
124078
+ if (pastParentNode) {
124079
+ this.removeNode(pastParentNode.children, targetNode);
124080
+ }
124081
+ targetNode.model.set('nestParent', this.buildNodePatch(parentNode));
124082
+ if (cookie('env') && this.isDebug) {
124083
+ console.log(`new parent: ${targetNode.model.get('nestParent.name') || null}`);
124084
+ }
124049
124085
  }
124050
- }
124051
- if (!this.nodeIsEqual(parentNode, pastParentNode)) {
124052
- if (parentNode) {
124086
+ const branch = parentNode ? parentNode.children : tree;
124087
+ let targetDropIndex = event.currentIndex;
124088
+ if (this.cdkDropListSortingDisabled) {
124089
+ targetDropIndex = null;
124053
124090
  switch (this.dropData.action) {
124054
124091
  case 'before':
124055
124092
  case 'after':
124056
- let targetIndex = parentNode.children.findIndex((n) => n.id === targetNode.id);
124093
+ targetDropIndex = branch.findIndex((n) => n.id === targetDropNode.id);
124057
124094
  if (this.dropData.action === 'after') {
124058
- targetIndex++;
124095
+ targetDropIndex++;
124096
+ }
124097
+ if (cookie('env') && this.isDebug) {
124098
+ console.log('index change (drop node):', `${event.previousIndex} -> ${targetDropIndex}`);
124059
124099
  }
124060
- parentNode.children.splice(targetIndex, 0, targetNode);
124061
- break;
124062
- case 'inside':
124063
- parentNode.children.push(targetNode);
124064
124100
  break;
124065
124101
  }
124066
- parentNode.meta.expanded = true;
124067
- }
124068
- if (pastParentNode) {
124069
- this.removeNode(pastParentNode.children, targetNode);
124070
- }
124071
- targetNode.model.set('nestParent', this.buildNodePatch(parentNode));
124072
- if (cookie('env') && this.dropDebug) {
124073
- console.log(`new parent: ${targetNode.model.get('nestParent.name') || null}`);
124074
124102
  }
124075
- }
124076
- const branch = parentNode ? parentNode.children : tree;
124077
- let targetDropIndex = event.currentIndex;
124078
- if (this.cdkDropListSortingDisabled) {
124079
- targetDropIndex = null;
124080
- switch (this.dropData.action) {
124081
- case 'before':
124082
- case 'after':
124083
- targetDropIndex = branch.findIndex((n) => n.id === targetDropNode.id);
124084
- if (this.dropData.action === 'after') {
124085
- targetDropIndex++;
124086
- }
124087
- if (cookie('env') && this.dropDebug) {
124088
- console.log('index change (drop node):', `${event.previousIndex} -> ${targetDropIndex}`);
124103
+ if (_.isNumber(targetDropIndex)) {
124104
+ moveItemInArray(branch, event.previousIndex, targetDropIndex);
124105
+ let priority = 0;
124106
+ _.forEach(branch, (node) => {
124107
+ if (!node.model || !node.model.set) {
124108
+ return;
124089
124109
  }
124090
- break;
124091
- }
124092
- }
124093
- if (_.isNumber(targetDropIndex)) {
124094
- moveItemInArray(branch, event.previousIndex, targetDropIndex);
124095
- let priority = 0;
124096
- _.forEach(branch, (node) => {
124097
- if (!node.model || !node.model.set) {
124098
- return;
124110
+ node.model.set('priority', priority++);
124111
+ });
124112
+ if (cookie('env') && this.isDebug) {
124113
+ console.log('new priority:', targetNode.model.get('priority'));
124099
124114
  }
124100
- node.model.set('priority', priority++);
124101
- });
124102
- if (cookie('env') && this.dropDebug) {
124103
- console.log('new priority:', targetNode.model.get('priority'));
124104
124115
  }
124105
- }
124106
- if (cookie('env') && this.dropDebug) {
124107
- console.log(`new parent: ${targetNode.model.get('nestParent.name') || null}`);
124108
- console.groupEnd();
124109
- }
124110
- targetNode.model.save();
124111
- this.unsettled = false;
124116
+ if (cookie('env') && this.isDebug) {
124117
+ console.groupEnd();
124118
+ }
124119
+ yield targetNode.model.save();
124120
+ this.unsettled = false;
124121
+ this.subscriber.next(this.dataRef());
124122
+ this.ref.detectChanges();
124123
+ });
124112
124124
  }
124113
124125
  onDragMove(event) {
124114
124126
  const e = this.document.elementFromPoint(event.pointerPosition.x, event.pointerPosition.y);