Skip to content

Commit

Permalink
remove reset while type onchange envet and fix automation type select…
Browse files Browse the repository at this point in the history
…or visibility
  • Loading branch information
jeffibm committed Jul 11, 2023
1 parent e43627c commit 3dadda5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@
<option value="{{vm.treeOptions.automationTypes.automate}}" translate>Embedded Automate</option>
<option value="{{vm.treeOptions.automationTypes.workflow}}" translate>Embedded Workflows</option>
</select>
<div class="input-group entry_point" style="margin-top:0;" ng-if="vm.modalData.automation_type == vm.treeOptions.automationTypes.automate">
<div class="input-group entry_point" style="margin-top:0;" ng-if="vm.treeOptions.displayAutomationType().automate">
<input type="text" placeholder="Embedded Automate" class="form-control" ng-value="vm.showFullyQualifiedName(vm.modalData.resource_action)" disabled>
<span class="input-group-btn">
<button class="btn btn-default" ng-click="vm.treeOptions.toggle();"><i class="ff ff-load-balancer"></i></button>
</span>
</div>
<div ng-show="vm.treeOptions.emsWorkflowsEnabled" class="input-group" ng-if="vm.modalData.automation_type == vm.treeOptions.automationTypes.workflow">
<div ng-show="vm.treeOptions.emsWorkflowsEnabled" class="input-group" ng-if="vm.treeOptions.displayAutomationType().workflow">
<input type="text" placeholder="Embedded Workflow" class="form-control" ng-value="vm.modalData.resource_action.workflow_name" disabled>
<span class="input-group-btn">
<button class="btn btn-default" ng-click="vm.treeOptions.toggleWorkflows();"><i class="ff ff-load-balancer"></i></button>
Expand Down
46 changes: 20 additions & 26 deletions src/dialog-editor/components/modal-field/modalFieldComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ class ModalFieldController extends ModalController {

public $onInit() {

const emsWorkflowsEnabled = this.treeOptions.emsWorkflowsEnabled === 'true' ? true : false;

/** Function to load the selected workflow if configuration_script_id is available. */
if (this.modalData.resource_action && this.modalData.resource_action.configuration_script_id) {
if (emsWorkflowsEnabled && this.modalData.resource_action && this.modalData.resource_action.configuration_script_id) {
this.loadWorkflow(this.modalData.resource_action.configuration_script_id);
};

Expand All @@ -38,33 +40,25 @@ class ModalFieldController extends ModalController {
automate: 'embedded_automate',
workflow: 'embedded_workflow',
},
emsWorkflowsEnabled: this.treeOptions.emsWorkflowsEnabled === 'true' ? true : false,

/** Function to reset the automation entries when the Automation Type drop down is changed. */
resetAutomationEntries: () => {
const resetFields = {
automate: ['ae_namespace', 'ae_class', 'ae_instance', 'ae_message'],
workflow: ['configuration_script_id', 'workflow_name'],
};

if (this.modalData.resource_action) {
const isEmbeddedAutomate = this.modalData.automation_type === this.treeOptions.automationTypes.automate;
const resetEntries = isEmbeddedAutomate ? resetFields.workflow : resetFields.automate;
resetEntries.forEach((item) => {
if (this.modalData.resource_action.hasOwnProperty(item)) {
this.modalData.resource_action = {
...this.modalData.resource_action,
[item]: '',
};
}
});
}
},
emsWorkflowsEnabled: emsWorkflowsEnabled,

/** Function to reset the modalData while changin the Automation Type. */
onAutomationTypeChange: () => {
this.treeOptions.automationType = this.modalData.automation_type;
this.treeOptions.resetAutomationEntries();
},

/** Function to display the automation_type select box
* 'Embedded Automate' will be displayed, by default.
* When the workflows are enabled, and automation_type === embedded_automate, 'Embedded Automate' select box will be displayed.
* Else, 'Embedded Workflow' will be selected.
*/
displayAutomationType: () => {
let displayAutomate = true;

if(emsWorkflowsEnabled) {
displayAutomate = this.modalData.automation_type === this.treeOptions.automationTypes.automate;
}
return {automate: displayAutomate, workflow: !displayAutomate};
},

/** Function to open the modal box and load the automate tree. */
Expand Down Expand Up @@ -161,8 +155,8 @@ class ModalFieldController extends ModalController {

/** Function to load a selected workflow. */
public loadWorkflow(id: number) {
this.treeOptions.loadWorkflow(id).then((workflow) => {
this.modalData.resource_action.workflow_name = workflow.name;
this.treeOptions.loadWorkflow(id).then(({data, status}) => {
this.modalData.resource_action.workflow_name = status ? data.name : '';
});
}
}

0 comments on commit 3dadda5

Please sign in to comment.