[Lada-commits] [PATCH] Re-Added Kommentare

Wald Commits scm-commit at wald.intevation.org
Mon Jul 1 10:16:01 CEST 2013


# HG changeset patch
# User Torsten Irländer <torsten.irlaender at intevation.de>
# Date 1372666500 -7200
# Node ID 7b1140bd8b3d193016ac6222ff6ac9d8db7b7337
# Parent  62b757ccdd8fe3a23845ecacc3c04c0c3d891e51
Re-Added Kommentare

diff -r 62b757ccdd8f -r 7b1140bd8b3d app.js
--- a/app.js	Fri Jun 28 11:16:44 2013 +0200
+++ b/app.js	Mon Jul 01 10:15:00 2013 +0200
@@ -28,8 +28,8 @@
     controllers: [
         'Sql',
         'Proben',
-        'Zusatzwerte'
-        //'Kommentare',
+        'Zusatzwerte',
+        'Kommentare'
         //'Sql',
         //'Orte',
         //'Messungen'
diff -r 62b757ccdd8f -r 7b1140bd8b3d app/controller/Kommentare.js
--- a/app/controller/Kommentare.js	Fri Jun 28 11:16:44 2013 +0200
+++ b/app/controller/Kommentare.js	Mon Jul 01 10:15:00 2013 +0200
@@ -1,7 +1,6 @@
 Ext.define('Lada.controller.Kommentare', {
     extend: 'Ext.app.Controller',
     views: [
-        'kommentare.List',
         'kommentare.Create'
     ],
     stores: [
@@ -24,6 +23,9 @@
             'kommentarelist toolbar button[action=delete]': {
                 click: this.deleteKommentar
             },
+            'kommentarecreate button[action=save]': {
+                click: this.saveKommentar
+            },
             'kommentarecreate form': {
                 savesuccess: this.createSuccess,
                 savefailure: this.createFailure
@@ -34,9 +36,16 @@
             }
         });
     },
+    saveKommentar: function(button) {
+        console.log('Saving Kommentar');
+        var form = button.up('window').down('form');
+        form.commit();
+    },
     addKommentar: function(button) {
-        console.log('Adding new Kommentar');
-        var view = Ext.widget('kommentarecreate');
+        console.log('Adding new Kommentar for Probe ' + button.probeId);
+        var kommentar = Ext.create('Lada.model.Kommentar');
+        kommentar.set('probeId', button.probeId);
+        var view = Ext.widget('kommentarecreate', {model: kommentar});
     },
     editKommentar: function(grid, record) {
         console.log('Editing Kommentar');
@@ -50,8 +59,14 @@
         Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){
             if(btn === 'yes'){
                 var store = grid.getStore();
-                store.remove(selection);
-                store.sync();
+                var deleteUrl = selection.getProxy().url + selection.getEidi();
+                Ext.Ajax.request({
+                    url: deleteUrl,
+                    method: 'DELETE',
+                    success: function(response, opts) {
+                        store.reload();
+                    }
+                });
                 console.log('Deleting Kommentar');
             } else {
                 console.log('Cancel Deleting Kommentar');
diff -r 62b757ccdd8f -r 7b1140bd8b3d app/controller/Proben.js
--- a/app/controller/Proben.js	Fri Jun 28 11:16:44 2013 +0200
+++ b/app/controller/Proben.js	Mon Jul 01 10:15:00 2013 +0200
@@ -7,7 +7,8 @@
     stores: [
         'Proben',
         'Zusatzwerte',
-        'Probenzusatzwerte'
+        'Probenzusatzwerte',
+        'Kommentare'
     //    'Orte',
     //    'Messungen',
     ],
@@ -50,6 +51,13 @@
                 probeId: id
             }
         });
+        // Load Kommentare 
+        var kstore = this.getKommentareStore();
+        kstore.load({
+            params: {
+                probeId: id
+            }
+        });
         console.log("Loaded Probe with ID " + record.getId()); //outputs ID
     },
     createSuccess: function(form, record, operation) {
diff -r 62b757ccdd8f -r 7b1140bd8b3d app/model/Kommentar.js
--- a/app/model/Kommentar.js	Fri Jun 28 11:16:44 2013 +0200
+++ b/app/model/Kommentar.js	Mon Jul 01 10:15:00 2013 +0200
@@ -1,15 +1,13 @@
 Ext.define('Lada.model.Kommentar', {
     extend: 'Ext.data.Model',
     fields: [
-        {name: "id"},
-        {name: "kid", mapping:"id.kid"},
-        {name: "convertedId", convert:buildId},
+        {name: "kId"},
         {name: "probeId"},
         {name: "erzeuger"},
         {name: "kdatum", type: 'date', convert: ts2date, defaultValue: new Date()},
         {name: "ktext"}
     ],
-    idProperty: "convertedId",
+    idProperty: "kId",
     proxy: {
         type: 'rest',
         appendId: true, //default
@@ -18,13 +16,14 @@
             type: 'json',
             root: 'data'
         }
+    },
+    getEidi: function() {
+        var kid =  this.get('kId');
+        var probeId = this.get('probeId');
+        return "/" + kid + "/" + probeId;
     }
 });
 
-function buildId(v, record){
-    return record.get('probeId') + record.get('kid');
-}
-
 function ts2date(v, record){
     // Converts a timestamp into a date object.
     return new Date(v);
diff -r 62b757ccdd8f -r 7b1140bd8b3d app/view/kommentare/Create.js
--- a/app/view/kommentare/Create.js	Fri Jun 28 11:16:44 2013 +0200
+++ b/app/view/kommentare/Create.js	Mon Jul 01 10:15:00 2013 +0200
@@ -15,13 +15,13 @@
         'Lada.view.kommentare.CreateForm'
     ],
     initComponent: function() {
-        var form = Ext.create('Lada.view.kommentare.CreateForm');
+        var form = Ext.create('Lada.view.kommentare.CreateForm', this.initialConfig);
         this.items = [form];
         this.buttons = [
             {
                 text: 'Speichern',
-                handler: form.commit,
-                scope: form
+                scope: form,
+                action: 'save'
             }
         ];
         this.callParent();
diff -r 62b757ccdd8f -r 7b1140bd8b3d app/view/kommentare/CreateForm.js
--- a/app/view/kommentare/CreateForm.js	Fri Jun 28 11:16:44 2013 +0200
+++ b/app/view/kommentare/CreateForm.js	Mon Jul 01 10:15:00 2013 +0200
@@ -19,13 +19,6 @@
                 fieldLabel: 'Text'
             }
         ];
-        //this.buttons = [
-        //    {
-        //        text: 'Speichern',
-        //        handler: this.commit,
-        //        scope: this
-        //    }
-        //];
         this.callParent();
     }
 });
diff -r 62b757ccdd8f -r 7b1140bd8b3d app/view/kommentare/List.js
--- a/app/view/kommentare/List.js	Fri Jun 28 11:16:44 2013 +0200
+++ b/app/view/kommentare/List.js	Mon Jul 01 10:15:00 2013 +0200
@@ -10,6 +10,7 @@
         minHeight: 35,
         deferEmptyText: false
     },
+    probeId: null,
     initComponent: function() {
         this.dockedItems = [
             {
@@ -19,7 +20,8 @@
                     {
                         text: 'Hinzufügen',
                         icon: 'gfx/plus.gif',
-                        action: 'add'
+                        action: 'add',
+                        probeId: this.probeId
                     },
                     {
                         text: 'Löschen',
diff -r 62b757ccdd8f -r 7b1140bd8b3d app/view/proben/Edit.js
--- a/app/view/proben/Edit.js	Fri Jun 28 11:16:44 2013 +0200
+++ b/app/view/proben/Edit.js	Mon Jul 01 10:15:00 2013 +0200
@@ -16,34 +16,6 @@
         // creation of this window. We need to pass it throuh to the form as
         // we need the "modelId" param to load the correct item.
         var form = Ext.create('Lada.view.proben.EditForm', this.initialConfig);
-        /// Load kommentare
-        ////var record = form.getRecord();
-        //var kommentare = form.down('kommentarelist'); //form.down('kommentare');
-        //var kstore = kommentare.getStore();
-        //kstore.load({
-        //    params: {
-        //        probe: this.initialConfig['modelId']
-        //        //probe: record.data['probeId']
-        //    }
-        //});
-        //// Load Orte
-        //var orte = form.down('ortelist');
-        //var ostore = orte.getStore();
-        //ostore.load({
-        //    params: {
-        //        probe: this.initialConfig['modelId']
-        //        //probe: record.data['probeId']
-        //    }
-        //});
-        //// Load Messungen 
-        //var messungen = form.down('messungenlist');
-        //var mstore = messungen.getStore();
-        //mstore.load({
-        //    params: {
-        //        probe: this.initialConfig['modelId']
-        //        //probe: record.data['probeId']
-        //    }
-        //});
         this.items = [form];
         this.buttons = [
             {
diff -r 62b757ccdd8f -r 7b1140bd8b3d app/view/proben/EditForm.js
--- a/app/view/proben/EditForm.js	Fri Jun 28 11:16:44 2013 +0200
+++ b/app/view/proben/EditForm.js	Mon Jul 01 10:15:00 2013 +0200
@@ -7,7 +7,8 @@
         'Lada.view.widgets.Testdatensatz',
         'Lada.view.widgets.Probenart',
         'Lada.view.widgets.Uwb',
-        'Lada.view.zusatzwerte.List'
+        'Lada.view.zusatzwerte.List',
+        'Lada.view.kommentare.List'
     ],
     model: 'Lada.model.Probe',
     alias: 'widget.probeneditform',
@@ -174,20 +175,21 @@
                         probeId: this.modelId
                     }
                 ]
+            },
+            // Probenkommentar
+            {
+                xtype: 'fieldset',
+                title: 'Probenkommentare',
+                collapsible: true,
+                collapsed: true,
+                padding: '10 10',
+                items: [
+                    {
+                        xtype: 'kommentarelist',
+                        probeId: this.modelId
+                    }
+                ]
             }
-            //// Probenkommentar
-            //{
-            //    xtype: 'fieldset',
-            //    title: 'Probenkommentare',
-            //    collapsible: true,
-            //    collapsed: true,
-            //    padding: '10 10',
-            //    items: [
-            //        {
-            //            xtype: 'kommentarelist'
-            //        }
-            //    ]
-            //},
             //// Messungsangaben
             //{
             //    xtype: 'fieldset',
diff -r 62b757ccdd8f -r 7b1140bd8b3d app/view/zusatzwerte/Create.js
--- a/app/view/zusatzwerte/Create.js	Fri Jun 28 11:16:44 2013 +0200
+++ b/app/view/zusatzwerte/Create.js	Mon Jul 01 10:15:00 2013 +0200
@@ -17,7 +17,6 @@
         this.buttons = [
             {
                 text: 'Speichern',
-                //handler: form.commit,
                 scope: form,
                 action: 'save'
             }


More information about the Lada-commits mailing list