Skip to content

Commit

Permalink
How: fix pin/unpin stack(s) feature (#576)
Browse files Browse the repository at this point in the history
* fix for stack items being expanded by default

* WIP #571 pin working

* #571 pin/unpin stack fixes
  • Loading branch information
arawinters authored Aug 31, 2023
1 parent 96dbd3f commit 07ede20
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 55 deletions.
13 changes: 8 additions & 5 deletions src/lib/how/cards/sz-how-card-base.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,11 @@ export class SzHowStepCardBase implements OnInit, OnDestroy {
return !this.howUIService.isStepPinned(this._data.resolvedVirtualEntityId, this._groupId);
}
get canBeGrouped(): boolean {
if(this.isAddRecordStep && !this.isGroup) {
// only bother checking if this step is an ADD step
return this.howUIService.stepCanBeUnPinned(this._data.resolvedVirtualEntityId);
}
return false;
//return this.howUIService.stepCanBeUnPinned(this._data.resolvedVirtualEntityId);
}
get parentStep() {
return this._parentStep;
Expand Down Expand Up @@ -607,12 +610,12 @@ export class SzHowStepCardBase implements OnInit, OnDestroy {
});
}
public pinStep() {
console.log(`pinStep()`, this._data.resolvedVirtualEntityId, this._groupId);
this.howUIService.pinStep(this._data.resolvedVirtualEntityId, this._groupId);
let res = this.howUIService.pinStep(this._data.resolvedVirtualEntityId, this._groupId);
console.log(`pinStep()`, this._data.resolvedVirtualEntityId, this._groupId, res);
}
public unPinStep() {
console.log(`unPinStep()`, this._data.resolvedVirtualEntityId, this._groupId);
this.howUIService.unPinStep(this._data.resolvedVirtualEntityId);
let res = this.howUIService.unPinStep(this._data.resolvedVirtualEntityId);
console.log(`unPinStep(${this._data.resolvedVirtualEntityId},${this.stepType})`, this._data.resolvedVirtualEntityId, this._groupId, this.howUIService.stepNodes);
}

constructor(
Expand Down
5 changes: 3 additions & 2 deletions src/lib/how/cards/sz-how-step-card.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ <h3 class="title">
<span *ngIf="dataSourcesAsString && !isStackGroupMember" class="datasources"> [ <span class="datasources-list">{{dataSourcesAsString}}</span> ]</span>
</div>
<!--<mat-icon class="debug-icon" (click)="checkIsStackGroup()" fontIcon="adb"></mat-icon>-->
<!--<mat-icon *ngIf="isStackGroupMember && isUnpinned && !isGroupCollapsed && !isCollapsed" class="pin-icon" (click)="pinStep()" fontIcon="push_pin"></mat-icon>
<mat-icon *ngIf="canBeGrouped && !isUnpinned && !isCollapsed" class="unpin-icon" (click)="unPinStep()" fontIcon="adjust"></mat-icon>-->
<mat-icon *ngIf="isStackGroupMember && isUnpinned && !isGroupCollapsed && !isCollapsed" class="pin-icon" (click)="pinStep()" fontIcon="push_pin"></mat-icon>
<mat-icon *ngIf="canBeGrouped && !isUnpinned && !isCollapsed" class="unpin-icon" (click)="unPinStep()" fontIcon="adjust"></mat-icon>
<!--(isUnpinned: {{isUnpinned}} | canBeGrouped: {{canBeGrouped}})-->
</h3>
<div class="columns hide-on-collapsed hide-on-group-collapsed">
<div class="column info-block">
Expand Down
27 changes: 19 additions & 8 deletions src/lib/how/sz-how-entity.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export class SzHowEntityComponent implements OnInit, OnDestroy {
this._stepNodes = this.getStepNodesFromFinalStates(this._data.finalStates, this._data.resolutionSteps);
// get step nodes that are groups
this._stepNodeGroups = this.getGroupsFromStepNodes(this._stepNodes);
console.log(`step node groups: `, this._stepNodeGroups);
//console.log(`step node groups: `, this._stepNodeGroups);
// store in the service
this.howUIService.stepNodeGroups = this._stepNodeGroups;
this.howUIService.stepNodes = this._stepNodes;
Expand Down Expand Up @@ -412,6 +412,7 @@ export class SzHowEntityComponent implements OnInit, OnDestroy {
* recursively scan a nodes children and their childrens children to collect
* all virtual entity id's that are decendents of this node
*/
/*
getVirtualEntityIdsForNode(_rStep?: SzResolutionStepNode): string[] {
let retVal: Array<string> = [];
Expand All @@ -427,7 +428,7 @@ export class SzHowEntityComponent implements OnInit, OnDestroy {
});
}
return retVal;
}
}*/

/** @internal */
public getRecordsForNode(onlySingletons: boolean, step: SzResolutionStepNode): Array<SzVirtualEntityRecord> {
Expand Down Expand Up @@ -507,6 +508,13 @@ export class SzHowEntityComponent implements OnInit, OnDestroy {
let sortByStepNumber = (a: SzResolutionStepNode, b: SzResolutionStepNode) => {
return (a.stepNumber > b.stepNumber) ? -1 : 1;
}
let collapseSteps = (virtualEntityIds: string[]) => {
if(virtualEntityIds && virtualEntityIds.forEach) {
virtualEntityIds.forEach((vId)=>{
this.howUIService.collapseNode(vId, SzResolutionStepListItemType.STEP);
});
}
}
let createStacksForContiguousAddRecords = (_stepNodes: Array<SzResolutionStepNode | SzResolutionStep>): SzResolutionStepNode[] => {
let itemsToRemove = [];
//let addChildrenAtIndexPosition = -1;
Expand Down Expand Up @@ -542,19 +550,22 @@ export class SzHowEntityComponent implements OnInit, OnDestroy {
// mark for deletion
let _idToDelete = (sNode as SzResolutionStepNode).id ? (sNode as SzResolutionStepNode).id : ((sNode as SzResolutionStep).resolvedVirtualEntityId);
itemsToRemove.push(_idToDelete);

}
} else if(stackToAddChildrenTo) {
// node is not an "ADD" but the previous one was
// end stack chain
//addChildrenAtIndexPosition = -1;
stackToAddChildrenTo.virtualEntityIds = this.getVirtualEntityIdsForNode(stackToAddChildrenTo);
stackToAddChildrenTo.virtualEntityIds = SzHowUIService.getVirtualEntityIdsForNode(stackToAddChildrenTo);
// make sure that steps are collapsed by default
collapseSteps(stackToAddChildrenTo.virtualEntityIds);
stackToAddChildrenTo = undefined;
}
if(stackToAddChildrenTo && nodeIndex === (sNodes.length - 1)) {
// we were currently in a stack aggregation step but this is the last one
// calculate virtualEntityIds from members
stackToAddChildrenTo.virtualEntityIds = this.getVirtualEntityIdsForNode(stackToAddChildrenTo);
stackToAddChildrenTo.virtualEntityIds = SzHowUIService.getVirtualEntityIdsForNode(stackToAddChildrenTo);
// make sure that steps are collapsed by default
collapseSteps(stackToAddChildrenTo.virtualEntityIds);
}
return sNode;
});
Expand Down Expand Up @@ -611,7 +622,7 @@ export class SzHowEntityComponent implements OnInit, OnDestroy {
.concat(stepChildren)
.sort(sortByStepNumber);
if(extendedNode.children && extendedNode.children.length > 1) { extendedNode.children = createStacksForContiguousAddRecords(extendedNode.children); }
extendedNode.virtualEntityIds = this.getVirtualEntityIdsForNode(extendedNode);
extendedNode.virtualEntityIds = SzHowUIService.getVirtualEntityIdsForNode(extendedNode);
retVal.push(extendedNode);
} else {
// we still need to traverse these but we're not going to mark them as interim
Expand All @@ -629,7 +640,7 @@ export class SzHowEntityComponent implements OnInit, OnDestroy {
.concat(stepAncestors)
.sort(sortByStepNumber);
if(extendedNode.children && extendedNode.children.length > 1) { extendedNode.children = createStacksForContiguousAddRecords(extendedNode.children); }
extendedNode.virtualEntityIds = this.getVirtualEntityIdsForNode(extendedNode);
extendedNode.virtualEntityIds = SzHowUIService.getVirtualEntityIdsForNode(extendedNode);
retVal.push(extendedNode);
} else {
// we are just going to inject the ancestors at the same level
Expand Down Expand Up @@ -668,7 +679,7 @@ export class SzHowEntityComponent implements OnInit, OnDestroy {
}, step) as SzResolutionStepNode)]
.sort(sortByStepNumber);
//if(extendedNode.children && extendedNode.children.length > 1) { extendedNode.children = createStacksForContiguousAddRecords(extendedNode.children); }
finalNode.virtualEntityIds = this.getVirtualEntityIdsForNode(finalNode);
finalNode.virtualEntityIds = SzHowUIService.getVirtualEntityIdsForNode(finalNode);
retVal.push(finalNode);
} else {
// just append to list
Expand Down
Loading

0 comments on commit 07ede20

Please sign in to comment.