--- /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.UserManagement");
+EntSavoie.UserManagement.SearchUserPanel = function (config) {
+ Ext.apply(this, config);
+
+ // Ajoute le texte des erreurs
+ Ext.QuickTips.init();
+
+ // turn on validation errors beside the field globally
+ Ext.form.Field.prototype.msgTarget = 'side';
+
+ // Nom
+ this.lastNameTextField = this.lastNameTextField || new Ext.form.TextField({
+ fieldLabel: "Nom",
+ emptyText: "Nom",
+ anchor: "95%",
+ enableKeyEvents: true
+ });
+
+ // Prenom
+ this.firstNameTextField = this.firstNameTextField || new Ext.form.TextField({
+ fieldLabel: "Prénom",
+ emptyText: "Prénom",
+ anchor: "95%",
+ enableKeyEvents: true
+ });
+
+ // Identifiant
+ this.screenNameTextField = this.screenNameTextField || new Ext.form.TextField({
+ fieldLabel: "Identifiant",
+ emptyText: "Identifiant",
+ anchor: "95%",
+ enableKeyEvents: true
+ });
+
+ // Role
+ this.roleStore = this.roleStore || new Ext.data.JsonStore({
+ root: 'roles',
+ idProperty: 'roleId',
+ fields: [
+ 'roleId',
+ 'name',
+ 'label'
+ ],
+ autoLoad: true,
+ url: this.renderURLAjax+'&jspPage=%2Fajax%2FgestionMembres%2FlistRoles.jsp',
+ sortInfo: {
+ field: 'name',
+ direction: 'ASC'
+ }
+ });
+
+ this.roleComboBox = this.roleComboBox || new Ext.form.ComboBox({
+ listClass: "userManagement-portlet",
+ emptyText: "Rôle",
+ fieldLabel: "Rôle",
+ valueField: 'roleId',
+ displayField: 'label',
+ editable: false,
+ store: this.roleStore,
+ triggerAction: "all",
+ mode: 'local',
+ anchor: "95%",
+ enableKeyEvents: true
+ });
+
+ // Etablissement
+ this.etablissementStore = this.etablissementStore || new Ext.data.JsonStore({
+ root: 'etabs',
+ idProperty: 'etabId',
+ fields: ['etabId', 'name', 'dn'],
+ autoLoad: true,
+ url: this.renderURLAjax+'&jspPage=%2Fajax%2FlistEtablissementsFromLDAP.jsp',
+ sortInfo: {
+ field: 'name',
+ direction: 'ASC'
+ }
+ });
+
+ this.etablissementComboBox = this.etablissementComboBox || new Ext.form.ComboBox({
+ listClass: "userManagement-portlet",
+ emptyText: "Etablissement",
+ fieldLabel: "Etablissement",
+ valueField: 'etabId',
+ displayField: 'name',
+ editable: false,
+ triggerAction: 'all',
+ mode: 'local',
+ store: this.etablissementStore,
+ listWidth: 250,
+ anchor: "95%",
+ enableKeyEvents: true
+ });
+
+ // Classe
+ this.classeStore = this.classeStore || new Ext.data.JsonStore({
+ root: 'orgs',
+ idProperty: 'organizationId',
+ fields: ['organizationId', 'name', 'dn', 'type'],
+ url: this.renderURLAjax+'&jspPage=%2Fajax%2FlistOrganizationsFromLDAP.jsp',
+ sortInfo: {
+ field: 'name',
+ direction: 'ASC'
+ }
+ });
+
+ this.classeComboBox = this.classeComboBox || new Ext.form.ComboBox({
+ listClass: "userManagement-portlet",
+ fieldLabel: "Classe",
+ emptyText: "Classe",
+ valueField: 'organizationId',
+ displayField: 'name',
+ editable: false,
+ triggerAction: 'all',
+ store: this.classeStore,
+ mode: "local",
+ disabled: true,
+ listWidth: 250,
+ anchor: "95%",
+ enableKeyEvents: true
+ });
+
+ // Panel de gauche
+ this.topLeftPanel = this.topLeftPanel || new Ext.Panel({
+ border: false,
+ columnWidth: .5,
+ layout: "form",
+ labelWidth: 100,
+ padding: 5,
+ items: [
+ this.lastNameTextField,
+ this.screenNameTextField,
+ this.etablissementComboBox
+ ]
+ });
+
+ // Panel de droite
+ this.topRightPanel = this.topRightPanel || new Ext.Panel({
+ border: false,
+ columnWidth: .5,
+ layout: "form",
+ labelWidth: 100,
+ padding: 5,
+ items: [
+ this.firstNameTextField,
+ this.roleComboBox,
+ this.classeComboBox
+ ]
+ });
+
+ // Panel du haut
+ this.topPanel = this.topPanel || new Ext.Panel({
+ border: false,
+ layout: "column",
+ anchor: '100%',
+ items: [
+ this.topLeftPanel,
+ this.topRightPanel
+ ]
+ });
+
+ // Utilisateurs jamais connectes
+ this.onlyNeverLoginUserCB = this.onlyNeverLoginUserCB || new Ext.form.Checkbox({
+ boxLabel: "Utilisateurs qui ne se sont jamais connectés",
+ checked: true
+ });
+
+ // Utilisateurs deja connectes
+ this.onlyAlreadyLoginUserCB = this.onlyAlreadyLoginUserCB || new Ext.form.Checkbox({
+ boxLabel: "Utilisateurs qui se sont déjà connectés",
+ checked: true
+ });
+
+ // Bouton de recherche
+ this.searchButton = this.searchButton || new Ext.Button ({
+ style: "margin: 0 auto;",
+ iconCls: "search",
+ text: "Rechercher",
+ handler: this.onSearchButton,
+ width:200,
+ scope: this
+ });
+
+ // Panel du bas
+ this.bottomPanel = this.bottomPanel || new Ext.Panel({
+ border: false,
+ layout: "column",
+ anchor: '100%',
+ items: [
+ {
+ border: false,
+ columnWidth: .99,
+ layout: 'form',
+ padding: 5,
+ items: [
+ this.onlyNeverLoginUserCB,
+ this.onlyAlreadyLoginUserCB
+ ]
+ },
+ {
+ border: false,
+ width:210,
+ padding: 5,
+ items: [
+ {border: false, html: "<br/>"},
+ this.searchButton
+ ]
+ }
+ ]
+ });
+
+ EntSavoie.UserManagement.SearchUserPanel.superclass.constructor.call(this, {
+ title: "Panel de recherche",
+ height: 200,
+ width: "auto",
+ border: true,
+ region: "north",
+ items: [
+ this.topPanel,
+ this.bottomPanel
+ ]
+ });
+
+ /*
+ * Definition des evenements
+ */
+
+ this.roleStore.on("load", this.onLoadRoleStore, this);
+ this.roleComboBox.on("specialkey", this.onSpecialKey, this);
+
+ this.etablissementStore.on("load", this.onLoadEtablissementStore, this);
+ this.etablissementComboBox.on("select", this.onSelectEtablissementComboBox, this);
+ this.etablissementComboBox.on("specialkey", this.onSpecialKey, this);
+
+ this.classeStore.on("load", this.onLoadClasseStore, this);
+ this.classeComboBox.on("specialkey", this.onSpecialKey, this);
+
+ this.lastNameTextField.on("specialkey", this.onSpecialKey, this);
+ this.firstNameTextField.on("specialkey", this.onSpecialKey, this);
+ this.screenNameTextField.on("specialkey", this.onSpecialKey, this);
+
+};
+
+Ext.extend(EntSavoie.UserManagement.SearchUserPanel, Ext.form.FieldSet, {
+ initComponent: function () {
+ EntSavoie.UserManagement.SearchUserPanel.superclass.initComponent.call(this);
+ },
+
+ /*
+ * Role
+ */
+
+ onLoadRoleStore: function(store, records, options){
+ if(isPP || isReferentNumerique){
+ var record = records[0];
+ this.roleComboBox.setValue(record.get("roleId"));
+ }
+ },
+
+ /*
+ * Etablissement
+ */
+
+ onLoadEtablissementStore: function(store, records, options) {
+ if (records.length == 1) {
+ var record = records[0];
+ this.etablissementComboBox.setValue(record.get("etabId"));
+ this.classeComboBox.reset();
+ this.loadClasseStore(record.get("dn"), record.get("name"));
+ }
+ },
+
+ onSelectEtablissementComboBox: function(combo, record, index) {
+ this.classeComboBox.reset();
+ if (record.get("etabId")==0) {
+ this.classeComboBox.disable();
+ }
+ else {
+ this.loadClasseStore(record.get("dn"), record.get("name"));
+ }
+ },
+
+ /*
+ * Classe
+ */
+
+ loadClasseStore: function(etabDN, name) {
+ this.classeStore.load({
+ params: {
+ etabDN: etabDN,
+ name: name
+ }
+ });
+ },
+
+ onLoadClasseStore: function(store){
+ this.classeComboBox.enable();
+ },
+
+ /*
+ * General
+ */
+
+ onSpecialKey: function(field, e){
+ if (e.getKey() == e.ENTER) {
+ this.onSearchButton();
+ }
+ },
+
+ onSearchButton: function(){
+ var etabDN = "";
+ if(this.etablissementComboBox.getValue()>0){
+ etabDN = this.etablissementStore.getById(this.etablissementComboBox.getValue()).get("dn");
+ }
+
+ var classDN = "";
+ if(this.classeComboBox.getValue()>0){
+ classDN = this.classeStore.getById(this.classeComboBox.getValue()).get("dn");
+ }
+
+ var roleName = "";
+ if(this.roleComboBox.getValue()>0){
+ roleName = this.roleStore.getById(this.roleComboBox.getValue()).get("name");
+ }
+
+ var params = {
+ lastName: this.lastNameTextField.getValue(),
+ firstName: this.firstNameTextField.getValue(),
+ screenName: this.screenNameTextField.getValue(),
+ role: roleName,
+ etabDN: etabDN,
+ orgId: this.classeComboBox.getValue(),
+ classDN: classDN,
+ neverLogin: this.onlyNeverLoginUserCB.getValue(),
+ alreadyLogin: this.onlyAlreadyLoginUserCB.getValue()
+ };
+
+ this.mainContainer.loadUserStore(params);
+ }
+});
+