From 4e8f3700d1094c87e67d256268ada9c519b18fa9 Mon Sep 17 00:00:00 2001 From: Xavier Guimard Date: Sat, 16 Jan 2016 08:00:44 +0000 Subject: [PATCH] Detect deleted entries in app list (Closes: #907) --- .../lib/Lemonldap/NG/Manager/Conf/Parser.pm | 38 ++++++++++++++++++- .../site/static/js/manager.js | 4 +- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Parser.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Parser.pm index df4d7004d..fa4dffd55 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Parser.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Parser.pm @@ -378,8 +378,42 @@ sub _scanNodes { #################### # Application list # #################### + + # Application list root node + elsif ( $leaf->{title} eq 'applicationList' ) { + hdebug( $leaf->{title} ); + if ( $leaf->{cnodes} ) { + hdebug(' unopened'); + $self->newConf->{applicationList} = + $self->refConf->{applicationList} // {}; + } + else { + $self->_scanNodes($subNodes) or return 0; + + # Check for deleted + my @listCatRef = keys %{ $self->refConf->{applicationList} }; + my @listCatNew = + keys( + ref $self->newConf->{applicationList} + ? $self->newConf->{applicationList} + : {} ); + foreach my $cat (@listCatNew) { + @listCatRef = grep { $_ ne $cat } @listCatRef; + } + if (@listCatRef) { + $self->confChanged(1); + foreach my $cat (@listCatRef) { + push @{ $self->changes }, + { key => $leaf->{id}, old => $cat }; + } + } + } + next; + } + + # Application list sub nodes elsif ( $leaf->{id} =~ /^applicationList\/(.+)$/ ) { - hdebug('Application list'); + hdebug('Application list subnode'); use feature 'state'; my @cats = split /\//, $1; my $app = pop @cats; @@ -441,7 +475,7 @@ sub _scanNodes { push @{ $self->changes }, { key => join( ', ', 'applicationList', @path ), - new => 'New cat(s)/app(s)', + new => 'Changes in cat(s)/app(s)', }; } } diff --git a/lemonldap-ng-manager/site/static/js/manager.js b/lemonldap-ng-manager/site/static/js/manager.js index d86f037b8..6af34485f 100644 --- a/lemonldap-ng-manager/site/static/js/manager.js +++ b/lemonldap-ng-manager/site/static/js/manager.js @@ -121,12 +121,12 @@ modalInstance.result.then(function(msgok) { $scope.message.title = ''; $scope.message.items = []; - $d.resolve(msgok); + d.resolve(msgok); }, function(msgnok) { $scope.message.title = ''; $scope.message.items = []; - $d.reject(msgok); + d.reject(msgok); }); return modalInstance.result; }