Link in title of formitem only present in case entity access allowed
authorMartin Taal <martin.taal@openbravo.com>
Wed, 26 Jan 2011 09:54:36 +0100
changeset 10136 9b35aa971d72
parent 10135 8207d391925f
child 10137 92b18c4a18e1
Link in title of formitem only present in case entity access allowed
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/ApplicationComponent.java
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/templates/application-js.ftl
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js	Wed Jan 26 06:17:52 2011 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js	Wed Jan 26 09:54:36 2011 +0100
@@ -672,7 +672,7 @@
   getTitleHTML: function(item, error){
     var titleHTML = this.Super('getTitleHTML', arguments);
     
-    if (item.showLinkIcon) {
+    if (item.showLinkIcon && item.targetEntity && OB.AccessibleEntities[item.targetEntity]) {
     
       // the parent property does not need a link, as it is shown in the 
       // parent view
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/ApplicationComponent.java	Wed Jan 26 06:17:52 2011 +0100
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/ApplicationComponent.java	Wed Jan 26 09:54:36 2011 +0100
@@ -21,7 +21,9 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
+import java.util.Set;
 
+import org.openbravo.base.model.Entity;
 import org.openbravo.base.session.OBPropertiesProvider;
 import org.openbravo.client.kernel.reference.UIDefinitionController;
 import org.openbravo.client.kernel.reference.UIDefinitionController.FormatDefinition;
@@ -56,6 +58,13 @@
     return formatDefinition;
   }
 
+  public Set<Entity> getAccessibleEntities() {
+    final Set<Entity> entities = OBContext.getOBContext().getEntityAccessChecker()
+        .getReadableEntities();
+    entities.addAll(OBContext.getOBContext().getEntityAccessChecker().getWritableEntities());
+    return entities;
+  }
+
   public String getDefaultGroupingSymbol() {
     return getFormatDefinition().getGroupingSymbol();
   }
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/templates/application-js.ftl	Wed Jan 26 06:17:52 2011 +0100
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/templates/application-js.ftl	Wed Jan 26 09:54:36 2011 +0100
@@ -70,5 +70,11 @@
         ERROR : "error"        
     },
     
-    I18N: {}
+    I18N: {},
+    
+    AccessibleEntities: {
+    <#list data.accessibleEntities as entity>
+    '${entity.name?js_string}':  true<#if entity_has_next>,</#if>
+    </#list>
+    }
 };
\ No newline at end of file