Commit 37aa9596 authored by Yadd's avatar Yadd
Browse files

Manage "force saving"

parent 76dda5fd
......@@ -6,9 +6,6 @@
## Bugs
* When we get needConfirm: 1 in save response, configuration is already saved.
It should only be saved after confirmation. We should have a "cancel" button
in confirmation window to refuse the changes.
* SAML IDP/SP exported attributes not working
## Configuration management
......
......@@ -620,12 +620,6 @@ sub newConf {
$res->{details}->{$t} = $parser->$t if ( @{ $parser->$t } );
}
if ( $res->{result} ) {
if ( @{ $parser->needConfirm } and not $req->params('force') ) {
push @{ $res->{details}->{errors} }, @{ $parser->needConfirm };
$res->{result} = 0;
$res->{needConfirm} = 1;
$res->{message} .= '__needConfirmation__';
}
if ( $self->{demoMode} ) {
$res->{message} = '__demoModeOn__';
}
......@@ -640,12 +634,14 @@ sub newConf {
$res->{cfgNum} = $s;
}
else {
$self->userNoticeInfo( $req,
$self->userNotice( $req,
'Saving attempt rejected, asking for confirmation to '
. $self->userId($req) );
$res->{result} = 0;
$res->{needConfirm} = 1 if ( $s == CONFIG_WAS_CHANGED );
$res->{message} .= '__needConfirmation__';
if ( $s == CONFIG_WAS_CHANGED ) {
$res->{needConfirm} = 1;
$res->{message} .= '__needConfirmation__';
}
}
}
}
......@@ -672,13 +668,13 @@ sub newRawConf {
# chances to be equal to last config cfgNum
my $s = $self->confAcc->saveConf( $new, force => 1 );
if ( $s > 0 ) {
$self->userNoticeInfo( $req,
$self->userNotice( $req,
'User ' . $self->userId($req) . " has stored (raw) conf $s" );
$res->{result} = 1;
$res->{cfgNum} = $s;
}
else {
$self->userNoticeInfo( $req,
$self->userNotice( $req,
'Raw saving attempt rejected, asking for confirmation to '
. $self->userId($req) );
$res->{result} = 0;
......
......@@ -133,10 +133,11 @@
$scope.message = {
'title': '',
'message': '',
'items': []
'items': [],
};
if (data.message && data.message == 'needConfirmation') {
// TODO
console.log(data);
if (data.message && data.message == '__needConfirmation__') {
$scope.confirmNeeded = true;
}
if (data.message) $scope.message.message = data.message;
if (data.details) {
......@@ -166,7 +167,7 @@
"title": "cfgLog",
"data": $scope.result
});
$http.post($scope.confPrefix + '?cfgNum=' + $scope.currentCfg.cfgNum, $scope.data).success(function(data) {
$http.post($scope.confPrefix + '?cfgNum=' + $scope.currentCfg.cfgNum + ($scope.forceSave ? "&force=1" : ''), $scope.data).success(function(data) {
$scope.data.pop();
_checkSaveResponse(data);
}).error(function(j, e) {
......@@ -738,6 +739,8 @@
var tmp;
$scope.waiting = true;
$scope.data = [];
$scope.confirmNeeded = false;
$scope.forceSave = false;
$q.all([
$translator.init($scope.lang), $http.get(staticPrefix + "struct.json").success(function(data) {
tmp = data;
......@@ -766,4 +769,4 @@
};
}]);
})();
})();
\ No newline at end of file
......@@ -168,6 +168,7 @@
"facebookParams": "Facebook parameters",
"failedLoginNumber": "Number of registered failed logins",
"fileToUpload": "File to upload",
"forceSave": "Force save",
"format": "Format",
"formReplay": "Form replay",
"friendlyName": "Friendly name",
......@@ -290,6 +291,7 @@
"multiUserDBStack": "UserDB stack string",
"multiValuesSeparator": "Separator",
"name": "Name",
"needConfirmation": "A new configuration is available. To force saving this one, click on the check box near the 'save' button",
"newApp": "New application",
"newChain": "New chain",
"newCat": "New category",
......
......@@ -168,6 +168,7 @@
"facebookParams": "Paramètres Facebook",
"failedLoginNumber": "Nombre d'échecs de connexion mémorisés",
"fileToUpload": "Fichier à télécharger",
"forceSave": "Forcer la sauvegarde",
"format": "Format",
"formReplay": "Rejeu de formulaires",
"friendlyName": "Nom alternatif",
......@@ -290,6 +291,7 @@
"multiUserDBStack": "Pile d'identification",
"multiValuesSeparator": "Separateur",
"name": "Nom",
"needConfirmation": "Une nouvelle configuration est disponible. Pour sauvegarder celle-ci, cocher la case à côté du bouton 'sauver'",
"newApp": "Nouvelle application",
"newChain": "Nouvelle chaîne",
"newCat": "Nouvelle catégorie",
......
......@@ -21,7 +21,7 @@
<div class="navbar navbar-default" ng-class="{'hidden-xs':!showM}">
<div class="navbar-collapse" ng-class="{'collapse':!showM}" id="formmenu">
<ul class="nav navbar-nav">
<li><a class="link" ng-click="save()"><i class="glyphicon glyphicon-save"></i> {{translate('save')}}</a></li>
<li><a class="link" ng-click="save()" tabIndex="-1"><i class="glyphicon glyphicon-save"></i> {{translate('save')}}<input type="checkbox" ng-model="forceSave" title="{{translate('forceSave')}}" ng-show="confirmNeeded"></a></li>
<li ng-class="{'disabled':!currentCfg.prev}"><a class="link" ng-click="currentCfg.prev && getCfg(currentCfg.prev)" title="Configuration {{currentCfg.prev}}"><i class="glyphicon glyphicon-arrow-left"></i> {{translate('previous')}}</a></li>
<li ng-class="{'disabled':!currentCfg.next}"><a class="link" ng-click="currentCfg.next && getCfg(currentCfg.next)" title="Configuration {{currentCfg.next}}"><i class="glyphicon glyphicon-arrow-right"></i> {{translate('next')}}</a></a></li>
<li><a class="link" ng-click="getCfg('latest')" title="Latest configuration"><i class="glyphicon glyphicon-refresh"></i> {{translate('latest')}}</a></li>
......@@ -94,7 +94,7 @@
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="ok()" trspan="ok"></button>
<button class="btn btn-warning" ng-click="cancel()" ng-if="message.displayCancel" trspan="cancel"></button>
<button class="btn btn-warning" ng-click="cancel()" ng-if="elem('message').displayCancel" trspan="cancel"></button>
</div>
</script>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment