details: /erp/devel/pi/rev/e41a8f8d9536
changeset: 10842:e41a8f8d9536
user: Martin Taal <martin.taal <at> openbravo.com>
date: Wed Feb 23 12:59:40 2011 +0100
summary: Solved auto-save for new records in grid/form editing
diffstat:
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
| 12 ++--
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
| 8 ++-
modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
| 24 ++++-----
3 files changed, 23 insertions(+), 21 deletions(-)
diffs (112 lines):
diff -r 3bdb5f5f4e05 -r e41a8f8d9536
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
Wed Feb 23 10:03:05 2011 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
Wed Feb 23 12:59:40 2011 +0100
@@ -120,9 +120,7 @@
this.setHasChanged(false);
- // the new state can also be signaled through the record
- // this is to edit new records which have been edited before
- this.setNewState(isNew || this.getValue('_new'));
+ this.setNewState(isNew);
// focus is done automatically, prevent the focus event if needed
// the focus event will set the active view
@@ -136,8 +134,7 @@
this.ignoreFirstFocusEvent = preventFocus;
this.retrieveInitialValues(isNew);
- // note on purpose using this.isNew, also takes into account the _new flag
- if (this.isNew) {
+ if (isNew) {
this.view.statusBar.setStateLabel('OBUIAPP_New',
this.view.statusBar.newIcon);
} else {
this.view.statusBar.setStateLabel();
@@ -184,6 +181,11 @@
this.view.statusBar.setNewState(isNew);
this.view.updateTabTitle();
this.enableLinkedItemSection(!isNew);
+
+ if (isNew) {
+ // signal that autosave is needed after this
+ this.view.standardWindow.setDirtyEditForm(this);
+ }
},
// reset the focus item to the first item which can get focus
diff -r 3bdb5f5f4e05 -r e41a8f8d9536
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
Wed Feb 23 10:03:05 2011 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
Wed Feb 23 12:59:40 2011 +0100
@@ -1214,7 +1214,11 @@
this.view.toolBar.updateButtonState(true);
}
},
-
+
+ saveEdits : function (editCompletionEvent, callback, rowNum, colNum,
validateOnly) {
+ return this.Super('saveEdits', arguments);
+ },
+
// saveEdits: when saving, first check if a FIC call needs to be done to
update to the
// latest values. This can happen when the focus is in a field and the save
action is
// done, at that point first try to force a fic call (handleItemChange) and
if that
@@ -1229,7 +1233,7 @@
}
// nothing changed just fire the calback and bail
- if (!ficCallDone && this.getEditForm() && !this.getEditForm().hasChanged) {
+ if (!ficCallDone && this.getEditForm() && !this.getEditForm().hasChanged
&& !this.getEditForm().isNew) {
if (saveCallback) {
this.fireCallback(saveCallback,
"rowNum,colNum,editCompletionEvent,success",
diff -r 3bdb5f5f4e05 -r e41a8f8d9536
modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
---
a/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
Wed Feb 23 10:03:05 2011 +0100
+++
b/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
Wed Feb 23 12:59:40 2011 +0100
@@ -343,12 +343,13 @@
},
setValueFromRecord: function(record){
- this._hasChanged = true;
if (!record) {
this.setValue(null);
+ this.form.setValue(this.name + '.' + this.displayField, null);
} else {
this.handleOutFields(record);
this.setValue(record[this.valueField]);
+ this.form.setValue(this.name + '.' + this.displayField,
record[OB.Constants.IDENTIFIER]);
}
if (this.form && this.form.handleItemChange) {
this._hasChanged = true;
@@ -491,24 +492,19 @@
this.selectorWindow.open();
},
- setValueFromGrid: function(record){
- this._hasChanged = true;
+ setValueFromRecord: function(record){
if (!record) {
- this.clearValue();
- this.form.clearValue(this.displayField);
+ this.setValue(null);
+ this.form.setValue(this.name + '.' + this.displayField, null);
} else {
- // use a special valuemap to store the value
- if (!this.valueMap) {
- this.valueMap = {};
- }
this.setValue(record[this.gridValueField]);
- this.valueMap[this.getValue()] = record[this.gridDisplayField];
- this.form.setValue(this.displayField, record[this.gridDisplayField]);
- this.updateValueMap(true);
+ this.form.setValue(this.name + '.' + this.displayField,
record[this.gridDisplayField]);
}
this.handleOutFields(record);
- this._hasChanged = true;
- this.form.handleItemChange(this);
+ if (this.form && this.form.handleItemChange) {
+ this._hasChanged = true;
+ this.form.handleItemChange(this);
+ }
},
handleOutFields: function(record){
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits