details: /erp/devel/pi/rev/62707f6cf5db
changeset: 10509:62707f6cf5db
user: Martin Taal <martin.taal <at> openbravo.com>
date: Thu Feb 10 08:17:24 2011 +0100
summary: Solved api failure
details: /erp/devel/pi/rev/ae63b8518ed6
changeset: 10510:ae63b8518ed6
user: Martin Taal <martin.taal <at> openbravo.com>
date: Thu Feb 10 08:18:22 2011 +0100
summary: Solved change of id, several smaller issues
diffstat:
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
| 33 +++---
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFormComponent.java
| 8 +
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
| 3 +
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view-datasource.js
| 16 +++-
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
| 9 +-
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
| 49 +++++++--
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
| 34 +++++-
modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java
| 27 +++++
modules/org.openbravo.service.json/src/org/openbravo/service/json/JsonConstants.java
| 7 +
modules/org.openbravo.service.json/src/org/openbravo/service/json/JsonToDataConverter.java
| 7 +
10 files changed, 156 insertions(+), 37 deletions(-)
diffs (truncated from 436 to 300 lines):
diff -r 7e13188acaec -r ae63b8518ed6
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
Thu Feb 10 06:28:27 2011 +0100
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
Thu Feb 10 08:18:22 2011 +0100
@@ -291,25 +291,26 @@
}
if (mode.equals("EDIT") && row != null) {
- final String rowClientId = ((ClientEnabled) row).getClient().getId();
- final String currentClientId =
OBContext.getOBContext().getCurrentClient().getId();
- if (!rowClientId.equals(currentClientId)) {
- finalObject.put("_readOnly", true);
- } else {
- boolean writable = false;
- final String objectOrgId = ((OrganizationEnabled)
row).getOrganization().getId();
- for (String orgId :
OBContext.getOBContext().getWritableOrganizations()) {
- if (orgId.equals(objectOrgId)) {
- writable = true;
- break;
+ if (((ClientEnabled) row).getClient() != null
+ || ((OrganizationEnabled) row).getOrganization() != null) {
+ final String rowClientId = ((ClientEnabled) row).getClient().getId();
+ final String currentClientId =
OBContext.getOBContext().getCurrentClient().getId();
+ if (!rowClientId.equals(currentClientId)) {
+ finalObject.put("_readOnly", true);
+ } else {
+ boolean writable = false;
+ final String objectOrgId = ((OrganizationEnabled)
row).getOrganization().getId();
+ for (String orgId :
OBContext.getOBContext().getWritableOrganizations()) {
+ if (orgId.equals(objectOrgId)) {
+ writable = true;
+ break;
+ }
+ }
+ if (!writable) {
+ finalObject.put("_readOnly", true);
}
}
- if (!writable) {
- finalObject.put("_readOnly", true);
- }
}
- } else {
- finalObject.put("writable", true);
}
log.debug(finalObject.toString(1));
diff -r 7e13188acaec -r ae63b8518ed6
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFormComponent.java
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFormComponent.java
Thu Feb 10 06:28:27 2011 +0100
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFormComponent.java
Thu Feb 10 08:18:22 2011 +0100
@@ -238,6 +238,14 @@
private String showIf = "";
private String readOnlyIf = "";
+ /**
+ * @deprecated use {@link #setRedrawOnChange(boolean)}
+ */
+ @Deprecated
+ public void setReadrawOnChange(boolean value) {
+ this.setRedrawOnChange(value);
+ }
+
public boolean isReadOnly() {
return isParentProperty() || field.isReadOnly();
}
diff -r 7e13188acaec -r ae63b8518ed6
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
Thu Feb 10 06:28:27 2011 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
Thu Feb 10 08:18:22 2011 +0100
@@ -169,6 +169,9 @@
},
showPicker: function(){
+ if (this.isDisabled()) {
+ return;
+ }
var parameters = [], index = 0, i = 0, length, propDef, inpName, values;
var form = this.form, view = form.view;
if (this.isFocusable()) {
diff -r 7e13188acaec -r ae63b8518ed6
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view-datasource.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view-datasource.js
Thu Feb 10 06:28:27 2011 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view-datasource.js
Thu Feb 10 08:18:22 2011 +0100
@@ -92,7 +92,8 @@
// standard update is not sent with operationType
var additionalPara = {
_operationType : 'update',
- _noActiveFilter : true
+ _noActiveFilter : true,
+ sendOriginalIDBack: true
};
isc.addProperties(newRequestProperties.params, additionalPara);
if (!newRequestProperties.dataSource) {
@@ -102,7 +103,20 @@
newRequestProperties ]);
},
+ // do special id-handling so that we can replace the old if with the new id
+ // in the correct way, see the ob-view-grid.js editComplete method
+ validateJSONRecord: function(record) {
+ record = this.Super('validateJSONRecord', arguments);
+ var newId = record.id;
+ if (record._originalId) {
+ record.id = record._originalId;
+ record._newId = newId;
+ }
+ return record;
+ },
+
transformResponse : function(dsResponse, dsRequest, jsonData) {
+
if (dsRequest.clientContext &&
dsRequest.clientContext.progressIndicatorSelectedRecord) {
this.hideProgress(dsRequest.clientContext.progressIndicatorSelectedRecord);
}
diff -r 7e13188acaec -r ae63b8518ed6
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
Thu Feb 10 06:28:27 2011 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
Thu Feb 10 08:18:22 2011 +0100
@@ -959,6 +959,13 @@
},
getParentId: function(){
+ var parentRecord = this.getParentRecord();
+ if (parentRecord) {
+ return parentRecord.id;
+ }
+ },
+
+ getParentRecord: function(){
if (!this.parentView || !this.parentView.viewGrid.getSelectedRecords() ||
this.parentView.viewGrid.getSelectedRecords().length !== 1) {
return null;
}
@@ -968,7 +975,7 @@
return null;
}
- return this.parentView.viewGrid.getSelectedRecord()[OB.Constants.ID];
+ return this.parentView.viewGrid.getSelectedRecord();
},
updateChildCount: function(){
diff -r 7e13188acaec -r ae63b8518ed6
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
Thu Feb 10 06:28:27 2011 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
Thu Feb 10 08:18:22 2011 +0100
@@ -86,12 +86,7 @@
editRecord: function(record, preventFocus){
var ret = this.Super('editRecord', arguments);
- this.doEditRecordActions(preventFocus, false);
-
- if (this.view.parentProperty) {
- this.setValue(this.view.parentProperty,
record[this.view.parentProperty]);
- }
-
+ this.doEditRecordActions(preventFocus, false);
return ret;
},
@@ -119,7 +114,8 @@
this.retrieveInitialValues(isNew);
this.view.messageBar.hide();
- if (isNew) {
+ // note on purpose using this.isNew, also takes into account the _new flag
+ if (this.isNew) {
this.view.statusBar.setStateLabel('OBUIAPP_New',
this.view.statusBar.newIcon);
} else {
this.view.statusBar.setStateLabel();
@@ -137,6 +133,22 @@
return ret;
},
+ // set parent display info in the record
+ setParentDisplayInfo: function() {
+ if (this.view.parentProperty) {
+ var parentRecord = this.view.getParentRecord();
+ if (parentRecord) {
+ this.setValue(this.view.parentProperty, parentRecord.id);
+ this.setValue(this.view.parentProperty + '.' +
OB.Constants.IDENTIFIER, parentRecord[OB.Constants.IDENTIFIER]);
+ if (this.getField(this.view.parentProperty) &&
!this.getField(this.view.parentProperty).valueMap) {
+ var valueMap = {};
+ this.getField(this.view.parentProperty).valueMap = valueMap;
+ valueMap[parentRecord.id] = parentRecord[OB.Constants.IDENTIFIER];
+ }
+ }
+ }
+ },
+
enableLinkedItemSection: function(enable){
if (!this.linkedItemSection) {
return;
@@ -223,6 +235,8 @@
},
retrieveInitialValues: function(isNew){
+ this.setParentDisplayInfo();
+
var parentId = this.view.getParentId(), requestParams, parentColumn, me =
this, mode;
// note also in this case initial vvalues are passed in as in case of grid
// editing the unsaved/error values from a previous edit session are
maintained
@@ -368,11 +382,12 @@
valueMap[id] = (identifier === 'null' ? null : identifier);
}
field.setValueMap(valueMap);
- if (editValues) {
- // store the valuemap in the edit values so it can be retrieved later
- // when the form is rebuild
- editValues[prop + '._valueMap'] = valueMap;
- }
+ }
+
+ if (editValues && field.valueMap) {
+ // store the valuemap in the edit values so it can be retrieved later
+ // when the form is rebuild
+ editValues[prop + '._valueMap'] = field.valueMap;
}
if (columnValue.value && columnValue.value === 'null') {
@@ -451,7 +466,8 @@
if (this.view.parentProperty) {
parentId = this.view.getParentId();
}
-
+ this.setParentDisplayInfo();
+
requestParams = {
MODE: 'CHANGE',
PARENT_ID: parentId,
@@ -560,6 +576,12 @@
if (localRecord) {
localRecord[view.viewGrid.selection.selectionProperty] = true;
}
+
+ // a new id has been computed use that now
+ if (localRecord._newId) {
+ localRecord.id = localRecord._newId;
+ delete localRecord._newId;
+ }
}
if (status === isc.RPCResponse.STATUS_SUCCESS) {
@@ -583,6 +605,7 @@
// do this after doing autoSave as the setHasChanged will clean
// the autosave info
this.setHasChanged(false);
+
} else if (status === isc.RPCResponse.STATUS_VALIDATION_ERROR &&
resp.errors) {
form.handleFieldErrors(resp.errors);
view.standardWindow.autoSaveDone(view, false);
diff -r 7e13188acaec -r ae63b8518ed6
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
Thu Feb 10 06:28:27 2011 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
Thu Feb 10 08:18:22 2011 +0100
@@ -129,6 +129,7 @@
rowEndEditAction: 'next',
listEndEditAction: 'next',
enforceVClipping: true,
+ validateByCell: true,
currentEditColumnLayout: null,
@@ -820,7 +821,7 @@
// close any editors we may have
this.closeAnyOpenEditor();
-
+ this.view.messageBar.hide();
this.stopHover();
this.updateSelectedCountDisplay();
this.view.recordSelected();
@@ -1041,6 +1042,7 @@
_new: true,
id: '_' + new Date().getTime()
};
+
this.data.insertCacheData(record, rowNum);
this.updateRowCountDisplay();
this.redraw();
@@ -1067,10 +1069,22 @@
view.standardWindow.cleanUpAutoSaveProperties();
view.updateTabTitle();
view.toolBar.updateButtonState();
+
+ // if nothing else got selected, select ourselves then
+ if (!this.getSelectedRecord()) {
+ this.selectRecord(record);
+ }
+ this.view.messageBar.hide();
},
editComplete: function(rowNum, colNum, newValues, oldValues,
editCompletionEvent, dsResponse){
var record = this.getRecord(rowNum), editRow, editSession, autoSaveAction;
+
+ // a new id has been computed use that now
+ if (record._newId) {
+ record.id = record._newId;
+ delete record._newId;
+ }
// during save the record looses the link to the editColumnLayout,
// restore it
@@ -1084,6 +1098,9 @@
record.editColumnLayout.showEditOpen();
}
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits