[Lada-commits] [PATCH] Inheritance of Mkommentare from Kommentare does not work as expected. So write
Wald Commits
scm-commit at wald.intevation.org
Tue Jul 9 15:27:28 CEST 2013
# HG changeset patch
# User Torsten Irländer <torsten.irlaender at intevation.de>
# Date 1373376389 -7200
# Node ID 62e116cd3e3bbc2f9b142747b18c21dcdb4bb3fe
# Parent 32e1356cf391a15ceb395a58771cd340a2baceac
Inheritance of Mkommentare from Kommentare does not work as expected. So write
mostly duplicated code for MKommentare.
diff -r 32e1356cf391 -r 62e116cd3e3b app/controller/MKommentare.js
--- a/app/controller/MKommentare.js Mon Jul 08 16:47:50 2013 +0200
+++ b/app/controller/MKommentare.js Tue Jul 09 15:26:29 2013 +0200
@@ -1,17 +1,74 @@
Ext.define('Lada.controller.MKommentare', {
- extend: 'Lada.controller.Kommentare',
+ extend: 'Ext.app.Controller',
+ views: [
+ 'mkommentare.Create'
+ ],
stores: [
'MKommentare'
],
models: [
'MKommentar'
],
+ init: function() {
+ console.log('Initialising the MKommentare controller');
+ this.control({
+ // CSS like selector to select element in the viewport. See
+ // ComponentQuery documentation for more details.
+ 'mkommentarelist': {
+ itemdblclick: this.editKommentar
+ },
+ 'mkommentarelist toolbar button[action=add]': {
+ click: this.addKommentar
+ },
+ 'mkommentarelist toolbar button[action=delete]': {
+ click: this.deleteKommentar
+ },
+ 'mkommentarecreate button[action=save]': {
+ click: this.saveKommentar
+ },
+ 'mkommentarecreate form': {
+ savesuccess: this.createSuccess,
+ savefailure: this.createFailure
+ }
+ });
+ },
+ saveKommentar: function(button) {
+ console.log('Saving MKommentar');
+ var form = button.up('window').down('form');
+ form.commit();
+ },
addKommentar: function(button) {
- console.log('Adding new Kommentar for Messung ' + button.parentId + ' Probe ' + button.probeId);
+ console.log('Adding new MKommentar for Messung ' + button.parentId + ' Probe ' + button.probeId);
var kommentar = Ext.create('Lada.model.MKommentar');
kommentar.set('probeId', button.probeId);
kommentar.set('messungsId', button.parentId);
- var view = Ext.widget('kommentarecreate', {model: kommentar});
+ var view = Ext.widget('mkommentarecreate', {model: kommentar});
+ },
+ editKommentar: function(grid, record) {
+ console.log('Editing Kommentar');
+ var view = Ext.widget('mkommentarecreate', {model: record});
+ console.log("Loaded MKommentar with ID " + record.getId()); //outputs ID
+ },
+ deleteKommentar: 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 deleteUrl = selection.getProxy().url + selection.getEidi();
+ Ext.Ajax.request({
+ url: deleteUrl,
+ method: 'DELETE',
+ success: function(response, opts) {
+ store.reload();
+ }
+ });
+ console.log('Deleting MKommentar');
+ } else {
+ console.log('Cancel Deleting MKommentar');
+ }
+ });
},
createSuccess: function(form, record, operation) {
// Reload store
@@ -20,11 +77,12 @@
var win = form.up('window');
win.close();
},
- editSuccess: function(form, record, operation) {
- // Reload store
- var store = this.getMKommentareStore();
- 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
+ });
}
});
diff -r 32e1356cf391 -r 62e116cd3e3b app/view/mkommentare/Create.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/mkommentare/Create.js Tue Jul 09 15:26:29 2013 +0200
@@ -0,0 +1,27 @@
+Ext.define('Lada.view.mkommentare.Create', {
+ extend: 'Ext.window.Window',
+ alias: 'widget.mkommentarecreate',
+
+ title: 'Maske für Messungskommentare',
+ // Make size of the dialog dependend of the available space.
+ // TODO: Handle resizing the browser window.
+ autoShow: true,
+ autoScroll: true,
+ modal: true,
+
+ requires: [
+ 'Lada.view.mkommentare.CreateForm'
+ ],
+ initComponent: function() {
+ var form = Ext.create('Lada.view.mkommentare.CreateForm', this.initialConfig);
+ this.items = [form];
+ this.buttons = [
+ {
+ text: 'Speichern',
+ scope: form,
+ action: 'save'
+ }
+ ];
+ this.callParent();
+ }
+});
diff -r 32e1356cf391 -r 62e116cd3e3b app/view/mkommentare/CreateForm.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/mkommentare/CreateForm.js Tue Jul 09 15:26:29 2013 +0200
@@ -0,0 +1,24 @@
+Ext.define('Lada.view.mkommentare.CreateForm', {
+ extend: 'Lada.view.widgets.LadaForm',
+ model: 'Lada.model.MKommentar',
+ initComponent: function() {
+ this.items = [
+ {
+ xtype: 'textfield',
+ name: 'erzeuger',
+ fieldLabel: 'Erzeuger'
+ },
+ {
+ xtype: 'datefield',
+ name: 'kdatum',
+ fieldLabel: 'Datum'
+ },
+ {
+ xtype: 'textareafield',
+ name: 'ktext',
+ fieldLabel: 'Text'
+ }
+ ];
+ this.callParent();
+ }
+});
diff -r 32e1356cf391 -r 62e116cd3e3b app/view/mkommentare/List.js
--- a/app/view/mkommentare/List.js Mon Jul 08 16:47:50 2013 +0200
+++ b/app/view/mkommentare/List.js Tue Jul 09 15:26:29 2013 +0200
@@ -1,6 +1,44 @@
Ext.define('Lada.view.mkommentare.List' ,{
- extend: 'Lada.view.kommentare.List',
+ extend: 'Ext.grid.Panel',
alias: 'widget.mkommentarelist',
store: 'MKommentare',
- messungsId: null
+ viewConfig: {
+ maxHeight: 350,
+ emptyText: 'Keine Kommentare gefunden.',
+ // minHeight and deferEmptyText are needed to be able to show the
+ // emptyText message.
+ minHeight: 35,
+ deferEmptyText: false
+ },
+ probeId: null,
+ parentId: null,
+ initComponent: function() {
+ this.dockedItems = [
+ {
+ xtype: 'toolbar',
+ dock: 'top',
+ items: [
+ {
+ text: 'Hinzufügen',
+ icon: 'gfx/plus.gif',
+ action: 'add',
+ probeId: this.probeId,
+ parentId: this.parentId
+ },
+ {
+ text: 'Löschen',
+ icon: 'gfx/minus.gif',
+ action: 'delete'
+ }
+ ]
+ }
+ ];
+ this.columns = [
+ {header: 'Erzeuger', dataIndex: 'erzeuger'},
+ {header: 'Datum', dataIndex: 'kdatum'},
+ {header: 'Text', dataIndex: 'ktext', flex: 1}
+ ];
+ this.callParent(arguments);
+ }
});
+
More information about the Lada-commits
mailing list