Adds dialog to capture workflow spec metadata and filename

This commit is contained in:
Aaron Louie 2020-01-13 22:17:57 -05:00
parent 0e28d0e984
commit 04f44155ab
5 changed files with 86 additions and 0 deletions

View File

@ -0,0 +1,6 @@
export interface NewFileDialogData {
fileName: string;
workflowSpecId: string;
displayName: string;
description: string;
}

View 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>

View 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();
});
});

View 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('.');
}
}