details: /erp/devel/pi/rev/7990d87ea92e
changeset: 10944:7990d87ea92e
user: Asier Lostalé <asier.lostale <at> openbravo.com>
date: Tue Mar 01 13:58:07 2011 +0100
summary: fixed bug 15826: Do not show new button if no write access is granted
diffstat:
src-wad/src/org/openbravo/wad/javasource.javaxml | 10 +++++---
src/org/openbravo/erpCommon/utility/ToolBar.java | 26 ++++++++++++++++++-----
2 files changed, 26 insertions(+), 10 deletions(-)
diffs (113 lines):
diff -r 5dda40f03161 -r 7990d87ea92e
src-wad/src/org/openbravo/wad/javasource.javaxml
--- a/src-wad/src/org/openbravo/wad/javasource.javaxml Tue Mar 01 13:23:12
2011 +0100
+++ b/src-wad/src/org/openbravo/wad/javasource.javaxml Tue Mar 01 13:58:07
2011 +0100
@@ -863,10 +863,11 @@
if (vars.getSessionValue("#ShowTest", "N").equals("Y")) discard[1] = new
String("isTest");
XmlDocument xmlDocument =
xmlEngine.readXmlTemplate("org/openbravo/erpWindows/<PARAMETER_TMP
id="path">Window</PARAMETER_TMP>/<PARAMETER_TMP
id="class">Almacen</PARAMETER_TMP>_Relation", discard).createXmlDocument();
- ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "<PARAMETER_TMP
id="class">Almacen</PARAMETER_TMP>", false, "document.frmMain.inp<FIELD_TMP
id="keyData">Clave</FIELD_TMP>", "grid", "..<PARAMETER_TMP
id="paramReportPDF">xx</PARAMETER_TMP>", "<PARAMETER_TMP
id="paramReportDirectPrint">xx</PARAMETER_TMP>".equals("Y"), "<PARAMETER_TMP
id="windowName">Window</PARAMETER_TMP>", strReplaceWith, false);
+ boolean hasReadOnlyAccess =
org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this,
vars.getRole(), tabId);
+ ToolBar toolbar = new ToolBar(this, true, vars.getLanguage(),
"<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>", false,
"document.frmMain.inp<FIELD_TMP id="keyData">Clave</FIELD_TMP>", "grid",
"..<PARAMETER_TMP id="paramReportPDF">xx</PARAMETER_TMP>", "<PARAMETER_TMP
id="paramReportDirectPrint">xx</PARAMETER_TMP>".equals("Y"), "<PARAMETER_TMP
id="windowName">Window</PARAMETER_TMP>", strReplaceWith, false, false, false,
false, !hasReadOnlyAccess);
toolbar.setTabId(tabId);
- toolbar.setDeleteable(<PARAMETER_TMP id="deleteable"/> &&
!org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this,
vars.getRole(), tabId));
+ toolbar.setDeleteable(<PARAMETER_TMP id="deleteable"/> &&
!hasReadOnlyAccess);
toolbar.prepareRelationTemplate<PARAMETER_TMP
id="sameParent">NoSearch</PARAMETER_TMP>("<PARAMETER_TMP
id="paramHasTree">hasTree</PARAMETER_TMP>".equals("Y"), hasSearchCondition,
!vars.getSessionValue("#ShowTest", "N").equals("Y"), <PARAMETER_TMP
id="paramIsReadOnly">readonly</PARAMETER_TMP>, Utility.getContext(this, vars,
"ShowAudit", windowId).equals("Y"));
xmlDocument.setParameter("toolbar", toolbar.toString());
@@ -1045,14 +1046,15 @@
String currentClient =
(boolNew?"":(dataField!=null?dataField.getField("adClientId"):data[0].getField("adClientId")));
if (!currentClient.equals("") && !currentClient.startsWith("'"))
currentClient = "'"+currentClient+"'";
- boolean editableTab =
(!org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this,
vars.getRole(), tabId) && (currentOrg.equals("") ||
Utility.isElementInList(Utility.getContext(this, vars, "#User_Org", windowId,
accesslevel),currentOrg)) && (currentClient.equals("") ||
Utility.isElementInList(Utility.getContext(this, vars, "#User_Client",
windowId, accesslevel), currentClient)));
+ boolean hasReadOnlyAccess =
org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(this,
vars.getRole(), tabId);
+ boolean editableTab = (!hasReadOnlyAccess &&
(currentOrg.equals("") || Utility.isElementInList(Utility.getContext(this,
vars, "#User_Org", windowId, accesslevel),currentOrg)) &&
(currentClient.equals("") || Utility.isElementInList(Utility.getContext(this,
vars, "#User_Client", windowId, accesslevel), currentClient)));
if (editableTab)
xmlDocument =
xmlEngine.readXmlTemplate("org/openbravo/erpWindows/<PARAMETER_TMP
id="path">Window</PARAMETER_TMP>/<PARAMETER_TMP
id="class">Almacen</PARAMETER_TMP>_Edition",discard).createXmlDocument();
else
xmlDocument =
xmlEngine.readXmlTemplate("org/openbravo/erpWindows/<PARAMETER_TMP
id="path">Window</PARAMETER_TMP>/<PARAMETER_TMP
id="class">Almacen</PARAMETER_TMP>_NonEditable",discard).createXmlDocument();
xmlDocument.setParameter("tabId", tabId);
- ToolBar toolbar = new ToolBar(this, editableTab, vars.getLanguage(),
"<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>", (strCommand.equals("NEW")
|| boolNew || (dataField==null && (data==null || data.length==0))),
"document.frmMain.inp<FIELD_TMP id="keyData">Clave</FIELD_TMP>", "",
"..<PARAMETER_TMP id="paramReportPDF">xx</PARAMETER_TMP>", "<PARAMETER_TMP
id="paramReportDirectPrint">xx</PARAMETER_TMP>".equals("Y"), "<PARAMETER_TMP
id="windowName">Window</PARAMETER_TMP>", strReplaceWith, true, false, false,
Utility.hasTabAttachments(this, vars, tabId, str<KEY_TMP
id="key">PosicionAlmacen</KEY_TMP>));
+ ToolBar toolbar = new ToolBar(this, editableTab, vars.getLanguage(),
"<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>", (strCommand.equals("NEW")
|| boolNew || (dataField==null && (data==null || data.length==0))),
"document.frmMain.inp<FIELD_TMP id="keyData">Clave</FIELD_TMP>", "",
"..<PARAMETER_TMP id="paramReportPDF">xx</PARAMETER_TMP>", "<PARAMETER_TMP
id="paramReportDirectPrint">xx</PARAMETER_TMP>".equals("Y"), "<PARAMETER_TMP
id="windowName">Window</PARAMETER_TMP>", strReplaceWith, true, false, false,
Utility.hasTabAttachments(this, vars, tabId, str<KEY_TMP
id="key">PosicionAlmacen</KEY_TMP>), !hasReadOnlyAccess);
toolbar.setTabId(tabId);
toolbar.setDeleteable(<PARAMETER_TMP id="deleteable"/>);
toolbar.prepareEditionTemplate<PARAMETER_TMP
id="sameParent">NoSearch</PARAMETER_TMP>("<PARAMETER_TMP
id="paramHasTree">hasTree</PARAMETER_TMP>".equals("Y"), hasSearchCondition,
vars.getSessionValue("#ShowTest", "N").equals("Y"), "<PARAMETER_TMP
id="paramUIPattern">readonly</PARAMETER_TMP>", Utility.getContext(this, vars,
"ShowAudit", windowId).equals("Y"));
diff -r 5dda40f03161 -r 7990d87ea92e
src/org/openbravo/erpCommon/utility/ToolBar.java
--- a/src/org/openbravo/erpCommon/utility/ToolBar.java Tue Mar 01 13:23:12
2011 +0100
+++ b/src/org/openbravo/erpCommon/utility/ToolBar.java Tue Mar 01 13:58:07
2011 +0100
@@ -11,7 +11,7 @@
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2001-2010 Openbravo SLU
+ * All portions are Copyright (C) 2001-2011 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -50,6 +50,7 @@
private boolean email = false;
private String tabId;
private boolean deleteable = true;
+ private boolean hasNewButton = true;
public void setEmail(boolean email) {
this.email = email;
@@ -103,7 +104,7 @@
String _windowName, String _baseDirection, boolean _debug, boolean
_isSrcWindow,
boolean _isFrame, boolean _hasAttachements) {
this(_conn, true, _language, _action, _isNew, _keyINP, _gridID, _PDFName,
_isDirectPrinting,
- _windowName, _baseDirection, _debug, _isSrcWindow, _isFrame,
_hasAttachements);
+ _windowName, _baseDirection, _debug, _isSrcWindow, _isFrame,
_hasAttachements, true);
}
public ToolBar(ConnectionProvider _conn, boolean _isEditable, String
_language, String _action,
@@ -125,7 +126,16 @@
String _windowName, String _baseDirection, boolean _debug, boolean
_isSrcWindow,
boolean _isFrame) {
this(_conn, _isEditable, _language, _action, _isNew, _keyINP, _gridID,
_PDFName,
- _isDirectPrinting, _windowName, _baseDirection, _debug, _isSrcWindow,
false, false);
+ _isDirectPrinting, _windowName, _baseDirection, _debug, _isSrcWindow,
false, false, true);
+ }
+
+ public ToolBar(ConnectionProvider _conn, boolean _isEditable, String
_language, String _action,
+ boolean _isNew, String _keyINP, String _gridID, String _PDFName, boolean
_isDirectPrinting,
+ String _windowName, String _baseDirection, boolean _debug, boolean
_isSrcWindow,
+ boolean _isFrame, boolean _hasAttachments) {
+ this(_conn, _isEditable, _language, _action, _isNew, _keyINP, _gridID,
_PDFName,
+ _isDirectPrinting, _windowName, _baseDirection, _debug, _isSrcWindow,
_isFrame,
+ _hasAttachments, true);
}
/**
@@ -134,7 +144,7 @@
public ToolBar(ConnectionProvider _conn, boolean _isEditable, String
_language, String _action,
boolean _isNew, String _keyINP, String _gridID, String _PDFName, boolean
_isDirectPrinting,
String _windowName, String _baseDirection, boolean _debug, boolean
_isSrcWindow,
- boolean _isFrame, boolean _hasAttachments) {
+ boolean _isFrame, boolean _hasAttachments, boolean _hasNewButton) {
this.conn = _conn;
this.language = _language;
this.servlet_action = _action;
@@ -155,6 +165,7 @@
this.form = this.keyfield.substring(0, i);
this.isSrcWindow = _isSrcWindow;
this.hasAttachments = _hasAttachments;
+ this.hasNewButton = _hasNewButton;
createAllButtons();
}
@@ -267,8 +278,11 @@
}
private void createAllButtons() {
- buttons.put("NEW", new ToolBar_Button(base_direction, "New",
Utility.messageBD(conn, "New",
- language), getButtonScript("NEW")));
+ if (hasNewButton) {
+ buttons.put("NEW", new ToolBar_Button(base_direction, "New",
Utility.messageBD(conn, "New",
+ language), getButtonScript("NEW")));
+ }
+
buttons.put("EDIT", new ToolBar_Button(base_direction, "Edit",
Utility.messageBD(conn, "Edit",
language), getButtonScript("EDIT")));
buttons.put("RELATION", new ToolBar_Button(base_direction, "Relation",
Utility.messageBD(conn,
------------------------------------------------------------------------------
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