+ generateDefaultInputName = (): string => {
+ let defaultInputName: string;
+ let instancesIds = this.keysPipe.transform(this.instanceFePropertiesMap, []);
+ angular.forEach(instancesIds, (instanceId: string) => {
+ let selectedProperty: PropertyBEModel = new PropertyBEModel(this.propertiesService.getCheckedProperties(this.instanceFePropertiesMap[instanceId])[0]);
+ let selectedInstanceData: any = this.instances.find(instance => instance.uniqueId == instanceId);
+ defaultInputName = this.generateInputName(selectedInstanceData.invariantName, selectedProperty.name);
+ });
+ return defaultInputName;
+ }
+
+ private generateInputName = (componentName: string, propertyName: string): string => {
+ let inputName: string;
+ if (propertyName) {
+ if (propertyName.includes("::")) {
+ propertyName = propertyName.replace(/::/g, "_");
+ }
+ if (componentName) {
+ inputName = componentName + "_" + propertyName;
+ } else {
+ inputName = propertyName;
+ }
+ }
+ return inputName;
+ }
+
+ private openAddInputNameAndDeclareInputModal = (): void => {
+ const modalTitle = this.translateService.translate('ADD_INPUT_NAME_TO_DECLARE');
+ const modalButtons = [];
+ const modal = this.modalService.createCustomModal(new ModalModel(
+ 'sm',
+ modalTitle,
+ null,
+ modalButtons,
+ null /* type */
+ ));
+ modalButtons.push(new ButtonModel(this.translateService.translate('MODAL_SAVE'), 'blue',
+ () => {
+ const inputName: string = modal.instance.dynamicContent.instance.inputNameForm.value;
+ if (inputName) {
+ this.declareInputFromProperties(inputName);
+ } else {
+ this.notification.warning({
+ message: 'Failed to set input name',
+ title: 'Warning'
+ });
+ }
+ this.modalService.closeCurrentModal();
+ }
+ ));
+ modalButtons.push(new ButtonModel(this.translateService.translate('MODAL_CANCEL'), 'outline grey', () => {
+ this.modalService.closeCurrentModal();
+ }));
+ this.modalService.addDynamicContentToModal(modal, DeclareInputComponent, {defaultInputName: this.generateDefaultInputName()});
+ modal.instance.open();
+ }
+