mirror of
https://github.com/sartography/cr-connect-bpmn.git
synced 2025-02-23 05:38:25 +00:00
Adds dialog to capture workflow spec metadata and filename
This commit is contained in:
parent
0e28d0e984
commit
04f44155ab
6
src/app/_interfaces/new-file-dialog-data.ts
Normal file
6
src/app/_interfaces/new-file-dialog-data.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export interface NewFileDialogData {
|
||||
fileName: string;
|
||||
workflowSpecId: string;
|
||||
displayName: string;
|
||||
description: string;
|
||||
}
|
14
src/app/new-file-dialog/new-file-dialog.component.html
Normal file
14
src/app/new-file-dialog/new-file-dialog.component.html
Normal file
@ -0,0 +1,14 @@
|
||||
<mat-form-field>
|
||||
<input matInput [(ngModel)]="data.workflowSpecId" placeholder="Workflow specification id">
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput [(ngModel)]="data.fileName" placeholder="File name">
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput [(ngModel)]="data.displayName" placeholder="Display name">
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input matInput [(ngModel)]="data.description" placeholder="Description">
|
||||
</mat-form-field>
|
||||
<button mat-flat-button color="primary" (click)="onSubmit()">Save</button>
|
||||
<button mat-flat-button (click)="onNoClick()">Cancel</button>
|
25
src/app/new-file-dialog/new-file-dialog.component.spec.ts
Normal file
25
src/app/new-file-dialog/new-file-dialog.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NewFileDialogComponent } from './new-file-dialog.component';
|
||||
|
||||
describe('NewFileDialogComponent', () => {
|
||||
let component: NewFileDialogComponent;
|
||||
let fixture: ComponentFixture<NewFileDialogComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ NewFileDialogComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(NewFileDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
41
src/app/new-file-dialog/new-file-dialog.component.ts
Normal file
41
src/app/new-file-dialog/new-file-dialog.component.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import {Component, Inject} from '@angular/core';
|
||||
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';
|
||||
import {NewFileDialogData} from '../_interfaces/new-file-dialog-data';
|
||||
import {toSnakeCase} from '../_util/snake-case';
|
||||
|
||||
@Component({
|
||||
selector: 'app-new-file-dialog',
|
||||
templateUrl: './new-file-dialog.component.html',
|
||||
styleUrls: ['./new-file-dialog.component.scss']
|
||||
})
|
||||
export class NewFileDialogComponent {
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<NewFileDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: NewFileDialogData
|
||||
) {
|
||||
}
|
||||
|
||||
onNoClick() {
|
||||
this.dialogRef.close(this.data);
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.data.workflowSpecId = toSnakeCase(this.data.workflowSpecId);
|
||||
this.data.fileName = this._cleanUpFilename(this.data.fileName);
|
||||
this.dialogRef.close(this.data);
|
||||
}
|
||||
|
||||
private _cleanUpFilename(old: string): string {
|
||||
const arr = old.trim().split('.');
|
||||
|
||||
// Add file extension, if necessary
|
||||
if (arr.length < 2) {
|
||||
arr.push('bpmn');
|
||||
} else {
|
||||
(arr[arr.length - 1]) = 'bpmn';
|
||||
}
|
||||
|
||||
return arr.join('.');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user