mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
added switch for parameter types
This commit is contained in:
@@ -1,14 +1,16 @@
|
|||||||
<div class="form-group">
|
<div class="form-row">
|
||||||
<select required id="process-parameters"
|
<select required id="process-parameters"
|
||||||
class="form-control"
|
class="form-control col"
|
||||||
name="script"
|
name="script"
|
||||||
[(ngModel)]="selectedParameter"
|
[(ngModel)]="selectedParameter"
|
||||||
#param="ngModel">
|
#param="ngModel">
|
||||||
<option [ngValue]="undefined">Add a parameter...</option>
|
<option [ngValue]="undefined">Add a parameter...</option>
|
||||||
<option *ngFor="let param of parameters">
|
<option *ngFor="let param of parameters" [ngValue]="param.name">
|
||||||
{{param.nameLong || param.name}}
|
{{param.nameLong || param.name}}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<ds-string-input></ds-string-input>
|
<ds-parameter-value-input [parameter]="selectedScriptParameter" class="d-block col"></ds-parameter-value-input>
|
||||||
<button><span class="fas fa-trash"></span></button>
|
<button *ngIf="removable" class="btn btn-light col-1" (click)="removeParameter.emit(parameterValue);"><span class="fas fa-trash"></span></button>
|
||||||
|
<span *ngIf="!removable" class="col-1"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@@ -11,6 +11,8 @@ import { hasNoValue } from '../../../../shared/empty.util';
|
|||||||
export class ParameterSelectComponent implements OnInit {
|
export class ParameterSelectComponent implements OnInit {
|
||||||
@Input() parameterValue: ProcessParameter;
|
@Input() parameterValue: ProcessParameter;
|
||||||
@Input() parameters: ScriptParameter[];
|
@Input() parameters: ScriptParameter[];
|
||||||
|
@Input() removable: boolean;
|
||||||
|
@Output() removeParameter: EventEmitter<ProcessParameter> = new EventEmitter<ProcessParameter>();
|
||||||
@Output() changeParameter: EventEmitter<ProcessParameter> = new EventEmitter<ProcessParameter>();
|
@Output() changeParameter: EventEmitter<ProcessParameter> = new EventEmitter<ProcessParameter>();
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@@ -19,6 +21,10 @@ export class ParameterSelectComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get selectedScriptParameter(): ScriptParameter {
|
||||||
|
return this.parameters.find((parameter: ScriptParameter) => parameter.name === this.selectedParameter);
|
||||||
|
}
|
||||||
|
|
||||||
get selectedParameter(): string {
|
get selectedParameter(): string {
|
||||||
return this.parameterValue ? this.parameterValue.name : undefined;
|
return this.parameterValue ? this.parameterValue.name : undefined;
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,3 @@
|
|||||||
|
<div [ngSwitch]="parameter?.type">
|
||||||
|
<ds-string-value-input *ngSwitchCase="parameterTypes.STRING"></ds-string-value-input>
|
||||||
|
</div>
|
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ParameterValueInputComponent } from './parameter-value-input.component';
|
||||||
|
|
||||||
|
describe('ParameterValueInputComponent', () => {
|
||||||
|
let component: ParameterValueInputComponent;
|
||||||
|
let fixture: ComponentFixture<ParameterValueInputComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ ParameterValueInputComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(ParameterValueInputComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@@ -0,0 +1,13 @@
|
|||||||
|
import { Component, Input, OnChanges, OnInit } from '@angular/core';
|
||||||
|
import { ScriptParameterType } from '../../../scripts/script-parameter-type.model';
|
||||||
|
import { ScriptParameter } from '../../../scripts/script-parameter.model';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-parameter-value-input',
|
||||||
|
templateUrl: './parameter-value-input.component.html',
|
||||||
|
styleUrls: ['./parameter-value-input.component.scss']
|
||||||
|
})
|
||||||
|
export class ParameterValueInputComponent {
|
||||||
|
@Input() parameter: ScriptParameter;
|
||||||
|
parameterTypes = ScriptParameterType;
|
||||||
|
}
|
@@ -1,8 +1,10 @@
|
|||||||
<div class="form-group" *ngIf="script">
|
<div class="form-group" *ngIf="script">
|
||||||
<label>Parameters</label>
|
<label>Parameters</label>
|
||||||
<ds-parameter-select
|
<ds-parameter-select
|
||||||
*ngFor="let value of parameterValues; let i = index;"
|
*ngFor="let value of parameterValues; let i = index; let last = last"
|
||||||
[parameters]="script.parameters"
|
[parameters]="script.parameters"
|
||||||
[parameterValue]="value"
|
[parameterValue]="value"
|
||||||
|
[removable]="!last"
|
||||||
|
(removeParameter)="removeParameter(i)"
|
||||||
(changeParameter)="updateParameter($event, i)"></ds-parameter-select>
|
(changeParameter)="updateParameter($event, i)"></ds-parameter-select>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -29,6 +29,10 @@ export class ProcessParametersComponent implements OnChanges {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeParameter(index: number) {
|
||||||
|
this.parameterValues = this.parameterValues.filter((value, i) => i !== index);
|
||||||
|
}
|
||||||
|
|
||||||
addParameter() {
|
addParameter() {
|
||||||
this.parameterValues = [...this.parameterValues, new ProcessParameter()];
|
this.parameterValues = [...this.parameterValues, new ProcessParameter()];
|
||||||
}
|
}
|
||||||
|
@@ -9,6 +9,7 @@ import { ScriptHelpComponent } from './new/script-help/script-help.component';
|
|||||||
import { ParameterSelectComponent } from './new/process-parameters/parameter-select/parameter-select.component';
|
import { ParameterSelectComponent } from './new/process-parameters/parameter-select/parameter-select.component';
|
||||||
import { ProcessParametersComponent } from './new/process-parameters/process-parameters.component';
|
import { ProcessParametersComponent } from './new/process-parameters/process-parameters.component';
|
||||||
import { StringValueInputComponent } from './new/process-parameters/parameter-value-input/string-value-input/string-value-input.component';
|
import { StringValueInputComponent } from './new/process-parameters/parameter-value-input/string-value-input/string-value-input.component';
|
||||||
|
import { ParameterValueInputComponent } from './new/process-parameters/parameter-value-input/parameter-value-input.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -22,6 +23,7 @@ import { StringValueInputComponent } from './new/process-parameters/parameter-va
|
|||||||
ParameterSelectComponent,
|
ParameterSelectComponent,
|
||||||
ProcessParametersComponent,
|
ProcessParametersComponent,
|
||||||
StringValueInputComponent,
|
StringValueInputComponent,
|
||||||
|
ParameterValueInputComponent,
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
],
|
],
|
||||||
|
@@ -2,9 +2,9 @@
|
|||||||
* List of parameter types used for scripts
|
* List of parameter types used for scripts
|
||||||
*/
|
*/
|
||||||
export enum ScriptParameterType {
|
export enum ScriptParameterType {
|
||||||
STRING = 'string',
|
STRING = 'String',
|
||||||
DATE = 'date',
|
DATE = 'date',
|
||||||
BOOLEAN = 'boolean',
|
BOOLEAN = 'boolean',
|
||||||
FILE = 'file',
|
FILE = 'InputStream',
|
||||||
OUTPUT = 'output'
|
OUTPUT = 'OutputStream'
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user