myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject [myfaces-tobago] branch master updated: TOBAGO-1633: TS refactoring
Date Fri, 02 Aug 2019 14:52:41 GMT
This is an automated email from the ASF dual-hosted git repository.

lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


The following commit(s) were added to refs/heads/master by this push:
     new decb978  TOBAGO-1633: TS refactoring
decb978 is described below

commit decb978f34fc54b2c5e1ce8cf2d6314e72bfd265
Author: Udo Schnurpfeil <lofwyr@apache.org>
AuthorDate: Fri Aug 2 16:52:28 2019 +0200

    TOBAGO-1633: TS refactoring
    
    progress on command
---
 .../src/main/npm/ts/tobago-calendar.ts             |   3 +-
 .../src/main/npm/ts/tobago-command.test.ts         |  22 +-
 .../src/main/npm/ts/tobago-command.ts              | 461 +++++++++++++++------
 .../src/main/npm/ts/tobago-core.ts                 | 170 +-------
 .../src/main/npm/ts/tobago-sheet.ts                |   5 +-
 .../src/main/npm/ts/tobago-tab.ts                  |   2 +-
 6 files changed, 356 insertions(+), 307 deletions(-)

diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-calendar.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-calendar.ts
index a02f9f7..b5dfa36 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-calendar.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-calendar.ts
@@ -17,6 +17,7 @@
 
 import {Listener, Phase} from "./tobago-listener";
 import {DomUtils} from "./tobago-utils";
+import {Command} from "./tobago-command";
 
 class DateTime {
 
@@ -168,7 +169,7 @@ class DateTime {
                   render: commands.change.render
                 });
           } else if (commands.change.action) {
-            Tobago4.submitAction(this.firstElementChild, commands.change.action, commands.change);
+            Command.submitAction(this.firstElementChild, commands.change.action, commands.change);
           }
         }
       });
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-command.test.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-command.test.ts
index c089144..7de9ada 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-command.test.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-command.test.ts
@@ -15,14 +15,26 @@
  * limitations under the License.
  */
 
-import {CommandMap} from "./tobago-command";
+import {Command, CommandMap} from "./tobago-command";
+
+test('class Command: string', () => {
+  let command = new Command('{"omit":false,"execute":"execute-id"}');
+  expect(command.omit).toBe(false);
+  expect(command.stringify()).toBe('{"omit":false,"execute":"execute-id"}');
+});
+
+test('class Command: object', () => {
+  let command = new Command({"omit": false, "execute": "execute-id"});
+  expect(command.omit).toBe(false);
+  expect(command.stringify()).toBe('{"omit":false,"execute":"execute-id"}');
+});
 
 test('class CommandMap: click', () => {
-  let command = CommandMap.parse('{"click":{"omit":false}}');
-  expect(command.stringify()).toBe('{"commands":{"click":{"omit":false}}}');
+  let commands = new CommandMap('{"click":{"omit":false}}');
+  expect(commands.stringify()).toBe('{"commands":{"click":{"omit":false}}}');
 });
 
 test('class CommandMap: change', () => {
-  let command = CommandMap.parse('{"change":{"action":"page:header:j_id_k"}}');
-  expect(command.stringify()).toBe('{"commands":{"change":{"action":"page:header:j_id_k"}}}');
+  let commands = new CommandMap('{"change":{"action":"page:header:j_id_k"}}');
+  expect(commands.stringify()).toBe('{"commands":{"change":{"action":"page:header:j_id_k"}}}');
 });
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-command.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-command.ts
index e2e1fa6..c1e8d8f 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-command.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-command.ts
@@ -23,178 +23,303 @@ import {Tobago4} from "./tobago-core";
 
 export class CommandMap {
 
-  commands: Map<string, Command5> = new Map<string, Command5>();
+  commands: Map<string, Command>;
 
-  constructor(data: any) {
-    this.commands = typeof data === "string" ? JSON.parse(data) : data;
+  // XXX remove me later... may be, if using "Custom Elements"
+  /** @deprecated */
+  public static getData(element: HTMLElement, eventType: string): Command {
+    const commandMap: CommandMap = new CommandMap(element.dataset["tobagoCommands"]);
+    return commandMap.commands.get(eventType);
   }
 
-  public static parse(value: string): CommandMap {
-    return new CommandMap(value);
+  static change(event: TextEvent) {
+    const element = event.currentTarget as HTMLElement;
+    const change = CommandMap.getData(element, "change");
+
+    if (change.execute || change.render) {
+      jsf.ajax.request(
+          element.getAttribute("name"),
+          event,
+          {
+            "javax.faces.behavior.event": "change",
+            execute: change.execute,
+            render: change.render
+          });
+    } else {
+      Command.submitAction(this, change.action, change);
+    }
+  }
+
+  static resize(event: Event) { // TBD MouseEvent?
+    const element = event.currentTarget as HTMLElement;
+    const resize = CommandMap.getData(element, "resize");
+    console.debug("window resize event: " + resize);
+    Command.submitAction(this, resize.action, resize);
+  }
+
+  static otherEvent(event: Event) {
+    const element = event.currentTarget as HTMLElement;
+    const command = CommandMap.getData(element, event.type);
+
+    const confirmation = command.confirmation;
+    if (confirmation) {
+      if (!confirm(confirmation)) {
+        event.preventDefault();
+        return;
+      }
+    }
+    const collapse = command.collapse;
+    if (collapse) {
+      Collapse.execute(collapse);
+    }
+
+    if (!command.omit) {
+      const popup = command.popup;
+      if (popup && popup.command === "close" && popup.immediate) {
+        Popup.close(this);
+      } else {
+        const action = command.action ? command.action : element.id;
+        if (command.execute || command.render) {
+          Command.preparePartialOverlay(command);
+          jsf.ajax.request(
+              action,
+              event,
+              {
+                "javax.faces.behavior.event": event.type,
+                execute: command.execute,
+                render: command.render
+              });
+        } else {
+          Command.submitAction(this, action, command);
+        }
+        if (popup && popup.command === "close") {
+          Popup.close(this);
+        }
+      }
+    }
+  }
+
+  constructor(data: string) {
+    this.commands = new Map<string, Command>();
+    const object = JSON.parse(data);
+    for (let key of Object.keys(object)) {
+      const command5 = new Command(object[key]);
+      this.commands.set(key, command5);
+    }
+  }
+
+  get change() {
+    return this.commands.get("change");
+  }
+
+  get complete() {
+    return this.commands.get("complete");
+  }
+
+  get load() {
+    return this.commands.get("load");
+  }
+
+  get resize() {
+    return this.commands.get("resize");
   }
 
   public stringify(): string {
-    return JSON.stringify(this);
+    let object = Object.create(null);
+    for (let [k, v] of this.commands) {
+      object[k] = v;
+    }
+    const outer = JSON.stringify(this);
+    // remove {} and replace with object-JSON
+    return outer.substring(0, outer.length - 3) + JSON.stringify(object) + "}";
   }
 }
 
-class Command5 {
-  confirmation: boolean;
+export class Command {
+
+  // XXX this is a state of the page
+  static isSubmit: boolean = false;
+
+  confirmation: string;
   collapse: boolean;
   omit: boolean;
-  popup;
-  action;
+  popup; // todo: type
+  action: string;
   execute: string;
   render: string;
   transition: boolean;
-}
+  delay: number;
+  target: string;
 
-class Command {
+  /**
+   * Submitting the page with specified actionId.
+   * options.transition
+   * options.target
+   */
+  public static submitAction = function (source: any, actionId: string, command: Command
= new Command()) {
 
-  static initEnter(elements) {
-    elements = elements.jQuery ? elements : jQuery(elements); // fixme jQuery -> ES5
-    var page = Tobago4Utils.selectWithJQuery(elements, ".tobago-page");
-    page.keypress(function (event) {
-      var code = event.which;
-      if (code === 0) {
-        code = event.keyCode;
-      }
-      if (code === 13) {
-        var target = event.target;
-        if (target.tagName === "A" || target.tagName === "BUTTON") {
-          return;
+    let transition = command.transition === undefined || command.transition;
+
+    Transport.request(function () {
+      if (!Command.isSubmit) {
+        Command.isSubmit = true;
+        const form = document.getElementsByTagName("form")[0] as HTMLFormElement;
+        var oldTarget = form.getAttribute("target");
+        const sourceHidden = document.getElementById("javax.faces.source") as HTMLInputElement;
+        sourceHidden.disabled = false;
+        sourceHidden.value = actionId;
+        if (command.target) {
+          form.setAttribute("target", command.target);
         }
-        if (target.tagName === "TEXTAREA") {
-          if (!event.metaKey && !event.ctrlKey) {
-            return;
+        this.oldTransition = this.transition;
+        this.transition = transition && !command.target;
+
+        var listenerOptions = {
+          source: source,
+          actionId: actionId,
+          options: command
+        };
+        var onSubmitResult = Command.onSubmit(listenerOptions);
+        if (onSubmitResult) {
+          try {
+            form.submit();
+            // reset the source field after submit, to be prepared for possible next AJAX
with transition=false
+            sourceHidden.disabled = true;
+            sourceHidden.value = "";
+          } catch (e) {
+            Overlay.destroy(DomUtils.page().id);
+            Command.isSubmit = false;
+            alert('Submit failed: ' + e); // XXX localization, better error handling
           }
         }
-        var id = target.name ? target.name : target.id;
-        while (id != null) {
-          var command = jQuery("[data-tobago-default='" + id + "']");
-          if (command.length > 0) {
-            command.click();
-            break;
+        if (command.target) {
+          if (oldTarget) {
+            form.setAttribute("target", oldTarget);
+          } else {
+            form.removeAttribute("target");
           }
-          id = Tobago4Utils.getNamingContainerId(id);
         }
-        return false;
+        if (command.target || !transition || !onSubmitResult) {
+          Command.isSubmit = false;
+          Transport.pageSubmitted = false;
+        }
+      }
+      if (!Command.isSubmit) {
+        Transport.requestComplete(); // remove this from queue
       }
-    });
+    }, true);
+  };
+
+  static initEnter(element: HTMLElement) {
+    for (const page of DomUtils.selfOrQuerySelectorAll(element, ".tobago-page")) {
+      page.addEventListener("keypress", function (event: KeyboardEvent) {
+        let code = event.which; // XXX deprecated
+        if (code === 0) {
+          code = event.keyCode;
+        }
+        if (code === 13) {
+          let target = event.target as HTMLElement;
+          if (target.tagName === "A" || target.tagName === "BUTTON") {
+            return;
+          }
+          if (target.tagName === "TEXTAREA") {
+            if (!event.metaKey && !event.ctrlKey) {
+              return;
+            }
+          }
+          const name = target.getAttribute("name");
+          let id = name ? name : target.id;
+          while (id != null) {
+            const command = document.querySelector("[data-tobago-default='" + id + "']");
+            if (command) {
+              command.dispatchEvent(new MouseEvent("click"));
+              break;
+            }
+            id = Tobago4Utils.getNamingContainerId(id);
+          }
+          return false;
+        }
+      });
+    }
   }
 
   static init = function (element: HTMLElement) {
 
     for (const commandElement of DomUtils.selfOrQuerySelectorAll(element, "[data-tobago-commands]"))
{
 
-      const $element = jQuery(commandElement);
-
-      const commands = $element.data("tobago-commands");
-
-      var normalEvents = []; // todo: find a better way to do that in JS
-      if (commands.click) {
-        normalEvents.push({event: "click", command: commands.click});
-      }
-      if (commands.dblclick) {
-        normalEvents.push({event: "dblclick", command: commands.dblclick});
-      }
-      if (commands.focus) {
-        normalEvents.push({event: "focus", command: commands.focus});
-      }
-      if (commands.blur) {
-        normalEvents.push({event: "blur", command: commands.blur});
-      }
+      const commandMap = new CommandMap(commandElement.dataset["tobagoCommands"]);
 
-      for (var i in normalEvents) {
-
-        $element.on(normalEvents[i].event, {command: normalEvents[i].command}, function (event)
{
-          var command = event.data.command;
-          var confirmation = command.confirmation;
-          if (confirmation != null) {
-            if (!confirm(confirmation)) {
-              event.preventDefault();
-              return;
-            }
-          }
-          var collapse = command.collapse;
-          if (collapse) {
-            Collapse.execute(collapse);
-          }
+      for (const entry of commandMap.commands.entries()) {
+        const key: string = entry[0];
+        const value: Command = entry[1];
 
-          if (command.omit !== true) {
-            var popup = command.popup;
-            if (popup && popup.command === "close" && popup.immediate) {
-              Popup.close(this);
-            } else {
-              var action = command.action ? command.action : jQuery(this).attr("id");
-              if (command.execute || command.render) {
-                Command.preparePartialOverlay(command);
+        console.info("[command] key='" + key + "' value='" + JSON.stringify(value) + "'");
+        switch(key) {
+          case "change":
+            commandElement.addEventListener("change", CommandMap.change);
+            break;
+          case "complete":
+            if (parseFloat(commandElement.getAttribute("value")) >= parseFloat(commandElement.getAttribute("max")))
{
+              if (commandMap.complete.execute || commandMap.complete.render) {
                 jsf.ajax.request(
-                    action,
-                    event,
+                    this.id,
+                    null,
                     {
-                      "javax.faces.behavior.event": event.type,
-                      execute: command.execute,
-                      render: command.render
+                      "javax.faces.behavior.event": "complete",
+                      execute: commandMap.complete.execute,
+                      render: commandMap.complete.render
                     });
               } else {
-                Tobago4.submitAction(this, action, command);
-              }
-              if (popup && popup.command === "close") {
-                Popup.close(this);
+                Command.submitAction(this, commandMap.complete.action, commandMap.complete);
               }
             }
-          }
-        });
-      }
-      if (commands.change) {
-        $element.change(function (event) {
-          if (commands.change.execute || commands.change.render) {
-            jsf.ajax.request(
-                jQuery(this).attr("name"),
-                event,
-                {
-                  "javax.faces.behavior.event": "change",
-                  execute: commands.change.execute,
-                  render: commands.change.render
-                });
-          } else {
-            Tobago4.submitAction(this, commands.change.action, commands.change);
-          }
-        });
-      }
-      if (commands.complete) {
-        if ($element.val() >= parseFloat($element.attr("max"))) {
-          if (commands.complete.execute || commands.complete.render) {
-            jsf.ajax.request(
-                jQuery(this).attr("id"),
-                null,
-                {
-                  "javax.faces.behavior.event": "complete",
-                  execute: commands.complete.execute,
-                  render: commands.complete.render
-                });
-          } else {
-            Tobago4.submitAction(this, commands.complete.action, commands.complete);
-          }
+            break;
+          case "load":
+            setTimeout(function () {
+                  Command.submitAction(this, commandMap.load.action, commandMap.load);
+                },
+                commandMap.load.delay || 100);
+            break;
+          case "resize":
+            window.addEventListener("resize", CommandMap.resize);
+            break;
+          default:
+            commandElement.addEventListener(key, CommandMap.otherEvent);
         }
       }
-      if (commands.load) {
-        setTimeout(function () {
-              Tobago4.submitAction(this, commands.load.action, commands.load);
-            },
-            commands.load.delay || 100);
-      }
-      if (commands.resize) {
-        jQuery(window).resize(function () {
-          console.debug("window resize event: " + commands.resize);
-          Tobago4.submitAction(this, commands.resize.action, commands.resize);
-        });
-      }
     }
   };
 
-  static preparePartialOverlay = function (command) {
+  static onSubmit = function (listenerOptions) {
+    Listener.executeBeforeSubmit();
+    /*
+    XXX check if we need the return false case
+    XXX maybe we cancel the submit, but we continue the rest?
+    XXX should the other phases also have this feature?
+
+        var result = true; // Do not continue if any function returns false
+        for (var order = 0; order < Listeners.beforeSubmit.length; order++) {
+          var list = Listeners.beforeSubmit[order];
+          for (var i = 0; i < list.length; i++) {
+            result = list[i](listenerOptions);
+            if (result === false) {
+              break;
+            }
+          }
+        }
+        if (result === false) {
+          this.isSubmit = false;
+          return false;
+        }
+    */
+    Command.isSubmit = true;
+
+    Tobago4.onBeforeUnload();
+
+    return true;
+  };
+
+  static preparePartialOverlay = function (command: Command) {
     if (command.transition === undefined || command.transition == null || command.transition)
{
       console.debug("[tobago-command] render: '" + command.render + "'");
       if (command.render) {
@@ -205,9 +330,83 @@ class Command {
       }
     }
   };
+
+  constructor(data?: string | object) {
+    let object;
+    if (data) {
+      if (typeof data === "string") {
+        object = JSON.parse(data);
+      } else {
+        object = data;
+      }
+      for (let key of Object.keys(object)) {
+        this[key] = object[key];
+      }
+    }
+  }
+
+  public stringify(): string {
+    return JSON.stringify(this);
+  }
 }
 
 Listener.register(Command.initEnter, Phase.DOCUMENT_READY);
 
 Listener.register(Command.init, Phase.DOCUMENT_READY, Order.LATER);
 Listener.register(Command.init, Phase.AFTER_UPDATE, Order.LATER);
+
+class Transport {
+  static requests = [];
+  static currentActionId = null;
+  static pageSubmitted = false;
+  static startTime: Date;
+
+  /**
+   * @return true if the request is queued.
+   */
+  static request = function (req, submitPage, actionId?) {
+    var index = 0;
+    if (submitPage) {
+      Transport.pageSubmitted = true;
+      index = Transport.requests.push(req);
+      //console.debug('index = ' + index)
+    } else if (!Transport.pageSubmitted) { // AJAX case
+      console.debug('Current ActionId = ' + Transport.currentActionId + ' action= ' + actionId);
+      if (actionId && Transport.currentActionId === actionId) {
+        console.info('Ignoring request');
+        // If actionId equals currentActionId assume double request: do nothing
+        return false;
+      }
+      index = Transport.requests.push(req);
+      //console.debug('index = ' + index)
+      Transport.currentActionId = actionId;
+    } else {
+      console.debug("else case");
+      return false;
+    }
+    console.debug('index = ' + index);
+    if (index === 1) {
+      console.info('Execute request!');
+      Transport.startTime = new Date();
+      Transport.requests[0]();
+    } else {
+      console.info('Request queued!');
+    }
+    return true;
+  };
+
+
+// TBD XXX REMOVE is this called in non AJAX case?
+
+  static requestComplete = function () {
+    Transport.requests.shift();
+    Transport.currentActionId = null;
+    console.debug('Request complete! Duration: ' + (new Date().getTime() - Transport.startTime.getTime())
+ 'ms; '
+        + 'Queue size : ' + Transport.requests.length);
+    if (Transport.requests.length > 0) {
+      console.debug('Execute request!');
+      Transport.startTime = new Date();
+      Transport.requests[0]();
+    }
+  };
+}
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-core.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-core.ts
index a1a235b..6feff42 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-core.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-core.ts
@@ -18,6 +18,7 @@
 import {Listener, Phase, Order} from "./tobago-listener";
 import {Overlay} from "./tobago-overlay";
 import {DomUtils, Tobago4Utils} from "./tobago-utils";
+import {Command} from "./tobago-command";
 
 export class Tobago {
   /**
@@ -37,14 +38,6 @@ export class Tobago4 {
 
   // -------- Variables -------------------------------------------------------
 
-  /**
-   * The html form object of current page.
-   * set via init function
-   */
-  static form = null;
-
-  static isSubmit = false;
-
   static initMarker = false;
 
   // -------- Functions -------------------------------------------------------
@@ -63,7 +56,7 @@ export class Tobago4 {
 
     console.time("[tobago] init");
 
-    document.querySelector("form").addEventListener('submit', Tobago4.onSubmit);
+    document.querySelector("form").addEventListener('submit', Command.onSubmit);
 
     window.addEventListener('unload', Tobago4.onUnload);
 
@@ -82,35 +75,6 @@ export class Tobago4 {
     console.timeEnd("[tobago] init");
   };
 
-  static onSubmit = function (listenerOptions) {
-    Listener.executeBeforeSubmit();
-    /*
-    XXX check if we need the return false case
-    XXX maybe we cancel the submit, but we continue the rest?
-    XXX should the other phases also have this feature?
-
-        var result = true; // Do not continue if any function returns false
-        for (var order = 0; order < Listeners.beforeSubmit.length; order++) {
-          var list = Listeners.beforeSubmit[order];
-          for (var i = 0; i < list.length; i++) {
-            result = list[i](listenerOptions);
-            if (result === false) {
-              break;
-            }
-          }
-        }
-        if (result === false) {
-          this.isSubmit = false;
-          return false;
-        }
-    */
-    Tobago4.isSubmit = true;
-
-    Tobago4.onBeforeUnload();
-
-    return true;
-  };
-
   static onBeforeUnload = function () {
     if (this.transition) {
       new Overlay(DomUtils.page());
@@ -125,83 +89,11 @@ export class Tobago4 {
 
     console.info('on onload');
 
-    if (Tobago4.isSubmit) {
+    if (Command.isSubmit) {
       Listener.executeBeforeUnload();
     } else {
       Listener.executeBeforeExit();
     }
-    /*
-        var phase = this.isSubmit ? Listeners.beforeUnload : Listeners.beforeExit;
-
-        for (var order = 0; order < phase.length; order++) {
-          var list = phase[order];
-          for (var i = 0; i < list.length; i++) {
-            list[i]();
-          }
-        }
-        */
-  };
-
-  /**
-   * Submitting the page with specified actionId.
-   * options.transition
-   * options.target
-   */
-  static submitAction = function (source, actionId, options?) {
-    options = options || {};
-
-    var transition = options.transition === undefined || options.transition == null || options.transition;
-
-    Transport.request(function () {
-      if (!Tobago4.isSubmit) {
-        Tobago4.isSubmit = true;
-        const form = document.getElementsByTagName("form")[0] as HTMLFormElement;
-        var oldTarget = form.getAttribute("target");
-        var $sourceHidden = jQuery(DomUtils.escapeClientId("javax.faces.source"));
-        $sourceHidden.prop("disabled", false);
-        $sourceHidden.val(actionId);
-        if (options.target) {
-          form.setAttribute("target", options.target);
-        }
-        this.oldTransition = this.transition;
-        this.transition = transition && !options.target;
-
-        var listenerOptions = {
-          source: source,
-          actionId: actionId,
-          options: options
-        };
-        var onSubmitResult = Tobago4.onSubmit(listenerOptions);
-        if (onSubmitResult) {
-          try {
-            form.submit();
-            // reset the source field after submit, to be prepared for possible next AJAX
with transition=false
-            $sourceHidden.prop("disabled", true);
-            $sourceHidden.val();
-          } catch (e) {
-            Overlay.destroy(DomUtils.page().id);
-            Tobago4.isSubmit = false;
-            alert('Submit failed: ' + e); // XXX localization, better error handling
-          }
-        }
-        if (options.target) {
-          if (oldTarget) {
-            form.setAttribute("target", oldTarget);
-          } else {
-            form.removeAttribute("target");
-          }
-        }
-        if (options.target || !transition || !onSubmitResult) {
-          Tobago4.isSubmit = false;
-          Transport.pageSubmitted = false;
-        }
-      }
-      if (!Tobago4.isSubmit) {
-        Transport.requestComplete(); // remove this from queue
-      }
-
-
-    }, true);
   };
 
   static initDom = function (elements) {
@@ -265,59 +157,3 @@ window.addEventListener("load", function () {
 // e. g. selectOne in a toolBar).
 Listener.register(Tobago4.initDom, Phase.DOCUMENT_READY, Order.LATER);
 Listener.register(Tobago4.initDom, Phase.AFTER_UPDATE, Order.LATER);
-
-class Transport {
-  static requests = [];
-  static currentActionId = null;
-  static pageSubmitted = false;
-  static startTime: Date;
-
-  /**
-   * @return true if the request is queued.
-   */
-  static request = function (req, submitPage, actionId?) {
-    var index = 0;
-    if (submitPage) {
-      Transport.pageSubmitted = true;
-      index = Transport.requests.push(req);
-      //console.debug('index = ' + index)
-    } else if (!Transport.pageSubmitted) { // AJAX case
-      console.debug('Current ActionId = ' + Transport.currentActionId + ' action= ' + actionId);
-      if (actionId && Transport.currentActionId === actionId) {
-        console.info('Ignoring request');
-        // If actionId equals currentActionId assume double request: do nothing
-        return false;
-      }
-      index = Transport.requests.push(req);
-      //console.debug('index = ' + index)
-      Transport.currentActionId = actionId;
-    } else {
-      console.debug("else case");
-      return false;
-    }
-    console.debug('index = ' + index);
-    if (index === 1) {
-      console.info('Execute request!');
-      Transport.startTime = new Date();
-      Transport.requests[0]();
-    } else {
-      console.info('Request queued!');
-    }
-    return true;
-  };
-
-
-// TBD XXX REMOVE is this called in non AJAX case?
-
-  static requestComplete = function () {
-    Transport.requests.shift();
-    Transport.currentActionId = null;
-    console.debug('Request complete! Duration: ' + (new Date().getTime() - Transport.startTime.getTime())
+ 'ms; '
-        + 'Queue size : ' + Transport.requests.length);
-    if (Transport.requests.length > 0) {
-      console.debug('Execute request!');
-      Transport.startTime = new Date();
-      Transport.requests[0]();
-    }
-  };
-}
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-sheet.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-sheet.ts
index 576caa4..f20dac6 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-sheet.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-sheet.ts
@@ -18,6 +18,7 @@
 import {Listener, Phase} from "./tobago-listener";
 import {DomUtils} from "./tobago-utils";
 import {Tobago4} from "./tobago-core";
+import {Command} from "./tobago-command";
 
 class Sheet {
 
@@ -436,7 +437,7 @@ class Sheet {
                 render: clickRenderIds
               });
         } else {
-          Tobago4.submitAction(row, action);
+          Command.submitAction(row, action);
         }
       }
     }
@@ -536,7 +537,7 @@ class Sheet {
               render: this.dblClickReloadComponentId
             });
       } else {
-        Tobago4.submitAction(row, action);
+        Command.submitAction(row, action);
       }
     }
   }
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-tab.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-tab.ts
index 73032d1..cb6518e 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-tab.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-tab.ts
@@ -20,7 +20,7 @@ import {DomUtils} from "./tobago-utils";
 
 /**
  * Initializes the tab-groups.
- * @param elements  a jQuery object to initialize (ajax) or null for initializing the whole
document (full load).
+ * @param element
  */
 class TabGroup {
   static init = function (element: HTMLElement) {


Mime
View raw message