Author: echatellier Date: 2014-06-05 16:47:30 +0200 (Thu, 05 Jun 2014) New Revision: 137 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/137 Log: refs #4662: Modification du formuaire des comptes mails Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java 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/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java 2014-06-05 13:48:35 UTC (rev 136) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java 2014-06-05 14:47:30 UTC (rev 137) @@ -25,6 +25,7 @@ */ import java.lang.reflect.Type; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -35,6 +36,7 @@ import com.franciaflex.faxtomail.persistence.entities.Configuration; import com.franciaflex.faxtomail.persistence.entities.DemandType; import com.franciaflex.faxtomail.persistence.entities.EmailAccount; +import com.franciaflex.faxtomail.persistence.entities.EmailProtocol; import com.franciaflex.faxtomail.persistence.entities.EtatAttente; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; import com.franciaflex.faxtomail.persistence.entities.FolderAction; @@ -198,4 +200,12 @@ public Map<MailField, String> getMailFields() { return getEnumAsMap(MailField.values()); } + + public Map<EmailProtocol, Integer> getEmailProtocolPorts() { + Map<EmailProtocol, Integer> result = new LinkedHashMap<>(); + for (EmailProtocol protocol : EmailProtocol.values()) { + result.put(protocol, protocol.getDefaultPort()); + } + return result; + } } 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-05 13:48:35 UTC (rev 136) +++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-06-05 14:47:30 UTC (rev 137) @@ -50,6 +50,7 @@ 'mailActions': <s:property value="toJson(mailActions)" escapeHtml="false"/>, 'folderActions': <s:property value="toJson(folderActions)" escapeHtml="false"/>, 'mailFields': <s:property value="toJson(mailFields)" escapeHtml="false"/>, + 'emailProtocolPorts': <s:property value="toJson(emailProtocolPorts)" escapeHtml="false"/>, // datas 'configuration': <s:property value="toJson(configuration)" escapeHtml="false"/>, 'etatAttentes': <s:property value="toJson(etatAttentes)" escapeHtml="false"/>, @@ -421,13 +422,11 @@ </table> <div class="form-inline" ng-form="addAddressForm" role="form"> - <div class="form-group has-feedback" + <div class="form-group" ng-class="{'has-error': addAddressForm.address.$dirty && addAddressForm.address.$invalid, 'has-success': addAddressForm.address.$dirty && addAddressForm.address.$valid}"> <label for="newAddressField" class="control-label">Nouvelle adresse : </label> <input id="newAddressField" class="form-control" name="address" type="email" ng-model="newReplyAddress" placeholder="nom.prenom@franciaflex.fr" /> - <span class="glyphicon glyphicon-ok form-control-feedback" ng-if="addAddressForm.address.$dirty && addAddressForm.address.$valid"></span> - <span class="glyphicon glyphicon-remove form-control-feedback" ng-if="addAddressForm.address.$dirty && addAddressForm.address.$invalid"></span> </div> <a class="btn btn-success btn-xs" ng-click="addReplyAddress()" ng-disabled="!newReplyAddress"> <span class="glyphicon glyphicon-ok"></span> @@ -461,13 +460,11 @@ </table> <div class="form-inline" ng-form="addDomainForm" role="form"> - <div class="form-group has-feedback" + <div class="form-group" ng-class="{'has-error': addDomainForm.domain.$dirty && addDomainForm.domain.$invalid, 'has-success': addDomainForm.domain.$dirty && addDomainForm.domain.$valid}"> <label for="newDomainField" class="control-label">Nouveau domaine : </label> <input id="newDomainField" class="form-control" type="text" name="domain" ng-model="newReplyDomain" placeholder="franciaflex.fr" /> - <span class="glyphicon glyphicon-ok form-control-feedback" ng-if="addDomainForm.domain.$dirty && addDomainForm.domain.$valid"></span> - <span class="glyphicon glyphicon-remove form-control-feedback" ng-if="addDomainForm.domain.$dirty && addDomainForm.domain.$invalid"></span> </div> <a class="btn btn-success btn-xs" ng-click="addReplyDomain()" ng-disabled="!newReplyDomain"> <span class="glyphicon glyphicon-ok"></span> @@ -692,6 +689,7 @@ <tr> <th>Protocole</th> <th>Serveur</th> + <th>Port</th> <th>Utilisateur</th> <th>Mot de passe</th> <th/> @@ -701,6 +699,7 @@ <tr ng-repeat="emailAccount in emailAccounts"> <td>{{emailAccount.protocol}}</td> <td>{{emailAccount.host}}</td> + <td>{{emailAccount.port}}</td> <td>{{emailAccount.login}}</td> <td>{{emailAccount.password}}</td> <td> @@ -711,25 +710,33 @@ </tbody> </table> - <div class="form" role="form"> - <div class="form-group"> - <label>Protocole: - <input type="text" class="form-control" ng-model="newAccount.protocol"></label> + <div class="form row" role="form" ng-form="addEmailAccountForm"> + <div class="form-group col-xs-1"> + <label for="emailAccountProtocol" class="control-label">Protocole:</label> + <!-- <input type="text" class="form-control" ng-model="newAccount.protocol" /> --> + <select id="emailAccountProtocol" ng-model="newAccount.protocol" ng-options="protocol as protocol for (protocol, port) in emailProtocolPorts"></select> </div> - <div class="form-group"> - <label>Serveur: - <input type="text" class="form-control" ng-model="newAccount.host"></label> + <div class="form-group col-xs-4"> + <label for="emailAccountHost" class="control-label">Serveur:</label> + <input id="emailAccountHost" name="newAccountHost" type="text" class="form-control" ng-model="newAccount.host" ng-minlength="1" /> </div> - <div class="form-group"> - <label>Utilisateur: - <input type="text" class="form-control" ng-model="newAccount.login"></label> + <div class="form-group col-xs-1" + ng-class="{'has-error': addEmailAccountForm.newAccountPort.$dirty && addEmailAccountForm.newAccountPort.$invalid, + 'has-success': addEmailAccountForm.newAccountPort.$dirty && addEmailAccountForm.newAccountPort.$valid}"> + <label for="emailAccountPort" class="control-label">Port:</label> + <input id="emailAccountPort" name="newAccountPort" type="text" class="form-control" ng-model="newAccount.port" ng-pattern="/^\d+$/" ng-minlength="1" /> </div> - <div class="form-group"> - <label>Mot de passe: - <input type="text" class="form-control" ng-model="newAccount.password"></label> + <div class="form-group col-xs-2"> + <label for="emailAccountUser" class="control-label">Utilisateur:</label> + <input id="emailAccountUser" type="text" class="form-control" ng-model="newAccount.login"/> </div> - <div class="form-group"> - <button type="button" class="btn btn-success" ng-disabled="!newAccount.protocol || !newAccount.host" ng-click="addEmailAccount()"> + <div class="form-group col-xs-2"> + <label for="emailAccountPassword" class="control-label">Mot de passe:</label> + <input id="emailAccountPassword" type="text" class="form-control" ng-model="newAccount.password"> + </div> + <div class="form-group col-xs-1"> + <br /> + <button type="button" class="btn btn-success" ng-disabled="!newAccount.host || !newAccount.port || addEmailAccountForm.$invalid" ng-click="addEmailAccount()"> <i class="glyphicon glyphicon-plus"></i> Ajouter </button> </div> Modified: trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js =================================================================== --- trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-06-05 13:48:35 UTC (rev 136) +++ trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-06-05 14:47:30 UTC (rev 137) @@ -482,10 +482,12 @@ /** * Email accounts controller. */ -ConfigurationModule.controller('ConfigurationEmailAccountsController', ['$scope', '$http', 'ConfigurationData', - function($scope, $http, ConfigurationData) { +ConfigurationModule.controller('ConfigurationEmailAccountsController', ['$scope', '$window', 'ConfigurationData', + function($scope, $window, ConfigurationData) { //{Array} Email accounts $scope.emailAccounts = ConfigurationData.emailAccounts; + //{Array} Port par défaut des protocols + $scope.emailProtocolPorts = ConfigurationData.emailProtocolPorts; //{Object} New accout empty object $scope.newAccount = {}; @@ -493,10 +495,21 @@ $scope.addEmailAccount = function() { $scope.emailAccounts.push($scope.newAccount); $scope.newAccount = {}; + $scope.addEmailAccountForm.$setPristine(); }; // suppression d'un compte $scope.removeEmailAccount = function(index) { - $scope.emailAccounts.splice(index, 1); + if ($window.confirm("Êtes-vous sûr de vouloir supprimer ce compte email ?")) { + $scope.emailAccounts.splice(index, 1); + } }; + + // selection d'un protocol + $scope.$watch("newAccount.protocol", function(newValue, oldValue) { + // auto remplissage du port par defaut + if (newValue && ((oldValue && $scope.newAccount.port == $scope.emailProtocolPorts[oldValue]) || !$scope.newAccount.port)) { + $scope.newAccount.port = $scope.emailProtocolPorts[newValue]; + } + }); }]);