QADAdvancedTS March2023 Day 1
QADAdvancedTS March2023 Day 1
Training Agenda
Maint Handler ViewForm Handler Grid Handler
Training Agenda
Server-side TypeScript
• common workflow
• validations and
errors
• browse API
• DO
• disallowed messages
and actions
What we will do
• We will check each TS handler and review
which needs it could cover
• We will implement part of “real”
requirements according to current topic
• We will review API which was used during
implementation
QAD Enterprise Platform March 2023
Event Handler is
TypeScript code which
is compiled into
JavaScript and is saved
to the database so
that it can be executed
on the front-end side
for the corresponding
UI of the business
component.
9
QAD Enterprise Platform
What is Server-side TS?
Server-side TS is
TypeScript code which
is deployed to the
environment and
extends or overrides
CRUD methods for the
corresponding business
component. It will be
executed on the back-
end side.
10
QAD Enterprise Platform
There are three types of Event Handlers
• Primary – primary event handler for corresponding
business component. Can be created only for
platform BC and has the same purpose as a TS
handler for coded BC.
• Pre – runs before Primary or coded event handler.
• Post – runs after Primary or coded event handler.
11
QAD Enterprise Platform
Maint handler:
Event handler class structure This is the main
event handler
which is reacting on
page lifecycle
events. This type is
always needed as a
starting point for
event handlers.
12
QAD Enterprise Platform
ViewForm handler:
Event handler class structure This is an event
handler that can
act on all UI events
related to form
elements (such as
labels, input fields,
group panels,
buttons)
13
QAD Enterprise Platform
Event handler class structure
ViewGrid handler:
This type of event
handler handles
events coming from
grids.
14
QAD Enterprise Platform
Base Classes
• QraViewTSHandlerWithViewFormTSHandler: This is
a class that can be used to easily develop a view event
handlers and easily connect to a view form event
handler. This class is auto-generated for event handlers.
• QraViewFormTSHandlerV2: Class that can be used to
develop a view form event handlers. This class is also
auto-generated for event handlers.
• ViewGridTSHandler: Class that can be used to
develop a view grid event handler. Each grid on the form
needs to have its own event handler.
15
Maint Event Handler
QAD Enterprise Platform March 2023
Topics
Maint Handler
• common workflow
• actions
• confirmation dialogs
Before we start …
Navigate to the My
Development Settings
screen.
Set conference-app as
a default development
App.
QAD Enterprise Platform March 2023
Before we start …
Navigate to the
Business Components
screen.
Find Speakers.
Do next:
1 Scroll to Form panel
2 Click New in Event
Handlers grid
QAD Enterprise Platform March 2023
Before we start …
In the opened modal
dialog, check Active
checkbox.
QAD Enterprise Platform March 2023
Before we start …
Pay attention on the code
which generated by
default.
Here you can find:
Imports
Implementation of the
QraViewTSHandlerWithVi
ewFormTSHandler class
Implementation of the
QraViewFormTSHandlerV
2 class
Common Workflow
QAD Enterprise Platform March 2023
Common workflow
We will explore:
onBindData (eventData) Called when the view screen binds new data to its model/fields. Fired
after the new data is bound.
onBeforeUpdate (eventData) Called before an update submit is attempted (for either a create or
update operation).
onAfterUpdate (eventData) Called after an update submit has finished, whether the update
succeeded or not. Fired after data binding in the view.
onAfterDelete (eventData) Called after a delete submit has finished, whether the delete succeeded
or not. Fired after data binding in the view.
onActionChange (eventData) Called when the view switches from "CREATE" to "UPDATE" or
"UPDATE" to "CREATE" or when the first view comes up. For example,
when the "New" button is clicked the action switches to "CREATE" or
after "Save" is clicked on a "New" record the action switches to
"UPDATE".
QAD Enterprise Platform March 2023
onBeforeInit (eventData) Called before the initialize url is called when "New" is clicked.
onAfterInit (eventData) Called after the initialize url call has been made when "New" is clicked.
You can find more information in the Event handlers API reference documentation
QAD Enterprise Platform March 2023
Common workflow
We will explore:
SummaryPanel
All new records should have
Draft status by default
QAD Enterprise Platform March 2023
Testing
Compile the code and
Save changes.
QAD Enterprise Platform March 2023
Testing
Navigate to the
Speakers screen
enum SpeakerConstants
Useful and correct way to define literal variables.
NgData
The property for referencing a JSON object which is bound to the
view (a model part of the MVC).
35
QAD Enterprise Platform
What’s happening there
this.$scope.screenState
Property which store saving status of the current record:
0 for unsaved records, 1 – for saved.
eventData.action
Property of evenData object (input parameter of onBindData
event) which contain information about status of selected
record: “CREATE” if records is new and “UPDATE” if existing
record
⚠
was selected.
Pay attention that action will not be changed immediately after saving.
Value will be set to “UPDATE” only after next selection of record.
36
QAD Enterprise Platform March 2023
Common workflow
We will explore:
Main Panel
For all existing records, an
accumulated Person information
(Name, Country, Email, Company)
should be displayed under the ID
field
QAD Enterprise Platform March 2023
Testing
Compile the code and
Save changes.
QAD Enterprise Platform March 2023
Testing
Navigate to the
Speakers screen.
getPersonInfo()
Own private method for separate peace of logic.
DTO.Speakers
Type definition for model part of the MVC and, as a result, is a
type of a JSON object which is stored in the NgData property.
43
Fields, Panels, Toolbars
QAD Enterprise Platform March 2023
• How to add button into toolbar or hide new, edit, delete buttons
QAD Enterprise Platform March 2023
Main Panel
Get ID button should be QAD Employee Panel
enabled only during record
creation QAD User ID field and Load
Details button should be
disabled after the record
Main Panel saving
Registration fields (Name,
Country, Email, Employment
Type) should be hidden after
the record saving
46
QAD Enterprise Platform March 2023
⚠
How to enable/disable field or buttonBy default, Platform
generates similar enum
with control names:
Constants
It contains two
subcollections
ButtonNames and
FieldNames Current
training ignores it
intentionally, but do not
reject it without special
needs.
Create a set of
constants specially
for Registration fields
Time to use
toggleRegistrationFieldsVisibility
method
QAD Enterprise Platform
⚠
Notes: Please pay attention, that form
control could be hidden by
security configurations or via
There are two ways to enable/disable or hide/show controls on the form.
design layout. In this case call of
- First way is to call global functions: setControlDisabled() and setControlVisible().
this.ViewController.getViewField
- Second way is to call appropriate properties of ViewField
or or ViewButton objects.
this.ViewController.getViewButto
n
As a result, next two pieces of code will have the same effect:
will return undefined and
setControlDisabled(buttonName, this.$element, attempt isDisabled);
to access IsVisible or
and IsDisabled will lead to error.
this.ViewController.getViewButton(buttonName).IsDisabled = isDisabled;
On the other hand, IsVisible and
IsDisable allow not only set
Same for two next pieces: value, but also read it.
setControlVisible(fieldName, this.$element, isVisible);
and
this.ViewController.getViewField(fieldName).IsVisible = isVisible;
52
QAD Enterprise Platform March 2023
Define appropriate
constant for QADUserID
field
QAD Enterprise Platform March 2023
Use toggleQADEmployeeFieldsDisabling
method
QAD Enterprise Platform March 2023
Testing
Compile code and
save it.
Navigate to the
Speakers screen and
click New
Testing
Then select any
existing record.
setControlVisible()
Method which could hide/show view form control (field, button,
link).
Constants
Enum which is automatically generated by the system and contains
two sub collections with names of fields and buttons on the form.
57
QAD Enterprise Platform
What’s happening there
this.ViewController
That ViewController property is an interface with a lot of methods to
manipulate the view and to call other systems via http calls. Also contains
such methods as getViewGrid(), getViewButton(), getViewField(), etc.
ViewController API reference
58
QAD Enterprise Platform March 2023
• How to add button into toolbar or hide new, edit, delete buttons
QAD Enterprise Platform March 2023
Company Panel
SummaryPanel
This panel should be hidden
if Employment Type is QAD Company field should be
Employee hidden if Employment Type
is Self-Employed
This panel should be
disabled if Employment Type QAD Employee Panel
is Self-Employed This panel should be hidden
if Employment Type is not
QAD Employee
60
QAD Enterprise Platform March 2023
Extend toggleEmployeePanels
method with logic for Company
panel disabling
QAD Enterprise Platform March 2023
Testing
Compile code and
save it.
Navigate to the
Speakers screen and
create test records
with different
Employment Types.
Testing
Next select a record
with Subcontractor
Employment type and
verify that Company
panel now is displayed,
but this time a QAD
Employee panel is
hidden.
Pay attention:
Company field in
SummaryPanel is still
present.
QAD Enterprise Platform March 2023
Testing
Finally, select a record
with Employment type
Self-employed and
verify that Company
panel is still present,
but disabled, and QAD
Employee panel is still
hidden.
69
QAD Enterprise Platform March 2023
• How to add button into toolbar or hide new, edit, delete buttons
QAD Enterprise Platform March 2023
Top Toolbar
New and Delete buttons
should be hidden if record
was opened from Verification Bottom Toolbar
screen
Confirm Verification and
Delete button should be Reject Verification buttons
hidden if Verification status is should be displayed instead of
“Under Verification” Save and Cancel if record
was opened from Verification
screen
Verify Person button should
be added into bottom toolbar
Verify Person button should
be disabled for new records
and if record in status “Under
Verification” or “Verified”
QAD Enterprise Platform March 2023
Testing
Compile code and
save it.
Navigate to the
Speakers
Put call of
replaceSaveAndCloseButto
ns() into the
onAfterBindData event.
QAD Enterprise Platform March 2023
Testing
Compile code and
save it.
Navigate to the
Speakers
Testing
Compile code and
save it.
Navigate to the
Speakers
Testing
Modify Verification
Status of any record
(set it to Under
Verification)
Select modified
record.
BottomToolbar.addButton
Method which add button to the bottom toolbar.
If isSubmitButton option is set to true, button will submit form.
88