Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html

TypeScript Configuration

The TypeScript configuration 

The CLAPI TypeScript configuration file should be in the application CLientLogic/ directory, for example: sports-webui/ClientLogic/tsconfig.json

Note that you do not need to be familiar 

For 

For a list of tsconfig.json compiler options see the link below

https://www.typescriptlang.org/docs/handbook/compiler-options.html

Visual Studio Code

In the following examples we will be using Visual Studio Code.

...

https://code.visualstudio.com/docs/getstarted/introvideos

TSLint

 

Migrating to the CLAPI

In the following example we will migrate a function to the CLAPI. The function gets the foreign keys (or initial field values) when launching a window to create a new record.

...

Open the /sports-webui/ClientLogic/ folder in VS Code. Open Order/getOrderForeignKeys.js from the Explorer view (see picture below).

  1. Start by renaming (F2) the file to getOrderForeignKeys.ts using the .ts TypeScript file extension.

    Now that the file is saved as a TypeScript file, you can 

  2. Replace 

    if (akioma.samples)
    akioma.samples = {};
    akioma.samples.getOrderForeignKeys = function(self) {

    With

    namespace akioma.samples {
        export function getOrderForeignKeys(self) { 

    Use namespaces to avoid naming conflicts. Note that functions must be exported to be used outside the namespace (namespaces are compiled into closures).

  3. Replace self with eventSource: akioma.swat.SwatObject.

    Note that the function parameter name does not have to be eventSource. For example: eventGrid eventForm, eventRibbon etc. Although self might be confusing with the JavaScript dynObject.

    Note that the function parameter type does not have to be the generic base SwatObject as in this case. Use the correct Object Type class to avoid casting.

  4. Replace getObject("CustomerDetailsForm") with getForm("CustomerDetailsForm")getObject("CustomerGrid") with getGrid("CustomerGrid") and container with window.

    The CLAPI supports generic traversing functions like getObject(), getLink() etc. which return the generic base SwatObject class object.

    The CLAPI also supports type specific function like getForm(), getGrid(), getRibbon() etc. to avoid casting.

    Alternatively you can use TypeScript casting. For example: (eventSource.getObject("MyForm") as akioma.swat.Form).

  5. Replace getValue with getDataValue.

    The Form and Grid classes have both a getScreenValue() and getDataValue() functions for getting the field screen value or record value respectively.
    Save
  6. Remember to save (Ctrl-S) and rename (F2) the file as Order/getOrderForeignKeys.ts using the .ts TypeScript file extension (see picture below)your work.

Documentation

In addition to the intellisense of the class methods, properties and their explanations

...