Engine

Simplicite.UI. Engine

new Engine()

Description:
  • Main UI Controller with abstract view to display components.

    • Controller implements the UI logic with interactions between components (list, form, menu...) and the data (ajax).
    • It does not contain UI drawing and must load the view service to display controls.
    • Each View engine implements the UI interfaces (without data access) and interacts with the controller (to access to data).

Members

app

Description:
  • Ajax session

Ajax session

grant

Description:
  • User rights

User rights

Description:
  • Main navigation

Main navigation

options

Description:
  • global options: merge of the launch parameters with Simplicite.UI.Globals

global options: merge of the launch parameters with Simplicite.UI.Globals

view

Description:
  • View: main renderer

View: main renderer

Methods

addLocalLogin(g)

Description:
  • Add the connected login to local storage

Parameters:
Name Type Description
g Object

grant

applyConstraints(ctn, obj, elt, index, context, cbk)

Description:
  • Apply constraints

Parameters:
Name Type Description
ctn jQuery

Container

obj Simplicite.Ajax.BusinessObject

Object

elt string

Optional DOM element (input, select, textarea) with data {field, index}

index string

Optional editlist line index (row Id or creation index 00 01...)

context number

Optional context (default Simplicite.CONTEXT_UPDATE)

cbk function

Optional callback

bind(name, fn)

Description:
  • Bind one UI action with implementation

Parameters:
Name Type Description
name string

action name

fn function

handler

bindChange(ctn, obj, selector)

Description:
  • Attach change event to fields

    • set the hasChanged on object
    • apply related constraints
    • exclude elements with class js-ignore-haschanged
Parameters:
Name Type Description
ctn jQuery

Container of inputs, selects and textareas

obj Simplicite.Ajax.BusinessObject | Simplicite.Ajax.BusinessProcess

Object or Process

selector string

Optional selector (default: input, select and textarea)

bindEnabled(name, enable)

Description:
  • Enable action binding

Parameters:
Name Type Description
name string

Action name

enable boolean

True to activate / false to disable binding

bindGenericActions()

Description:
  • Bind generic actions (create, copy, delete...)

bindSaveAndQuit(ctn, obj, save)

Description:
  • Manage the save and close when fields have changed

Parameters:
Name Type Description
ctn jQuery

Container

obj Simplicite.Ajax.BusinessObject | Simplicite.Ajax.BusinessProcess

Object or Process

save function

Save handler

canCloseContent(ctn, cbk)

Description:
  • Checks if the content can close

Parameters:
Name Type Description
ctn jQuery

Container

cbk function

Callback if the content can close

changeLang(lang, pref)

Description:
  • Change user's language on server side and reload the page

Parameters:
Name Type Description
lang string

Language FRA, ENU...

pref boolean

true to update also the preferred language

clickDocument(doc)

Description:
  • Click on a document: open the document

Parameters:
Name Type Description
doc Object

Document data

Properties
Name Type Description
object Object

Object name

field Object

Document field name

rowId Object

Row ID

docId Object

Document ID

name Object

Document name

clickImage(doc)

Description:
  • Click on image: default open a dialog with the image

Parameters:
Name Type Description
doc Object

Image data

Properties
Name Type Description
object Object

Object name

field Object

Document field name

rowId Object

Row ID

docId Object

Image ID

name Object

Image name

clickMenu(item)

Description:
  • Main menu handler

Parameters:
Name Type Description
item Object

Menu item

Properties
Name Type Description
label string

Displayed label

object string

Optional object name

field string

Optional enum field

code string

Optional enum filter (or status)

search string

Optional search mode: list, dock or dialog

workflow string

Optional screenflow name

process string

Optional process name

step string

Optional step filter

bam string

Optional object name for metrics view

tray string

Optional object name for trays view

domain string

Optional domain home

view string

Optional view name

href string

Optional URL

target string

Optional href target

clickShortcut(item)

Description:
  • Shortcut handler

Parameters:
Name Type Description
item

Item { name, url, target, label }

closeForm(ctn)

Description:
  • Close the object form: default going back in navigation

Parameters:
Name Type Description
ctn jQuery

Container

contentClose(ctn, cbk)

Description:
  • Force to close a content and destroy components

Parameters:
Name Type Description
ctn jQuery

Container

cbk function

Callback when done

contentLoaded(ctn, onload, onunload, params)

Description:
  • Prepare content handlers

Parameters:
Name Type Description
ctn jQuery

Container

onload function

Optional load handler

onunload function

Optional unload handler

params Object

Optional context parameters (workflow)

contentUnload(ctn, cbk)

Description:
  • Unload the container = destroy embedded components (editors...)

Parameters:
Name Type Description
ctn jQuery

Container

cbk function

Callback when done

countList(ctn, obj, options, cbk)

Description:
  • Count rows with context and filters

Parameters:
Name Type Description
ctn string | jQuery

Container

obj string | Simplicite.Ajax.BusinessObject

Name or Business Object

options Simplicite.UI.Globals.list

Options to override Globals

cbk function

Optional callback(obj) to read obj.count

countReference(obj, parent, cbk)

Description:
  • Count references of a parent object in PANELLIST context

Parameters:
Name Type Description
obj string

Referenced object name or business object

parent Object

Specify the parent object and the foreign-key { name, inst, field, rowId }

cbk function

Callback(obj, count)

doAction(a, obj, rowId)

Description:
  • Execute one action

Parameters:
Name Type Description
a Object

Action metadata

obj Simplicite.Ajax.BusinessObject

Business object

rowId string

Optional object row ID on form/row

doActionCustom(a, obj, rowId, values, cbk)

Description:
  • Execute a custom/backend action (object.action call) after saving the form

Parameters:
Name Type Description
a Object

Action metadata

obj Simplicite.Ajax.BusinessObject

Business object

rowId string

Optional object row ID on form/row

values Object

Optional confirm field values

cbk function

Optional callback(msg)

doActionGeneric(a, obj, rowId)

Description:
  • Execute a generic/UI action (all binded implementations)

Parameters:
Name Type Description
a Object

Action metadata

obj Simplicite.Ajax.BusinessObject

Business object

rowId string

Optional object row ID on form/row

doActionModel()

Description:
  • Wrap "open model" actions

doActionURL(a, obj, rowId)

Description:
  • Wrap a backend URL action to front

Parameters:
Name Type Description
a Object

Action metadata

obj Simplicite.Ajax.BusinessObject

Business object

rowId string

Optional object row ID on form/row

getAjax()

Description:
  • Current ajax session (deprecated use getApp)

Deprecated:
  • Yes
Returns:

Simplicite.Ajax instance

getApp()

Description:
  • Current ajax session

Returns:

Simplicite.Ajax instance

getGrant()

Description:
  • Get user rights

getLocalLogins()

Description:
  • All logins from local storage

getNav(c)

Description:
  • Get container navigator, default returns the main navigation of #work area

Parameters:
Name Type Description
c string | jQuery

Component or selector

Returns:

Simplicite.UI.Navigator instance

getNavContainer(c)

Description:
  • Find the closest container with a navigator

Parameters:
Name Type Description
c string | jQuery

component

getUIAction(ctn, obj, action)

Description:
  • Gets the action with UIAction interface

Parameters:
Name Type Description
ctn string | jQuery

Container

obj Simplicite.Ajax.BusinessObject

Object

action Object

Action metadata or name

getUIArea(ctn, obj, area)

Description:
  • Gets the area with UIArea interface

Parameters:
Name Type Description
ctn string | jQuery

Container

obj Simplicite.Ajax.BusinessObject

Object

area Object

Area metadata or name or position

getUIField(ctn, obj, field, index, silent)

Description:
  • Gets the field extended with the UIField interface

Parameters:
Name Type Description
ctn string | jQuery

Container

obj Simplicite.Ajax.BusinessObject

Object

field string | Simplicite.Ajax.ObjectField

Object field or name

index string

Optional for multiple inputs of the same field (edit list)

silent boolean

No trace when field is unknown

getUIView(ctn, obj, view)

Description:
  • Gets the view with UIView interface

Parameters:
Name Type Description
ctn string | jQuery

Container

obj Simplicite.Ajax.BusinessObject

Optional object

view Object

View metadata or name

isActionBinded(a)

Description:
  • Is action binded ?

Parameters:
Name Type Description
a Object

Action metadata

Returns:

True if the action is binded

isBinded(name)

Description:
  • Is UI action binded and enabled ?

Parameters:
Name Type Description
name string

Action name

Returns:

True if the action is enabled

keepAlive(enable, obj, id)

Description:
  • Keep the session alive during data updates (used by form and edit list) and refresh object usage by other people

Parameters:
Name Type Description
enable boolean

true to start the timer, false to stop

obj string

optional object name to get usage

id string

optional rowId

linkedLists(ctn, obj, field, code, index, cbk, all)

Description:
  • Reload the linked lists of an enum field

Parameters:
Name Type Description
ctn string | jQuery

Container

obj Simplicite.Ajax.BusinessObject

Object

field Simplicite.Ajax.ObjectField

Enum field

code string | Array

Selected value(s)

index string

Edit list index

cbk function

Callback function(target) to rebuild each target field with the new listOfValues

all boolean

Get all values when code is empty (case of a search field)

onFollow(method, param, cbk)

Description:
  • Follow service wrapper

Parameters:
Name Type Description
method string

Method name

param string

Mmethod param

cbk function

Optional callback

openObject(ctn, obj, rowId, params)

Description:
  • Open handler (on a list row or summary): default switch to open object form, reference, doc or image

Parameters:
Name Type Description
ctn string | jQuery

Container

obj Simplicite.Ajax.BusinessObject | String

Target object or name

rowId string

Target row ID

params Object

Optional parameters

Properties
Name Type Description
object Simplicite.Ajax.BusinessObject

Source object

inst string

Instance name

rowId string

Source row ID

ref string

Reference object name

refId string

With the reference row ID

field string

Or the doc/image field name

docId string

With the document ID

imageId string

Or the image ID

preview boolean

Preview document?

populateAction(ctn, obj, refField, refId, action, cbk)

Description:
  • Populate the referenced fields of action

Parameters:
Name Type Description
ctn string | jQuery

Container

obj Simplicite.Ajax.BusinessObject

Object

refField string

Foreign key field

refId string

Reference row ID, or null to reset referenced fields

action Object

Current action on object

cbk function

Optional callback

populateReference(ctn, obj, refField, refId, index, cbk, noChange, userKey)

Description:
  • Populate the referenced fields

Parameters:
Name Type Description
ctn string | jQuery

Container

obj Simplicite.Ajax.BusinessObject

Object

refField string

Foreign key field

refId string

Reference row ID, or null to reset referenced fields

index string

Optional row index (edit list)

cbk function

Optional callback

noChange boolean

Optional to bypass change events on each fields

userKey boolean

Optional to get foreign user-key

previewDocument(doc, embedded)

Description:
  • Preview a document: default open a dialog with the preview

Parameters:
Name Type Description
doc Object

Document data

Properties
Name Type Description
object Object

Object name

field Object

Document field name

rowId Object

Row ID

docId Object

Document ID

name Object

Document name

embedded boolean

Embedded or dialog

readForm(ctn, obj, index)

Description:
  • Read all form fields into object fields (async/file reading)

Parameters:
Name Type Description
ctn string | jQuery

Container to find fields

obj Simplicite.Ajax.BusinessObject

Business object

index string

Optional index (list edit)

Returns:

Promise

reloadForm(ctn)

Description:
  • Reload the object form: default reload navigation

Parameters:
Name Type Description
ctn jQuery

Container

removeLocalLogin(login)

Description:
  • Remove a login from local storage

Parameters:
Name Type Description
login string

remove all logins if null

saveForm(ctn, obj, params)

Description:
  • Save the object form

Parameters:
Name Type Description
ctn jQuery

Container

obj Simplicite.Ajax.BusinessObject

Business object

params Object

Optional parameters (parent)

Returns:

Promise with messages or catch errors

saveList(ctn, obj, params)

Description:
  • Save the object list

Parameters:
Name Type Description
ctn jQuery

List container

obj Simplicite.Ajax.BusinessObject

Business object

params Object

Optional parameters (parent)

Returns:

Promise with optional results { messages, errors }

saveObject(ctn, obj, index, params)

Description:
  • Save the object after reading UI values

Parameters:
Name Type Description
ctn jQuery

Container

obj Simplicite.Ajax.BusinessObject

Business object

index string

Optional index/row ID in list

params Object

Optional parameters (parent, inline)

Returns:

Promise with messages or errors

setApp()

Description:
  • Set ajax session

setCompletionMinSize(size)

Description:
  • Completion minimum size to trigger the search

Parameters:
Name Type Description
size number

Positive number (0 = disable)

setGrant()

Description:
  • Set user rights

setNav()

Description:
  • Set main navigation

setView()

Description:
  • Set the View engine

speechAssist(options, cbk)

Description:
  • Speech assistant (experimental)

Parameters:
Name Type Description
options Object

Options

Properties
Name Type Description
hotword string

optional hotword to detect commands (supports translated TEXT)

commands Array.<Object>

optional commands { name, priority, phrase, callback, regexp }

continuous boolean

continuous speaking? (default true to accept sentences)

autoRestart boolean

auto restart the recognition? (default true to accept long silence)

maxAlternatives number

max recognition alternatives (default 10)

lang string

optional lang (default user's language)

debug boolean

optional console info

cbk function

Callback(assist)

speechRecognition(el, options)

Description:
  • Speech recognition

Parameters:
Name Type Description
el Object

Element input or textarea

options Object

Options

Properties
Name Type Description
lang string

Language (ex: FRA, ENU or fr-FR, en-GB...)

continuous boolean

Continuous speaking (sentence)?

autoRestart boolean

Continuous speaking (no timeout after long silence)?

interimResults boolean

Get interim results?

maxAlternatives number

Max alternatives search

firstCapital boolean

First character uppercase in a sentence?

newLine boolean

Accept new line symbol?

onStart function

Optional handler when started

onEnd function

Optional handler when ended

onError function

Optional handler on error

onChange function

Optional handler to override change event

debug boolean

Optional console info

speechSynthesis(el, options)

Description:
  • Speech synthesis

Parameters:
Name Type Description
el Object

Text or input or textarea

options Object

Options

Properties
Name Type Description
lang string

Preferred language FRA, ENU...

voice string

Optional voice name to force if exists

uri string

Service URI, default native

volume string

0 to 1, default 1

rate string

0.1 to 10, default 1

pitch string

0 to 2, default 1

onStart function

Optional handler when started

onEnd function

Optional handler when ended

debug boolean

Optional console info

unbind(name)

Description:
  • Unbind one UI action

Parameters:
Name Type Description
name string

Action name

undoRedo(ctn, action, num, url)

Description:
  • Undo/Redo service

Parameters:
Name Type Description
ctn string | jQuery

Target container

action string

Undo|redo

num string

Number of iterations (default 1)

url string

Optional URL to reload after server call (else use response url)