+ declareOutput = (): void => {
+ if (this.checkedAttributesCount == 1) {
+ this.openAddOutputNameModal();
+ } else if (this.checkedAttributesCount > 1) {
+ this.declareAttributes();
+ }
+ }
+
+ private openAddOutputNameModal = (): void => {
+ const modalTitle = 'Enter name of the ouput to be created';
+ const modalButtons = [];
+ const modal = this.ModalService.createCustomModal(new ModalModel(
+ 'sm',
+ modalTitle,
+ null,
+ modalButtons,
+ null /* type */
+ ));
+ modalButtons.push(new ButtonModel('Save', 'blue',
+ () => {
+ const outputName: string = modal.instance.dynamicContent.instance.inputNameForm.value;
+ if (outputName) {
+ this.declareAttributes(outputName);
+ } else {
+ this.Notification.warning({
+ message: 'Failed to set input name',
+ title: 'Warning'
+ });
+ }
+ this.ModalService.closeCurrentModal();
+ }
+ ));
+ modalButtons.push(new ButtonModel('Cancel', 'outline grey', () => {
+ this.ModalService.closeCurrentModal();
+ }));
+ this.ModalService.addDynamicContentToModal(modal, DeclareInputComponent, {defaultInputName: this.generateDefaultOutputName()});
+ modal.instance.open();
+ }
+
+ generateDefaultOutputName = (): string => {
+ let defaultInputName: string;
+ let instancesIds = this.keysPipe.transform(this.instanceFeAttributesMap, []);
+ angular.forEach(instancesIds, (instanceId: string) => {
+ const selectedOutput : AttributeBEModel = this.attributesService.getCheckedAttributes(this.instanceFeAttributesMap[instanceId])[0];
+ let selectedInstanceData: any = this.instances.find(instance => instance.uniqueId == instanceId);
+ defaultInputName = selectedOutput.name;
+ if (selectedInstanceData.invariantName) {
+ defaultInputName = selectedInstanceData.invariantName+'_'+selectedOutput.name;
+ }
+ });
+ return defaultInputName;
+ }