Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/cydrobolt/polr.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChaoyi Zha <summermontreal@gmail.com>2017-05-06 19:45:58 +0300
committerChaoyi Zha <summermontreal@gmail.com>2017-05-06 19:45:58 +0300
commitaa961efd0634b3a0af48c3cd3a5f630de9e4670a (patch)
tree516f5be78281eca1f463f68dd608bacbd65f27d0
parent4c08c49c54692810c893af1686da5ce763285c5e (diff)
Use angular bindings for toggleAPIStatus
-rw-r--r--public/directives/editUserApiInfoModal.html6
-rw-r--r--public/js/AdminCtrl.js9
2 files changed, 5 insertions, 10 deletions
diff --git a/public/directives/editUserApiInfoModal.html b/public/directives/editUserApiInfoModal.html
index d46029e..fe16db4 100644
--- a/public/directives/editUserApiInfoModal.html
+++ b/public/directives/editUserApiInfoModal.html
@@ -11,11 +11,9 @@
<p>
<span>API Active</span>:
- <code class='status-display'>
- {{apiActive}}
- </code>
+ <code class='status-display' ng-bind="apiActive"></code>
- <a ng-click="toggleAPIStatus($event)" class='btn btn-xs btn-success'>toggle</a>
+ <a ng-click="toggleAPIStatus()" class='btn btn-xs btn-success'>toggle</a>
</p>
<p>
diff --git a/public/js/AdminCtrl.js b/public/js/AdminCtrl.js
index bd0a2af..586fb96 100644
--- a/public/js/AdminCtrl.js
+++ b/public/js/AdminCtrl.js
@@ -57,15 +57,12 @@ polr.directive('editUserApiInfoModal', function () {
}
// Toggle API access status
- $scope.toggleAPIStatus = function($event) {
- var el = $($event.target);
- var status_display_elem = el.prevAll('.status-display');
-
+ $scope.toggleAPIStatus = function() {
apiCall('admin/toggle_api_active', {
'user_id': $scope.userId,
}, function(new_status) {
- new_status = res_value_to_text(new_status);
- status_display_elem.text(new_status);
+ $scope.apiActive = res_value_to_text(new_status);
+ $scope.$digest();
});
};