Mercurial > lada > lada-client
changeset 144:7b1140bd8b3d
Re-Added Kommentare
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Mon, 01 Jul 2013 10:15:00 +0200 |
parents | 62b757ccdd8f |
children | 89e331978e33 |
files | app.js app/controller/Kommentare.js app/controller/Proben.js app/model/Kommentar.js app/view/kommentare/Create.js app/view/kommentare/CreateForm.js app/view/kommentare/List.js app/view/proben/Edit.js app/view/proben/EditForm.js app/view/zusatzwerte/Create.js |
diffstat | 10 files changed, 60 insertions(+), 70 deletions(-) [+] |
line wrap: on
line diff
--- 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'
--- 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');
--- 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) {
--- 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);
--- 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();
--- 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(); } });
--- 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',
--- 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 = [ {
--- 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',