Trying to fix modifying workflow_spec_id issues

This commit is contained in:
Aaron Louie 2020-01-15 17:10:58 -05:00
parent e74e1c309a
commit d381328472
3 changed files with 32 additions and 19 deletions

6
package-lock.json generated
View File

@ -9917,9 +9917,9 @@
"dev": true "dev": true
}, },
"sartography-workflow-lib": { "sartography-workflow-lib": {
"version": "0.0.8", "version": "0.0.10",
"resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.8.tgz", "resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.10.tgz",
"integrity": "sha512-0fOCHoLUWuMh828iXJVUlADiMCNdU/WBihJ9DCvFbdU24qvuKklAXxgF9a7pu3CrCHPTajNrL7pfAbjSUwx21w==", "integrity": "sha512-Awy80Q7h+fvNRYsCEOPFlvbZ5X0wtUEOWPmGzdxQCZB4btBkxE2utxcazzVSigl/2ai5Fmr8JIgWDn2M5y1vVQ==",
"requires": { "requires": {
"tslib": "^1.9.0" "tslib": "^1.9.0"
} }

View File

@ -41,7 +41,7 @@
"file-saver": "^2.0.2", "file-saver": "^2.0.2",
"hammerjs": "^2.0.8", "hammerjs": "^2.0.8",
"rxjs": "~6.5.4", "rxjs": "~6.5.4",
"sartography-workflow-lib": "^0.0.8", "sartography-workflow-lib": "^0.0.10",
"tslib": "^1.10.0", "tslib": "^1.10.0",
"zone.js": "~0.9.1" "zone.js": "~0.9.1"
}, },

View File

@ -116,7 +116,7 @@ export class AppComponent implements AfterViewInit {
if (this.diagramFileMeta && this.diagramFileMeta.workflow_spec_id) { if (this.diagramFileMeta && this.diagramFileMeta.workflow_spec_id) {
this.xml = this.draftXml; this.xml = this.draftXml;
this.diagramFileMeta.file = new File([this.xml], this.diagramFileMeta.name, {type: 'text/xml'}); this.diagramFileMeta.file = new File([this.xml], this.diagramFileMeta.name, {type: 'text/xml'});
this.api.updateFileMeta(this.diagramFileMeta).subscribe(() => { this.api.updateFileMeta(this.workflowSpec.id, this.diagramFileMeta).subscribe(() => {
this.snackBar.open('Saved changes.', 'Ok', {duration: 5000}); this.snackBar.open('Saved changes.', 'Ok', {duration: 5000});
}); });
} else { } else {
@ -197,7 +197,9 @@ export class AppComponent implements AfterViewInit {
description: data.description, description: data.description,
}; };
const fileMetaId = this.diagramFileMeta ? this.diagramFileMeta.id : undefined;
this.diagramFileMeta = { this.diagramFileMeta = {
id: fileMetaId,
content_type: 'text/xml', content_type: 'text/xml',
name: data.fileName, name: data.fileName,
type: FileType.BPMN, type: FileType.BPMN,
@ -214,7 +216,7 @@ export class AppComponent implements AfterViewInit {
if (specId) { if (specId) {
// Update existing workflow spec and file // Update existing workflow spec and file
this.api.updateWorkflowSpecification(specId, newSpec).subscribe(spec => { this.api.updateWorkflowSpecification(specId, newSpec).subscribe(spec => {
this.api.updateFileMeta(this.diagramFileMeta).subscribe(fileMeta => { this.api.updateFileMeta(specId, this.diagramFileMeta).subscribe(fileMeta => {
this.loadFilesFromDb(); this.loadFilesFromDb();
this.snackBar.open('Saved changes to workflow spec and file.', 'Ok', {duration: 5000}); this.snackBar.open('Saved changes to workflow spec and file.', 'Ok', {duration: 5000});
}); });
@ -236,22 +238,33 @@ export class AppComponent implements AfterViewInit {
} }
getFileMetaDisplayString(fileMeta: FileMeta) { getFileMetaDisplayString(fileMeta: FileMeta) {
const wfsName = this.getWorkflowSpec(fileMeta.workflow_spec_id).display_name; const spec = this.getWorkflowSpec(fileMeta.workflow_spec_id);
const lastUpdated = new DatePipe('en-us').transform(fileMeta.last_updated);
return `${wfsName} (${fileMeta.name}) - v${fileMeta.version} (${lastUpdated})`; if (spec) {
const specName = spec.display_name;
const lastUpdated = new DatePipe('en-us').transform(fileMeta.last_updated);
return `${specName} (${fileMeta.name}) - v${fileMeta.version} (${lastUpdated})`;
} else {
return 'Loading...';
}
} }
getFileMetaTooltipText(fileMeta: FileMeta) { getFileMetaTooltipText(fileMeta: FileMeta) {
const wfs = this.getWorkflowSpec(fileMeta.workflow_spec_id); const spec = this.getWorkflowSpec(fileMeta.workflow_spec_id);
const lastUpdated = new DatePipe('en-us').transform(fileMeta.last_updated);
return ` if (spec) {
Workflow spec ID: ${wfs.id} const lastUpdated = new DatePipe('en-us').transform(fileMeta.last_updated);
Display name: ${wfs.display_name} return `
Description: ${wfs.description} Workflow spec ID: ${spec.id}
File name: ${fileMeta.name} Display name: ${spec.display_name}
Last updated: ${lastUpdated} Description: ${spec.description}
Version: ${fileMeta.version} File name: ${fileMeta.name}
`; Last updated: ${lastUpdated}
Version: ${fileMeta.version}
`;
} else {
return 'Loading...';
}
} }
private isXmlFile(file: File) { private isXmlFile(file: File) {