From d2caf8c96a566ce3abc646169261959b15184874 Mon Sep 17 00:00:00 2001 From: Francesc Guasch Date: Tue, 6 Nov 2018 13:17:25 +0100 Subject: [PATCH] wip(frontend): small fixes suggested by @gloriarodriguez - sort attributes - remove default after delete the last restriction - set last to true by default on new issue #916 --- public/js/ravada.js | 1 + rvd_front.pl | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/public/js/ravada.js b/public/js/ravada.js index 7853443ea..d048bb86c 100644 --- a/public/js/ravada.js +++ b/public/js/ravada.js @@ -375,6 +375,7 @@ $scope.ldap_attribute = ''; $scope.ldap_attribute_value = ''; $scope.ldap_attribute_allowed=true; + $scope.ldap_attribute_last=true; $http.get('/list_ldap_access/'+$scope.showmachine.id).then(function(response) { $scope.ldap_attributes_domain = response.data.list; $scope.ldap_attributes_default = response.data.default; diff --git a/rvd_front.pl b/rvd_front.pl index 8bd90295f..c952b083f 100644 --- a/rvd_front.pl +++ b/rvd_front.pl @@ -651,7 +651,7 @@ return $c->render(json => []) if !$user; $c->session(ldap_attributes_cn => $cn) if $user; - return $c->render(json => {attributes => [$user->attributes]}); + return $c->render(json => {attributes => [sort $user->attributes]}); }; get '/count_ldap_entries/(#attribute)/(#value)' => sub { @@ -726,6 +726,12 @@ ($c, $domain, $allowed) $domain->delete_ldap_access($c->stash('id_access')); + # delete default if it is the only one left + my @ldap_access = $domain->list_ldap_access(); + if (scalar @ldap_access == 1 && $ldap_access[0]->{value} eq '*') { + $domain->delete_ldap_access($ldap_access[0]->{id}); + } + return $c->render(json => { ok => 1 }); };