[Lada-commits] [PATCH] changed behaviour of ortserstellung window on save; fix update (form)
Wald Commits
scm-commit at wald.intevation.org
Fri Feb 3 11:08:47 CET 2017
# HG changeset patch
# User Maximilian Krambach <mkrambach at intevation.de>
# Date 1486116524 -3600
# Node ID 8ace34d9352a202d8f36e96d86e5b919a98ff5a5
# Parent c4ac1c09c0b038be9d796be663cb6d5ac04cca07
changed behaviour of ortserstellung window on save; fix update (form)
diff -r c4ac1c09c0b0 -r 8ace34d9352a app/controller/grid/Ortszuordnung.js
--- a/app/controller/grid/Ortszuordnung.js Fri Feb 03 09:47:52 2017 +0100
+++ b/app/controller/grid/Ortszuordnung.js Fri Feb 03 11:08:44 2017 +0100
@@ -172,7 +172,8 @@
var grid = button.up('ortszuordnungwindow').down('ortstammdatengrid').getView();
var selected = grid.getSelectionModel().getSelection()[0];
var newRecord = Ext.create('Lada.model.Ort', selected.data);
- newRecord.set('ortId', '');
+ newRecord.set('ortId', null);
+ newRecord.set('id', null);
Ext.create('Lada.view.window.Ortserstellung', {
record: newRecord,
parentWindow: button.up('ortszuordnungwindow')
diff -r c4ac1c09c0b0 -r 8ace34d9352a app/view/form/Ortserstellung.js
--- a/app/view/form/Ortserstellung.js Fri Feb 03 09:47:52 2017 +0100
+++ b/app/view/form/Ortserstellung.js Fri Feb 03 11:08:44 2017 +0100
@@ -22,6 +22,8 @@
record: null,
+ trackResetOnLoad: true,
+
initComponent: function() {
var i18n = Lada.getApplication().bundle;
var me = this;
@@ -214,17 +216,21 @@
checkCommitEnabled: function() {
var savebutton = this.down('toolbar').down('button[action=save]');
var form = this.getForm();
- if (form.findField('kdaId').getValue() ||
- form.findField('koordYExtern').getValue() ||
- form.findField('koordXExtern').getValue()) {
- if (this.checkCoordinates()) {
+ if (form.isDirty()) {
+ if (form.findField('kdaId').getValue() ||
+ form.findField('koordYExtern').getValue() ||
+ form.findField('koordXExtern').getValue()) {
+ if (this.checkCoordinates()) {
+ savebutton.setDisabled(false);
+ } else {
+ savebutton.setDisabled(true);
+ }
+ } else if (form.findField('gemId').getValue() ||
+ form.findField('staatId').getValue() >= 0 ) {
savebutton.setDisabled(false);
} else {
savebutton.setDisabled(true);
}
- } else if (form.findField('gemId').getValue() ||
- form.findField('staatId').getValue() >= 0 ) {
- savebutton.setDisabled(false);
} else {
savebutton.setDisabled(true);
}
@@ -268,14 +274,15 @@
var this_panel = this.up('panel');
var form = this_panel.getForm();
var record = form.getRecord();
+ var oldId = record.get('ortId');
var data = form.getFieldValues(true);
for (var key in data) {
record.set(key, data[key]);
}
record.set('netzbetreiberId', Lada.netzbetreiber[0]);
record.save({
- success: function(record, response) {
- var newOrtId;
+ success: function(newrecord, response) {
+ form.loadRecord(newrecord);
var ozw = this_panel.up().parentWindow;
var json = Ext.decode(response.response.responseText);
if (json) {
@@ -291,10 +298,23 @@
var record = osg.store.getById(id);
var selmod = osg.getView().getSelectionModel();
selmod.select(record);
+ var resulttext;
+ if (json) {
+ if (json.message == '201') {
+ resulttext = 'Dieser Ort existiert bereits!';
+ }
+ if (json.message == '200') {
+ if (oldId === undefined) {
+ resulttext = 'Ort erfolgreich angelegt!';
+ } else {
+ resulttext = 'Bestehender Ort erfolgreich modifiziert!';
+ }
+ }
+ }
Ext.Msg.show({
title: Lada.getApplication().bundle.getMsg('success'),
autoScroll: true,
- msg: 'Ort erfolgreich angelegt!',
+ msg: resulttext,
buttons: Ext.Msg.OK
});
},
More information about the Lada-commits
mailing list