Author: echatellier Date: 2014-07-02 15:51:52 +0200 (Wed, 02 Jul 2014) New Revision: 314 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/314 Log: Ajout de check sur les doublons 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-07-02 13:26:03 UTC (rev 313) +++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-07-02 13:51:52 UTC (rev 314) @@ -462,7 +462,7 @@ <div class="form-group"> <label for="newCustomerResponsibleField" class="control-label">Nouveau :</label> <select id="newCustomerResponsibleField" class="form-control" ng-model="newCustomerResponsible" - ng-options="user as user.firstName + ' ' + user.lastName for user in users"></select> + ng-options="user as user.firstName + ' ' + user.lastName for user in users|filter:filterByAlreadyInCollection(selectedMailFolder.customerResponsibles)"></select> </div> <a class="btn btn-success btn-xs" ng-click="addCustomerResponsible()" ng-disabled="!newCustomerResponsible"> <span class="glyphicon glyphicon-plus"></span> @@ -499,7 +499,7 @@ </td> </tr> - <tr ng-repeat="replyAddress in selectedMailFolder.replyAddresses track by $index"> + <tr ng-repeat="replyAddress in selectedMailFolder.replyAddresses"> <td> <span class="glyphicon glyphicon-user"></span> {{replyAddress}}</td> @@ -545,7 +545,7 @@ </td> </tr> - <tr ng-repeat="replyDomain in selectedMailFolder.replyDomains track by $index"> + <tr ng-repeat="replyDomain in selectedMailFolder.replyDomains"> <td> <span class="glyphicon glyphicon-globe"></span> {{replyDomain}}</td> @@ -592,19 +592,23 @@ 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.containsByTopiaId(etatAttente)" - disabled> {{etatAttente.label}} - </label> + <div class="checkbox" ng-repeat="etatAttente in etatAttentes" ng-if="selectedMailFolder.$parent && !selectedMailFolder.useCurrentLevelEtatAttente"> + <label> + <input type="checkbox" ng-checked="parentScopeValues.etatAttentes.containsByTopiaId(etatAttente)" + disabled> {{etatAttente.label}} + </label> + </div> <label> <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> - <label class="checkbox" ng-repeat="etatAttente in etatAttentes" ng-if="selectedMailFolder.useCurrentLevelEtatAttente || !selectedMailFolder.$parent"> - <input type="checkbox" ng-checked="selectedMailFolder.etatAttentes.containsByTopiaId(etatAttente)" - ng-click="changeFolderEtatAttente(etatAttente)"> {{etatAttente.label}} - </label> + <div class="checkbox" ng-repeat="etatAttente in etatAttentes" ng-if="selectedMailFolder.useCurrentLevelEtatAttente || !selectedMailFolder.$parent"> + <label> + <input type="checkbox" ng-checked="selectedMailFolder.etatAttentes.containsByTopiaId(etatAttente)" + ng-click="changeFolderEtatAttente(etatAttente)"> {{etatAttente.label}} + </label> + </div> </div> </div> </div> @@ -771,7 +775,8 @@ <div class="form-group"> <label for="newRightUserField" class="control-label">Nouveau utilisateur :</label> <select id="newRightUserField" class="form-control" - ng-model="newRightUser" ng-options="user as user.firstName + ' ' + user.lastName for user in users"> + ng-model="newRightUser" + ng-options="user as user.firstName + ' ' + user.lastName for user in users|filter:filterByAlreadyInCollection(selectedMailFolder.rightUsers)"> </select> <a class="btn btn-success btn-xs" ng-click="addRightUser()" ng-disabled="!newRightUser"> <span class="glyphicon glyphicon-plus"></span> @@ -783,7 +788,8 @@ <div class="form-group"> <label for="newRightGroupField" class="control-label">Nouveau groupe :</label> <select id="newRightGroupField" class="form-control" - ng-model="newRightGroup" ng-options="group as group.completeName for group in groups"> + ng-model="newRightGroup" + ng-options="group as group.completeName for group in groups|filter:filterByAlreadyInCollection(selectedMailFolder.rightGroups)"> </select> <a class="btn btn-success btn-xs" ng-click="addRightGroup()" ng-disabled="!newRightGroup"> <span class="glyphicon glyphicon-plus"></span> Modified: trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js =================================================================== --- trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-07-02 13:26:03 UTC (rev 313) +++ trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-07-02 13:51:52 UTC (rev 314) @@ -134,6 +134,13 @@ // update when root folder collection changes (and for init) $scope.$watchCollection("mailFolders", $scope.updateMetaFilter); + + // filtre qui supprime les items déjà present dans une collection donnée + $scope.filterByAlreadyInCollection = function(coll) { + return function(item) { + return coll && !coll.containsByTopiaId(item); + } + } }]); /** @@ -794,9 +801,14 @@ // add reply address $scope.addReplyAddress = function() { - $scope.selectedMailFolder.replyAddresses.push($scope.newReplyAddress); - delete $scope.newReplyAddress; - $scope.addAddressForm.$setPristine(); + // check if already exists + if ($scope.selectedMailFolder.replyAddresses.indexOf($scope.newReplyAddress) != -1) { + $window.alert("Cette adresse existe déjà !"); + } else { + $scope.selectedMailFolder.replyAddresses.push($scope.newReplyAddress); + delete $scope.newReplyAddress; + $scope.addAddressForm.$setPristine(); + } }; // remove customer responsible @@ -808,9 +820,14 @@ // add reply domain $scope.addReplyDomain = function() { - $scope.selectedMailFolder.replyDomains.push($scope.newReplyDomain); - delete $scope.newReplyDomain; - $scope.addDomainForm.$setPristine(); + // check if already exists + if ($scope.selectedMailFolder.replyDomains.indexOf($scope.newReplyDomain) != -1) { + $window.alert("Ce domaine existe déjà !"); + } else { + $scope.selectedMailFolder.replyDomains.push($scope.newReplyDomain); + delete $scope.newReplyDomain; + $scope.addDomainForm.$setPristine(); + } }; // remove customer responsible