--- /dev/null
+/*
+Copyright (c) Igor Barma, Alexandre Desoubeaux, Christian Martel, Eric Brun, Mathieu Amblard, Gwenael Gevet, Pierre Guillot, 2012
+ * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Alexandre Lefevre, Marc Salvat 2014-2016
+ * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Marc Salvat, Marc Suarez, Harifetra Ramamonjy 2017
+For licensing, see README.txt or http://www.pentilanero.com (Cecill-C or AGPL or LGPL)
+*/
+Ext.ns("EntSavoie.Annuaire");
+EntSavoie.annuaire = function(config) {
+ Ext.apply(this, config);
+ Ext.QuickTips.init();
+ this.COUNT_FOR_LIST_WARNING = 2000;
+ this.isIconView = false;
+ this.isGridView = true;
+ //fenetre d'attente
+ this.wait = new Ext.LoadMask(Ext.getBody(), {msg:this.i18n.annuaire.wait.msg});
+
+
+ //fenetre de creation de new msg
+ this.createMessageWindow = this.createMessageWindow || new EntSavoie.InternalMessaging.CreateMessageView({
+ renderURLAjax: this.renderURLAjax,
+ actionURLAjax: this.actionURLAjax,
+ userGroupId: this.userGroupId,
+ closeActionWindow: 'hide',
+ sendToCasierBtnHide: true,
+ language: this.language,
+ isGroupManagment: this.isGroupManagment
+ });
+
+
+ //Definit les stores de donnees
+ this.userStore = this.userStore || new Ext.data.JsonStore({
+ root: "users",
+ totalProperty: "nombreTotal",
+ idProperty: "userId",
+ remoteSort: true,
+ fields: ["userId", "nom", "prenom", "etabRatt", "statut", "img", "details"],
+ proxy: new Ext.data.HttpProxy({
+ url: this.renderURLAjax+"&jspPage=%2Fajax%2FlistUsersWithPictures.jsp"
+ })
+ });
+
+ this.rolesStore = this.rolesStore || new Ext.data.JsonStore({
+ root: 'roles',
+ idProperty: 'roleId',
+ fields: [
+ {name: 'roleId', mapping: "roleId"},
+ {name: 'label', mapping: 'label'},
+ {name: 'roleCode', mapping: 'roleCode'}
+ ],
+ url: this.renderURLAjax+'&jspPage=%2Fajax%2FgestionMembres%2FlistRoles.jsp'
+ });
+
+ this.matieresStore = this.matieresStore || new Ext.data.JsonStore({
+ root: 'matieres',
+ idProperty: 'matiereId',
+ fields: [
+ {name: 'matiereId', mapping: "matiereId"},
+ {name: 'name', mapping: 'name'}
+ ],
+ sortInfo: {
+ field: 'name',
+ direction: 'ASC'
+ },
+ url: this.renderURLAjax+'&jspPage=%2Fajax%2FgestionMembres%2FlistMatieres.jsp'
+ });
+
+ this.etabStore = this.etabStore || new Ext.data.JsonStore({
+ root: 'etabs',
+ idProperty: 'etabId',
+ fields: ['etabId', 'name'],
+ url: this.renderURLAjax+'&jspPage=%2Fajax%2FgestionMembres%2FlistEtablissements.jsp'
+ });
+
+ this.classeStore = this.classeStore || new Ext.data.GroupingStore({
+ reader: new Ext.data.JsonReader({
+ root: 'orgs',
+ idProperty: 'organizationId',
+ fields: ['organizationId', 'name', 'group']
+ }),
+ groupField:'group',
+ url: this.renderURLAjax+'&jspPage=%2Fajax%2FgestionMembres%2FlistOrganizations.jsp'
+ });
+
+ this.listes_store = this.listes_store || new Ext.data.Store({
+ // load using HTTP
+ url: this.renderURLAjax+"&jspPage=/listesCarnetAdresses.jsp",
+
+ // the return will be XML, so lets set up a reader
+ reader: new Ext.data.XmlReader({
+ record: "liste",
+ id: "listId"
+ }, ["name", "type", "orgId", "roleId", "listId"])
+ });
+
+
+ //Research fields
+ this.nameSearchFieldValue = "";
+ this.nameSearchField = this.nameSearchField || new Ext.form.TextField({
+ name: "nom",
+ emptyText: this.i18n.annuaire.nameSearchField.emptyText,
+ fieldLabel: this.i18n.annuaire.nameSearchField.fieldLabel,
+ hideLabel: true,
+ width: 260
+ });
+
+ this.firstNameSearchFieldValue = "";
+ this.firstNameSearchField = this.firstNameSearchField || new Ext.form.TextField({
+ name: "prenom",
+ emptyText: this.i18n.annuaire.firstNameSearchField.emptyText,
+ fieldLabel: this.i18n.annuaire.firstNameSearchField.fieldLabel,
+ hideLabel: true,
+ width: 260
+ });
+
+
+ //Research combo
+ this.statutComboValue = "";
+ this.statutCombo = this.statutCombo || new Ext.form.ComboBox({
+ listClass: "annuaire-portlet",
+ name: "statut",
+ fieldLabel: this.i18n.annuaire.statutCombo.fieldLabel,
+ emptyText: this.i18n.annuaire.statutCombo.emptyText,
+ valueField: 'roleId',
+ displayField: 'label',
+ editable: false,
+ store: this.rolesStore,
+ triggerAction: "all",
+ hideLabel: true,
+ width: 260
+ });
+
+ this.matiereComboValue = "";
+ this.matiereCombo = this.matiereCombo || new Ext.form.ComboBox({
+ listClass: "annuaire-portlet",
+ name: "matiere",
+ fieldLabel: this.i18n.annuaire.matiereCombo.fieldLabel,
+ emptyText: this.i18n.annuaire.matiereCombo.emptyText,
+ valueField: 'matiereId',
+ displayField: 'name',
+ editable: true,
+ store: this.matieresStore,
+ triggerAction: "all",
+ disabled: true,
+ listWidth: 250,
+ hidden: true,//!this.isGroupManagment,
+ hideLabel: true,
+ typeAhead: true,
+ lazyRender: true,
+ mode: 'local',
+ minChars: 2,
+ width: 260
+ });
+
+ this.etabComboValue = "";
+ this.etabCombo = this.etabCombo || new Ext.form.ComboBox({
+ listClass: "annuaire-portlet",
+ name: "etablissement",
+ fieldLabel: this.i18n.annuaire.etabCombo.fieldLabel,
+ emptyText: this.i18n.annuaire.etabCombo.emptyText,
+ valueField: 'etabId',
+ displayField: 'name',
+ qtipField: 'name',
+ editable: true,
+ triggerAction: 'all',
+ allowBlank: true,
+ store: this.etabStore,
+ listWidth: 250,
+ hideLabel: true,
+ typeAhead: true,
+ lazyRender: true,
+ mode: 'local',
+ minChars: 2,
+ width: 260
+ });
+
+ this.classeComboValue = "";
+ this.classeCombo = this.classeCombo || new Ext.form.ComboBox({
+ listClass: "annuaire-portlet",
+ name: "organization",
+ fieldLabel: this.i18n.annuaire.classeCombo.fieldLabel,
+ emptyText: this.i18n.annuaire.classeCombo.emptyText,
+ valueField: 'organizationId',
+ displayField: 'name',
+ triggerAction: 'all',
+ allowBlank: true,
+ store: this.classeStore,
+ mode: "local",
+ disabled: true,
+ listWidth: 250,
+ hidden: !this.isGroupManagment,
+ hideLabel: true,
+ typeAhead: true,
+ minChars: 2,
+ width: 260
+ });
+
+ //research btn
+ this.searchBtn = this.searchBtn || new Ext.Button ({
+ text: this.i18n.annuaire.searchBtn.text,
+ formBind: true,
+ handler: this.onSearch,
+ scope: this
+ });
+
+ this.sendMessageBtn = this.sendMessageBtn || new Ext.Button ({
+ text: this.i18n.annuaire.sendMessageBtn.text,
+ handler: this.onSendMessage,
+ scope: this,
+ iconCls: "sendMsg"
+ });
+
+
+ this.contactGridBbar = this.contactGridBbar || new Ext.PagingToolbar({
+ pageSize: 30,
+ store: this.userStore,
+ displayInfo: true,
+ displayMsg: this.i18n.annuaire.contactGridBbar.displayMsg,
+ emptyMsg: this.i18n.annuaire.contactGridBbar.emptyMsg
+ });
+
+
+ // Menu Vue
+ this.viewMenu = this.viewMenu || new Ext.menu.Menu({
+ cls: "annuaire-portlet",
+ items: [
+ {
+ text: "Liste",
+ handler: this.onSelectGridView,
+ iconCls: 'listViewMenu',
+ scope: this
+ },
+ {
+ text: "Trombinoscope",
+ handler: this.onSelectIconView,
+ iconCls: 'iconViewMenu',
+ scope: this
+ }
+ ]
+ });
+
+
+ //Icon View
+ this.iconView = this.iconView || new EntSavoie.Annuaire.IconView({
+ hidden: true,
+ userStore: this.userStore
+ });
+
+ this.contactGridTitle = this.contactGridTitle || new Ext.form.Label({
+ text: this.i18n.annuaire.title[1],
+ cls: "toolBarHeaderTextCls"
+ });
+
+ // Menu Utilisation des resultats
+ this.useSearchResultMenu = this.useSearchResultMenu || new Ext.menu.Menu({
+ cls: "annuaire-portlet",
+ items: [
+ {
+ text: "Créer une nouvelle liste",
+ handler: this.onCreateNewListeWithAllResults,
+ iconCls: 'addList',
+ scope: this
+ },
+ {
+ text: "Ajouter à une liste existante",
+ handler: this.onAddAllResultsToExistingList,
+ iconCls: 'editList',
+ scope: this
+ }
+ ]
+ });
+
+ this.contactGridTbar = this.contactGridTbar || new Ext.Toolbar({
+ cls: "x-panel-header",
+ width: "auto",
+ items: [
+ this.contactGridTitle,
+ "->",
+ {
+ text: "Vue",
+ iconCls: 'chooseViewMenu',
+ menu: this.viewMenu
+ },
+ "-",
+ this.sendMessageBtn,
+ "-",
+ {
+ text: "Résultats de recherche",
+ iconCls: 'searchResult',
+ menu: this.useSearchResultMenu
+ }
+ ]
+ });
+
+ //Fenetre d'information
+
+ this.closeBtn = this.closeBtn || new Ext.Button({
+ text: "fermer",
+ handler: this.onClose,
+ scope: this
+ });
+
+ this.userResume = this.userResume || new Ext.form.DisplayField({
+ value: "",
+ hideLabel: true
+ });
+
+ this.detailsPanel = this.detailsPanel || new Ext.Panel({
+ border: true,
+ height: 545,
+ width: 420,
+ padding: 10,
+ autoScroll: true,
+ width: 'auto',
+ items: [
+ this.userResume
+ ]
+ });
+
+ this.detailsWindow = this.detailsWindow || new Ext.Window({
+ cls: "annuaire-portlet",
+ closeAction: 'hide',
+ modal: true,
+ width: 510,
+// height: 300,
+ layout: 'form',
+ labelWidth: 130,
+ autoScroll: true,
+ closable: true,
+ padding: 10,
+ items: [
+ this.userResume
+ ],
+ buttons: [
+ this.closeBtn
+ ]
+ });
+
+
+ this.action_column = this.action_column || new Ext.grid.ActionColumn({
+ width: 30,
+ fixed: true,
+// header:this.i18n.annuaire.contactGrid.columns[4],
+ sortable: false,
+ menuDisabled: true,
+ dataIndex: "details",
+ align: 'left',
+ items: [
+ {
+ getClass: function(v, meta, rec, row, col, store) { // Or return a class from a function
+ if(rec.get('details') == true){
+ return 'details x-action-col-icon';
+ }
+ },
+ tooltip: "Afficher les informations personnelles",
+ scope: this,
+ handler: this.onRowAction
+ }
+ ]
+ });
+
+ //grids
+ this.contactGrid = this.contactGrid || new Ext.grid.GridPanel({
+ border: false,
+ store: this.userStore,
+// trackMouseOver:false,
+ autoFill: true,
+ loadMask: true,
+ enableDrag: true,
+ ddGroup: "addFicheToListe",
+ ddText: this.i18n.annuaire.contactGrid.ddText,
+ autoExpandColumn: 'nom',
+ autoExpandMin: 130,
+ columns:[{header:this.i18n.annuaire.contactGrid.columns[0], id:"nom", dataIndex: "nom", width: 130, sortable: true},
+ {header:this.i18n.annuaire.contactGrid.columns[1], dataIndex: "prenom", width: 130, sortable: true},
+ this.action_column,
+ {header:this.i18n.annuaire.contactGrid.columns[2], dataIndex: "etabRatt", width: 150, sortable: false},
+ {header:this.i18n.annuaire.contactGrid.columns[3], dataIndex: "statut", width: 140, sortable: false}
+
+ ]
+ });
+
+ this.listGridBbar = this.listGridBbar || new Ext.Toolbar({
+ items: [{
+ xtype: 'displayfield',
+ width: 170,
+ height: 105,
+ name: 'noticeField',
+ value: this.i18n.annuaire.listGridBbar.value
+ }]
+
+ });
+
+ this.listGrid = this.listGrid || new Ext.grid.GridPanel({
+ border: false,
+ hideHeaders: true,
+ store: this.listes_store,
+ trackMouseOver: true,
+ forceFit: true,
+ autoFill: true,
+ loadMask: true,
+ viewConfig: {
+ getRowClass: function(record, index) {
+ var tL = record.get("type");
+ if (tL == "local") {
+ return 'list-local-row';
+ } else {
+ return 'list-pseudo-row';
+ }
+ }
+ },
+ autoExpandColumn: 'name',
+ columns:[{header:"", id:'name', dataIndex: "name", width: 20, sortable: false}],
+ bbar: [this.listGridBbar]
+ });
+
+ this.comboLists = new Ext.form.ComboBox({
+ fieldLabel: "Sélectionner la liste",
+ valueField: 'listId',
+ displayField: 'name',
+ editable: false,
+ tpl: '<tpl for="."><tpl if="listId != -1"><div class="x-combo-list-item">{name}</div></tpl></tpl>',
+ triggerAction: 'all',
+ mode: 'local',
+ width: 180,
+ store: this.listes_store,
+ listeners:{
+ scope: this,
+ 'select': this.onSelectListElement
+ }
+ });
+
+ this.warningLabel = new Ext.form.DisplayField({
+ value: this.i18n.annuaire.addUsersToNewList.MessageBox.warningLabel,
+ hideLabel: true
+ });
+
+ this.addToExistingListWindow = this.addToExistingListWindow || new Ext.Window({
+ cls: "annuaire-portlet",
+ title: "Ajouts des résultats",
+ modal: true,
+ width: 360,
+ height: 'auto',
+ closable: false,
+ autoScroll: true,
+ padding: 10,
+ layout:'form',
+ items: [
+ this.warningLabel,
+ this.comboLists
+ ],
+ buttons: [{
+ text: "Valider",
+ handler: this.onValidAddToExistingListWindow,
+ scope: this
+ },
+ {
+ text: "Annuler",
+ handler: this.onCloseAddToExistingListWindow,
+ scope: this
+ }
+ ]
+ });
+
+ this.centerPanel = this.centerPanel || new Ext.Panel({
+ region: "center",
+ layout: 'card',
+ activeItem: 0,
+ width: "auto",
+ items: [this.contactGrid, this.iconView],
+ tbar: this.contactGridTbar,
+ bbar: this.contactGridBbar
+ });
+
+ // definition des listeners
+ // on gere les roles
+ this.rolesStore.on("load", this.onloadRolesStore, this);
+ this.statutCombo.on("render", this.onRenderStatutCombo, this);
+ this.statutCombo.on("specialkey", this.onSpecialKey, this);
+ this.statutCombo.on("select", this.onSelectStatutCombo, this);
+
+ // on gere les matieres
+ this.matiereCombo.on("specialkey", this.onSpecialKey, this);
+ this.matiereCombo.on("select", this.onSelectMatiereCombo, this);
+ this.matiereCombo.on("render", this.onRenderMatiereCombo, this);
+
+ // on gere les etablissements
+ this.etabStore.on("load", this.onLoadEtabStore, this);
+ this.etabCombo.on("select", this.onSelectEtabCombo, this);
+ this.etabCombo.on("specialkey", this.onSpecialKey, this);
+ this.etabCombo.on("render", this.onRenderEtabCombo, this);
+
+ // on gere les classes
+ this.classeStore.on("load", this.onLoadClasseStore, this);
+ this.classeCombo.on("specialkey", this.onSpecialKey, this);
+ this.classeCombo.on("select", this.onSelectClasseCombo, this);
+
+ // Pour definir le drop area et loader les listes
+ this.listGrid.on("render", this.onRenderListGrid, this);
+ //load du proxy pour la grille des contacts
+ this.userStore.proxy.on("beforeload", this.prepareParams, this);
+
+ //on gere le reste du formulaire (les textfields)
+ this.nameSearchField.on("specialkey", this.onSpecialKey, this);
+ this.firstNameSearchField.on("specialkey", this.onSpecialKey, this);
+
+
+ EntSavoie.annuaire.superclass.constructor.call(this, {
+ layout: 'border',
+ height: EntSavoie.FullScreen.fired()?EntSavoie.FullScreen.getContainerHeight():Global.Portlet.height,
+ width: "auto",
+ monitorResize: true,
+ defaults: {
+ collapsible: false,
+ split: true,
+ border: true
+ },
+ items: [{
+ title:this.i18n.annuaire.title[0],
+ region: "west",
+ xtype: "form",
+ width: 275,
+ collapsible: true,
+ padding: 5,
+ items: [
+ this.nameSearchField,
+ this.firstNameSearchField,
+ this.statutCombo,
+ this.matiereCombo,
+ this.etabCombo,
+ this.classeCombo
+ ],
+ buttons: [this.searchBtn]
+ },
+ this.centerPanel,
+ {
+ title:this.i18n.annuaire.title[2],
+ region: "east",
+ collapsible: true,
+ xtype: "panel",
+ layout: 'fit',
+ width: 200,
+ items: [this.listGrid]
+ }]
+ });
+
+};
+
+
+
+Ext.extend(EntSavoie.annuaire, Ext.Panel, {
+ initComponent: function () {
+ EntSavoie.annuaire.superclass.initComponent.call(this);
+ },
+
+ refreshInfos: function() {
+ //this.listes_store.load();
+ //this.nameSearchField.focus();
+
+ //this.userStore.load({params:{start:0,limit:35}});
+ },
+
+ // METHODE POUR LA VUE
+ /**
+ * Sélection de la vue grille
+ */
+ onSelectGridView: function(btn){
+ this.centerPanel.layout.setActiveItem(0);
+ this.iconView.iconDataView.clearSelections();
+ this.isIconView = false;
+ this.isGridView = true;
+ },
+
+ /**
+ * Sélection de la vue icone
+ */
+ onSelectIconView: function(btn){
+ this.centerPanel.layout.setActiveItem(1);
+ this.contactGrid.getSelectionModel().clearSelections();
+ this.isIconView = true;
+ this.isGridView = false;
+ },
+
+ // METHODE POUR LES ROLES
+ onloadRolesStore: function(store, records, options) {
+ if (records.length==1) {
+ // on selectionne alors ce role
+ var roleIdFilter = records[0].get("roleId");
+ this.statutCombo.setValue(roleIdFilter);
+ }
+ },
+
+ onSelectStatutCombo: function(cmp, record, index) {
+ if (record.get("roleId")==0) {
+ cmp.reset();
+ this.matiereCombo.reset();
+ this.matiereCombo.disable();
+ } else if(record.get("roleCode")!="National_3") {
+ this.matiereCombo.reset();
+ this.matiereCombo.disable();
+ } else {
+ this.matiereCombo.enable();
+ }
+ },
+
+ onRenderStatutCombo: function(combo) {
+ this.rolesStore.load();
+ },
+
+ // METHODE POUR LES MATIERES
+ onSelectMatiereCombo: function(cmp, record, index) {
+ if (record.get("matiereId")==0) {
+ cmp.reset();
+ }
+ },
+
+ onRenderMatiereCombo: function(combo) {
+ this.matieresStore.load();
+ },
+
+ // METHODE POUR LES ETABLISSEMENTS
+ onRenderEtabCombo: function(etabCombo) {
+ this.etabStore.load();
+ },
+
+ onLoadEtabStore: function(store, records, options) {
+ if (records.length==1) {
+ // on selectionne alors cet etab
+ var principalEtabId = records[0].get("etabId");
+ this.etabCombo.setValue(principalEtabId);
+ this.classeCombo.reset();
+ this.classeStore.load({params: {etabId: principalEtabId}});
+ this.matieresStore.load({params: {etabId: principalEtabId}});
+ }
+ },
+
+ onSelectEtabCombo: function(combo, record, index) {
+
+ this.classeCombo.reset();
+ if (record.get("etabId")==0) {
+ combo.reset();
+ this.classeCombo.disable();
+ this.matieresStore.load();
+ }
+ else {
+ this.classeStore.load({params: {etabId: record.get("etabId")}});
+ this.matieresStore.load({params: {etabId: record.get("etabId")}});
+ }
+ },
+
+ //METHODE QUI GERE LES CLASSES
+ onLoadClasseStore: function(store, records, options) {
+ if (records.length>0) {
+ this.classeCombo.enable();
+ } else {
+ this.classeCombo.disable();
+ }
+ },
+
+ onSelectClasseCombo: function(cmp, record, index) {
+ if (record.get("organizationId")==0) {
+ cmp.reset();
+ }
+ },
+
+
+
+ //forms elements
+ onSpecialKey: function(field, e){
+ // e.HOME, e.END, e.PAGE_UP, e.PAGE_DOWN,
+ // e.TAB, e.ESC, arrow keys: e.LEFT, e.RIGHT, e.UP, e.DOWN
+ if (e.getKey() == e.ENTER) {
+ this.onSearch();
+ }
+ },
+
+
+ //send msg to the selected users from the Contact-grid
+ onSendMessage: function(btn) {
+ // on prend les dest choisi
+ var recDestArray = this.contactGrid.getSelectionModel().getSelections();
+ var recDestIconArray = this.iconView.iconDataView.getSelectedRecords();
+ if (recDestArray.length==0 && recDestIconArray == 0) {
+ Ext.MessageBox.alert(this.i18n.annuaire.onSendMessage.alert.title, this.i18n.annuaire.onSendMessage.alert.msg, function(btn){});
+ return false;
+ }
+
+ //on initialise les champs d'ecriture des new msg
+ this.createMessageWindow.createNewMessage();
+
+ //On expand les destinataires IM
+ this.createMessageWindow.imFieldSet.expand(false);
+
+ var arrayReceiversIM = [];
+
+ if(recDestArray.length!=0){
+ for(i=0; i<recDestArray.length; i++) {
+ var idRec = '2' + recDestArray[i].get("userId");
+ var val = {
+ itemValue: idRec,
+ displayValue: recDestArray[i].get("nom")+ " " +recDestArray[i].get("prenom"),
+ type:""
+ };
+ arrayReceiversIM.push(val);
+ }
+ }else if(recDestIconArray.length!=0){
+ for(i=0; i<recDestIconArray.length; i++) {
+ var idRec = '2' + recDestIconArray[i].get("userId");
+ var val = {
+ itemValue: idRec,
+ displayValue: recDestIconArray[i].get("nom")+ " " +recDestIconArray[i].get("prenom"),
+ type:""
+ };
+ arrayReceiversIM.push(val);
+ }
+ }
+ this.createMessageWindow.destinataireChooser.setValues(arrayReceiversIM);
+
+ },
+
+
+ //on render grid, Drag/Drop
+ onRenderListGrid: function(grid) {
+ // on charge les listes
+ this.listes_store.load();
+ // definition de la zone de drop pour ajouter des users dans les listes
+ grid.dropTarget = new Ext.dd.DropTarget(grid.getId(),
+ {
+ scope: this,
+ ddGroup : 'addFicheToListe',
+ notifyDrop : function(dd, e, data){
+ var droppedUserIds = new Array();
+
+ //regupere ou les contacts ont ete drag
+ var t = Ext.lib.Event.getTarget(e);
+ var rowIndex = this.scope.listGrid.getView().findRowIndex(t);
+
+ if(this.scope.listes_store.getAt(rowIndex)){
+ var destId = this.scope.listes_store.getAt(rowIndex).get("listId");
+ var typeList = this.scope.listes_store.getAt(rowIndex).get("type");
+ if(this.scope.isIconView){
+ var recDestIconArray = this.scope.iconView.iconDataView.getSelectedRecords();
+ for(i=0; i<recDestIconArray.length; i++) {
+ droppedUserIds.push(recDestIconArray[i].get("userId"));
+ }
+ }else if(this.scope.isGridView){
+ for (i=0; i<data.selections.length; i++) {
+ droppedUserIds.push(data.selections[i].get("userId"));
+ }
+ }
+
+ if (typeList=='creation') {
+ // on cree une liste puis on ajoute
+ this.scope.addUsersToNewList(droppedUserIds, this.scope);
+ }
+ else {
+ //ajout simple
+ this.scope.addUsersToList(destId, droppedUserIds, this.scope);
+ }
+ return true;
+ } else {
+ return false;
+ }
+ },
+ notifyOver: function(dd, e, data) {
+ var t = Ext.lib.Event.getTarget(e);
+ var rindex = this.scope.listGrid.getView().findRowIndex(t);
+ // Si on est sur une ligne
+ if(this.scope.listes_store.getAt(rindex)){
+ return 'x-dd-drop-ok';
+ } else {
+ return "";
+ }
+ }
+ });
+ },
+
+
+ //btn
+ onSearch: function(){
+ //on load le store
+ //this.userStore.load({params:{limit:35}});
+ this.userStore.load({params:{limit:30}});
+ },
+
+ prepareParams: function(proxy, params) {
+ //Recupere le champ du panel form
+ var nameSearchFieldValue = this.nameSearchField.getValue();
+ if ( nameSearchFieldValue != "") {
+ params.lastName = nameSearchFieldValue;
+ }
+
+ var firstNameSearchFieldValue = this.firstNameSearchField.getValue();
+ if (firstNameSearchFieldValue != "") {
+ params.firstName = firstNameSearchFieldValue;
+ }
+
+ var statutComboValue = this.statutCombo.getValue();
+ if (statutComboValue != "") {
+ params.statut = statutComboValue;
+ }
+
+ var classeComboValue = this.classeCombo.getValue();
+ if (classeComboValue != "") {
+ params.organizationId = classeComboValue;
+ }
+
+ var etabComboValue = this.etabCombo.getValue();
+ if (etabComboValue != "") {
+ params.etabId = etabComboValue;
+ }
+
+ var etabComboStore = this.etabCombo.store.data.keys;
+ if (etabComboStore != "") {
+ params.etabStore = etabComboStore;
+ }
+
+ var matiereComboValue = this.matiereCombo.getValue();
+ if (matiereComboValue != "") {
+ params.matiereId = matiereComboValue;
+ }
+ },
+
+
+ /*will add users to a list*/
+ addUsersToList : function(listId, userIds, scope) {
+ //Gere le cas ss utilisateurs
+ if (userIds.length==0) {
+ return;
+ }
+ scope.wait.show();
+ Ext.Ajax.request({
+ url: scope.actionURLAjax,
+ params: {
+ cmd: "addUsersToList",
+ listId: listId,
+ userIds: userIds
+ },
+ scope: scope,
+ success: scope.onSuccessAddUserList,
+ failure: scope.onFailureAddUserList
+ });
+ },
+
+ onSuccessAddUserList: function(response, options){
+ /* Code verifiant le succes de la requete */
+ var backObj = Ext.decode(response.responseText);
+ if (!backObj.success) {
+ Ext.MessageBox.alert(this.i18n.annuaire.onSuccessAddUserList.alert.title, this.i18n.annuaire.onSuccessAddUserList.alert.msg, function(btn){});
+ }
+ /* Code verifiant le succes de la requete */
+ this.wait.hide();
+ if (this.contactGrid.getSelectionModel().getCount() == 1) {
+ Ext.slideMsg.msg(this.i18n.annuaire.onSuccessAddUserList.slideMsg.title, this.i18n.annuaire.onSuccessAddUserList.slideMsg.msg[0]);
+ } else {
+ Ext.slideMsg.msg(this.i18n.annuaire.onSuccessAddUserList.slideMsg.title, this.i18n.annuaire.onSuccessAddUserList.slideMsg.msg[1]);
+ }
+ this.contactGrid.getSelectionModel().clearSelections();
+ },
+
+ onFailureAddUserList: function(response, options){
+ Ext.MessageBox.alert(this.i18n.annuaire.onFailureAddUserList.alert.title, this.i18n.annuaire.onFailureAddUserList.alert.msg, function(btn){});
+ this.contactGrid.getSelectionModel().clearSelections();
+ this.wait.hide();
+ },
+
+ /*will add users to a NEW list*/
+ addUsersToNewList : function(userIds, scope) {
+ //Gere le cas sans utilisateurs
+ if (userIds.length==0) {
+ return;
+ }
+
+ // on sauve les users pendant que l'on demande
+ scope.tempUserIds=userIds;
+
+ Ext.MessageBox.show({
+ title: this.i18n.annuaire.addUsersToNewList.MessageBox.title,
+ msg: this.i18n.annuaire.addUsersToNewList.MessageBox.msg,
+ buttons: {yes: this.i18n.annuaire.addUsersToNewList.MessageBox.buttons.yes, cancel: this.i18n.annuaire.addUsersToNewList.MessageBox.buttons.cancel},
+ scope: scope,
+ fn: scope.add_list_call,
+ prompt: true,
+ minWidth:250,
+ animEl: 'addListBtn',
+ closable: false
+ });
+ },
+
+ add_list_call : function(btn, listName) {
+ if (btn == "cancel") {
+ return false;
+ }
+ this.wait.show();
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "addUsersToNewList",
+ listName: listName,
+ userIds: this.tempUserIds
+ },
+ scope: this,
+ success: this.onSuccessAddUsersToNewList,
+ failure: this.onFailureAddUsersToNewList
+ });
+ },
+
+ onSuccessAddUsersToNewList: function(response, options){
+ /* Code verifiant le succes de la requete */
+ var backObj = Ext.decode(response.responseText);
+ if (!backObj.success) {
+ Ext.MessageBox.alert(this.i18n.annuaire.onSuccessAddUsersToNewList.alert.title, this.i18n.annuaire.onSuccessAddUsersToNewList.alert.msg, function(btn){});
+ }
+ /* Code verifiant le succes de la requete */
+ else{
+ this.listes_store.load();
+ }
+ this.contactGrid.getSelectionModel().clearSelections();
+ this.wait.hide();
+ Ext.slideMsg.msg(this.i18n.annuaire.onSuccessAddUsersToNewList.slideMsg.title, this.i18n.annuaire.onSuccessAddUsersToNewList.slideMsg.msg);
+ },
+
+ onFailureAddUsersToNewList: function(response, options){
+ Ext.MessageBox.alert(this.i18n.annuaire.onFailureAddUsersToNewList.alert.title, this.i18n.annuaire.onFailureAddUsersToNewList.alert.msg, function(btn){});
+ this.contactGrid.getSelectionModel().clearSelections();
+ this.wait.hide();
+ },
+
+ onCreateNewListeWithAllResults: function(btn){
+ if(this.userStore.getTotalCount() != 0){
+ var boxMessage = this.i18n.annuaire.addUsersToNewList.MessageBox.msg;
+
+ if(this.userStore.getTotalCount() >= this.COUNT_FOR_LIST_WARNING){
+ boxMessage = this.i18n.annuaire.addUsersToNewList.MessageBox.warningMsg;
+ }
+
+ Ext.MessageBox.show({
+ title: this.i18n.annuaire.addUsersToNewList.MessageBox.title,
+ msg: boxMessage,
+ buttons: {yes: this.i18n.annuaire.addUsersToNewList.MessageBox.buttons.yes, cancel: this.i18n.annuaire.addUsersToNewList.MessageBox.buttons.cancel},
+ scope: this,
+ fn: this.useAllResultsAction,
+ prompt: true,
+ minWidth:250,
+ animEl: 'addListBtn',
+ closable: false
+ });
+ }
+ },
+
+ onSelectListElement: function(){
+ var listId = this.comboLists.getValue();
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "countListMember",
+ listId: listId
+ },
+ scope: this,
+ success: this.onSuccessSelectListElement
+ });
+
+ },
+
+ onSuccessSelectListElement: function(response, options){
+ /* Code verifiant le succes de la requete */
+
+ var backObj = Ext.decode(response.responseText);
+ if (backObj.success) {
+ if( (backObj.size + this.userStore.getTotalCount()) >= this.COUNT_FOR_LIST_WARNING ){
+ this.warningLabel.show();
+ }
+ else{
+ this.warningLabel.hide();
+ }
+ }
+ },
+
+
+ onAddAllResultsToExistingList: function(btn){
+ if(this.userStore.getTotalCount() != 0){
+ this.addToExistingListWindow.show();
+ if (this.userStore.getTotalCount() >= this.COUNT_FOR_LIST_WARNING){
+ this.warningLabel.show();
+ }
+ else{
+ this.warningLabel.hide();
+ }
+ }
+ },
+
+ onValidAddToExistingListWindow: function(btn){
+ var listId = this.comboLists.getValue();
+ if(listId != ""){
+ this.addToExistingListWindow.hide();
+ this.useAllResultsAction(btn, "", this.comboLists.getValue());
+ this.comboLists.clearValue();
+ }
+ },
+
+ onCloseAddToExistingListWindow: function(btn){
+ this.addToExistingListWindow.hide();
+ this.comboLists.clearValue();
+ },
+
+ useAllResultsAction: function(btn, listName, listId){
+ if (btn == "cancel") {
+ return false;
+ }
+
+ this.wait.show();
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "useAllResultsAction",
+ listName: listName,
+ listId: listId,
+ lastName: this.nameSearchField.getValue(),
+ firstName: this.firstNameSearchField.getValue(),
+ statut: this.statutCombo.getValue(),
+ organizationId: this.classeCombo.getValue(),
+ etabId: this.etabCombo.getValue(),
+ matiereId: this.matiereCombo.getValue(),
+ etabStore: this.etabCombo.store.data.keys
+ },
+ scope: this,
+ success: this.onSuccessUseAllResultsAction,
+ failure: this.onFailureUseAllResultsAction
+ });
+ },
+
+ onSuccessUseAllResultsAction: function(response, options){
+ /* Code verifiant le succes de la requete */
+ var backObj = Ext.decode(response.responseText);
+ if (!backObj.success) {
+ Ext.MessageBox.alert(this.i18n.annuaire.onSuccessAddUsersToNewList.alert.title, this.i18n.annuaire.onSuccessAddUsersToNewList.alert.msg, function(btn){});
+ }
+ /* Code verifiant le succes de la requete */
+ else{
+ this.listes_store.load();
+ }
+ this.contactGrid.getSelectionModel().clearSelections();
+ this.wait.hide();
+ Ext.slideMsg.msg(this.i18n.annuaire.onSuccessAddUsersToNewList.slideMsg.title, this.i18n.annuaire.onSuccessAddUsersToNewList.slideMsg.msg);
+ },
+
+ onFailureUseAllResultsAction: function(response, options){
+ Ext.MessageBox.alert(this.i18n.annuaire.onFailureAddUsersToNewList.alert.title, this.i18n.annuaire.onFailureAddUsersToNewList.alert.msg, function(btn){});
+ this.contactGrid.getSelectionModel().clearSelections();
+ this.wait.hide();
+ },
+
+ //METHODE POUR GERER LES INFO PERSO
+ onRowAction: function(grid, rowIndex, colIndex) {
+ var record = grid.getStore().getAt(rowIndex);
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "getUserDetails",
+ userId: record.get('userId')
+ },
+ scope: this,
+ success: this.onSuccessRowAction,
+ failure: this.onFailureRowAction
+ });
+
+ },
+
+ onSuccessRowAction: function(response, options){
+ var backObj = Ext.decode(response.responseText);
+ if (!backObj.success) {
+ Ext.MessageBox.alert(this.i18n.annuaire.onSuccessAddUsersToNewList.alert.title, this.i18n.annuaire.onSuccessAddUsersToNewList.alert.msg, function(btn){});
+ }
+ /* Code verifiant le succes de la requete */
+ else{
+ this.userResume.setValue(backObj.html);
+ this.detailsWindow.show();
+ }
+
+ },
+
+ onFailureRowAction: function(response, options){
+
+ },
+
+ onClose: function(btn){
+ this.detailsWindow.hide();
+ }
+
+
+});
+