* @author bahj
*/
eliot.absences.saisie.incident.creermodifier.ProtagonisteView =
- Ext.extend(Ext.util.Observable, {
+ Ext.extend(Ext.util.Observable, {
- constructor: function(config) {
+ constructor: function(config) {
- this.NameSpace = eliot.absences.saisie.incident.creermodifier;
+ this.NameSpace = eliot.absences.saisie.incident.creermodifier;
- // Définition de la configuration par défaut
- var cfg = {
- listeProtagoniste : undefined,
- protagonisteController : undefined,
- comboTypeProtagoniste : undefined,
- qualiteProtagonisteStore : undefined,
- protagonisteToolbar : undefined
- };
+ // Définition de la configuration par défaut
+ var cfg = {
+ listeProtagoniste : undefined,
+ protagonisteController : undefined,
+ comboTypeProtagoniste : undefined,
+ qualiteProtagonisteStore : undefined,
+ protagonisteToolbar : undefined,
+ boutonsActifs: false
+ };
- // Charge la config passée en paramètre
- Ext.apply(cfg, config);
+ // Charge la config passée en paramètre
+ Ext.apply(cfg, config);
- this.addEvents(
- /**
- * @event actionAfterEdit est déclenché quand on clique sur "enregistrer"
- * @param record record selectionné
- * @param change informations changés
- */
- this.NameSpace.Constantes.eventId.actionAfterEdit,
- /**
- * @event actionEditCancel est déclenché quand on clique sur "Annuler"
- */
- this.NameSpace.Constantes.eventId.actionEditCancel,
- /**
- * @event actionDoubleClic est déclenché quand on double clique
- * sur une ligne
- */
- this.NameSpace.Constantes.eventId.actionDoubleClic,
- /**
- * @event actionSelecterMemeRecord est déclenché quand on clique
- * sur une ligne déjà sélectionnée
- */
- this.NameSpace.Constantes.eventId.actionSelecterMemeRecord,
- /**
- * @event actionChangeRecord est déclenché quand on sélectionne à
- * autre ligne
- * @param record record sélectionné
- */
- this.NameSpace.Constantes.eventId.actionChangeRecord,
- /**
- * @event confirmerSuppression est déclenché quand on clique sur
- * 'oui' en cas de suppression
- * @param record record sélectionné à supprimer
- */
- this.NameSpace.Constantes.eventId.confirmerSuppression
- );
+ this.addEvents(
+ /**
+ * @event actionAfterEdit est déclenché quand on clique sur "enregistrer"
+ * @param record record selectionné
+ * @param change informations changés
+ */
+ this.NameSpace.Constantes.eventId.actionAfterEdit,
+ /**
+ * @event actionEditCancel est déclenché quand on clique sur "Annuler"
+ */
+ this.NameSpace.Constantes.eventId.actionEditCancel,
+ /**
+ * @event actionDoubleClic est déclenché quand on double clique
+ * sur une ligne
+ */
+ this.NameSpace.Constantes.eventId.actionDoubleClic,
+ /**
+ * @event actionSelecterMemeRecord est déclenché quand on clique
+ * sur une ligne déjà sélectionnée
+ */
+ this.NameSpace.Constantes.eventId.actionSelecterMemeRecord,
+ /**
+ * @event actionChangeRecord est déclenché quand on sélectionne à
+ * autre ligne
+ * @param record record sélectionné
+ */
+ this.NameSpace.Constantes.eventId.actionChangeRecord,
+ /**
+ * @event confirmerSuppression est déclenché quand on clique sur
+ * 'oui' en cas de suppression
+ * @param record record sélectionné à supprimer
+ */
+ this.NameSpace.Constantes.eventId.confirmerSuppression
+ );
- this.protagonisteController = cfg.protagonisteController;
- this.rowIndexAModifier = undefined;
- this.comboTypeProtagoniste = cfg.comboTypeProtagoniste;
- this.qualiteProtagonisteStore = cfg.qualiteProtagonisteStore;
+ this.protagonisteController = cfg.protagonisteController;
+ this.rowIndexAModifier = undefined;
+ this.comboTypeProtagoniste = cfg.comboTypeProtagoniste;
+ this.qualiteProtagonisteStore = cfg.qualiteProtagonisteStore;
+ this.boutonsActifs = cfg.boutonsActifs;
- // Plugin pour edition
- this.editor = new Ext.ux.grid.RowEditor({
- saveText : this.NameSpace.Modele.libelle.enregistrer,
- cancelText : this.NameSpace.Modele.libelle.annuler,
- style : {
- 'z-index': '1000'
- },
- errorSummary : false
- });
+ // Plugin pour edition
+ this.editor = new Ext.ux.grid.RowEditor({
+ saveText : this.NameSpace.Modele.libelle.enregistrer,
+ cancelText : this.NameSpace.Modele.libelle.annuler,
+ style : {
+ 'z-index': '1000'
+ },
+ errorSummary : false
+ });
- /**
- * Ajouter un listener sur editor pour capter l'évènement
- * "afteredit" et "canceledit"
- */
- this.editor.addListener(
- 'afteredit',
- function(roweditor, changes, record, rowIndex) {
- var noRecordSelectionne = this.hasRecordSelectionne();
- this.fireEvent(
- this.NameSpace.Constantes.eventId.actionAfterEdit,
- record,
- changes,
- noRecordSelectionne
- );
- },
- this
- );
- this.editor.addListener(
- 'canceledit',
- function(roweditor, boolean) {
- var noRecordSelectionne = this.hasRecordSelectionne();
- this.fireEvent(
- this.NameSpace.Constantes.eventId.actionEditCancel,
- noRecordSelectionne
- );
- },
- this
- );
- this.editor.addListener(
- 'validateedit',
- function(roweditor, changes, record, rowIndex) {
- record.set(
- 'idAutorite',
- this.protagonisteController.idAutoriteSelect
- );
- },
- this
- );
+ /**
+ * Ajouter un listener sur editor pour capter l'évènement
+ * "afteredit" et "canceledit"
+ */
+ this.editor.addListener(
+ 'afteredit',
+ function(roweditor, changes, record, rowIndex) {
+ var noRecordSelectionne = this.hasRecordSelectionne();
+ this.fireEvent(
+ this.NameSpace.Constantes.eventId.actionAfterEdit,
+ record,
+ changes,
+ noRecordSelectionne
+ );
+ },
+ this
+ );
+ this.editor.addListener(
+ 'canceledit',
+ function(roweditor, boolean) {
+ var noRecordSelectionne = this.hasRecordSelectionne();
+ this.fireEvent(
+ this.NameSpace.Constantes.eventId.actionEditCancel,
+ noRecordSelectionne
+ );
+ },
+ this
+ );
+ this.editor.addListener(
+ 'validateedit',
+ function(roweditor, changes, record, rowIndex) {
+ record.set(
+ 'idAutorite',
+ this.protagonisteController.idAutoriteSelect
+ );
+ },
+ this
+ );
- // Initialiser les colonnes du tableau des protagonistes
- this.cm = new Ext.grid.ColumnModel({
- defaults :
- {
- menuDisabled : true,
- resizable : false,
- align : 'left',
- fixed : false
+ // Initialiser les colonnes du tableau des protagonistes
+ this.cm = new Ext.grid.ColumnModel({
+ defaults :
+ {
+ menuDisabled : true,
+ resizable : false,
+ align : 'left',
+ fixed : false
+ },
+ columns : [
+ {
+ id : this.NameSpace.Constantes.idTypeProtagoniste,
+ header : "<p style= font-weight:bold>" +
+ this.NameSpace.Modele.header.type + "</p>",
+ dataIndex : 'idType',
+ width : 140,
+ resizable : true,
+ sortable : true,
+ align : 'left',
+ editor : this.comboTypeProtagoniste,
+ renderer : function(value) {
+ return this.comboRenderer(value, this.comboTypeProtagoniste);
},
- columns : [
- {
- id : this.NameSpace.Constantes.idTypeProtagoniste,
- header : "<p style= font-weight:bold>" +
- this.NameSpace.Modele.header.type + "</p>",
- dataIndex : 'idType',
- width : 140,
- resizable : true,
- sortable : true,
- align : 'left',
- editor : this.comboTypeProtagoniste,
- renderer : function(value) {
- return this.comboRenderer(value, this.comboTypeProtagoniste);
- },
- scope : this
- },
- {
- header : "<p style= font-weight:bold>" +
- this.NameSpace.Modele.header.nom + "</p>",
- dataIndex : 'nom',
- align:'left',
- width : 200,
- renderer: this.rendererNomEleve,
- editor : new Ext.form.TextField({
- id : this.NameSpace.Constantes.composantId.nomProtagoniste,
- readOnly : true,
- allowBlank : false
- })
- },
- {
- header : "<p style= font-weight:bold>" +
- this.NameSpace.Modele.header.qualite + "</p>",
- dataIndex : 'idQualite',
- align:'left',
- width : 100,
- editor : new Ext.form.ComboBox({
- id : this.NameSpace.Constantes.composantId.
- comboQualiteProtagoniste,
- store : this.qualiteProtagonisteStore,
- allowBlank : false,
- valueField: 'id',
- displayField: 'libelle',
- lazyRender : true, // Charger comboBox dans grid
- triggerAction: 'all',
- editable : false,
- mode: 'local'
- }),
- renderer : function(value) {
- return this.comboRenderer(
- value,
- Ext.getCmp(this.NameSpace.Constantes.composantId.
- comboQualiteProtagoniste)
- );
- },
- scope : this
- }
- ]
- });
-
- // Dans le mode de modification
- if (cfg.listeProtagoniste !== undefined) {
- var store = this.protagonisteController.protagonisteStore;
- store.loadData(cfg.listeProtagoniste);
- store.each(function(record) {
- this.protagonisteController.protagonistes.push(record.data);
- }, this);
+ scope : this
+ },
+ {
+ header : "<p style= font-weight:bold>" +
+ this.NameSpace.Modele.header.nom + "</p>",
+ dataIndex : 'nom',
+ align:'left',
+ width : 200,
+ renderer: this.rendererNomEleve,
+ editor : new Ext.form.TextField({
+ id : this.NameSpace.Constantes.composantId.nomProtagoniste,
+ readOnly : true,
+ allowBlank : false
+ })
+ },
+ {
+ header : "<p style= font-weight:bold>" +
+ this.NameSpace.Modele.header.qualite + "</p>",
+ dataIndex : 'idQualite',
+ align:'left',
+ width : 100,
+ editor : new Ext.form.ComboBox({
+ id : this.NameSpace.Constantes.composantId.
+ comboQualiteProtagoniste,
+ store : this.qualiteProtagonisteStore,
+ allowBlank : false,
+ valueField: 'id',
+ displayField: 'libelle',
+ lazyRender : true, // Charger comboBox dans grid
+ triggerAction: 'all',
+ editable : false,
+ mode: 'local'
+ }),
+ renderer : function(value) {
+ return this.comboRenderer(
+ value,
+ Ext.getCmp(this.NameSpace.Constantes.composantId.
+ comboQualiteProtagoniste)
+ );
+ },
+ scope : this
}
+ ]
+ });
- var baliseZoneObligatoire = '<span class="red"> * </span>';
+ // Dans le mode de modification
+ if (cfg.listeProtagoniste !== undefined) {
+ var store = this.protagonisteController.protagonisteStore;
+ store.loadData(cfg.listeProtagoniste);
+ store.each(function(record) {
+ this.protagonisteController.protagonistes.push(record.data);
+ }, this);
+ }
- // Construction du grid
- this.protogonisteGrid = new Ext.grid.GridPanel({
- tbar : cfg.protagonisteToolbar,
- fieldLabel : this.NameSpace.Modele.libelle.listeProtagoniste,
- labelSeparator : ' : ' + baliseZoneObligatoire,
- store : this.protagonisteController.protagonisteStore,
- enableColumnMove: false,
- autoSize : false,
- colModel: this.cm,
- height : 150,
- width: 485,
- plugins : [this.editor],
- cls : 'portal-default_table',
- margins : '0 5 5 5',
- border : true,
- columnLines : true,
- stripeRows: true
- });
+ var baliseZoneObligatoire = '<span class="red"> * </span>';
- this.observeProtagonisteGrid();
- },
+ // Construction du grid
+ this.protogonisteGrid = new Ext.grid.GridPanel({
+ tbar : cfg.protagonisteToolbar,
+ fieldLabel : this.NameSpace.Modele.libelle.listeProtagoniste,
+ labelSeparator : ' : ' + baliseZoneObligatoire,
+ store : this.protagonisteController.protagonisteStore,
+ enableColumnMove: false,
+ autoSize : false,
+ colModel: this.cm,
+ height : 150,
+ width: 485,
+ plugins : this.boutonsActifs ? [this.editor] : [],
+ cls : 'portal-default_table',
+ margins : '0 5 5 5',
+ border : true,
+ columnLines : true,
+ stripeRows: true
+ });
- rendererNomEleve: function(eleveNom, obj, record) {
- var eleveId = record.get('idAutorite');
- var typeId = record.get('idType');
+ this.observeProtagonisteGrid();
+ },
- if (typeId === 1) {
- return '<a href="#" onclick="eliot.ficheeleve.Application.' +
- 'afficheFicheEleve(' + eleveId + ',' + false + ');">' + eleveNom + '</a>';
- } else {
- return eleveNom;
- }
+ rendererNomEleve: function(eleveNom, obj, record) {
+ var eleveId = record.get('idAutorite');
+ var typeId = record.get('idType');
+ if (typeId === 1) {
+ return '<a href="#" onclick="eliot.ficheeleve.Application.' +
+ 'afficheFicheEleve(' + eleveId + ',' + false + ');">' + eleveNom + '</a>';
+ } else {
+ return eleveNom;
+ }
- },
- /**
- * Valeur rendu dans comboBox, normalement value dans un combo qui se
- * trouve dans un grid, son displayed champ est son id, donc cette function
- * permet d'afficher son libellé dans le combo
- * @param value valeur à afficher
- * @param combo l'objet comboBox
- */
- comboRenderer : function(value, combo) {
- var record = undefined;
- record = combo.findRecord(combo.valueField, value);
- return record ? record.get(combo.displayField) : value;
- },
- /**
- * La méthode permet d'observer l'évènement 'actionChangeEvaluation' qui
- * se lance par composant graphique grid(service)
- */
- observeProtagonisteGrid : function() {
- this.protogonisteGrid.addListener({
- rowclick : {
- fn: function(grid, rowIndex) {
- this.selecterRecord(grid, rowIndex);
- },
- scope: this
- },
- rowdblclick : {
- fn: function(grid, rowIndex) {
- this.fireEvent(
- this.NameSpace.Constantes.eventId.actionDoubleClic
- );
- },
- scope: this
+ },
+ /**
+ * Valeur rendu dans comboBox, normalement value dans un combo qui se
+ * trouve dans un grid, son displayed champ est son id, donc cette function
+ * permet d'afficher son libellé dans le combo
+ * @param value valeur à afficher
+ * @param combo l'objet comboBox
+ */
+ comboRenderer : function(value, combo) {
+ var record = undefined;
+ record = combo.findRecord(combo.valueField, value);
+ return record ? record.get(combo.displayField) : value;
+ },
+
+ /**
+ * La méthode permet d'observer l'évènement 'actionChangeEvaluation' qui
+ * se lance par composant graphique grid(service)
+ */
+ observeProtagonisteGrid : function() {
+ this.protogonisteGrid.addListener({
+ rowclick : {
+ fn: function(grid, rowIndex) {
+ if (this.boutonsActifs){
+ this.selecterRecord(grid, rowIndex);
}
- })
+ },
+ scope: this
},
+ rowdblclick : {
+ fn: function(grid, rowIndex) {
+ if (this.boutonsActifs){
+ this.fireEvent(
+ this.NameSpace.Constantes.eventId.actionDoubleClic
+ );
+ }
+ },
+ scope: this
+ }
+ })
+ },
- /**
- * La méthode permet de récupérer le record sélectioné et déclencher
- * un événement
- * @param grid protagoniste grille
- * @param rowIndex numéro de ligne sélectionné
- */
- selecterRecord : function(grid, rowIndex) {
- var record = grid.store.data.items[rowIndex];
+ /**
+ * La méthode permet de récupérer le record sélectioné et déclencher
+ * un événement
+ * @param grid protagoniste grille
+ * @param rowIndex numéro de ligne sélectionné
+ */
+ selecterRecord : function(grid, rowIndex) {
+ var record = grid.store.data.items[rowIndex];
- if (this.protagonisteController.recordSelectionne === record) {
- this.fireEvent(
- this.NameSpace.Constantes.eventId.actionSelecterMemeRecord
- );
- }
- else {
- this.fireEvent(
- this.NameSpace.Constantes.eventId.actionChangeRecord,
- record
- );
- }
- },
+ if (this.protagonisteController.recordSelectionne === record) {
+ this.fireEvent(
+ this.NameSpace.Constantes.eventId.actionSelecterMemeRecord
+ );
+ }
+ else {
+ this.fireEvent(
+ this.NameSpace.Constantes.eventId.actionChangeRecord,
+ record
+ );
+ }
+ },
- /**
- * La méthode permet d'écouté les évènements déclenchés par
- * protagonisteController
- * @param protagonisteController l'objet de ProtagonisteController
- */
- observeProtagonisteController : function(protagonisteController) {
- var idTypeProtagoniste =
- this.NameSpace.Constantes.idTypeProtagoniste;
- protagonisteController.addListener(
- this.NameSpace.Constantes.eventId.actionEditRecordSelectionne,
- function(recordSelectionne) {
- var rowIndex = this.protagonisteController.
- protagonisteStore.indexOf(
- recordSelectionne
- );
- this.editRecordSelectionne(rowIndex);
- },
- this
- );
- protagonisteController.addListener(
- eliot.absences.saisie.incident.creermodifier.Constantes.
- eventId.actionSupprimerRecordSelectionne,
- function(recordSelectionne) {
- eliot.absences.Message.afficherDialogConfirmation(
- this.NameSpace.Modele.message.titreSuppression,
- this.NameSpace.Modele.message.supprimerRecordSelect +
- ' "' + recordSelectionne.data.nom + '" ?',
- this.confirmerSuppression.createDelegate(this),
- null,
- recordSelectionne
- );
- },
- this
- );
- protagonisteController.addListener(
- this.NameSpace.Constantes.eventId.actionCreerUnRecord,
- function() {
- this.startEditing(0);
- },
- this
- );
- },
+ /**
+ * La méthode permet d'écouté les évènements déclenchés par
+ * protagonisteController
+ * @param protagonisteController l'objet de ProtagonisteController
+ */
+ observeProtagonisteController : function(protagonisteController) {
+ var idTypeProtagoniste =
+ this.NameSpace.Constantes.idTypeProtagoniste;
+ protagonisteController.addListener(
+ this.NameSpace.Constantes.eventId.actionEditRecordSelectionne,
+ function(recordSelectionne) {
+ var rowIndex = this.protagonisteController.
+ protagonisteStore.indexOf(
+ recordSelectionne
+ );
+ this.editRecordSelectionne(rowIndex);
+ },
+ this
+ );
+ protagonisteController.addListener(
+ eliot.absences.saisie.incident.creermodifier.Constantes.
+ eventId.actionSupprimerRecordSelectionne,
+ function(recordSelectionne) {
+ eliot.absences.Message.afficherDialogConfirmation(
+ this.NameSpace.Modele.message.titreSuppression,
+ this.NameSpace.Modele.message.supprimerRecordSelect +
+ ' "' + recordSelectionne.data.nom + '" ?',
+ this.confirmerSuppression.createDelegate(this),
+ null,
+ recordSelectionne
+ );
+ },
+ this
+ );
+ protagonisteController.addListener(
+ this.NameSpace.Constantes.eventId.actionCreerUnRecord,
+ function() {
+ this.startEditing(0);
+ },
+ this
+ );
+ },
- /**
- * La méthode permet d'éditer le record sélectionné
- * @param rowIndex numéro de ligne sélectionnée
- */
- editRecordSelectionne : function(rowIndex) {
- this.startEditing(rowIndex, false);
- },
+ /**
+ * La méthode permet d'éditer le record sélectionné
+ * @param rowIndex numéro de ligne sélectionnée
+ */
+ editRecordSelectionne : function(rowIndex) {
+ this.startEditing(rowIndex, false);
+ },
- hasRecordSelectionne : function() {
- var noRecordSelectionne = true;
- if (this.protogonisteGrid.getSelectionModel().getSelected()) {
- noRecordSelectionne = false;
- }
- return noRecordSelectionne;
- },
+ hasRecordSelectionne : function() {
+ var noRecordSelectionne = true;
+ if (this.protogonisteGrid.getSelectionModel().getSelected()) {
+ noRecordSelectionne = false;
+ }
+ return noRecordSelectionne;
+ },
- /**
- * La méthode permet de déclencher un événement 'confirmerSuppression',
- * il y a cudToolbar et crudController qui écoutent
- * @param recordSelectionne record sélectionné à supprimer
- */
- confirmerSuppression : function(recordSelectionne) {
- this.fireEvent(
- this.NameSpace.Constantes.eventId.confirmerSuppression,
- recordSelectionne
- );
- },
+ /**
+ * La méthode permet de déclencher un événement 'confirmerSuppression',
+ * il y a cudToolbar et crudController qui écoutent
+ * @param recordSelectionne record sélectionné à supprimer
+ */
+ confirmerSuppression : function(recordSelectionne) {
+ this.fireEvent(
+ this.NameSpace.Constantes.eventId.confirmerSuppression,
+ recordSelectionne
+ );
+ },
- /** Surcharge "initFields" appeler par "startEditing" de RowEditor
- * pour supprimer l'interprètation de l'action "Enter" sur la colonne
- * TypeProtagoniste (car déjà interprété par le ComboBox -> conflit)
- * @param rowIndex index de la ligne à éditer
- * @param doFocus 'true' pour mettre le focus sur la ligne à éditer
- */
- startEditing : function(rowIndex, doFocus){
- this.editor.startEditing(rowIndex, doFocus);
- var colonneType =
- this.cm.getColumnById(this.NameSpace.Constantes.idTypeProtagoniste);
- var colonneTypeEditor = colonneType.getEditor();
- colonneTypeEditor.column = colonneType;
- colonneTypeEditor.un(
- 'specialkey',
- this.editor.onKey,
- this.editor
- );
- }
-
- });
\ No newline at end of file
+ /** Surcharge "initFields" appeler par "startEditing" de RowEditor
+ * pour supprimer l'interprètation de l'action "Enter" sur la colonne
+ * TypeProtagoniste (car déjà interprété par le ComboBox -> conflit)
+ * @param rowIndex index de la ligne à éditer
+ * @param doFocus 'true' pour mettre le focus sur la ligne à éditer
+ */
+ startEditing : function(rowIndex, doFocus){
+ this.editor.startEditing(rowIndex, doFocus);
+ var colonneType =
+ this.cm.getColumnById(this.NameSpace.Constantes.idTypeProtagoniste);
+ var colonneTypeEditor = colonneType.getEditor();
+ colonneTypeEditor.column = colonneType;
+ colonneTypeEditor.un(
+ 'specialkey',
+ this.editor.onKey,
+ this.editor
+ );
+ }
+
+ });
\ No newline at end of file