Sorts workflow spec categories in display order. Updates is_status to is_master_spec

This commit is contained in:
Aaron Louie 2020-03-30 15:03:55 -04:00
parent 30b10f252a
commit 336c5d4656
9 changed files with 33 additions and 21 deletions

6
package-lock.json generated
View File

@ -12171,9 +12171,9 @@
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
}, },
"sartography-workflow-lib": { "sartography-workflow-lib": {
"version": "0.0.83", "version": "0.0.84",
"resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.83.tgz", "resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.84.tgz",
"integrity": "sha512-cbelOLGgLpYq6I8VRooKBNOxPSBQT/UshdWeC5o6wZ9wf6ooE+Skh6X+awQR6V3cF0Ur0HasRfcdUgGkqgcLCg==" "integrity": "sha512-0pXqY9k17louQ7pZIiSlpfNjHI8qKHb8k+AvECO4ENcX9Kgpb+SuDx+nplfIns2hKoiBgU6hJHTOdm4Ow1Fbvw=="
}, },
"sass": { "sass": {
"version": "1.23.3", "version": "1.23.3",

View File

@ -49,7 +49,7 @@
"ngx-file-drop": "^8.0.8", "ngx-file-drop": "^8.0.8",
"ngx-markdown": "^9.0.0", "ngx-markdown": "^9.0.0",
"rxjs": "~6.5.4", "rxjs": "~6.5.4",
"sartography-workflow-lib": "^0.0.83", "sartography-workflow-lib": "^0.0.84",
"tslib": "^1.11.1", "tslib": "^1.11.1",
"uuid": "^7.0.2", "uuid": "^7.0.2",
"zone.js": "^0.10.3" "zone.js": "^0.10.3"

View File

@ -57,9 +57,8 @@ export class WorkflowSpecCategoryDialogComponent {
templateOptions: { templateOptions: {
type: 'number', type: 'number',
label: 'Display Order', label: 'Display Order',
placeholder: 'Title of the workflow spec category', placeholder: 'Order in which category will be displayed',
description: 'This is a human-readable title for the workflow spec category,' + description: 'Sort order that the category should appear in. Lower numbers will appear first.',
'which should be easy for others to read and remember.',
required: true, required: true,
}, },
}, },

View File

@ -57,9 +57,9 @@ export class WorkflowSpecDialogComponent {
}, },
}, },
{ {
key: 'workflow_spec_category_id', key: 'category_id',
type: 'select', type: 'select',
defaultValue: this.data.name, defaultValue: this.data.category_id,
templateOptions: { templateOptions: {
label: 'Category', label: 'Category',
placeholder: 'Category of workflow specification', placeholder: 'Category of workflow specification',

View File

@ -22,11 +22,14 @@ describe('ApiErrorsComponent', () => {
{ {
provide: MatBottomSheetRef, provide: MatBottomSheetRef,
useValue: { useValue: {
close: (dialogResult: any) => { dismiss: (dialogResult: any) => {
} }
} }
}, },
{provide: MAT_BOTTOM_SHEET_DATA, useValue: []}, {provide: MAT_BOTTOM_SHEET_DATA, useValue: {apiErrors: [{
status_code: 400,
code: 'error_code'
}]}},
] ]
}) })
@ -41,5 +44,14 @@ describe('ApiErrorsComponent', () => {
it('should create', () => { it('should create', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
expect(component.data).toBeTruthy();
expect(component.apiErrors).toBeTruthy();
}); });
it('should dismiss', () => {
const dismissSpy = spyOn((component as any)._bottomSheetRef, 'dismiss').and.stub();
component.dismiss(new MouseEvent('click'));
expect(dismissSpy).toHaveBeenCalled();
});
}); });

View File

@ -1,4 +1,4 @@
<mat-card class="mat-elevation-z0 {{workflowSpec.is_status ? 'master-status' : ''}}" [id]="workflowSpec.id"> <mat-card class="mat-elevation-z0 {{workflowSpec.is_master_spec ? 'master-status' : ''}}" [id]="workflowSpec.id">
<mat-card-header> <mat-card-header>
<mat-card-title fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="10px"> <mat-card-title fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="10px">
<h3>{{workflowSpec.display_name}}</h3> <h3>{{workflowSpec.display_name}}</h3>
@ -7,11 +7,11 @@
</div> </div>
<span fxFlex></span> <span fxFlex></span>
<ng-container> <ng-container>
<button (click)="makeMasterStatus()" *ngIf="!workflowSpec.is_status" mat-button color="accent"> <button (click)="makeMasterStatus()" *ngIf="!workflowSpec.is_master_spec" mat-button color="accent">
<mat-icon>radio_button_unchecked</mat-icon> <mat-icon>radio_button_unchecked</mat-icon>
Master status spec Master status spec
</button> </button>
<button *ngIf="workflowSpec.is_status" (click)="makeMasterStatus()" mat-button color="accent"> <button *ngIf="workflowSpec.is_master_spec" (click)="makeMasterStatus()" mat-button color="accent">
<mat-icon>radio_button_checked</mat-icon> <mat-icon>radio_button_checked</mat-icon>
Master status spec Master status spec
</button> </button>

View File

@ -20,7 +20,7 @@ export class WorkflowSpecCardComponent implements OnInit {
} }
makeMasterStatus() { makeMasterStatus() {
this.workflowSpec.is_status = true; this.workflowSpec.is_master_spec = true;
this.api.updateWorkflowSpecification(this.workflowSpec.id, this.workflowSpec).subscribe(spec => { this.api.updateWorkflowSpecification(this.workflowSpec.id, this.workflowSpec).subscribe(spec => {
this.workflowUpdated.emit(spec); this.workflowUpdated.emit(spec);
}); });

View File

@ -149,7 +149,7 @@ describe('WorkflowSpecListComponent', () => {
_updateWorkflowSpecSpy.calls.reset(); _updateWorkflowSpecSpy.calls.reset();
component.selectedSpec = mockWorkflowSpec0; component.selectedSpec = mockWorkflowSpec0;
const modifiedData: WorkflowSpecDialogData = createClone()(mockWorkflowSpec0); const modifiedData: WorkflowSpecDialogData = createClone({circles: true})(mockWorkflowSpec0);
modifiedData.display_name = 'Modified'; modifiedData.display_name = 'Modified';
(component as any)._upsertWorkflowSpecification(modifiedData); (component as any)._upsertWorkflowSpecification(modifiedData);
expect(_addWorkflowSpecSpy).not.toHaveBeenCalled(); expect(_addWorkflowSpecSpy).not.toHaveBeenCalled();
@ -245,7 +245,7 @@ describe('WorkflowSpecListComponent', () => {
_updateWorkflowSpecCategorySpy.calls.reset(); _updateWorkflowSpecCategorySpy.calls.reset();
component.selectedCat = mockWorkflowSpecCategory0; component.selectedCat = mockWorkflowSpecCategory0;
const modifiedData: WorkflowSpecCategoryDialogData = createClone()(mockWorkflowSpecCategory0); const modifiedData: WorkflowSpecCategoryDialogData = createClone({circles: true})(mockWorkflowSpecCategory0);
modifiedData.display_name = 'Modified'; modifiedData.display_name = 'Modified';
(component as any)._upsertWorkflowSpecCategory(modifiedData); (component as any)._upsertWorkflowSpecCategory(modifiedData);
expect(_addWorkflowSpecCategorySpy).not.toHaveBeenCalled(); expect(_addWorkflowSpecCategorySpy).not.toHaveBeenCalled();

View File

@ -91,6 +91,7 @@ export class WorkflowSpecListComponent implements OnInit {
id: this.selectedCat ? this.selectedCat.id : null, id: this.selectedCat ? this.selectedCat.id : null,
name: this.selectedCat ? this.selectedCat.name || this.selectedCat.id : '', name: this.selectedCat ? this.selectedCat.name || this.selectedCat.id : '',
display_name: this.selectedCat ? this.selectedCat.display_name : '', display_name: this.selectedCat ? this.selectedCat.display_name : '',
display_order: this.selectedCat ? this.selectedCat.display_order : null,
}, },
}); });
@ -133,7 +134,7 @@ export class WorkflowSpecListComponent implements OnInit {
private _loadWorkflowSpecCategories() { private _loadWorkflowSpecCategories() {
this.api.getWorkflowSpecCategoryList().subscribe(cats => { this.api.getWorkflowSpecCategoryList().subscribe(cats => {
this.categories = cats; this.categories = cats.sort((a, b) => (a.display_order < b.display_order) ? -1 : 1);
this.workflowSpecsByCategory = [{ this.workflowSpecsByCategory = [{
id: null, id: null,
name: 'none', name: 'none',
@ -249,12 +250,12 @@ export class WorkflowSpecListComponent implements OnInit {
} }
onWorkflowUpdated(spec: WorkflowSpec) { onWorkflowUpdated(spec: WorkflowSpec) {
if (spec.is_status) { if (spec.is_master_spec) {
// Mark all other specs as not is_status // Mark all other specs as not is_master_spec
let numUpdated = this.workflowSpecs.length - 1; let numUpdated = this.workflowSpecs.length - 1;
this.workflowSpecs.forEach(wfs => { this.workflowSpecs.forEach(wfs => {
if (wfs.id !== spec.id) { if (wfs.id !== spec.id) {
wfs.is_status = false; wfs.is_master_spec = false;
this.api.updateWorkflowSpecification(wfs.id, wfs).subscribe(() => { this.api.updateWorkflowSpecification(wfs.id, wfs).subscribe(() => {
numUpdated--; numUpdated--;
if (numUpdated === 0) { if (numUpdated === 0) {