Skip to content

Commit d0d0a66

Browse files
author
Davide Negretti
committed
[DSC-828] new 'Integer' script parameter type
1 parent 7cf4661 commit d0d0a66

7 files changed

+73
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<input required #string="ngModel" type="number" name="number-value-{{index}}" class="form-control" id="number-value-{{index}}" [ngModel]="value" (ngModelChange)="setValue($event)"/>
2+
<div *ngIf="string.invalid && (string.dirty || string.touched)"
3+
class="alert alert-danger validation-error">
4+
<div *ngIf="string.errors.required">
5+
{{'process.new.parameter.number.required' | translate}}
6+
</div>
7+
</div>

src/app/process-page/form/process-parameters/parameter-value-input/number-value-input/number-value-input.component.scss

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { NumberValueInputComponent } from './number-value-input.component';
4+
5+
describe('NumberValueInputComponent', () => {
6+
let component: NumberValueInputComponent;
7+
let fixture: ComponentFixture<NumberValueInputComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [ NumberValueInputComponent ]
12+
})
13+
.compileComponents();
14+
});
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(NumberValueInputComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { Component, Optional, Input } from '@angular/core';
2+
import { ValueInputComponent } from '../value-input.component';
3+
import { ControlContainer, NgForm } from '@angular/forms';
4+
import { controlContainerFactory } from '../../../process-form.component';
5+
6+
/**
7+
* Represents the user inputted value of a numeric parameter
8+
*/
9+
@Component({
10+
selector: 'ds-number-value-input',
11+
templateUrl: './number-value-input.component.html',
12+
styleUrls: ['./number-value-input.component.scss'],
13+
viewProviders: [ { provide: ControlContainer,
14+
useFactory: controlContainerFactory,
15+
deps: [[new Optional(), NgForm]] } ]
16+
})
17+
export class NumberValueInputComponent extends ValueInputComponent<string> {
18+
/**
19+
* The current value of the string
20+
*/
21+
value: string;
22+
23+
/**
24+
* Initial value of the field
25+
*/
26+
@Input() initialValue;
27+
28+
ngOnInit() {
29+
this.value = this.initialValue;
30+
}
31+
32+
setValue(value) {
33+
this.value = value;
34+
this.updateValue.emit(value);
35+
}
36+
}

src/app/process-page/form/process-parameters/parameter-value-input/parameter-value-input.component.html

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<div [ngSwitch]="parameter?.type">
22
<ds-string-value-input *ngSwitchCase="parameterTypes.STRING" [initialValue]="initialValue" (updateValue)="updateValue.emit($event)" [index]="index"></ds-string-value-input>
3+
<ds-number-value-input *ngSwitchCase="parameterTypes.NUMBER" [initialValue]="initialValue" (updateValue)="updateValue.emit($event)" [index]="index"></ds-number-value-input>
34
<ds-string-value-input *ngSwitchCase="parameterTypes.OUTPUT" [initialValue]="initialValue" (updateValue)="updateValue.emit($event)" [index]="index"></ds-string-value-input>
45
<ds-date-value-input *ngSwitchCase="parameterTypes.DATE" [initialValue]="initialValue" (updateValue)="updateValue.emit($event)" [index]="index"></ds-date-value-input>
56
<ds-file-value-input *ngSwitchCase="parameterTypes.FILE" (updateValue)="updateValue.emit($event)" [index]="index"></ds-file-value-input>

src/app/process-page/process-page.module.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ProcessDetailFieldComponent } from './detail/process-detail-field/proce
1717
import { ProcessBreadcrumbsService } from './process-breadcrumbs.service';
1818
import { ProcessBreadcrumbResolver } from './process-breadcrumb.resolver';
1919
import { ProcessFormComponent } from './form/process-form.component';
20+
import { NumberValueInputComponent } from './form/process-parameters/parameter-value-input/number-value-input/number-value-input.component';
2021

2122
@NgModule({
2223
imports: [
@@ -37,7 +38,8 @@ import { ProcessFormComponent } from './form/process-form.component';
3738
ProcessOverviewComponent,
3839
ProcessDetailComponent,
3940
ProcessDetailFieldComponent,
40-
ProcessFormComponent
41+
ProcessFormComponent,
42+
NumberValueInputComponent
4143
],
4244
providers: [
4345
ProcessBreadcrumbResolver,

src/app/process-page/scripts/script-parameter-type.model.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
export enum ScriptParameterType {
55
STRING = 'String',
66
DATE = 'date',
7+
NUMBER = 'Integer',
78
BOOLEAN = 'boolean',
89
FILE = 'InputStream',
910
OUTPUT = 'OutputStream'

0 commit comments

Comments
 (0)