Merge pull request #150 from sartography/bug/rename-file-issue-768
Bug/rename file issue #768
This commit is contained in:
commit
e72e5981b7
31
README.md
31
README.md
|
@ -12,6 +12,37 @@ Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app w
|
|||
|
||||
You can also user `npm run start:dev` to get a dev server with lazy loading. This makes development much more efficient
|
||||
|
||||
## Development server
|
||||
|
||||
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
|
||||
|
||||
## Local Development with Sartography Libraries
|
||||
If you are making changes to the Sartography Libraries dependency, you
|
||||
can use npm link to connect the two systems.
|
||||
On the library side, run
|
||||
```bash
|
||||
ng build --watch
|
||||
```
|
||||
Then create a link to the built values by cd'ing into the dist directory (in a new terminal, leave the build above running)
|
||||
```bash
|
||||
cd sartography-libraries/dist/sartography-workflow-lib
|
||||
npm link
|
||||
```
|
||||
|
||||
On the frontend code, link to the sartgraph-workflow-lib:
|
||||
```bash
|
||||
npm link sartography-workflow-lib
|
||||
ng serve
|
||||
```
|
||||
|
||||
Also note that you may need to add
|
||||
```json
|
||||
"preserveSymlinks": true
|
||||
```
|
||||
to your angular.json file in build/options.
|
||||
|
||||
At this point any changes you make to the shared libraries should be immediately reflected in your locally running front end.
|
||||
|
||||
## Code scaffolding
|
||||
|
||||
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
"ngx-markdown": "^12.0.1",
|
||||
"protractor": "^7.0.0",
|
||||
"rxjs": "^6.5.3",
|
||||
"sartography-workflow-lib": "0.0.616",
|
||||
"sartography-workflow-lib": "0.0.626",
|
||||
"tslib": "^2.3.0",
|
||||
"uuid": "^8.3.2",
|
||||
"zone.js": "~0.11.4"
|
||||
|
@ -16907,9 +16907,9 @@
|
|||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||
},
|
||||
"node_modules/sartography-workflow-lib": {
|
||||
"version": "0.0.616",
|
||||
"resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.616.tgz",
|
||||
"integrity": "sha512-m7lKhp8kpGt3kgkl9WOkznyc1c65uKt9cyYG7NOTaRSA1PO9dgfo12SRqycPiiSpaR/HxHA0R2U6zvCgQLa1Eg==",
|
||||
"version": "0.0.626",
|
||||
"resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.626.tgz",
|
||||
"integrity": "sha512-TCd5z8OaF7hj01Sr4EOVPs3Dwl//6lRUA9slgugmP6Up6fQ7c5KebpwgMRi2149yrqUcH7lXGWV7CQJ2l2BMYA==",
|
||||
"dependencies": {
|
||||
"tslib": "^2.2.0"
|
||||
}
|
||||
|
@ -33429,9 +33429,9 @@
|
|||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||
},
|
||||
"sartography-workflow-lib": {
|
||||
"version": "0.0.616",
|
||||
"resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.616.tgz",
|
||||
"integrity": "sha512-m7lKhp8kpGt3kgkl9WOkznyc1c65uKt9cyYG7NOTaRSA1PO9dgfo12SRqycPiiSpaR/HxHA0R2U6zvCgQLa1Eg==",
|
||||
"version": "0.0.626",
|
||||
"resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.626.tgz",
|
||||
"integrity": "sha512-TCd5z8OaF7hj01Sr4EOVPs3Dwl//6lRUA9slgugmP6Up6fQ7c5KebpwgMRi2149yrqUcH7lXGWV7CQJ2l2BMYA==",
|
||||
"requires": {
|
||||
"tslib": "^2.2.0"
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
"ngx-markdown": "^12.0.1",
|
||||
"protractor": "^7.0.0",
|
||||
"rxjs": "^6.5.3",
|
||||
"sartography-workflow-lib": "0.0.616",
|
||||
"sartography-workflow-lib": "0.0.626",
|
||||
"tslib": "^2.3.0",
|
||||
"uuid": "^8.3.2",
|
||||
"zone.js": "~0.11.4"
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
<button mat-menu-item (click)="diagram.saveXML()"><mat-icon>code</mat-icon> Download XML File</button>
|
||||
</mat-menu>
|
||||
|
||||
<button mat-button *ngIf="diagramFile" (click)="editFileMeta()">
|
||||
<button mat-button *ngIf="!hasChanged()" (click)="editFileMeta()">
|
||||
<mat-icon>edit</mat-icon>
|
||||
{{getFileName()}}
|
||||
</button>
|
||||
|
|
|
@ -327,7 +327,11 @@ export class ModelerComponent implements AfterViewInit {
|
|||
|
||||
dialogRef.afterClosed().subscribe((data: FileMetaDialogData) => {
|
||||
if (data && data.fileName) {
|
||||
this._upsertFileMeta(data);
|
||||
if (this.diagramFileMeta) {
|
||||
this._updateFileFilename(data);
|
||||
} else {
|
||||
this._upsertFileMeta(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -379,6 +383,17 @@ export class ModelerComponent implements AfterViewInit {
|
|||
});
|
||||
}
|
||||
|
||||
private _updateFileFilename(data: FileMetaDialogData) {
|
||||
// If it's the first time, we don't have this.fileMetaName
|
||||
if ((!this.fileMetaName) || ((data.fileName) && (this.fileMetaName !== data.fileName))) {
|
||||
this.api.updateSpecFileFilename(this.workflowSpec, this.diagramFileMeta, data.fileName).subscribe(newFileMeta => {
|
||||
this.diagramFileMeta = newFileMeta;
|
||||
this.router.navigate(['/modeler', this.workflowSpec.id, 'file', data.fileName]);
|
||||
this.snackBar.open(`Renamed file to ${this.diagramFileMeta.name}.`, 'Ok', {duration: 5000});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private _upsertFileMeta(data: FileMetaDialogData) {
|
||||
if (data.fileName) {
|
||||
this.xml = this.draftXml;
|
||||
|
@ -391,7 +406,7 @@ export class ModelerComponent implements AfterViewInit {
|
|||
};
|
||||
this.diagramFile = new File([this.xml], data.fileName, {type: 'text/xml'});
|
||||
|
||||
if (this.bpmnFiles.find(x => x.name === data.fileName)) {
|
||||
if (this.bpmnFiles.find(x => x.name === data.fileName)) {
|
||||
// Update the existing file meta
|
||||
this.api.updateSpecFileData(this.workflowSpec, this.diagramFileMeta, this.diagramFile).subscribe(() => {
|
||||
this.api.updateSpecFileMeta(this.workflowSpec, this.diagramFileMeta, false).subscribe(() => {
|
||||
|
@ -400,13 +415,9 @@ export class ModelerComponent implements AfterViewInit {
|
|||
});
|
||||
});
|
||||
} else {
|
||||
// If the filename has changed, delete the old version
|
||||
// The filename has changed
|
||||
if (this.fileMetaName !== data.fileName && this.fileMetaName !== null) {
|
||||
this.api.deleteSpecFileMeta(this.workflowSpec, this.fileMetaName).subscribe(() => {
|
||||
this.api.getSpecFileMetas(this.workflowSpec.id).subscribe(fms => {
|
||||
this.bpmnFiles = fms.sort((a, b) => (a.name > b.name) ? 1 : -1);
|
||||
});
|
||||
});
|
||||
this._updateFileFilename(data);
|
||||
}
|
||||
this.api.addSpecFile(this.workflowSpec, this.diagramFileMeta, this.diagramFile).subscribe(fileMeta => {
|
||||
this.router.navigate(['/modeler', this.workflowSpec.id, 'file', fileMeta.name]);
|
||||
|
|
Loading…
Reference in New Issue