rendering ...

Overview

The appname.js file is the file that contains the Javascript code that supports the matching appname-html file. By convention it is uses the same name as the appname.html file with a replacement of the extension with .js.

Samples include the Deps.js and Chqs.js in the Apps and tutorial examples. The samples are documented and can be used to create new appname.js files.

The following major sections are found in the appname.js file:

ctrlMain function

The ctrlMain function is called by the AngularJS infrastructure because it is the ng-controller specified on the <body> statement of the appname.html file.

Here is a sample of the beginning of the ctrlMain function taken from Deps.js.

function ctrlMain($scope,servSess,servGAE,tblDEP,tblENV,tblDON,servCRUD,servREG) {
  log("Created ctrlMain for deps application");
  servGAE.setCust("deps");
  servSess.setTitle("Deposit Recording System");
  var oOpts = [{menu:"Admin Functions",func:xfrAdminFunctions,role:'admin'},{menu:"Deposit Summaries",func:printDepSum,role:'elder',sandbox:true}];
  servSess.setOptMenuItems(oOpts);

  function xfrAdminFunctions() {
    servSess.xfrAdminApp("deps",["TableDonors"]);
  }
  ...

It contains the following components.

  1. Line 1, the function statement references, beside the Triangular services such as servSess, the Tables that should be accessible to the application.

  2. Line 3, initialization code that defines the customer (see servGAE.setCust)

  3. Line 4, initialization code that defines the application title (see servSess.setTitle)

  4. lines 4 & 5, initialization code that defines the optional menu items (see servSess.setOptMenuItems)

  5. line 8, the local function referenced in line 5 that defines how to transfer to the Admin app.

  6. An optional logonExit that modifies the optional menu items depending on the role or profile of the User that logged on. See Chq.js as an example.

  7. Any functions required to support the optional menu items

  8. Any functions that extend the standard Edit Controller or List Controller. Note that the sample Deps.js code does extend the Edit Controller but has no additional functions as they were found useful and moved to the standard Edit Controller.

Table definition(s)

The table defintition(s) can be defined in an external .js file or here. By convention at least the primary 'Table` definition is coded here. External definitions have the advantage that they can be used in more than 1 application (such as the Admin Application where updates to certain tables can be limited to the system administrator).

The Table defintion syntax is extensive and defined in Table (static version).