Milestone import support
[sdc.git] / catalog-ui / src / app / ng2 / pages / composition / interface-operatons / operation-creator / add-input / add-input.component.ts
index 6632d1a..d3b596e 100644 (file)
@@ -38,6 +38,7 @@ export class AddInputComponent implements OnInit {
   @Input('dataTypeMap') dataTypeMap$: Observable<Map<string, DataTypeModel>>;
   @Input('isView') isView: boolean;
   @Input() existingInputNames: Array<string> = [];
+  @Input('defaultType') defaultType: string;
   @Output('onAddInput') onAddInputEvent: EventEmitter<InputOperationParameter>;
 
   dataTypeMap: Map<string, DataTypeModel>;
@@ -136,7 +137,6 @@ export class AddInputComponent implements OnInit {
         input.schema.property = new SchemaProperty();
         input.schema.property.type = schemaForm.value;
       }
-      input.inputId = this.generateUniqueId();
       this.onAddInputEvent.emit(input);
       this.hideAddInput();
       this.resetForm();
@@ -144,6 +144,9 @@ export class AddInputComponent implements OnInit {
   }
 
   showAddInput() {
+    if (this.defaultType) {
+      this.onChangeInputType(this.defaultType);
+    }
     this.showForm = true;
     this.showAddLink = false;
   }
@@ -158,16 +161,6 @@ export class AddInputComponent implements OnInit {
     this.resetForm();
   }
 
-  private generateUniqueId(): string {
-    let result = '';
-    const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
-    const charactersLength = characters.length;
-    for (let i = 0; i < 36; i++ ) {
-      result += characters.charAt(Math.floor(Math.random() * charactersLength));
-    }
-    return result;
-  }
-
   private resetForm() {
     this.inputForm.reset();
     this.showInputSchema = false;