Mercurial > lada > lada-client
changeset 690:e88381fb3bdb
Use treeModiefied timestamp to determine if working with 'old' objects.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 25 Mar 2015 16:46:48 +0100 |
parents | c07419f07a0c |
children | c31644b3d445 |
files | app/controller/grid/Messung.js app/controller/grid/Ort.js app/view/window/MessungEdit.js app/view/window/OrtEdit.js app/view/window/ProbeEdit.js |
diffstat | 5 files changed, 71 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controller/grid/Messung.js Wed Mar 25 16:45:29 2015 +0100 +++ b/app/controller/grid/Messung.js Wed Mar 25 16:46:48 2015 +0100 @@ -31,7 +31,10 @@ }, editItem: function(grid, record) { + var probe = grid.up('window').record; var win = Ext.create('Lada.view.window.MessungEdit', { + parentWindow: grid.up('window'), + probe: probe, record: record, grid: grid });
--- a/app/controller/grid/Ort.js Wed Mar 25 16:45:29 2015 +0100 +++ b/app/controller/grid/Ort.js Wed Mar 25 16:46:48 2015 +0100 @@ -29,7 +29,10 @@ }, open: function(grid, record) { + var probe = grid.up('window').record; var win = Ext.create('Lada.view.window.OrtEdit', { + parentWindow: grid.up('window'), + probe: probe, record: record, grid: grid });
--- a/app/view/window/MessungEdit.js Wed Mar 25 16:45:29 2015 +0100 +++ b/app/view/window/MessungEdit.js Wed Mar 25 16:46:48 2015 +0100 @@ -26,6 +26,9 @@ autoscroll: true, layout: 'fit', constrain: true, + + probe: null, + parentWindow: null, record: null, grid: null, @@ -35,6 +38,11 @@ this.callParent(arguments); return; } + if (this.probe === null) { + Ext.Msg.alert('Zu der Messung existiert keine Probe!'); + this.callParent(arguments); + return; + } this.title = 'Messung ' + this.record.get('nebenprobenNr'); this.buttons = [{ text: 'Schließen', @@ -88,14 +96,33 @@ initData: function() { this.clearMessages(); - this.down('messungform').setRecord(this.record); Ext.ClassManager.get('Lada.model.Messung').load(this.record.get('id'), { failure: function(record) { // TODO console.log(record); }, success: function(record, response) { + var me = this; + if (this.probe.get('treeModified') < record.get('treeModified')) { + Ext.Msg.show({ + title: 'Probe nicht aktuell!', + msg: 'Die zugehörige Probe wurde verändert.\nMöchten Sie zu der Probe zurückkehren und neu laden?\nOhne das erneute Laden der Probe wird das Speichern der Messung nicht möglich sein.', + buttons: Ext.Msg.OKCANCEL, + icon: Ext.Msg.WARNING, + closable: false, + fn: function(button) { + if (button === 'ok') { + me.close(); + me.parentWindow.initData(); + } + else { + me.record.set('treeModified', me.probe.get('treeModified')); + } + } + }); + } this.down('messungform').setRecord(record); + this.record = record; var json = Ext.decode(response.response.responseText); if (json) { this.setMessages(json.errors, json.warnings); @@ -103,23 +130,6 @@ }, scope: this }); - - if (this.record.get('readonly') == true){ - this.down('messungform').setReadOnly(true); - this.disableChildren(); - } - }, - - disableChildren: function(){ - this.down('fset[name=messwerte]').down('messwertgrid').setReadOnly(true); - this.down('fset[name=messungstatus]').down('statusgrid').setReadOnly(true); - this.down('fset[name=messungskommentare]').down('mkommentargrid').setReadOnly(true); - }, - - enableChildren: function(){ - this.down('fset[name=messwerte]').down('messwertgrid').setReadOnly(false); - this.down('fset[name=messungstatus]').down('statusgrid').setReadOnly(false); - this.down('fset[name=messungskommentare]').down('mkommentargrid').setReadOnly(false); }, setMessages: function(errors, warnings) {
--- a/app/view/window/OrtEdit.js Wed Mar 25 16:45:29 2015 +0100 +++ b/app/view/window/OrtEdit.js Wed Mar 25 16:46:48 2015 +0100 @@ -25,6 +25,8 @@ layout: 'border', constrain: true, + parentWindow: null, + probe: null, record: null, grid: null, @@ -34,6 +36,11 @@ this.callParent(arguments); return; } + if (this.probe === null) { + Ext.Msg.alert('Zu dem Ort existiert keine Probe!'); + this.callParent(arguments); + return; + } this.title = 'Ort'; this.buttons = [{ text: 'Schließen', @@ -83,7 +90,35 @@ }, initData: function() { - this.down('ortform').setRecord(this.record); + Ext.ClassManager.get('Lada.model.Ort').load(this.record.get('id'), { + failure: function(record, action) { + // TODO + }, + success: function(record, response) { + var me = this; + if (this.probe.get('treeModified') < record.get('treeModified')) { + Ext.Msg.show({ + title: 'Probe nicht aktuell!', + msg: 'Die zugehörige Probe wurde verändert.\nMöchten Sie zu der Probe zurückkehren und neu laden?\nOhne das erneute Laden der Probe wird das Speichern des Ortes nicht möglich sein.', + buttons: Ext.Msg.OKCANCEL, + icon: Ext.Msg.WARNING, + closable: false, + fn: function(button) { + if (button === 'ok') { + me.close(); + me.parentWindow.initData(); + } + else { + me.record.set('treeModified', me.probe.get('treeModified')); + } + } + }); + } + this.down('ortform').setRecord(record); + this.record = record; + }, + scope: this + }); Ext.ClassManager.get('Lada.model.Location').load(this.record.get('ort'), { failure: function(record, action) { // TODO
--- a/app/view/window/ProbeEdit.js Wed Mar 25 16:45:29 2015 +0100 +++ b/app/view/window/ProbeEdit.js Wed Mar 25 16:46:48 2015 +0100 @@ -114,6 +114,7 @@ }, success: function(record, response) { this.down('probeform').setRecord(record); + this.record = record; var json = Ext.decode(response.response.responseText); if (json) { this.setMessages(json.errors, json.warnings);