Author: echatellier Date: 2014-06-09 22:00:27 +0200 (Mon, 09 Jun 2014) New Revision: 166 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/166 Log: Edition des ?\195?\169tats d'attente Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp =================================================================== --- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-06-09 19:05:15 UTC (rev 165) +++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-06-09 20:00:27 UTC (rev 166) @@ -542,16 +542,23 @@ </div> <div id="collapse3" class="panel-collapse collapse"> <div class="panel-body"> + <label ng-if="selectedMailFolder.$parent"> + <input type="radio" ng-model="selectedMailFolder.useCurrentLevelEtatAttente" + ng-value="false" ng-change="initFolderEtatAttente()" /> + Hériter des états d'attente déclarés sur les dossiers parent : + </label> + <label class="checkbox" ng-repeat="etatAttente in etatAttentes" ng-if="selectedMailFolder.$parent && !selectedMailFolder.useCurrentLevelEtatAttente"> + <input type="checkbox" ng-checked="parentScopeValues.etatAttentes.indexOf(etatAttente) != -1" + disabled> {{etatAttente.label}} + </label> <label> - <input type="checkbox" ng-model="selectedMailFolder.useCurrentLevelEtatAttente" ng-value="true" /> - Redéfinir les états d'attente à ce niveau. + <input type="radio" ng-model="selectedMailFolder.useCurrentLevelEtatAttente" ng-value="true" + ng-change="initFolderEtatAttente()" ng-if="selectedMailFolder.$parent" /> + Définir des états d'attente pour ce dossier : </label> - Dans le cas contraires, les états d'attentes des dossiers parents seront pris en compte. - <hr /> - <label class="checkbox" ng-repeat="etatAttente in etatAttentes"> - <input type="checkbox" ng-checked="selectedMailFolder.etatAttente.indexOf(etatAttente) != -1" - ng-click="changeFolderEtatAttente(etatAttente)" - ng-disabled="!selectedMailFolder.useCurrentLevelEtatAttente"> {{etatAttente.label}} + <label class="checkbox" ng-repeat="etatAttente in etatAttentes" ng-if="selectedMailFolder.useCurrentLevelEtatAttente || !selectedMailFolder.$parent"> + <input type="checkbox" ng-checked="selectedMailFolder.etatAttentes.indexOf(etatAttente) != -1" + ng-click="changeFolderEtatAttente(etatAttente)"> {{etatAttente.label}} </label> </div> </div> Modified: trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js =================================================================== --- trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-06-09 19:05:15 UTC (rev 165) +++ trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-06-09 20:00:27 UTC (rev 166) @@ -317,8 +317,8 @@ if (!$scope.selectedMailFolder.folderTableColumns) { $scope.selectedMailFolder.folderTableColumns = []; } - if (!$scope.selectedMailFolder.etatAttente) { - $scope.selectedMailFolder.etatAttente = []; + if (!$scope.selectedMailFolder.etatAttentes) { + $scope.selectedMailFolder.etatAttentes = []; } // initialise la liste des colonnes pour le dossier courant @@ -329,6 +329,19 @@ label: $scope.mailFields[folderTableColumn] }); }); + + // change instance (for indexOf() to work) + if ($scope.selectedMailFolder.etatAttentes) { + var newArray = []; + angular.forEach($scope.selectedMailFolder.etatAttentes, function(folderEtatAttente) { + angular.forEach($scope.etatAttentes, function(etatAttente) { + if (etatAttente.topiaId == folderEtatAttente.topiaId) { + newArray.push(etatAttente); + } + }); + }); + $scope.selectedMailFolder.etatAttentes = newArray; + } }; // on doit faire ca par l'ordre des watch angular et ne pas l'appeler dans le edit @@ -351,7 +364,7 @@ replyDomains: [], folderActions: [], folderTableColumns: [], - etatAttente: [], + etatAttentes: [], //rigths readRightUsers: [], readRightGroups: [], @@ -388,14 +401,14 @@ if (!$scope.parentScopeValues.ediFolder) { $scope.parentScopeValues.ediFolder = folder.ediFolder; } - if (!$scope.parentScopeValues.folderActions) { + if ((!$scope.parentScopeValues.folderActions || $scope.parentScopeValues.folderActions.length == 0) && folder.folderActions) { $scope.parentScopeValues.folderActions = folder.folderActions; } - if (!$scope.parentScopeValues.folderTableColumns) { + if ((!$scope.parentScopeValues.folderTableColumns || $scope.parentScopeValues.folderTableColumns.length == 0) && folder.folderTableColumns) { $scope.parentScopeValues.folderTableColumns = folder.folderTableColumns; } - if (!$scope.parentScopeValues.etatAttente) { - $scope.parentScopeValues.etatAttente = folder.etatAttente; + if ((!$scope.parentScopeValues.etatAttentes || $scope.parentScopeValues.etatAttentes.length == 0) && folder.etatAttentes) { + $scope.parentScopeValues.etatAttentes = folder.etatAttentes; } // move to parent first to keed parent order for collection @@ -533,13 +546,24 @@ } }; + // initialise la liste des etats d'attente avec celle des niveaux supérieurs + $scope.initFolderEtatAttente = function() { + if ($scope.selectedMailFolder.useCurrentLevelEtatAttente) { + if ($scope.parentScopeValues.etatAttentes) { + $scope.selectedMailFolder.etatAttentes = $scope.parentScopeValues.etatAttentes.slice(); // soft copy + } + } else { + delete $scope.selectedMailFolder.etatAttentes; + } + }; + // selection/deselection d'un état d'attente possible pour ce dossier $scope.changeFolderEtatAttente = function(etatAttente) { - var index = $scope.selectedMailFolder.etatAttente.indexOf(etatAttente); + var index = $scope.selectedMailFolder.etatAttentes.indexOf(etatAttente); if (index != -1) { - $scope.selectedMailFolder.etatAttente.splice(index, 1); + $scope.selectedMailFolder.etatAttentes.splice(index, 1); } else { - $scope.selectedMailFolder.etatAttente.push(etatAttente); + $scope.selectedMailFolder.etatAttentes.push(etatAttente); } };