[process] Support for manual Process Definition
authorAsier Lostalé <asier.lostale@openbravo.com>
Mon, 16 Apr 2012 10:00:50 +0200
changeset 16369 088593c08cfa
parent 16097 6017d223d423
child 16370 6c05db2b64ec
[process] Support for manual Process Definition

Process Definitions with Manual UI Pattern are executed by invoking the JS
function defined within them.
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-tab.js.ftl
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-tab.js.ftl	Mon Apr 16 16:08:20 2012 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-tab.js.ftl	Mon Apr 16 10:00:50 2012 +0200
@@ -67,7 +67,8 @@
        command: '${field.command?js_string}',
        property: '${field.propertyName?js_string}',
        processId: '${field.processId?js_string}',
-       <#if field.newDefinition>newDefinition: ${field.newDefinition?string},</#if>
+       <#if field.newDefinition>newDefinition: ${field.newDefinition?string}, 
+       uiPattern: '${field.uiPattern?js_string}',</#if>
        <#if field.windowId != "">windowId: '${field.windowId?js_string}',</#if>
        <#if field.windowTitle != "">windowTitle: '${field.windowTitle?js_string}',</#if>
        <#if !field.modal>modal: ${field.modal?string},</#if>
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java	Mon Apr 16 16:08:20 2012 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java	Mon Apr 16 10:00:50 2012 +0200
@@ -514,6 +514,7 @@
     private String windowId = "";
     private String windowTitle = "";
     private boolean newDefinition = false;
+    private String uiPattern = "";
 
     public ButtonField(Field fld) {
       id = fld.getId();
@@ -533,8 +534,9 @@
         url = "/";
         command = newProcess.getJavaClassName();
         newDefinition = true;
+        uiPattern = newProcess.getUIPattern();
 
-        if ("OBUIAPP_PickAndExecute".equals(newProcess.getUIPattern())) {
+        if ("OBUIAPP_PickAndExecute".equals(uiPattern)) {
           // TODO: modal should be a parameter in the process definition?
           modal = false;
           for (org.openbravo.client.application.Parameter p : newProcess.getOBUIAPPParameterList()) {
@@ -704,6 +706,10 @@
       return newDefinition;
     }
 
+    public String getUiPattern() {
+      return uiPattern;
+    }
+
     public void setNewDefinition(boolean newDefinition) {
       this.newDefinition = newDefinition;
     }
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js	Mon Apr 16 16:08:20 2012 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js	Mon Apr 16 10:00:50 2012 +0200
@@ -116,25 +116,32 @@
         len = parts.length,
         className = '_',
         tabSet = OB.MainView.TabSet,
-        vStack;
+        vStack, manualJS;
 
-    if (params.windowId) {
-      className = className + params.windowId;
-      if (len === 3) {
-        // debug mode, we have added _timestamp
-        className = className + '_' + parts[2];
+    if (params.uiPattern === 'M') { // Manual UI Pattern
+      manualJS = eval(params.actionHandler);
+      if (isc.isA.Function(manualJS)) {
+        manualJS(params, this);
       }
+    } else {
+      if (params.windowId) {
+        className = className + params.windowId;
+        if (len === 3) {
+          // debug mode, we have added _timestamp
+          className = className + '_' + parts[2];
+        }
 
-      if (isc[className]) {
-        this.selectedState = this.activeView && this.activeView.viewGrid && this.activeView.viewGrid.getSelectedState();
-        this.runningProcess = isc[className].create(isc.addProperties({}, params, {
-          parentWindow: this
-        }));
+        if (isc[className]) {
+          this.selectedState = this.activeView && this.activeView.viewGrid && this.activeView.viewGrid.getSelectedState();
+          this.runningProcess = isc[className].create(isc.addProperties({}, params, {
+            parentWindow: this
+          }));
 
-        this.processLayout.addMember(this.runningProcess);
-        this.toolBarLayout.hide();
-        this.view.hide();
-        this.processLayout.show();
+          this.processLayout.addMember(this.runningProcess);
+          this.toolBarLayout.hide();
+          this.view.hide();
+          this.processLayout.show();
+        }
       }
     }
   },
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js	Mon Apr 16 16:08:20 2012 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js	Mon Apr 16 10:00:50 2012 +0200
@@ -91,7 +91,8 @@
           windowId: me.windowId,
           windowTitle: me.windowTitle,
           actionHandler: me.command,
-          buttons: me.labelValue
+          buttons: me.labelValue,
+          uiPattern: me.uiPattern
         });
         me.opening = false; // Activate again the button
       };