--- /dev/null
+Ext.ns("EntSavoie");
+EntSavoie.GestionPronote = 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';
+
+ this.pronoteURLStore = this.pronoteURLStore || new Ext.data.JsonStore({
+ autoLoad: true,
+ root: 'pronote',
+ idProperty: 'pronoteURLId',
+ fields: ['pronoteURLId', 'name', "pronoteURL"],
+ url: this.renderURLAjax+'&jspPage=%2Fajax%2FlistPronoteURL.jsp'
+ });
+
+ this.etabStore = this.etabStore || new Ext.data.JsonStore({
+ autoLoad: true,
+ root: 'etabs',
+ idProperty: 'name',
+ fields: ['etabId', 'name'],
+ url: this.renderURLAjax+'&jspPage=%2Fajax%2FlistEtablissementsWithoutBlank.jsp'
+ });
+
+ this.addPronoteURLBtn = this.addPronoteURLBtn || new Ext.Button ({
+ tooltip: "Ajouter une URL à un établissement",
+ text: "Ajouter",
+ iconCls: 'add',
+ handler: this.onAddPronoteURL,
+ scope: this
+ });
+
+ this.saveBtn = this.saveBtn || new Ext.Button ({
+ text: "Enregistrer",
+ iconCls: 'save',
+ handler: this.onSaveFn,
+ tooltip: "Enregistrer les urls",
+ scope: this
+ });
+
+ this.action_column = this.action_column || new Ext.grid.ActionColumn({
+ width: 50,
+ sortable: false,
+ menuDisabled: true,
+ //align: 'right',
+ css: 'text-align: left;',
+ items: [
+ {
+ //iconCls: 'delete',
+ tooltip: "Supprimer",
+ scope: this,
+ handler: this.onDeletePronoteURL,
+ getClass: function(v, meta, rec, row, col, store) { // Or return a class from a function
+ return 'delete';
+ }
+ }
+ ]
+ });
+
+ this.cm = this.cm || new Ext.grid.ColumnModel({
+ columns: [
+ {
+ header: 'Etablissement',
+ dataIndex: 'name',
+ width: 200,
+ editor: new Ext.form.ComboBox({
+ listClass: "pronoteCAS-portlet",
+ emptyText: "Etablissemennt",
+ valueField: 'name',
+ displayField: 'name',
+ editable: false,
+ triggerAction: 'all',
+ store: this.etabStore
+ })
+ },
+ {
+ id: 'pronoteUrl',
+ header: 'URL',
+ dataIndex: 'pronoteURL',
+ editor: new Ext.form.TextField({})
+ },
+ this.action_column
+ ]
+ });
+
+ /**
+ * Constructeur
+ */
+ EntSavoie.GestionPronote.superclass.constructor.call(this, {
+ store: this.pronoteURLStore,
+ cm: this.cm,
+ width: "auto",
+ height: 500,
+ autoExpandColumn: 'pronoteUrl',
+ style: "margin-left: 10px;",
+ clicksToEdit: 1,
+ tbar: [this.addPronoteURLBtn],
+ bbar: [this.saveBtn],
+ });
+
+
+};
+
+Ext.extend(EntSavoie.GestionPronote, Ext.grid.EditorGridPanel, {
+ initComponent: function () {
+ EntSavoie.GestionPronote.superclass.initComponent.call(this);
+ },
+
+ onAddPronoteURL: function(btn){
+ var record = new this.store.recordType({
+ pronoteURLId: "0",
+ name: this.etabUserName,
+ pronoteURL:"http://www.cartabledesavoie.com"});
+
+ this.stopEditing();
+ this.store.insert(0, record);
+ this.startEditing(0, 1);
+ },
+
+ onSaveFn: function(btn){
+ var pronoteUrlArray = new Array();
+ for (i=0; i<this.store.getCount(); i++) {
+ var pUrl = this.store.getAt(i);
+ //On recupère le record pour pouvoir passer l'etabId
+ var etabRecord = this.etabStore.getById(pUrl.get("name"));
+ pronoteUrlArray.push({pronoteURLId: pUrl.get("pronoteURLId"),etabId:etabRecord.get("etabId"), pronoteURL: pUrl.get("pronoteURL")});
+ }
+
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "savePronoteUrls",
+ pronoteUrls: Ext.util.JSON.encode(pronoteUrlArray)
+ },
+ scope: this,
+ success: this.onSuccessSaveFn,
+ failure: this.onFailureSaveFn
+ });
+ },
+
+ onSuccessSaveFn: function(response, options) {
+ var backObj = Ext.decode(response.responseText);
+ if (!backObj.success) {
+ Ext.MessageBox.alert("Attention", "Probème lors de la configuration des urls", function(btn){}, this);
+ } else {
+ Ext.slideMsg.msg("Configuration Pronote", "La configuration des urls des établissemnts s'est correctement déroulée.");
+ }
+ },
+
+ onFailureSaveFn: function(response, options) {
+ Ext.MessageBox.alert("Attention", "Probème lors de la configuration des urls", function(btn){}, this);
+ },
+
+ onDeletePronoteURL: function(grid, rowIndex, colIndex) {
+ var record = grid.getStore().getAt(rowIndex);
+ if(record.get("pronoteURLId") == "0"){
+ this.store.remove(record);
+ Ext.slideMsg.msg("Configuration Pronote", "La suppression de l'url s'est correctement déroulée.");
+ } else {
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "deletePronoteURL",
+ pronoteURLId: record.get("pronoteURLId")
+ },
+ scope: this,
+ success: this.onSuccessDelete,
+ failure: this.onFailureDelete
+ });
+ }
+ },
+
+ onSuccessDelete:function(response, options) {
+ var backObj = Ext.decode(response.responseText);
+ if (!backObj.success) {
+ Ext.MessageBox.alert("Attention", "Probème lors de la suppression des urls", function(btn){}, this);
+ }else{
+ var record = this.store.getById(backObj.pUrlId);
+ this.store.remove(record);
+ Ext.slideMsg.msg("Configuration Pronote", "La suppression de l'url s'est correctement déroulée.");
+ }
+ },
+
+ onFailureDelete:function(response, options) {
+ Ext.MessageBox.alert("Attention", "Probème lors de la suppression des urls", function(btn){}, this);
+ },
+
+});