Adds workflow spec category dialog.

This commit is contained in:
Aaron Louie 2020-03-16 16:36:51 -04:00
parent 7c1dd01a4d
commit 84eb6075d4
8 changed files with 39 additions and 47 deletions

6
package-lock.json generated
View File

@ -11734,9 +11734,9 @@
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"sartography-workflow-lib": {
"version": "0.0.59",
"resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.59.tgz",
"integrity": "sha512-Aylrdco6fei7P4VAF+ZG+q3F3TJLkyobPmzGJDe+8vfZ5jlUJ+EffWKFV6LKCdLdkaV3oYRpo4voPnm1OvuRSA=="
"version": "0.0.61",
"resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.61.tgz",
"integrity": "sha512-Gv3wZO4RTmApGeQc4SRoH5ioH+BBscFfwMZ9DmhrY7wsnWh/Zym9TjRYd4cEygVjlHsgSY6CAqiDMOxZ6Grf6A=="
},
"sass": {
"version": "1.23.3",

View File

@ -46,7 +46,7 @@
"dmn-js-properties-panel": "^0.3.4",
"file-saver": "^2.0.2",
"rxjs": "~6.5.4",
"sartography-workflow-lib": "^0.0.59",
"sartography-workflow-lib": "^0.0.61",
"tslib": "^1.10.0",
"uuid": "^7.0.0",
"zone.js": "~0.10.2"

View File

@ -1,5 +1,5 @@
<div mat-dialog-title>
<h1>Workflow Specification</h1>
<h1>Workflow Spec Category</h1>
</div>
<div mat-dialog-content>

View File

@ -19,13 +19,12 @@ export class WorkflowSpecCategoryDialogComponent {
{
key: 'id',
type: 'input',
defaultValue: this.data.id || uuidv4(),
defaultValue: this.data.id,
templateOptions: {
label: 'ID',
placeholder: 'UUID of workflow specification',
description: 'This is an autogenerated unique ID and is not editable.',
type: 'number',
placeholder: 'ID of workflow spec category',
required: true,
disabled: true,
},
},
{
@ -34,7 +33,7 @@ export class WorkflowSpecCategoryDialogComponent {
defaultValue: this.data.name,
templateOptions: {
label: 'Name',
placeholder: 'Name of workflow specification',
placeholder: 'Name of workflow spec category',
description: 'Enter a name, in lowercase letters, separated by underscores, that is easy for you to remember.' +
'It will be converted to all_lowercase_with_underscores when you save.',
required: true,
@ -46,23 +45,12 @@ export class WorkflowSpecCategoryDialogComponent {
defaultValue: this.data.display_name,
templateOptions: {
label: 'Display Name',
placeholder: 'Title of the workflow specification',
description: 'This is a human readable title for the workflow specification,' +
placeholder: 'Title of the workflow spec category',
description: 'This is a human-readable title for the workflow spec category,' +
'which should be easy for others to read and remember.',
required: true,
},
},
{
key: 'description',
type: 'textarea',
defaultValue: this.data.description,
templateOptions: {
label: 'Description',
placeholder: 'Description of workflow specification',
description: 'Write a few sentences explaining to users why this workflow exists and what it should be used for.',
required: true,
},
},
];
constructor(

View File

@ -47,7 +47,7 @@ export class WorkflowSpecDialogComponent {
templateOptions: {
label: 'Display Name',
placeholder: 'Title of the workflow specification',
description: 'This is a human readable title for the workflow specification,' +
description: 'This is a human-readable title for the workflow specification,' +
'which should be easy for others to read and remember.',
required: true,
},

View File

@ -21,7 +21,7 @@ export interface WorkflowSpecDialogData {
}
export interface WorkflowSpecCategoryDialogData {
id: string;
id: number;
name: string;
display_name: string;
}

View File

@ -6,7 +6,7 @@
<mat-icon>library_add</mat-icon>
Add new workflow specification
</button>
<button mat-flat-button color="primary" (click)="addWorkflowSpecCategory()">
<button mat-flat-button color="primary" (click)="editWorkflowSpecCategory()">
<mat-icon>library_add</mat-icon>
Add category
</button>

View File

@ -152,11 +152,11 @@ export class WorkflowSpecListComponent implements OnInit {
}
}
private _upsertWorkflowCategorySpecification(data: WorkflowSpecCategoryDialogData) {
private _upsertWorkflowSpecCategory(data: WorkflowSpecCategoryDialogData) {
if (data.id && data.name && data.display_name) {
// Save old workflow spec id, in case it's changed
const specId = this.selectedSpec ? this.selectedSpec.id : undefined;
const catId = this.selectedCat ? this.selectedCat.id : undefined;
const newCat: WorkflowSpecCategory = {
id: data.id,
@ -164,8 +164,8 @@ export class WorkflowSpecListComponent implements OnInit {
display_name: data.display_name,
};
if (specId) {
this._updateWorkflowSpecCategory(specId, newCat);
if (catId) {
this._updateWorkflowSpecCategory(catId, newCat);
} else {
this._addWorkflowSpecCategory(newCat);
}
@ -186,20 +186,6 @@ export class WorkflowSpecListComponent implements OnInit {
});
}
private _updateWorkflowSpecCategory(specId: string, newCat: WorkflowSpecCategory) {
this.api.updateWorkflowSpecCategory(specId, newCat).subscribe(spec => {
this._loadWorkflowSpecs();
this._displayMessage('Saved changes to workflow spec.');
});
}
private _addWorkflowSpecCategory(newCat: WorkflowSpecCategory) {
this.api.addWorkflowSpecCategory(newCat).subscribe(spec => {
this._loadWorkflowSpecs();
this._displayMessage('Saved new workflow spec.');
});
}
private _deleteWorkflowSpec(workflowSpec: WorkflowSpec) {
this.api.deleteWorkflowSpecification(workflowSpec.id).subscribe(() => {
this._loadWorkflowSpecs();
@ -207,12 +193,30 @@ export class WorkflowSpecListComponent implements OnInit {
});
}
private _updateWorkflowSpecCategory(catId: number, newCat: WorkflowSpecCategory) {
this.api.updateWorkflowSpecCategory(catId, newCat).subscribe(spec => {
this._loadWorkflowSpecs();
this._displayMessage('Saved changes to workflow spec category.');
});
}
private _addWorkflowSpecCategory(newCat: WorkflowSpecCategory) {
this.api.addWorkflowSpecCategory(newCat).subscribe(spec => {
this._loadWorkflowSpecs();
this._displayMessage('Saved new workflow spec category.');
});
}
private _deleteWorkflowSpecCategory(workflowSpecCategory: WorkflowSpecCategory) {
this.api.deleteWorkflowSpecCategory(workflowSpecCategory.id).subscribe(() => {
this._loadWorkflowSpecs();
this._displayMessage(`Deleted workflow spec category ${workflowSpecCategory.name}.`);
});
}
private _displayMessage(message: string) {
this.snackBar.open(message, 'Ok', {duration: 3000});
}
addWorkflowSpecCategory() {
}
}