Skip to content

Commit

Permalink
Fix problem related to multiple forms at the same time from settings tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesús Ángel González committed Feb 21, 2018
1 parent 7cad073 commit 9df1e31
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions public/controllers/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ app.controller('settingsController', function ($scope, $rootScope, $http, $route
return false;
}

$scope.toggleEditor = entry => {
$scope.showEditForm[entry._id] = !$scope.showEditForm[entry._id];
$scope.isEditing = $scope.showEditForm[entry._id];
$scope.addManagerContainer = false;
if(!$scope.$$phase) $scope.$digest();
}

// Save settings function
const saveSettings = async () => {
Expand Down
6 changes: 3 additions & 3 deletions public/templates/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ <h1 class="wazuh-h1"><i class="fa fa-cog ng-scope font-size-25" aria-hidden="tru
<i ng-click="setDefault(entry)" tooltip="Set as default Manager" class="fa fa-star font-size-18 cursor-pointer" aria-hidden="true"></i>
<i ng-click="removeManager(entry)" tooltip="Remove manager" class="fa fa-trash settings-template-2 cursor-pointer" aria-hidden="true"></i>
<i ng-click="checkManager(entry)" tooltip="Check connection" class="fa fa-refresh settings-template-2 cursor-pointer" aria-hidden="true"></i>
<i ng-click="showEditForm[entry._id] = !showEditForm[entry._id]" tooltip="Edit" class="fa fa-pencil settings-template-2 cursor-pointer" aria-hidden="true"></i>
<i ng-click="toggleEditor(entry)" tooltip="Edit" class="fa fa-pencil settings-template-2 cursor-pointer" aria-hidden="true"></i>
</p>
</span>
<span layout="row" layout-align="space-between center" ng-if="showEditForm[entry._id]">
<span layout="row" layout-align="space-between center" ng-if="showEditForm[entry._id] && isEditing">
<form flex ng-submit="updateSettings(entry)" layout="column" layout-align="start stretch" class="margin-top-30">
<md-input-container>
<label>Username</label>
Expand Down Expand Up @@ -111,7 +111,7 @@ <h1 class="wazuh-h1"><i class="fa fa-cog ng-scope font-size-25" aria-hidden="tru
</md-button>
</div>

<form flex ng-submit="processForm()" layout="column" layout-align="start stretch" ng-if="!currentAPI || $parent.addManagerContainer" class="margin-top-30">
<form flex ng-submit="processForm()" layout="column" layout-align="start stretch" ng-if="!currentAPI || ($parent.addManagerContainer && !isEditing)" class="margin-top-30">
<md-input-container>
<label>Username</label>
<input placeholder="" type="text" ng-model="formData.user" aria-label="username" required/>
Expand Down

0 comments on commit 9df1e31

Please sign in to comment.