// Ajoute les constantes propres à la toolbar ---------------------------------
eliot.textes.Constantes.leftToolbar = {
- idLeftToolBar:'toolBarL',
- idBoutonCreer:'bCreation',
- idBoutonCreerCahier:'bCreationCahier',
- idBoutonProprietesCahier:'proprietesCahierDeTexte',
- idBoutonImprimerCahier:'imprimerCahierDeTexte',
- idBoutonSupprimerCahier:'supprimerCahierDeTexte',
- idBoutonCreerDossier:'creationDossier',
- idBoutonRenommerDossier:'renommerDossier',
- idBoutonSupprimerDossier:'supprimerDossier',
- idBoutonAfficherCahiersMasques:'afficherCahiersMasques',
- idBoutonSuivreImpressions:'suivreImpressions'
+ idLeftToolBar:'toolBarL',
+ idBoutonCreer:'bCreation',
+ idBoutonCreerCahier:'bCreationCahier',
+ idBoutonProprietesCahier:'proprietesCahierDeTexte',
+ idBoutonImprimerCahier:'imprimerCahierDeTexte',
+ idBoutonSupprimerCahier:'supprimerCahierDeTexte',
+ idBoutonCreerDossier:'creationDossier',
+ idBoutonRenommerDossier:'renommerDossier',
+ idBoutonSupprimerDossier:'supprimerDossier',
+ idBoutonAfficherCahiersMasques:'afficherCahiersMasques',
+ idBoutonSuivreImpressions:'suivreImpressions'
};
eliot.textes.LeftToolBar = Ext.extend(Ext.util.Observable, {
- constructor:function (config) {
-
- this.dialogueImpression = config.dialogueImpression;
- this.observeImpressionView(this.dialogueImpression);
-
- this.toolbar = new Ext.Toolbar({
- border:false,
- autoWidth:true,
- height:36,
- id:eliot.textes.Constantes.leftToolbar.idLeftToolBar,
- items:[
- {
- id:eliot.textes.Constantes.leftToolbar.idBoutonCreer,
- xtype:'button',
- text:'Créer',
- icon:'../images/add16x16.gif',
- disabled:eliot.textes.Modele.isAcceesRestreint,
- menu:[
- {
- text:'Cahier de textes',
- cls:'x-btn-icon',
- icon:'../images/add16x16.gif',
- id:eliot.textes.Constantes.leftToolbar.idBoutonCreerCahier,
- disabled:eliot.textes.Constantes.desactiverCreationCdt
- },
-
- {
- text:'Dossier',
- cls:'x-btn-icon',
- icon:'../images/add16x16.gif',
- id:eliot.textes.Constantes.leftToolbar.idBoutonCreerDossier
- }
- ]
- },
- {
- xtype:'button',
- text:'Autres actions',
- menu:[
- {
- text:'Propriétés du cahier de textes',
- cls:'x-btn-icon',
- icon:'../images/info.png',
- id:eliot.textes.Constantes.leftToolbar.idBoutonProprietesCahier,
- disabled:true
- },
- {
- text:'Imprimer le cahier de textes',
- cls:'x-btn-icon',
- icon:'../images/printpreview.png',
- id:eliot.textes.Constantes.leftToolbar.idBoutonImprimerCahier,
- disabled:true
- },
- {
- text:'Supprimer un cahier de textes',
- cls:'x-btn-icon',
- icon:'../images/delete.gif',
- id:eliot.textes.Constantes.leftToolbar.idBoutonSupprimerCahier,
- disabled:true
- },
- {
- text:'Renommer le dossier',
- cls:'x-btn-icon',
- icon:'../images/edit.png',
- id:eliot.textes.Constantes.leftToolbar.idBoutonRenommerDossier,
- disabled:true
- },
- {
- text:'Supprimer le dossier',
- cls:'x-btn-icon',
- icon:'../images/delete.gif',
- id:eliot.textes.Constantes.leftToolbar.idBoutonSupprimerDossier,
- disabled:true
- },
- {
- text:'Afficher les cahiers de textes masqués',
- cls:'x-btn-icon',
- id:eliot.textes.Constantes.leftToolbar.idBoutonAfficherCahiersMasques,
- disabled:true
- }
- ]
- }
- ]
- });
- // Ajout des évènements persos
- this.suppressionCahierEvent = 'suppressionCahierEvent';
- this.echecSuppressionCahierEvent = 'echecSuppressionCahierEvent';
- this.creationDossierEvent = 'creationDossierEvent';
- this.suppressionDossierEvent = 'suppressionDossierEvent';
- this.addEvents(this.suppressionCahierEvent,
- this.echecSuppressionCahierEvent,
- this.creationDossierEvent,
- this.suppressionDossierEvent);
- this.listeners = config.listeners;
-
- this.creePopupAfficherCahiersMasques();
-
- this.observeToolbar();
- },
-
- observeToolbar:function () {
- // Observe le menu "Créer un cahier de textes"
- Ext.getCmp(eliot.textes.Constantes.leftToolbar.idBoutonCreerCahier).addListener({
- click:{
- fn:function () {
- this.actionCreerCahier();
- },
- scope:this
- }
- });
- // Observe le menu "Propriétés d'un cahier de textes"
- Ext.getCmp(eliot.textes.Constantes.leftToolbar.idBoutonProprietesCahier).addListener({
- click:{
- fn:function () {
- this.actionProprietesCahier();
- },
- scope:this
- }
- });
- // Observe le menu "Imprimer un cahier de textes"
- Ext.getCmp(eliot.textes.Constantes.leftToolbar.idBoutonImprimerCahier).addListener({
- click:{
- fn:function () {
- this.actionImprimerCahier();
- },
- scope:this
- }
- });
- // Observe le menu "Supprimer un cahier de textes"
- Ext.getCmp(eliot.textes.Constantes.leftToolbar.idBoutonSupprimerCahier).addListener({
- click:{
- fn:function () {
- this.actionSupprimerCahier(true);
- },
- scope:this
- }
- });
- // Observe le menu "Créer un dossier"
- Ext.getCmp(eliot.textes.Constantes.leftToolbar.idBoutonCreerDossier).addListener({
- click:{
- fn:function () {
- this.actionCreerDossier();
- },
- scope:this
- }
- });
- // Observe le menu "Renommer un dossier"
- Ext.getCmp(eliot.textes.Constantes.leftToolbar.idBoutonRenommerDossier).addListener({
- click:{
- fn:function () {
- this.actionRenommerDossier();
- },
- scope:this
- }
- });
- // Observe le menu "Supprimer un dossier"
- Ext.getCmp(eliot.textes.Constantes.leftToolbar.idBoutonSupprimerDossier).addListener({
- click:{
- fn:function () {
- this.actionSupprimerDossier();
- },
- scope:this
- }
- });
- // Observe le menu "Afficher les cahiers de textes masqués"
- Ext.getCmp(eliot.textes.Constantes.leftToolbar.idBoutonAfficherCahiersMasques).addListener({
- click:{
- fn:function () {
- this.actionAfficherCahiersMasques();
- },
- scope:this
- }
- });
- },
-
- /**
- * Méthode destinée à être appelée de l'extérieur pour passer la node
- * sélectionnée dans le tree folder.
- */
- // TOREFACT : refactoring cette méthode : supprmier et utiliser dans GestionnaireCdt
- setNodeSelectionnee:function (node) {
- this.nodeSelectionnee = node;
- },
-
- /**
- * Action appelée lors de la création d'un cahier de textes.
- */
- actionCreerCahier:function () {
- document.location.href = eliot.textes.Constantes.urlCahierDeTextesCreer;
- },
-
- /**
- * Action appelée lors du click sur le menu "Propriétés d'un cahier"
- */
- // TOREFACT : refactoring cette méthode: supprmier et utiliser dans GestionnaireCdt
- actionProprietesCahier:function () {
- var node = this.nodeSelectionnee;
- var idCdt = eliot.textes.Utils.getIdFromNode(node);
- var url = eliot.textes.Constantes.urlCahierDeTextesProprietes;
- url = url + '?id=' + idCdt;
- document.location.href = url;
- },
-
- /**
- * Action appelée lors du click sur le menu "Imprimer cahier"
- */
- actionImprimerCahier:function () {
-
- var node = this.nodeSelectionnee;
-
- var peutModifierLeContenuDuCdt = node.attributes.peutModifierLeContenuDuCdt;
-
- var idCdt = eliot.textes.Utils.getIdFromNode(node);
-
- // on lance ici la boite de dialogue
- this.dialogueImpression.afficherWindowSelectionActiviteView(idCdt, peutModifierLeContenuDuCdt);
- },
-
- /**
- * Action appelée lors du click sur le menu "Suprimer cahier"
- */
- actionSupprimerCahier:function (isCurrentCdtAsContextMenuSelected) {
- var node = this.nodeSelectionnee;
- eliot.textes.Messages.afficherDialogConfirmation(
- 'Supprimer le cahier de textes ?',
- 'Êtes-vous sûr de vouloir supprimer le cahier de textes : ' + node.text + ' ? '
- + 'Attention, cette opération supprimera toutes les activités et chapitres de ce cahier de textes.',
-
- this.executerSupprimerCahier.createDelegate(this),
- null,
- isCurrentCdtAsContextMenuSelected
- );
- },
-
- /**
- * Action déclenchée lors de la création d'un dossier
- */
- actionCreerDossier:function () {
- eliot.textes.Messages.afficherDialogSaisie(
- 'Ajouter un dossier',
- 'Nom du dossier:',
- this.executerCreerDossier.createDelegate(this));
-
- },
-
- // Renommer un dossier
- actionRenommerDossier:function () {
- eliot.textes.Messages.afficherDialogSaisie(
- 'Renommer un dossier',
- 'Nouveau nom du dossier:',
- this.executerRenommerDossier.createDelegate(this),
- null,
- this.nodeSelectionnee.text);
- },
-
- actionSupprimerDossier:function () {
- var node = this.nodeSelectionnee;
- eliot.textes.Messages.afficherDialogConfirmation(
- 'Supprimer le dossier ?',
- 'Êtes-vous sûr de vouloir supprimer le dossier : ' + node.text,
- this.executerSupprimerDossier.createDelegate(this)
- );
- },
-
- actionAfficherCahiersMasques:function () {
- this.popupAfficherCahiersMasques.show();
- },
-
-
- observeImpressionView:function (impressionView) {
-
- impressionView.addListener(
- eliot.textes.Constantes.actionImpression,
-
- function (idCdt, dateDebut, dateFin, chapitreSansActivite, activiteAvecDate) {
-
- var url = eliot.textes.Constantes.urlCahierDeTextesImprimer;
-
- var params = {
- ids:idCdt,
- dateDebut:dateDebut.format("d/m/Y"),
- dateFin:dateFin.format("d/m/Y"),
- chapitreSansActivite:chapitreSansActivite,
- activiteAvecDate:activiteAvecDate
- };
-
- Ext.Ajax.request({
- url:url,
- params:params,
- success:function (response, request) {
- var reponse = Ext.decode(response.responseText);
- if (reponse.success == true) {
- var url = eliot.textes.Constantes.urlGetImpressionPdf + '?demandeId=' + reponse.demandeId;
-
- // Les scrollbars ne sont pas affichés. Pour qoui ? On ne sait pas :(
- window.open(url, "_blank", "height=600, width=800, toolbar=no,menubar=no,scrollbars=yes");
-
-
- } else {
- if (reponse.message) {
- eliot.textes.Messages.showErreur(reponse.message);
- }
- else {
- request.failure.call(this);
- }
- }
- },
- scope:this,
- failure:function () {
- eliot.textes.Messages.showErreur(
- eliot.textes.Modele.message.ajoutDemandeImpressionErreur
- );
- }
- });
- }
- );
-
- },
-
- executerSupprimerCahier:function (isCurrentCdtAsContextMenuSelected) {
- var node = this.nodeSelectionnee;
- // Affichage de la progresse bar
- var mask = new Ext.LoadMask(
- Ext.getBody(),
+ constructor:function (config) {
+
+ this.dialogueImpression = config.dialogueImpression;
+ this.observeImpressionView(this.dialogueImpression);
+
+ this.toolbar = new Ext.Toolbar({
+ border:false,
+ autoWidth:true,
+ height:36,
+ id:eliot.textes.Constantes.leftToolbar.idLeftToolBar,
+ items:[
+ {
+ id:eliot.textes.Constantes.leftToolbar.idBoutonCreer,
+ xtype:'button',
+ text:'Créer',
+ icon:'../images/add16x16.gif',
+ disabled:eliot.textes.Modele.isAcceesRestreint,
+ menu:[
{
- msg:eliot.textes.Modele.message.suppressionEnCours
- });
- mask.show();
-
- Ext.Ajax.request({
- url:eliot.textes.Constantes.urlCahierDeTextesSupprimer,
- params:{ node:node.id },
- scope:this,
- success:function (response, request) {
- // On masque le sablier
- mask.hide();
- if (response.responseText.charAt(0) != 1) {
- request.failure();
- } else {
- node.remove();
- eliot.textes.Messages.showConfirmation(
- 'Le cahier de textes ' + node.text + ' a été supprimé');
- // On lance un évènement pour que le "parent"
- // manipule éventuellement les autres composants
- this.fireEvent(this.suppressionCahierEvent,
- node,
- isCurrentCdtAsContextMenuSelected
- );
- }
+ text:'Cahier de textes',
+ cls:'x-btn-icon',
+ icon:'../images/add16x16.gif',
+ id:eliot.textes.Constantes.leftToolbar.idBoutonCreerCahier,
+ disabled:eliot.textes.Constantes.desactiverCreationCdt
},
- failure:function () {
- // On masque le sablier
- mask.hide();
- // Help ! on dirait que "this" ici n'a pas l'air d'être celui
- // de leftToolbar ! pourtant le paramètre scope:this est censé
- //this.fireEvent(this.echecSuppressionCahierEvent, node);
- eliot.textes.Messages.showErreur(
- 'Le cahier de textes ' + node.text + ' n\'est pas vide. Il n\'a pas pu être supprimé');
- }
- });
- },
- executerCreerDossier:function (text) {
- Ext.Ajax.request({
- url:eliot.textes.Constantes.urlDossierCreer,
- params:{ nom:text },
- scope:this,
- success:function (response, request) {
- var retour = Ext.decode(response.responseText);
- if (!retour.success) {
- request.failure();
- } else {
- // Récupère l'id du dossier créer
- var nodeId = 'd' + retour.id;
- var nom = retour.nom;
- eliot.textes.Messages.showConfirmation('Le dossier ' + nom + ' a été créé');
- this.fireEvent(this.creationDossierEvent, nodeId, nom);
- }
- },
- failure:function () {
- eliot.textes.Messages.showErreur('Le dossier n\'a pas pu être créé');
- }
- });
- },
-
- executerRenommerDossier:function (text) {
- var node = this.nodeSelectionnee;
- // appeler la création de dossier
- var ancienNom = node.text;
- Ext.Ajax.request({
- url:eliot.textes.Constantes.urlDossierRenommer,
- params:{ nom:text, node:node.id },
- success:function (response, request) {
- if (response.responseText.charAt(0) != 1) {
- request.failure();
- } else {
- node.setText(text);
- eliot.textes.Messages.showConfirmation(
- 'Le dossier ' + ancienNom + ' a été renommé en ' + text);
- }
- },
- failure:function () {
- eliot.textes.Messages.showErreur(
- 'Le dossier ' + node.text + ' n\'a pas pu être renommé');
- }
- });
- },
-
- executerSupprimerDossier:function () {
- var node = this.nodeSelectionnee;
- // appeler la suppression de dossier
- Ext.Ajax.request({
- url:eliot.textes.Constantes.urlDossierSupprimer,
- params:{ node:node.id },
- scope:this,
- success:function (response, request) {
- if (response.responseText.charAt(0) != 1) {
- request.failure();
- } else {
- node.remove();
- eliot.textes.Messages.showConfirmation(
- 'Le dossier ' + node.text + ' a été supprimé');
- this.fireEvent(this.suppressionDossierEvent, node);
- }
- },
- failure:function () {
- eliot.textes.Messages.showErreur(
- 'Le dossier ' + node.text + ' n\'est pas vide. Il n\'a pas pu être supprimé');
+ {
+ text:'Dossier',
+ cls:'x-btn-icon',
+ icon:'../images/add16x16.gif',
+ id:eliot.textes.Constantes.leftToolbar.idBoutonCreerDossier
}
- });
- },
-
- // activer le bouton "créer"
- activerBoutonCreer:function () {
- var boutonCreer = Ext.getCmp(eliot.textes.Constantes.leftToolbar.
- idBoutonCreer);
- boutonCreer.enable();
-
- },
-
- // desactiver le bouton "créer"
- desactiverBoutonCreer:function () {
- var boutonCreer = Ext.getCmp(eliot.textes.Constantes.leftToolbar.
- idBoutonCreer);
- boutonCreer.disable();
- },
-
- creePopupAfficherCahiersMasques:function () {
-
- this.creeBoutonsPopupAffichageCahiersMasques();
-
- this.checkBox = new Ext.grid.CheckboxSelectionModel({
- header:'<div id="eliot-text-checker" class="x-grid3-hd-checker"> </div>'
- });
-
- this.gridCahiersAAfficher = new Ext.grid.GridPanel({
- store:new Ext.data.Store({
- autoDestroy:true,
- storeId:'cahiersMasquesStore',
- reader:new Ext.data.JsonReader(
- {
- root:'cahiers',
- idProperty:'id',
- fields:[
- {name:'id'},
- {name:'libelle'}
- ]
- })
- }),
- colModel:new Ext.grid.ColumnModel({
- defaults:{
- width:120,
- sortable:true
- },
- columns:[
- this.checkBox,
- {header:'Cahiers de textes', dataIndex:'libelle', sortable:true, menuDisabled:true, resizable:false}
- ]
- }),
- viewConfig:{
- stripeRows:true,
- autoExpandColumn:'libelle',
- forceFit:true
+ ]
+ },
+ {
+ xtype:'button',
+ text:'Autres actions',
+ menu:[
+ {
+ text:'Propriétés du cahier de textes',
+ cls:'x-btn-icon',
+ icon:'../images/info.png',
+ id:eliot.textes.Constantes.leftToolbar.idBoutonProprietesCahier,
+ disabled:true
},
- sm:this.checkBox,
- cls:'portal-default_table'
- });
-
- this.getCahiersMasques();
-
- this.popupAfficherCahiersMasques = new Ext.Window({
- id:'popupAfficherCahiersMasques',
- width:450,
- height:280,
- layout:'fit',
- modal:true,
- title:eliot.textes.Modele.libelle.popupAfficherCahiersMasques,
- closeAction:'hide',
- resizable:false,
- plain:true,
- items:[
- {
- xtype:'fieldset',
- border:false,
- autoHeight:true,
- items:[
- {
- xtype:'label',
- text:'Sélectionnez les cahiers de textes masqués à afficher :'
- }
- ,
- {
- xtype:'panel',
- border:false,
- style:'margin: 20px auto;',
- height:140,
- layout:'fit',
- items:[
- this.gridCahiersAAfficher
- ]
- }
- ]
- }
- ],
- buttons:[
- this.btnAfficher,
- this.btnAnnuler
- ]
- });
-
- var selectionModel = this.gridCahiersAAfficher.getSelectionModel();
-
- this.btnAnnuler.addListener("click",
- function () {
- this.popupAfficherCahiersMasques.hide()
+ {
+ text:'Imprimer le cahier de textes',
+ cls:'x-btn-icon',
+ icon:'../images/printpreview.png',
+ id:eliot.textes.Constantes.leftToolbar.idBoutonImprimerCahier,
+ disabled:true
},
- this
- );
-
- this.btnAfficher.addListener("click",
- function () {
- this.afficherCahiersMasques(
- selectionModel.getSelections()
- );
- this.popupAfficherCahiersMasques.hide();
- this.getCahiersMasques();
+ {
+ text:'Supprimer un cahier de textes',
+ cls:'x-btn-icon',
+ icon:'../images/delete.gif',
+ id:eliot.textes.Constantes.leftToolbar.idBoutonSupprimerCahier,
+ disabled:true
},
- this
- );
-
- selectionModel.addListener(
- "rowselect",
- function () {
- this.btnAfficher.enable()
+ {
+ text:'Renommer le dossier',
+ cls:'x-btn-icon',
+ icon:'../images/edit.png',
+ id:eliot.textes.Constantes.leftToolbar.idBoutonRenommerDossier,
+ disabled:true
},
- this
- );
-
- selectionModel.addListener(
- "rowdeselect",
- function () {
- if (selectionModel.getSelections().length == 0) {
- this.btnAfficher.disable()
- }
+ {
+ text:'Supprimer le dossier',
+ cls:'x-btn-icon',
+ icon:'../images/delete.gif',
+ id:eliot.textes.Constantes.leftToolbar.idBoutonSupprimerDossier,
+ disabled:true
},
- this
- );
- },
-
- /**
- * Création boutons popup affichage cahiers masqués
- */
- creeBoutonsPopupAffichageCahiersMasques:function () {
- this.btnAfficher = new Ext.Button({
- id:'boutonAfficher',
- text:eliot.textes.Modele.button.boutonAfficher
- });
- this.btnAnnuler = new Ext.Button({
- id:'boutonAnnuler',
- text:eliot.textes.Modele.button.boutonAnnuler
- });
+ {
+ text:'Afficher les cahiers de textes masqués',
+ cls:'x-btn-icon',
+ id:eliot.textes.Constantes.leftToolbar.idBoutonAfficherCahiersMasques,
+ disabled:true
+ }
+ ]
+ }
+ ]
+ });
+ // Ajout des évènements persos
+ this.suppressionCahierEvent = 'suppressionCahierEvent';
+ this.echecSuppressionCahierEvent = 'echecSuppressionCahierEvent';
+ this.creationDossierEvent = 'creationDossierEvent';
+ this.suppressionDossierEvent = 'suppressionDossierEvent';
+ this.addEvents(this.suppressionCahierEvent,
+ this.echecSuppressionCahierEvent,
+ this.creationDossierEvent,
+ this.suppressionDossierEvent);
+ this.listeners = config.listeners;
+
+ this.creePopupAfficherCahiersMasques();
+
+ this.observeToolbar();
+ },
+
+ observeToolbar:function () {
+ // Observe le menu "Créer un cahier de textes"
+ Ext.getCmp(eliot.textes.Constantes.leftToolbar.idBoutonCreerCahier).addListener({
+ click:{
+ fn:function () {
+ this.actionCreerCahier();
+ },
+ scope:this
+ }
+ });
+ // Observe le menu "Propriétés d'un cahier de textes"
+ Ext.getCmp(eliot.textes.Constantes.leftToolbar.idBoutonProprietesCahier).addListener({
+ click:{
+ fn:function () {
+ this.actionProprietesCahier();
+ },
+ scope:this
+ }
+ });
+ // Observe le menu "Imprimer un cahier de textes"
+ Ext.getCmp(eliot.textes.Constantes.leftToolbar.idBoutonImprimerCahier).addListener({
+ click:{
+ fn:function () {
+ this.actionImprimerCahier();
+ },
+ scope:this
+ }
+ });
+ // Observe le menu "Supprimer un cahier de textes"
+ Ext.getCmp(eliot.textes.Constantes.leftToolbar.idBoutonSupprimerCahier).addListener({
+ click:{
+ fn:function () {
+ this.actionSupprimerCahier(true);
+ },
+ scope:this
+ }
+ });
+ // Observe le menu "Créer un dossier"
+ Ext.getCmp(eliot.textes.Constantes.leftToolbar.idBoutonCreerDossier).addListener({
+ click:{
+ fn:function () {
+ this.actionCreerDossier();
+ },
+ scope:this
+ }
+ });
+ // Observe le menu "Renommer un dossier"
+ Ext.getCmp(eliot.textes.Constantes.leftToolbar.idBoutonRenommerDossier).addListener({
+ click:{
+ fn:function () {
+ this.actionRenommerDossier();
+ },
+ scope:this
+ }
+ });
+ // Observe le menu "Supprimer un dossier"
+ Ext.getCmp(eliot.textes.Constantes.leftToolbar.idBoutonSupprimerDossier).addListener({
+ click:{
+ fn:function () {
+ this.actionSupprimerDossier();
+ },
+ scope:this
+ }
+ });
+ // Observe le menu "Afficher les cahiers de textes masqués"
+ Ext.getCmp(eliot.textes.Constantes.leftToolbar.idBoutonAfficherCahiersMasques).addListener({
+ click:{
+ fn:function () {
+ this.actionAfficherCahiersMasques();
+ },
+ scope:this
+ }
+ });
+ },
+
+ /**
+ * Méthode destinée à être appelée de l'extérieur pour passer la node
+ * sélectionnée dans le tree folder.
+ */
+ // TOREFACT : refactoring cette méthode : supprmier et utiliser dans GestionnaireCdt
+ setNodeSelectionnee:function (node) {
+ this.nodeSelectionnee = node;
+ },
+
+ /**
+ * Action appelée lors de la création d'un cahier de textes.
+ */
+ actionCreerCahier:function () {
+ document.location.href = eliot.textes.Constantes.urlCahierDeTextesCreer;
+ },
+
+ /**
+ * Action appelée lors du click sur le menu "Propriétés d'un cahier"
+ */
+ // TOREFACT : refactoring cette méthode: supprmier et utiliser dans GestionnaireCdt
+ actionProprietesCahier:function () {
+ var node = this.nodeSelectionnee;
+ var idCdt = eliot.textes.Utils.getIdFromNode(node);
+ var url = eliot.textes.Constantes.urlCahierDeTextesProprietes;
+ url = url + '?id=' + idCdt;
+ document.location.href = url;
+ },
+
+ /**
+ * Action appelée lors du click sur le menu "Imprimer cahier"
+ */
+ actionImprimerCahier:function () {
+
+ var node = this.nodeSelectionnee;
+
+ var peutModifierLeContenuDuCdt = node.attributes.peutModifierLeContenuDuCdt;
+
+ var idCdt = eliot.textes.Utils.getIdFromNode(node);
+
+ // on lance ici la boite de dialogue
+ this.dialogueImpression.afficherWindowSelectionActiviteView(idCdt, peutModifierLeContenuDuCdt);
+ },
+
+ /**
+ * Action appelée lors du click sur le menu "Suprimer cahier"
+ */
+ actionSupprimerCahier:function (isCurrentCdtAsContextMenuSelected) {
+ var node = this.nodeSelectionnee;
+ eliot.textes.Messages.afficherDialogConfirmation(
+ 'Supprimer le cahier de textes ?',
+ 'Êtes-vous sûr de vouloir supprimer le cahier de textes : ' + node.text + ' ? '
+ + 'Attention, cette opération supprimera toutes les activités et chapitres de ce cahier de textes.',
+
+ this.executerSupprimerCahier.createDelegate(this),
+ null,
+ isCurrentCdtAsContextMenuSelected
+ );
+ },
+
+ /**
+ * Action déclenchée lors de la création d'un dossier
+ */
+ actionCreerDossier:function () {
+ eliot.textes.Messages.afficherDialogSaisie(
+ 'Ajouter un dossier',
+ 'Nom du dossier:',
+ this.executerCreerDossier.createDelegate(this));
+
+ },
+
+ // Renommer un dossier
+ actionRenommerDossier:function () {
+ eliot.textes.Messages.afficherDialogSaisie(
+ 'Renommer un dossier',
+ 'Nouveau nom du dossier:',
+ this.executerRenommerDossier.createDelegate(this),
+ null,
+ this.nodeSelectionnee.text);
+ },
+
+ actionSupprimerDossier:function () {
+ var node = this.nodeSelectionnee;
+ eliot.textes.Messages.afficherDialogConfirmation(
+ 'Supprimer le dossier ?',
+ 'Êtes-vous sûr de vouloir supprimer le dossier : ' + node.text,
+ this.executerSupprimerDossier.createDelegate(this)
+ );
+ },
+
+ actionAfficherCahiersMasques:function () {
+ var popupAfficherCahiersMasques = this.popupAfficherCahiersMasques;
+ this.getCahiersMasques(function(){popupAfficherCahiersMasques.show();});
+ },
+
+
+ observeImpressionView:function (impressionView) {
+
+ impressionView.addListener(
+ eliot.textes.Constantes.actionImpression,
+
+ function (idCdt, dateDebut, dateFin, chapitreSansActivite, activiteAvecDate) {
+
+ var url = eliot.textes.Constantes.urlCahierDeTextesImprimer;
+
+ var params = {
+ ids:idCdt,
+ dateDebut:dateDebut.format("d/m/Y"),
+ dateFin:dateFin.format("d/m/Y"),
+ chapitreSansActivite:chapitreSansActivite,
+ activiteAvecDate:activiteAvecDate
+ };
+
+ Ext.Ajax.request({
+ url:url,
+ params:params,
+ success:function (response, request) {
+ var reponse = Ext.decode(response.responseText);
+ if (reponse.success == true) {
+ var url = eliot.textes.Constantes.urlGetImpressionPdf + '?demandeId=' + reponse.demandeId;
- this.btnAfficher.disable();
- },
+ // Les scrollbars ne sont pas affichés. Pour qoui ? On ne sait pas :(
+ window.open(url, "_blank", "height=600, width=800, toolbar=no,menubar=no,scrollbars=yes");
- getCahiersMasques:function () {
- Ext.Ajax.request({
- url:eliot.textes.Modele.url.getCahiersMasques,
- failure:function (response, request) {
- eliot.textes.Messages.showErreur(
- eliot.textes.Modele.message.erreurInconnue);
- },
- success:function (response, request) {
- var resultats = Ext.decode(response.responseText);
- if (resultats.success) {
- this.reloadStoreCahiersAAfficher(resultats);
+ } else {
+ if (reponse.message) {
+ eliot.textes.Messages.showErreur(reponse.message);
+ }
+ else {
+ request.failure.call(this);
}
+ }
},
- scope:this
- });
+ scope:this,
+ failure:function () {
+ eliot.textes.Messages.showErreur(
+ eliot.textes.Modele.message.ajoutDemandeImpressionErreur
+ );
+ }
+ });
+ }
+ );
- },
+ },
- reloadStoreCahiersAAfficher:function (resultats) {
- this.gridCahiersAAfficher.store.loadData({
- cahiers:resultats.liste
+ executerSupprimerCahier:function (isCurrentCdtAsContextMenuSelected) {
+ var node = this.nodeSelectionnee;
+ // Affichage de la progresse bar
+ var mask = new Ext.LoadMask(
+ Ext.getBody(),
+ {
+ msg:eliot.textes.Modele.message.suppressionEnCours
});
- },
+ mask.show();
+
+ Ext.Ajax.request({
+ url:eliot.textes.Constantes.urlCahierDeTextesSupprimer,
+ params:{ node:node.id },
+ scope:this,
+ success:function (response, request) {
+ // On masque le sablier
+ mask.hide();
+ if (response.responseText.charAt(0) != 1) {
+ request.failure();
+ } else {
+ node.remove();
+ eliot.textes.Messages.showConfirmation(
+ 'Le cahier de textes ' + node.text + ' a été supprimé');
+ // On lance un évènement pour que le "parent"
+ // manipule éventuellement les autres composants
+ this.fireEvent(this.suppressionCahierEvent,
+ node,
+ isCurrentCdtAsContextMenuSelected
+ );
+ }
+ },
+ failure:function () {
+ // On masque le sablier
+ mask.hide();
+ // Help ! on dirait que "this" ici n'a pas l'air d'être celui
+ // de leftToolbar ! pourtant le paramètre scope:this est censé
+ //this.fireEvent(this.echecSuppressionCahierEvent, node);
+ eliot.textes.Messages.showErreur(
+ 'Le cahier de textes ' + node.text + ' n\'est pas vide. Il n\'a pas pu être supprimé');
+ }
+ });
+ },
+
+ executerCreerDossier:function (text) {
+ Ext.Ajax.request({
+ url:eliot.textes.Constantes.urlDossierCreer,
+ params:{ nom:text },
+ scope:this,
+ success:function (response, request) {
+ var retour = Ext.decode(response.responseText);
+ if (!retour.success) {
+ request.failure();
+ } else {
+ // Récupère l'id du dossier créer
+ var nodeId = 'd' + retour.id;
+ var nom = retour.nom;
+ eliot.textes.Messages.showConfirmation('Le dossier ' + nom + ' a été créé');
+ this.fireEvent(this.creationDossierEvent, nodeId, nom);
+ }
+ },
+ failure:function () {
+ eliot.textes.Messages.showErreur('Le dossier n\'a pas pu être créé');
+ }
+ });
+ },
+
+ executerRenommerDossier:function (text) {
+ var node = this.nodeSelectionnee;
+ // appeler la création de dossier
+ var ancienNom = node.text;
+ Ext.Ajax.request({
+ url:eliot.textes.Constantes.urlDossierRenommer,
+ params:{ nom:text, node:node.id },
+ success:function (response, request) {
+ if (response.responseText.charAt(0) != 1) {
+ request.failure();
+ } else {
+ node.setText(text);
+ eliot.textes.Messages.showConfirmation(
+ 'Le dossier ' + ancienNom + ' a été renommé en ' + text);
+ }
+ },
+ failure:function () {
+ eliot.textes.Messages.showErreur(
+ 'Le dossier ' + node.text + ' n\'a pas pu être renommé');
+ }
+ });
+ },
+
+ executerSupprimerDossier:function () {
+ var node = this.nodeSelectionnee;
+ // appeler la suppression de dossier
+ Ext.Ajax.request({
+ url:eliot.textes.Constantes.urlDossierSupprimer,
+ params:{ node:node.id },
+ scope:this,
+ success:function (response, request) {
+ if (response.responseText.charAt(0) != 1) {
+ request.failure();
+ } else {
+ node.remove();
+ eliot.textes.Messages.showConfirmation(
+ 'Le dossier ' + node.text + ' a été supprimé');
+ this.fireEvent(this.suppressionDossierEvent, node);
+ }
+ },
+ failure:function () {
+ eliot.textes.Messages.showErreur(
+ 'Le dossier ' + node.text + ' n\'est pas vide. Il n\'a pas pu être supprimé');
+ }
+ });
+ },
+
+ // activer le bouton "créer"
+ activerBoutonCreer:function () {
+ var boutonCreer = Ext.getCmp(eliot.textes.Constantes.leftToolbar.
+ idBoutonCreer);
+ boutonCreer.enable();
+
+ },
+
+ // desactiver le bouton "créer"
+ desactiverBoutonCreer:function () {
+ var boutonCreer = Ext.getCmp(eliot.textes.Constantes.leftToolbar.
+ idBoutonCreer);
+ boutonCreer.disable();
+ },
+
+ creePopupAfficherCahiersMasques:function () {
+
+ this.creeBoutonsPopupAffichageCahiersMasques();
+
+ this.checkBox = new Ext.grid.CheckboxSelectionModel({
+ header:'<div id="eliot-text-checker" class="x-grid3-hd-checker"> </div>'
+ });
+
+ this.gridCahiersAAfficher = new Ext.grid.GridPanel({
+ store:new Ext.data.Store({
+ autoDestroy:true,
+ storeId:'cahiersMasquesStore',
+ reader:new Ext.data.JsonReader(
+ {
+ root:'cahiers',
+ idProperty:'id',
+ fields:[
+ {name:'id'},
+ {name:'libelle'}
+ ]
+ })
+ }),
+ colModel:new Ext.grid.ColumnModel({
+ defaults:{
+ width:120,
+ sortable:true
+ },
+ columns:[
+ this.checkBox,
+ {header:'Cahiers de textes', dataIndex:'libelle', sortable:true, menuDisabled:true, resizable:false}
+ ]
+ }),
+ viewConfig:{
+ stripeRows:true,
+ autoExpandColumn:'libelle',
+ forceFit:true
+ },
+ sm:this.checkBox,
+ cls:'portal-default_table'
+ });
+
+ this.popupAfficherCahiersMasques = new Ext.Window({
+ id:'popupAfficherCahiersMasques',
+ width:450,
+ height:280,
+ layout:'fit',
+ modal:true,
+ title:eliot.textes.Modele.libelle.popupAfficherCahiersMasques,
+ closeAction:'hide',
+ resizable:false,
+ plain:true,
+ items:[
+ {
+ xtype:'fieldset',
+ border:false,
+ autoHeight:true,
+ items:[
+ {
+ xtype:'label',
+ text:'Sélectionnez les cahiers de textes masqués à afficher :'
+ }
+ ,
+ {
+ xtype:'panel',
+ border:false,
+ style:'margin: 20px auto;',
+ height:140,
+ layout:'fit',
+ items:[
+ this.gridCahiersAAfficher
+ ]
+ }
+ ]
+ }
+ ],
+ buttons:[
+ this.btnAfficher,
+ this.btnAnnuler
+ ]
+ });
+
+ var selectionModel = this.gridCahiersAAfficher.getSelectionModel();
+
+ this.btnAnnuler.addListener("click",
+ function () {
+ this.popupAfficherCahiersMasques.hide()
+ },
+ this
+ );
+
+ this.btnAfficher.addListener("click",
+ function () {
+ this.afficherCahiersMasques(
+ selectionModel.getSelections()
+ );
+ this.popupAfficherCahiersMasques.hide();
+ },
+ this
+ );
+
+ selectionModel.addListener(
+ "rowselect",
+ function () {
+ this.btnAfficher.enable()
+ },
+ this
+ );
+
+ selectionModel.addListener(
+ "rowdeselect",
+ function () {
+ if (selectionModel.getSelections().length == 0) {
+ this.btnAfficher.disable()
+ }
+ },
+ this
+ );
+ },
+
+ /**
+ * Création boutons popup affichage cahiers masqués
+ */
+ creeBoutonsPopupAffichageCahiersMasques:function () {
+ this.btnAfficher = new Ext.Button({
+ id:'boutonAfficher',
+ text:eliot.textes.Modele.button.boutonAfficher
+ });
+ this.btnAnnuler = new Ext.Button({
+ id:'boutonAnnuler',
+ text:eliot.textes.Modele.button.boutonAnnuler
+ });
+
+ this.btnAfficher.disable();
+ },
+
+ getCahiersMasques:function (callback) {
+ // Affichage de la progress bar
+ var mask = new Ext.LoadMask(Ext.getBody(),
+ {msg:eliot.textes.Modele.message.rechercheEnCours});
+ mask.show();
+
+ Ext.Ajax.request({
+ url:eliot.textes.Modele.url.getCahiersMasques,
+ failure:function (response, request) {
+ // Suppression de la progress bar
+ mask.hide();
+ eliot.textes.Messages.showErreur(
+ eliot.textes.Modele.message.erreurInconnue);
+ },
+ success:function (response, request) {
+ // Suppression de la progress bar
+ mask.hide();
+ var resultats = Ext.decode(response.responseText);
+ if (resultats.success) {
+ this.reloadStoreCahiersAAfficher(resultats);
+ callback();
+ } else {
+ eliot.textes.Messages.showErreur(
+ resultats.message);
+ }
+ },
+ scope:this
+ });
- afficherCahiersMasques:function (cahiersAAfficher) {
+ },
- var cdtIds = [];
+ reloadStoreCahiersAAfficher:function (resultats) {
+ this.gridCahiersAAfficher.store.loadData({
+ cahiers:resultats.liste
+ });
+ },
- for (var i = 0; i < cahiersAAfficher.length; ++i) {
- cdtIds.push(cahiersAAfficher[i].id);
- }
+ afficherCahiersMasques:function (cahiersAAfficher) {
- Ext.Ajax.request({
- url:eliot.textes.Modele.url.afficherCahiersMasques,
- params:{'cdtIds':cdtIds},
- failure:function (response, request) {
- eliot.textes.Messages.showErreur(
- eliot.textes.Modele.message.erreurInconnue);
- },
- success:function (response, request) {
- var resultats = Ext.decode(response.responseText);
- if (!resultats.success) {
- eliot.textes.Messages.showErreur(resultats.message);
- } else {
- window.location.reload(true);
- }
- },
- scope:this
- });
+ var cdtIds = [];
+ for (var i = 0; i < cahiersAAfficher.length; ++i) {
+ cdtIds.push(cahiersAAfficher[i].id);
}
+ Ext.Ajax.request({
+ url:eliot.textes.Modele.url.afficherCahiersMasques,
+ params:{'cdtIds':cdtIds},
+ failure:function (response, request) {
+ eliot.textes.Messages.showErreur(
+ eliot.textes.Modele.message.erreurInconnue);
+ },
+ success:function (response, request) {
+ var resultats = Ext.decode(response.responseText);
+ if (!resultats.success) {
+ eliot.textes.Messages.showErreur(resultats.message);
+ } else {
+ window.location.reload(true);
+ }
+ },
+ scope:this
+ });
+
+ }
+
});
\ No newline at end of file