Javascript Notes
Contents
Use of Javascript
Javascript is currently used to:
- In most display and data entry blocks: Open/close tables (the toggles)
- Drawing new/update: Manage the drawing code entry (syncronize the drawing horizontal vs. vertical code fields)
- Revision new/update: Manage the revision code entry (syncronize the drawing horizontal vs. vertical code fields)
- On change in the document (and comment) input forms
- Set focus (set for certain inputs form, mainly in the login form)
To manage the hiding/display of cascading selects in V12.x. See: MultiClassification
In revision new/update: to manage entry of approval/release comments (See below: Managing Approval/Release Comment Fields)
- Informing the server if the client has Javascript enabled
Issues
- Our Javascript currently assumes a single form on a page, this could cause problems if we want to have a search box in our page header.
- - See app/js/drawmgt.js, search for forms[0]
- We should add names for our forms
Managing Approval/Release Comment Fields
This applies to approval and release work flow steps for revisions. It is implemented for the new/update input forms.
Javascript Functionality
When the status Approved with Corrections (C) or Rejected (R) is selected, then the corresponding comment field should be displayed. When any other status value is selected then the display of the comment field is suppressed.
When the status Not Required (N) is selected, then the corresponding initials field should be set to -select-.
Other Supporting Functionality
- Values for the initials/status/comment fields are checked by app/config/Setting-Validations.php
Display of comment fields (in the revision detail) only occurs when the comment field contains text. This is handled by an if statement in the smart template.
Field Naming
The following fields are defined in the Revisions table:
Initials Field
Status Field
Comment Field
approver1Id
approval1StatusId
approval1Comment
approver2Id
approval2StatusId
approval2Comment
approver3Id
approval3StatusId
approval3Comment
approver4Id
approval4StatusId
approval4Comment
releaserId
releaseStatusId
releaseComment
The fields are also present in the Comments table, but the workflow templates that would display these fields have not yet been implemented.
Javascript Implementation
app/tran/draw/rnew/RevisionNewFormBT calls RevisionForm:
$form->displayJavascriptInclude() -- Emits an include statements to read doStatusChange.js
$form->displayJavasScriptOnload() -- Emits a Javascript window.onload call and an initialization function, which calls doStatusChange for each status field.
app/form/RevisionForm.php performs the following processing:
For each statusId field, it generates on onchange tag which calls the Javascript function doStatusChange.
doStatusChange is defined in the file app/js/doStatusChange.js. It does the following:
- show/hide the comment field based on the statusId
- show/hide the planDate, completeDate and initials fields based on the statusId
- clears fields which are hidden
The onload function calls doStatusChange for each statusId field.