Constructor
new ObjectField(app, field, obj)
- Description:
Constructor
Parameters:
Name | Type | Description |
---|---|---|
app |
Simplicite.Ajax | Ajax services |
field |
Object | Field metadata |
obj |
Simplicite.Ajax.BusinessObject | Optional related business object |
Methods
applyToReferences(obj, fn)
- Description:
Apply a function to all referenced fields
Parameters:
Name | Type | Description |
---|---|---|
obj |
Simplicite.Ajax.BusinessObject | Object |
fn |
function | function to apply to all referenced fields |
contains(code)
- Description:
Test if value or multi-enum contains a code
Parameters:
Name | Type | Description |
---|---|---|
code |
string | list code |
dateToUI(v, df, r)
- Description:
Convert the date to UI format
Parameters:
Name | Type | Description |
---|---|---|
v |
string | value YYYY-MM-DD |
df |
string | user date format |
r |
string | optional rendering Y|M|D|H|I|S |
datetimeToUI(v, df, r)
- Description:
Convert the datetime to UI format
Parameters:
Name | Type | Description |
---|---|---|
v |
string | value YYYY-MM-DD HH:MI:SS or ISO-8601 |
df |
string | datetime format DD/MM/YYYY HH:MI:SS or MM/DD/YYYY HH:MI:SS |
r |
string | optional rendering Y|M|D|H|I|S |
displayValue(v, r)
- Description:
Value in user language (enum label, boolean as yes/no, format date integer and float with the rendering)
Parameters:
Name | Type | Description |
---|---|---|
v |
string | number | Object | Array | Backend value to display in user language (default is current value) |
r |
boolean | true to apply the rendering |
evalCalc()
- Description:
Eval formula when value starts with the equals sign "=3*5+2", ignore syntax error
formatFloat(v, lang, prec, num)
- Description:
Format a float "1234567.8" => FRA or SC: "1 234 567,80000" - ENU or CD: "1,234,567.80000" - DC: "1.234.567,80000"
Parameters:
Name | Type | Description |
---|---|---|
v |
string | value "1234567.8" |
lang |
string | user language (FRA, ENU) or number format (SC, DC, CD) |
prec |
number | precision (ex: 5) |
num |
boolean | simple number = no thousand separator |
getCodeFromValue()
- Description:
Search the list code of a translated value
getDate(v)
- Description:
Convert the date value to javascript Date
Parameters:
Name | Type | Description |
---|---|---|
v |
string | service date YYYY-MM-DD or datetime YYYY-MM-DD HH:MI:SS |
getDisplay()
- Description:
Field label in user language
getDisplayValue()
- Description:
displayValue alias
getEnumItem(c, v)
- Description:
Get the list item by code (or value)
Parameters:
Name | Type | Description |
---|---|---|
c |
string | search by code |
v |
string | or search by value if c is null |
getOldValue()
- Description:
Get the service old value
getValue()
- Description:
Get the service value
hasChanged()
- Description:
Compare old and current value
isDate(v)
- Description:
Test if YYYY-MM-DD exists ?
Parameters:
Name | Type | Description |
---|---|---|
v |
String | date |
isDatetime(v)
- Description:
Test if YYYY-MM-DD HH:MI:SS exists ?
Parameters:
Name | Type | Description |
---|---|---|
v |
String | datetime |
isDoc()
- Description:
Is a document?
isEmpty()
- Description:
Test if value is empty (or null/undefined, or empty array or not a number)
isFile()
- Description:
Is a document or image?
isFilterExpr(v)
- Description:
Is the filter an expression?
Parameters:
Name | Type | Description |
---|---|---|
v |
string | optional value to test (default use current object filter) |
isFiltered(v)
- Description:
Is the field filtered?
Parameters:
Name | Type | Description |
---|---|---|
v |
string | number | boolean | Array | optional value to test (default use current object filter) |
isForbidden()
- Description:
Test if the field is forbidden
isForeignKey()
- Description:
Is a foreign key? (reference field belonging to object)
isFunctId()
- Description:
Is a functional Id?
isHidden(obj)
- Description:
Test if the field is hidden
Parameters:
Name | Type | Description |
---|---|---|
obj |
Simplicite.Ajax.BusinessObject | optional object to test if foreign-key is also visible |
isImage()
- Description:
Is an image?
isReferenced()
- Description:
Referenced/Belongs to other object?
isRequired(obj)
- Description:
Test if the field is required
Parameters:
Name | Type | Description |
---|---|---|
obj |
Simplicite.Ajax.BusinessObject | optional object to test if foreign-key is also required |
isTimestamp()
isTrue()
- Description:
Test if value is true or equals to "1"
isUpdatable()
- Description:
Test if the field is updatable
isUpdatableOnForm()
- Description:
isUpdatable alias
isUpdatableOnList()
- Description:
isUpdatable alias
isVisibleOnForm(obj)
- Description:
Test if the field is visible on form
Parameters:
Name | Type | Description |
---|---|---|
obj |
Simplicite.Ajax.BusinessObject | optional object to test if foreign-key is also visible |
isVisibleOnList(obj)
- Description:
Test if the field is visible on list
Parameters:
Name | Type | Description |
---|---|---|
obj |
Simplicite.Ajax.BusinessObject | optional object to test if foreign-key is also visible |
message(msg)
- Description:
UI message to display on field
Parameters:
Name | Type | Description |
---|---|---|
msg |
string | Optional message to set |
oldvalue(v)
- Description:
Get or set the old service value
Parameters:
Name | Type | Description |
---|---|---|
v |
string | Optional value to set |
percentage(v, t)
- Description:
Get value as percentage value
Parameters:
Name | Type | Description |
---|---|---|
v |
string | value |
t |
number | optional type (Simplicite.TYPE_INT, Simplicite.TYPE_FLOAT or Simplicite.TYPE_BIGDECIMAL) |
setDate(dt)
- Description:
Convert javascript Date to value YYYY-MM-DD or YYYY-MM-DD HH:MI:SS when field is a datetime
Parameters:
Name | Type | Description |
---|---|---|
dt |
Date | Date |
setOldValue(v)
- Description:
Set the service old value
Parameters:
Name | Type | Description |
---|---|---|
v |
string | Optional service value to set |
setUpdatable(upd)
- Description:
Set the field updatable
Parameters:
Name | Type | Description |
---|---|---|
upd |
boolean | number | updatable ? true/false or Simplicite.UPD_READ_ONLY|ALWAYS|FORM_ONLY|LIST_ONLY |
setValue(v, old)
- Description:
Set the service value
Parameters:
Name | Type | Description |
---|---|---|
v |
string | Optional service value to set |
old |
boolean | Copy value into old value? |
setVisible(vis)
- Description:
Change visibility
Parameters:
Name | Type | Description |
---|---|---|
vis |
boolean | number | true=both, false=hidden, or Simplicite.VIS_BOTH | VIS_HIDDEN | VIS_FORM | VIS_LIST |
timeToUI(v, r)
- Description:
Convert the time to UI format
Parameters:
Name | Type | Description |
---|---|---|
v |
string | value HH:MI:SS |
r |
string | optional rendering Y|M|D|H|I|S |
toService(v)
- Description:
Convert displayed value to service format
Parameters:
Name | Type | Description |
---|---|---|
v |
string | Front-end value |
toServiceDate(v, df)
- Description:
Convert UI date to service format YYYY-MM-DD
Parameters:
Name | Type | Description |
---|---|---|
v |
string | date from UI format |
df |
string | user date format |
toServiceDatetime(v, df)
- Description:
Convert UI datetime to service format YYYY-MM-DD HH:MI:SS (or ISO-8601 with user time zone)
Parameters:
Name | Type | Description |
---|---|---|
v |
string | datetime from UI format |
df |
string | user date format |
toServiceFloat(v, lang)
- Description:
Convert UI float to service format (as string to keep decimal precision) FRA or SC: "1 234 567,80808080808" - ENU or CD: "1,234,567.80808080808" - DC 1.234.567,80808080808 => "1234567.80808080808"
Parameters:
Name | Type | Description |
---|---|---|
v |
string | UI value |
lang |
string | user language (FRA, ENU) or number format (SC, CD, DC) |
toServiceTime(v)
- Description:
Convert UI time to service format HH:MM:SS
Parameters:
Name | Type | Description |
---|---|---|
v |
string | time from UI rendering |
typeLabel(type, cc)
- Description:
Get label of field type
Parameters:
Name | Type | Description |
---|---|---|
type |
string | optional type (default this type) |
cc |
boolean | optional Camel case (default lower case) |
tz(v)
- Description:
Convert service date to ISO-8601 when user has a specific timezone (exclude timestamp fields)
Parameters:
Name | Type | Description |
---|---|---|
v |
string | datetime YYYY-MM-DD HH:MM:SS |
value(v, old)
- Description:
Get or set the service value
Parameters:
Name | Type | Description |
---|---|---|
v |
string | Optional service value to set |
old |
boolean | Copy value into old value? |