fixes arrow logic for specs

This commit is contained in:
alicia pritchett 2021-09-07 11:22:45 -04:00
parent 55f558c5c7
commit 7fcaf72416
2 changed files with 14 additions and 23 deletions

View File

@ -76,11 +76,11 @@
</button> </button>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<mat-list> <mat-list>
<mat-list-item *ngFor="let wfs of cat.workflow_specs" class="workflow-spec" fxLayout="row" fxLayoutGap="10px" fxLayoutAlign="start center"> <mat-list-item *ngFor="let wfs of cat.workflow_specs; let i = index" class="workflow-spec" fxLayout="row" fxLayoutGap="10px" fxLayoutAlign="start center">
<span [ngClass]="{'spec_menu_item':true, 'spec-selected': selectedSpec && wfs.id === selectedSpec.id}" (click)="selectSpec(wfs)">{{wfs.display_name}}</span> <span [ngClass]="{'spec_menu_item':true, 'spec-selected': selectedSpec && wfs.id === selectedSpec.id}" (click)="selectSpec(wfs)">{{wfs.display_name}}</span>
<span class="spec-actions" fxLayout="row" fxLayoutGap="10px" *ngIf="cat && cat.id !== null"> <span class="spec-actions" fxLayout="row" fxLayoutGap="10px" *ngIf="cat.id !== null && cat">
<button <button
*ngIf="cat && cat.workflow_specs.length > 0 && wfs.display_order !== 0" *ngIf="i!==0 && cat.workflow_specs.length > 0"
mat-icon-button mat-icon-button
title="Move up" title="Move up"
color="primary" color="primary"
@ -89,7 +89,7 @@
<mat-icon>arrow_upward</mat-icon> <mat-icon>arrow_upward</mat-icon>
</button> </button>
<button <button
*ngIf="cat && cat.workflow_specs.length > 0 && (wfs.display_order < cat.workflow_specs.length - 1)" *ngIf="i!==cat.workflow_specs.length-1 && cat.workflow_specs.length > 0"
mat-icon-button mat-icon-button
title="Move down" title="Move down"
color="primary" color="primary"

View File

@ -233,8 +233,7 @@ export class WorkflowSpecListComponent implements OnInit {
// const reorderedSpecs = this._reorder(specId, direction, specs) as WorkflowSpec[]; // const reorderedSpecs = this._reorder(specId, direction, specs) as WorkflowSpec[];
// this._updateSpecDisplayOrders(reorderedSpecs); // this._updateSpecDisplayOrders(reorderedSpecs);
this.api.reorderWorkflowSpecification(specId, direction).subscribe(wfs => { this.api.reorderWorkflowSpecification(specId, direction).subscribe(wfs => {
console.log('reorder'); cat.workflow_specs= wfs;
// cat.workflow_specs= wfs;
}); });
} }
@ -254,7 +253,7 @@ export class WorkflowSpecListComponent implements OnInit {
display_order: -1, // Display it at the top display_order: -1, // Display it at the top
}]; }];
// note - wonder if this could also go to backend // ?
this.categories.forEach((cat, i) => { this.categories.forEach((cat, i) => {
this.workflowSpecsByCategory.push(cat); this.workflowSpecsByCategory.push(cat);
this.workflowSpecsByCategory[i + 1].workflow_specs = []; this.workflowSpecsByCategory[i + 1].workflow_specs = [];
@ -270,8 +269,6 @@ export class WorkflowSpecListComponent implements OnInit {
}); });
} }
// Need to step thru this
private _loadWorkflowSpecs(selectedSpecName: string = null, searchSpecName: string = null) { private _loadWorkflowSpecs(selectedSpecName: string = null, searchSpecName: string = null) {
this.api.getWorkflowSpecList().subscribe(wfs => { this.api.getWorkflowSpecList().subscribe(wfs => {
@ -318,7 +315,7 @@ export class WorkflowSpecListComponent implements OnInit {
display_name: data.display_name, display_name: data.display_name,
description: data.description, description: data.description,
category_id: data.category_id, category_id: data.category_id,
display_order: data.display_order, // display_order: data.display_order,
standalone: data.standalone, standalone: data.standalone,
library: data.library, library: data.library,
}; };
@ -397,23 +394,13 @@ export class WorkflowSpecListComponent implements OnInit {
}); });
} }
private _reorderWorkflowSpecCategory() {
//wip
}
private _reorderWorkflowSpec(specId: string, direction: number) {
//First, convert direction to string
let d = (direction == -1) ? "moveUp" : "moveDown";
// this.api.reorderWorkflowSpec(specId, d).subscribe(_ => {
//subscribe to some stuff
// });
}
private _displayMessage(message: string) { private _displayMessage(message: string) {
this.snackBar.open(message, 'Ok', {duration: 3000}); this.snackBar.open(message, 'Ok', {duration: 3000});
} }
/** /**
* Deprecated - backend now reorders
*
private _reorder( private _reorder(
id: number | string, direction: number, id: number | string, direction: number,
list: Array<WorkflowSpecCategoryGroup | WorkflowSpec>, list: Array<WorkflowSpecCategoryGroup | WorkflowSpec>,
@ -436,6 +423,9 @@ export class WorkflowSpecListComponent implements OnInit {
} }
**/ **/
/**
* Deprecated - backend updates display_order
*
private _updateCatDisplayOrders(cats: WorkflowSpecCategory[]) { private _updateCatDisplayOrders(cats: WorkflowSpecCategory[]) {
let numUpdated = 0; let numUpdated = 0;
cats.forEach((cat, j) => { cats.forEach((cat, j) => {
@ -454,6 +444,7 @@ export class WorkflowSpecListComponent implements OnInit {
}); });
} }
private _updateSpecDisplayOrders(specs: WorkflowSpec[]) { private _updateSpecDisplayOrders(specs: WorkflowSpec[]) {
if (this.selectedCat && this.selectedSpec.category) { if (this.selectedCat && this.selectedSpec.category) {
if (this.selectedCat.id !== this.selectedSpec.category.id) { if (this.selectedCat.id !== this.selectedSpec.category.id) {
@ -472,7 +463,7 @@ export class WorkflowSpecListComponent implements OnInit {
}); });
}); });
} }
*/
} }