Saves file data along with file metadata

This commit is contained in:
Aaron Louie 2020-01-31 15:50:20 -05:00
parent 4e5d6cc1c6
commit b21b55c79f
2 changed files with 9 additions and 4 deletions

View File

@ -312,6 +312,8 @@ describe('ModelerComponent', () => {
};
const updateFileMetaSpy = spyOn(component.api, 'updateFileMeta')
.and.returnValue(of(mockFileMeta0));
const updateFileDataSpy = spyOn(component.api, 'updateFileData')
.and.returnValue(of(mockFileMeta0.file));
const loadFilesFromDbSpy = spyOn(component, 'loadFilesFromDb').and.stub();
const snackBarSpy = spyOn(component.snackBar, 'open').and.stub();
const noDateOrVersion: FileMeta = {
@ -326,7 +328,8 @@ describe('ModelerComponent', () => {
component.draftXml = newXml;
component._upsertFileMeta(data);
expect(component.xml).toEqual(newXml);
expect(updateFileMetaSpy).toHaveBeenCalledWith(mockWorkflowSpec0.id, noDateOrVersion);
expect(updateFileMetaSpy).toHaveBeenCalledWith(noDateOrVersion);
expect(updateFileDataSpy).toHaveBeenCalledWith(noDateOrVersion);
expect(loadFilesFromDbSpy).toHaveBeenCalled();
expect(snackBarSpy).toHaveBeenCalled();
});

View File

@ -263,9 +263,11 @@ export class ModelerComponent implements AfterViewInit {
if (this.workflowSpec && isNumberDefined(fileMetaId)) {
// Update existing file meta
this.api.updateFileMeta(this.diagramFileMeta).subscribe(fileMeta => {
this.loadFilesFromDb();
this.snackBar.open(`Saved changes to file ${fileMeta.name}.`, 'Ok', {duration: 5000});
this.api.updateFileData(this.diagramFileMeta).subscribe(() => {
this.api.updateFileMeta(this.diagramFileMeta).subscribe(() => {
this.loadFilesFromDb();
this.snackBar.open(`Saved changes to file ${this.diagramFileMeta.name}.`, 'Ok', {duration: 5000});
});
});
} else {
// Add new file meta