Mercurial > lada > lada-client
view app/controller/Zusatzwerte.js @ 130:747d488b9203
Added function getEidi which returns the part of the id of an item which needs
to be appended to the store base URL for PUT and DELETE and GET Requests. This
function is used to build a custom id. On default it returns the value of
getId.
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Tue, 25 Jun 2013 17:29:17 +0200 |
parents | 33aed7dde69f |
children | 04439f3feba3 |
line wrap: on
line source
Ext.define('Lada.controller.Zusatzwerte', { extend: 'Ext.app.Controller', views: [ 'zusatzwerte.Create' ], stores: [ 'Zusatzwerte', 'Probenzusatzwerte' ], init: function() { console.log('Initialising the Zusatzwerte controller'); this.control({ // CSS like selector to select element in the viewpzusatzwert. See // ComponentQuery documentation for more details. 'zusatzwertelist': { itemdblclick: this.editZusatzwert }, 'zusatzwertelist toolbar button[action=add]': { click: this.addZusatzwert }, 'zusatzwertelist toolbar button[action=delete]': { click: this.deleteZusatzwert }, 'zusatzwertecreate form': { savesuccess: this.createSuccess, savefailure: this.createFailure }, 'zusatzwertecreate button[action=save]': { click: this.saveZusatzwert }, 'zusatzwerteedit form': { savesuccess: this.editSuccess, savefailure: this.editFailure } }); }, saveZusatzwert: function(button) { console.log('Saving Zusatzwert'); var form = button.up('window').down('form'); var values = form.getForm().getValues(); var model = form.model; // Set Probenzusatzwert and rebind the model to the form. var xxx = this.getProbenzusatzwerteStore(); var probenzusatz = xxx.getAt(xxx.find('pzsId', values.pzsId)); model.setProbenzusatz(probenzusatz); form.commit(); }, addZusatzwert: function(button) { console.log('Adding new Zusatzwert for Probe' + button.probenId); var zusatzwert = Ext.create('Lada.model.Zusatzwert'); zusatzwert.set('probeId', button.probeId); var view = Ext.widget('zusatzwertecreate', {model: zusatzwert}); }, editZusatzwert: function(grid, record) { console.log('Editing Zusatzwert'); var view = Ext.widget('zusatzwertecreate', {model: record}); console.log("Loaded Zusatzwert with ID " + record.getId()); //outputs ID }, deleteZusatzwert: function(button) { // Get selected item in grid var grid = button.up('grid'); var selection = grid.getView().getSelectionModel().getSelection()[0]; Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){ if(btn === 'yes'){ var store = grid.getStore(); var sprobenZusatz = selection.get('sprobenZusatz'); var pzsId = sprobenZusatz.pzsId; var probeId = selection.get('probeId'); var deleteUrl = selection.getProxy().url + "/" + pzsId + "/" + probeId; Ext.Ajax.request({ url: deleteUrl, method: 'DELETE', success: function(response, opts) { store.reload(); } }); console.log('Deleting Kommentar'); } else { console.log('Cancel Deleting Kommentar'); } }); }, createSuccess: function(form, record, operation) { // Reload store var store = this.getZusatzwerteStore(); store.reload(); var win = form.up('window'); win.close(); }, createFailure: function(form, record, operation) { Ext.MessageBox.show({ title: 'Fehler beim Speichern', msg: form.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); }, editSuccess: function(form, record, operation) { // Reload store var store = this.getZusatzwerteStore(); store.reload(); var win = form.up('window'); win.close(); }, editFailure: function(form, record, operation) { Ext.MessageBox.show({ title: 'Fehler beim Speichern', msg: form.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); } });