r97 - in trunk: faxtomail-persistence/src/main/xmi faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin faxtomail-ui-web/src/main/webapp/js
Author: echatellier Date: 2014-05-26 17:02:44 +0200 (Mon, 26 May 2014) New Revision: 97 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/97 Log: refs #4662: Sauvegarde des adresses de r?\195?\169ponse et charg?\195?\169 de clientele Modified: trunk/faxtomail-persistence/src/main/xmi/faxtomail.zargo trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailService.java trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIHandler.java 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-persistence/src/main/xmi/faxtomail.zargo =================================================================== (Binary files differ) Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailService.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailService.java 2014-05-26 13:25:59 UTC (rev 96) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailService.java 2014-05-26 15:02:44 UTC (rev 97) @@ -240,7 +240,7 @@ // categories MailFolder chargesClientelle = folderDao.create(MailFolder.PROPERTY_NAME, "Chargés de clientèle", MailFolder.PROPERTY_PARENT, franciaflex, - MailFolder.PROPERTY_REPLY_ADRESSES, Lists.newArrayList("no-reply@franciaflex.com")); + MailFolder.PROPERTY_REPLY_ADDRESSES, Lists.newArrayList("no-reply@franciaflex.com")); folders.put("Chargés de clientèle", chargesClientelle); Collections.shuffle(etatAttentes); Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java 2014-05-26 13:25:59 UTC (rev 96) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java 2014-05-26 15:02:44 UTC (rev 97) @@ -24,6 +24,21 @@ * #L% */ +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.topia.persistence.TopiaIdFactory; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderFactory; +import org.nuiton.util.pagination.PaginationParameter; + import com.franciaflex.faxtomail.persistence.entities.EtatAttente; import com.franciaflex.faxtomail.persistence.entities.MailFilter; import com.franciaflex.faxtomail.persistence.entities.MailFilterTopiaDao; @@ -32,19 +47,6 @@ import com.franciaflex.faxtomail.services.FaxToMailServiceSupport; import com.google.common.collect.Lists; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.topia.persistence.TopiaIdFactory; -import org.nuiton.util.pagination.PaginationParameter; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; - /** * @author kmorin <kmorin@codelutin.com> * @since 0.1 @@ -88,7 +90,12 @@ return new ArrayList<MailFolder>(dao.forTopiaIdIn(ids).findAll()); } - public Collection<MailFolder> saveMailFolders(Collection<MailFolder> mailFolders) { + public void saveMailFolders(Collection<MailFolder> mailFolders) { + saveMailFolders(null, mailFolders); + getPersistenceContext().commit(); + } + + protected Collection<MailFolder> saveMailFolders(MailFolder parent, Collection<MailFolder> mailFolders) { if (mailFolders == null) { return null; } @@ -96,23 +103,36 @@ MailFolderTopiaDao dao = getPersistenceContext().getMailFolderDao(); TopiaIdFactory factory = getPersistenceContext().getTopiaIdFactory(); + Binder<MailFolder, MailFolder> binderMailFolder = BinderFactory.newBinder(MailFolder.class); for (MailFolder mailFolder : mailFolders) { - Collection<MailFolder> children = saveMailFolders(mailFolder.getChildren()); + Collection<MailFolder> children = saveMailFolders(mailFolder, mailFolder.getChildren()); + MailFolder currentMailFolder; if (!factory.isTopiaId(mailFolder.getTopiaId())) { - mailFolder.setTopiaId(null); - mailFolder.setChildren(children); - mailFolder = dao.create(mailFolder); - result.add(mailFolder); + currentMailFolder = dao.create(); + } else { + currentMailFolder = dao.findByTopiaId(mailFolder.getTopiaId()); + } + + binderMailFolder.copyExcluding(mailFolder, currentMailFolder, + MailFolder.PROPERTY_TOPIA_ID, + MailFolder.PROPERTY_TOPIA_CREATE_DATE, + MailFolder.PROPERTY_TOPIA_VERSION, + MailFolder.PROPERTY_CHILDREN, + MailFolder.PROPERTY_PARENT); + currentMailFolder.setChildren(children); + currentMailFolder.setParent(parent); + + if (mailFolder.isPersisted()) { + currentMailFolder = dao.update(currentMailFolder); } else { - MailFolder original = dao.findByTopiaId(mailFolder.getTopiaId()); - original.setName(mailFolder.getName()); - original.setChildren(children); - original = dao.update(original); - result.add(original); + currentMailFolder = dao.create(currentMailFolder); } + result.add(currentMailFolder); } + + getPersistenceContext().commit(); return result; } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIHandler.java 2014-05-26 13:25:59 UTC (rev 96) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/reply/ReplyFormUIHandler.java 2014-05-26 15:02:44 UTC (rev 97) @@ -131,7 +131,7 @@ MailFolder folder = demand.getMailFolder(); Collection<String> folderReplyAdresses; do { - folderReplyAdresses = folder.getReplyAdresses(); + folderReplyAdresses = folder.getReplyAddresses(); folder = folder.getParent(); } while (CollectionUtils.isEmpty(folderReplyAdresses) && folder != null); 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-05-26 13:25:59 UTC (rev 96) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java 2014-05-26 15:02:44 UTC (rev 97) @@ -65,20 +65,6 @@ protected List<MailFolder> mailFolders; - //protected UserService userService; - - //protected List<MailFolder> mailFolders; - - //protected Map<String, String> mailFoldersFlat; - - //protected List<MailFilterUIBean> mailFilters; - - //protected List<FaxToMailUser> allUsers; - - //protected List<FaxToMailUserGroup> allUserGroups; - - //protected String activeTab; - @Override public void prepare() throws Exception { configuration = configurationService.getConfiguration(); @@ -100,6 +86,7 @@ configurationService.saveConfiguration(configuration); referentielService.saveEtatAttente(etatAttentes); + mailFolderService.saveMailFolders(mailFolders); return result; } @@ -144,156 +131,8 @@ return mailFolders; } - public void setMailFolders(List<MailFolder> mailFolders) { - this.mailFolders = mailFolders; + public void setMailFoldersJson(String json) { + Type type = new TypeToken<List<MailFolder>>() {}.getType(); + this.mailFolders = getGson().fromJson(json, type); } - - /*public void setMailFolderService(MailFolderService mailFolderService) { - this.mailFolderService = mailFolderService; - } - - public void setUserService(UserService userService) { - this.userService = userService; - }*/ - - /*public String getActiveTab() { - return activeTab; - } - - public void setActiveTab(String activeTab) { - this.activeTab = activeTab; - }*/ - - /*public Map<String, String> getEmailFields() { - Map<String, String> result = new HashMap<>(); - result.put(Email.PROPERTY_SENDER, "Adresse email"); - result.put(Email.PROPERTY_RECEPTION_DATE, "Date de réception"); - result.put(Email.PROPERTY_EDI_CODE_NUMBER, "Code EDI"); - result.put(Email.PROPERTY_OBJECT, "Objet"); - result.put(Email.PROPERTY_PROJECT_REFERENCE, "Référence travaux"); - result.put(Email.PROPERTY_PRIORITY, "Priorité"); - result.put(Email.PROPERTY_RANGE_ROW, "Gamme"); - result.put(Email.PROPERTY_MAIL_FOLDER, "Dossier"); - result.put(Email.PROPERTY_CLIENT, "Code Client"); - result.put(Email.PROPERTY_DEMAND_STATUS, "Statut"); - result.put(Email.PROPERTY_DEMAND_TYPE, "Type"); - result.put(Email.PROPERTY_TAKEN_BY, "Pris par"); - result.put(Email.PROPERTY_ETAT_ATTENTE, "État attente"); - result.put(Email.PROPERTY_ATTACHMENT, "Pièces jointes"); - return result; - } - - public String getFoldersTreeAsJson() { - if (company == null) { - return null; - } - GsonBuilder gsonBuilder = new GsonBuilder(); - String mailFolders = gsonBuilder.create().toJson(company.getMailFolder()); - return mailFolders; - } - - public void setFoldersTreeAsJson(String json) { - GsonBuilder gsonBuilder = new GsonBuilder().registerTypeAdapter(MailFolder.class, new MailFolderDeserializer()); - mailFolders = Arrays.asList((MailFolder[])gsonBuilder.create().fromJson(json, MailFolder[].class)); - log.debug(mailFolders); - } - - public Map<String, String> getAllFoldersFlat() { - if (mailFoldersFlat == null) { - mailFoldersFlat = new LinkedHashMap<>(); - if (company.getMailFolder() != null) { - List<MailFolder> folders = new ArrayList<>(company.getMailFolder()); - Collections.sort(folders, new Comparator<MailFolder>() { - @Override - public int compare(MailFolder o1, MailFolder o2) { - return ComparatorUtils.NATURAL_COMPARATOR.compare(o1.getName(), o2.getName()); - } - }); - for (MailFolder folder : folders) { - mailFoldersFlat.putAll(getAllFoldersFlat(folder, "")); - } - } - } - return mailFoldersFlat; - } - - public List<MailFilterUIBean> getMailFilters() { - if (mailFilters == null) { - mailFilters = new ArrayList<>(); - } - return mailFilters; - } - - public void setMailFilters(List<MailFilterUIBean> mailFilters) { - this.mailFilters = mailFilters; - } - - public List<FaxToMailUser> getAllUsers() { - if (allUsers == null) { - allUsers = userService.getAllUsers(); - } - return allUsers; - } - - public List<FaxToMailUserGroup> getAllUserGroups() { - if (allUserGroups == null) { - allUserGroups = userService.getAllUserGroups(); - } - return allUserGroups; - } - - protected Map<String, String> getAllFoldersFlat(MailFolder mailFolder, String prefix) { - Map<String, String> result = new LinkedHashMap<>(); - prefix += "/" + mailFolder.getName(); - result.put(mailFolder.getTopiaId(), prefix); - log.debug(prefix); - - if (mailFolder.getChildren() != null) { - List<MailFolder> children = new ArrayList<>(mailFolder.getChildren()); - Collections.sort(children, new Comparator<MailFolder>() { - @Override - public int compare(MailFolder o1, MailFolder o2) { - return ComparatorUtils.NATURAL_COMPARATOR.compare(o1.getName(), o2.getName()); - } - }); - for (MailFolder child : children) { - result.putAll(getAllFoldersFlat(child, prefix)); - } - } - return result; - } - - protected class MailFolderDeserializer implements JsonDeserializer<MailFolder> { - - @Override - public MailFolder deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - MailFolder mailFolder = new MailFolderImpl(); - JsonObject o = json.getAsJsonObject(); - - String name = o.get(MailFolder.PROPERTY_NAME).getAsString(); - mailFolder.setName(name); - - MailFolder[] children = context.deserialize(o.get(MailFolder.PROPERTY_CHILDREN), MailFolder[].class); - List<MailFolder> mailFolders = Arrays.asList(children); - mailFolder.setChildren(mailFolders); - - String topiaId = o.get(MailFolder.PROPERTY_TOPIA_ID).getAsString(); - mailFolder.setTopiaId(topiaId); - - return mailFolder; - } - } - - public static class MailFilterUIBean extends MailFilterImpl { - - protected String mailFolderId; - - public String getMailFolderId() { - return mailFolderId; - } - - public void setMailFolderId(String mailFolderId) { - this.mailFolderId = mailFolderId; - } - }*/ } 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-05-26 13:25:59 UTC (rev 96) +++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-05-26 15:02:44 UTC (rev 97) @@ -60,17 +60,21 @@ <div class="navbar-header"> <a href="<s:url value='/' />" class="navbar-brand">FaxToMail</a> </div> - + <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> + <ul class="nav navbar-nav"> + <li class="active"><a href="<s:url action='configuration-input' />" class="navbar-brand">Configuration</a></li> + <li><a href="<s:url action='import-input' />" class="navbar-brand">Import</a></li> + </ul> + </div> </div> </header> - + <div id="main-container" class="container"> <h1 class="page-header">Configuration</h1> <s:form id="main_form" action="configuration" ng-controller="ConfigurationController"> - - <s:hidden name="companyId"/> + <s:hidden name="activeTab"/> <ul id="tabs" class="nav nav-tabs"> @@ -79,7 +83,7 @@ <li><a href="#tabs-tree" data-toggle="tab">Arborescence</a></li> <li><a href="#tabs-filters" data-toggle="tab">Filtres de mail</a></li> <li><a href="#tabs-search" data-toggle="tab">Recherche</a></li> - <!-- <li><a href="#tabs-email-accounts" data-toggle="tab">Comptes mails</a></li> --> + <li><a href="#tabs-ldap" data-toggle="tab">Groupes lDAP</a></li> </ul> <div class="tab-content active" ng-controller="ConfigurationMiscController"> @@ -94,10 +98,6 @@ label="Refuser les mails dont l'email est inconnu de la base client" cssClass="margin-bottom25"/> - <s:textfield name="configuration.ediFolder" - label="Dossier de dépôt du fichier pour l'EDI" - cssClass="span12"/> - <s:textfield name="configuration.convertToPdfCommand" label="Ligne de commande de conversion de fichier X en pdf" cssClass="span12"/> @@ -152,19 +152,20 @@ </div> <div id="tabs-tree" class="tab-pane" ng-controller="ConfigurationTreeController"> - + <input type="hidden" name="mailFoldersJson" value="{{mailFolders}}" /> + <div class="row"> <div class="col-md-4"> <script type="text/ng-template" id="nodes_renderer.html"> <div ui-tree-handle ng-click="editMailFolder(mailFolder)" ng-class="{'bg-warning' : mailFolder == selectedMailFolder}"> - <a class="btn btn-success btn-xs" data-nodrag ng-click="toggle(this)"> - <span class="glyphicon" ng-class="{'glyphicon-chevron-right': collapsed, 'glyphicon-chevron-down': !collapsed}"></span> + <a class="btn btn-success btn-xs" data-nodrag ng-click="toggle(this)" ng-disabled="!mailFolder.children || mailFolder.children.length == 0"> + <span class="glyphicon" ng-class="{'glyphicon-chevron-right': !collapsed, 'glyphicon-chevron-down': collapsed}"></span> </a> {{mailFolder.name}} - <a class="pull-right btn btn-danger btn-xs" data-nodrag ng-click="remove(this)"><span class="glyphicon glyphicon-remove"></span></a> - <a class="pull-right btn btn-primary btn-xs" data-nodrag ng-click="newSubItem(this)" style="margin-right: 8px;"><span class="glyphicon glyphicon-plus"></span></a> + <a class="pull-right btn btn-primary btn-xs" data-nodrag ng-click="newSubFolder(this)" style="margin-left: 8px;"><span class="glyphicon glyphicon-plus"></span></a> + <a class="pull-right btn btn-danger btn-xs" data-nodrag ng-click="remove(this)" ng-if="!mailFolder.topiaId"><span class="glyphicon glyphicon-remove"></span></a> </div> - <ol ui-tree-nodes="options" ng-model="mailFolder.children" ng-class="{hidden: collapsed}"> + <ol ui-tree-nodes="options" ng-model="mailFolder.children" ng-class="{hidden: !collapsed}"> <li ng-repeat="mailFolder in mailFolder.children" ui-tree-node ng-include="'nodes_renderer.html'"> </li> </ol> @@ -176,7 +177,7 @@ </div> </div> - <div class="col-md-8" ng-if="selectedMailFolder"> + <div class="col-md-8" ng-show="selectedMailFolder"> <div class="panel-group" id="accordion"> <!-- Liste des chargés de clientèle --> @@ -184,13 +185,35 @@ <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" data-parent="#accordion" href="#collapse1"> - Liste des chargés de clientèle {{selectedMailFolder.name}} + Liste des chargés de clientèle </a> </h4> </div> <div id="collapse1" class="panel-collapse collapse"> <div class="panel-body"> - Toto + <table class="table table-bordered"> + <thead> + <tr> + <th>Adresse email</th> + <th>Action</th> + </tr> + </thead> + <tbody> + <tr ng-repeat="customerResponsible in selectedMailFolder.customerResponsibles track by $index"> + <td>{{customerResponsible}}</td> + <td> + <a class="pull-right btn btn-danger btn-xs" ng-click="removeCustomerResponsible($index)"> + <span class="glyphicon glyphicon-remove"></span> + </a> + </td> + </tr> + </tbody> + </table> + + Nouveau : <input type="email" ng-model="newCustomerResponsible" /> + <a class="btn btn-success btn-xs" ng-click="addCustomerResponsible()" ng-disabled="!newCustomerResponsible"> + <span class="glyphicon glyphicon-ok"></span> + </a> </div> </div> </div> @@ -206,7 +229,29 @@ </div> <div id="collapse2" class="panel-collapse collapse"> <div class="panel-body"> - Toto + <table class="table table-bordered"> + <thead> + <tr> + <th>Adresse email</th> + <th>Action</th> + </tr> + </thead> + <tbody> + <tr ng-repeat="replyAddress in selectedMailFolder.replyAddresses track by $index"> + <td>{{replyAddress}}</td> + <td> + <a class="pull-right btn btn-danger btn-xs" ng-click="removeReplyAddress($index)"> + <span class="glyphicon glyphicon-remove"></span> + </a> + </td> + </tr> + </tbody> + </table> + + Nouveau : <input type="email" ng-model="newReplyAddress" /> + <a class="btn btn-success btn-xs" ng-click="addReplyAddress()" ng-disabled="!newReplyAddress"> + <span class="glyphicon glyphicon-ok"></span> + </a> </div> </div> </div> @@ -222,7 +267,9 @@ </div> <div id="collapse3" class="panel-collapse collapse"> <div class="panel-body"> - Toto + <label class="checkbox" ng-repeat="etatAttente in etatAttentes"> + <input type="checkbox"> {{etatAttente.label}} + </label> </div> </div> </div> @@ -238,7 +285,16 @@ </div> <div id="collapse4" class="panel-collapse collapse"> <div class="panel-body"> - Toto + <!-- Droits d'accès --> + <table id="rights" class="table table-bordered"> + <thead> + <tr> + <th>Utilisateur ou groupe</th> + <th>Type</th> + </tr> + </thead> + <tbody></tbody> + </table> </div> </div> </div> @@ -254,7 +310,10 @@ </div> <div id="collapse5" class="panel-collapse collapse"> <div class="panel-body"> - Toto + <label class="checkbox" ng-repeat="(etatAttenteAction,label) in etatAttenteActions"> + <input type="checkbox" ng-checked="selectedMailFolder.actions.indexOf(etatAttenteAction) != -1" + ng-click="changeEtatAttenteAction(etatAttenteAction)"> {{label}} + </label> </div> </div> </div> @@ -270,11 +329,27 @@ </div> <div id="collapse6" class="panel-collapse collapse"> <div class="panel-body"> - Toto + <div class="control-group"> + <label class="control-label" for="tableColumns">Champs à afficher dans le tableau (l'ordre peut être changé en faisant un glisser/déposer sur les champs)</label> + + <div class="controls"> + <input type="hidden" ui-select2-sortable ng-model="mailFolder.searchDisplayColumns" + simple-query="getObjectsData" multiple sortable> + </div> + + <div> + <table id='table-snapshot' class="table table-bordered"> + <caption>Aperçu</caption> + <thead> + <tr> + <th ng-repeat="etatAttenteField in searchDisplayColumns">{{etatAttenteFields[etatAttenteField.id]}}</th> + </tr> + </thead> + </table> + </div> </div> </div> </div> - </div> <div class="checkbox"> @@ -294,6 +369,7 @@ </div> </div> </div> + </div> <div id="tabs-filters" class="tab-pane" ng-controller="ConfigurationFilterController"> <table class="table table-hover table-bordered"> @@ -349,6 +425,10 @@ </div> </div> + <div id="tabs-ldap" class="tab-pane" ng-controller="ConfigurationLdapController"> + Comming soon ... + </div> + <nav class="navbar navbar-default navbar-fixed-bottom"> <div class="container"> <button type="submit" class="btn btn-primary navbar-btn pull-right">Valider</button> Modified: trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js =================================================================== --- trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-05-26 13:25:59 UTC (rev 96) +++ trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-05-26 15:02:44 UTC (rev 97) @@ -10,6 +10,8 @@ $scope.etatAttenteActions = ConfigurationData.etatAttenteActions; //{Map} les champs obligatoires possibles $scope.etatAttenteFields = ConfigurationData.etatAttenteFields; + //{Array} les etats d'attentes disponibles + $scope.etatAttentes = ConfigurationData.etatAttentes; }]); /** @@ -25,8 +27,7 @@ */ FaxToMailModule.controller('ConfigurationWaitController', ['$scope', '$http', 'ConfigurationData', function($scope, $http, ConfigurationData) { - //{Array} les etats d'attentes disponibles - $scope.etatAttentes = ConfigurationData.etatAttentes; + //{Object} etat d'attente selectionné $scope.selectedEtatAttente; @@ -69,20 +70,81 @@ /** * Mail folder tab controller. */ -FaxToMailModule.controller('ConfigurationTreeController', ['$scope', '$http', 'ConfigurationData', - function($scope, $http, ConfigurationData) { +FaxToMailModule.controller('ConfigurationTreeController', ['$scope', '$http', '$window', 'ConfigurationData', + function($scope, $http, $window, ConfigurationData) { // selected mail folder $scope.selectedMailFolder; + // {String} add new customer responsible form value + $scope.newCustomerResponsible; - // toggle node + // collapse all subnodes (called by init) + $scope.collapseAll = function(scope) { + scope.collapseAll(); + }; + + // toggle node (expand or collapse) $scope.toggle = function(scope) { scope.toggle(); }; - + // edit mail folder $scope.editMailFolder = function(mailFolder) { $scope.selectedMailFolder = mailFolder; + + // edit undefined collections + if (!$scope.selectedMailFolder.customerResponsibles) { + $scope.selectedMailFolder.customerResponsibles = []; + } + if (!$scope.selectedMailFolder.replyAddresses) { + $scope.selectedMailFolder.replyAddresses = []; + } }; + + // new sub folder + $scope.newSubFolder = function(scope) { + var nodeData = scope.$modelValue; + var name = $window.prompt("Nom du nouveau noeud ? "); + if (name) { + nodeData.children.push({ + name: name, + children: [] + }); + } + }; + + // get select2 init data + $scope.getObjectsData = function(term, result) { + var result2 = []; + angular.forEach($scope.etatAttenteFields, function(v, k) { + result2.push({ + id: k, + label: v + }); + }); + result(result2); + }; + + // add customer responsible + $scope.addCustomerResponsible = function() { + $scope.selectedMailFolder.customerResponsibles.push($scope.newCustomerResponsible); + delete $scope.newCustomerResponsible; + }; + + // remove customer responsible + $scope.removeCustomerResponsible = function(index) { + $scope.selectedMailFolder.customerResponsibles.splice(index, 1); + }; + + // add reply address + $scope.addReplyAddress = function() { + $scope.selectedMailFolder.replyAddresses.push($scope.newReplyAddress); + delete $scope.newReplyAddress; + }; + + // remove customer responsible + $scope.removeReplyAddress = function(index) { + $scope.selectedMailFolder.replyAddresses.splice(index, 1); + }; }]); /** @@ -173,3 +235,12 @@ result(result2); }; }]); + + +/** + * Ldap tab controller. + */ +FaxToMailModule.controller('ConfigurationLdapController', ['$scope', '$http', 'ConfigurationData', + function($scope, $http, ConfigurationData) { + +}]); \ No newline at end of file
participants (1)
-
echatellier@users.forge.codelutin.com