Skip to content

Commit

Permalink
bf & enhancements
Browse files Browse the repository at this point in the history
- static.setTitle() now resolves “resname” or XLIFF references (“ :xliff:resname”)
- tabControl.new() now handles a choice list as a data source and allows you to set the initial page to be displayed
- input  class can now replace “.” with the current decimal separator when entering data
- Widget classes now better handle proxies
- the onBoard widget can now read or write the parent form
  • Loading branch information
vdelachaux committed Aug 30, 2024
1 parent a57d74e commit ca9d732
Show file tree
Hide file tree
Showing 7 changed files with 459 additions and 189 deletions.
4 changes: 3 additions & 1 deletion UI/Project/Sources/Classes/comboBox.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Function set filter($filter)

// === === === === === === === === === === === === === === === === === === === === === === === === === ===
// Display the selection list (to use in the On getting focus event)
Function expand()
Function expand() : cs:C1710.comboBox

var $o : Object

Expand All @@ -99,6 +99,8 @@ Function expand()

End if

return This:C1470

// === === === === === === === === === === === === === === === === === === === === === === === === === ===
// Display the selection list (to use in the On Data change event)
Function automaticInsertion($ordered : Boolean)
Expand Down
32 changes: 16 additions & 16 deletions UI/Project/Sources/Classes/input.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -259,21 +259,7 @@ Function getFilter() : Text
// === === === === === === === === === === === === === === === === === === === === === === === === === ===
Function setPlaceholder($placeholder : Text) : cs:C1710.input

var $t : Text

//%W-533.1
If (Length:C16($placeholder)>0)\
&& (Length:C16($placeholder)<=255)\
&& ($placeholder[[1]]#Char:C90(1))


$t:=Formula from string:C1601("Get localized string:C991($1)"; sk execute in host database:K88:5).call(Null:C1517; $placeholder)
$placeholder:=Length:C16($t)>0 ? $t : $placeholder // Revert if no localization

End if
//%W+533.1

OBJECT SET PLACEHOLDER:C1295(*; This:C1470.name; $placeholder)
OBJECT SET PLACEHOLDER:C1295(*; This:C1470.name; This:C1470._getLocalizeString($placeholder))

return This:C1470

Expand Down Expand Up @@ -314,4 +300,18 @@ Function setEnterable($enterable : Boolean; $focusable : Boolean) : cs:C1710.inp

End if

return This:C1470
return This:C1470

// === === === === === === === === === === === === === === === === === === === === === === === === === ===
// Replace the point by the decimal parameter in a text box
// This function must be called during management of the "On Before Keystroke" event.
Function swapDecimalSeparator()

var $separator : Text

If (Keystroke:C390=".")

GET SYSTEM FORMAT:C994(Decimal separator:K60:1; $separator)
FILTER KEYSTROKE:C389($separator)

End if
30 changes: 28 additions & 2 deletions UI/Project/Sources/Classes/onBoard.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,32 @@ Class constructor($widget : Text; $form : Text)
// ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==>
Function set me($me : cs:C1710.onBoard)

This:C1470.instances[0].data.me:=$me
If (This:C1470.instances#Null:C1517)\
&& (This:C1470.instances.length>0)

This:C1470.instances[0].data.me:=$me

End if

// ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==>
Function set parent($parent : Object)

If (This:C1470.instances#Null:C1517)\
&& (This:C1470.instances.length>0)

This:C1470.instances[0].parent:=$parent

End if

// ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==>
Function get parent() : Object

If (This:C1470.instances#Null:C1517)\
&& (This:C1470.instances.length>0)

return This:C1470.instances[0].parent

End if

// <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <==
// Returns the name of the widget on the current page
Expand Down Expand Up @@ -268,7 +293,8 @@ Function onLoad()
//╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍
Else

// A "Case of" statement should never omit "Else"
OBJECT SET VALUE:C1742($key; Form:C1466[$key])

//╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍
End case
End for each
Expand Down
77 changes: 62 additions & 15 deletions UI/Project/Sources/Classes/static.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,7 @@ Function set title($title : Text)
// === === === === === === === === === === === === === === === === === === === === === === === === === ===
Function setTitle($title : Text) : cs:C1710.static

var $t : Text

//%W-533.1
If (Length:C16($title)>0)\
&& (Length:C16($title)<=255)\
&& ($title[[1]]#Char:C90(1))

$t:=Formula from string:C1601("Get localized string:C991($1)"; sk execute in host database:K88:5).call(Null:C1517; $title)
$title:=Length:C16($t)>0 ? $t : $title // Revert if no localization

End if
//%W+533.1

OBJECT SET TITLE:C194(*; This:C1470.name; $title)
OBJECT SET TITLE:C194(*; This:C1470.name; This:C1470._getLocalizeString($title))

return This:C1470

Expand Down Expand Up @@ -1072,4 +1059,64 @@ Function hiddenFromView() : cs:C1710.static

OBJECT SET COORDINATES:C1248(*; This:C1470.name; -100; -100; -100; -100)

return This:C1470
return This:C1470

// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Function _proxy($proxy : Text) : Text

Case of

//______________________________________________________
: (Position:C15("path:"; $proxy)=1)\
|| (Position:C15("file:"; $proxy)=1)\
|| (Position:C15("var:"; $proxy)=1)\
|| (Position:C15("!"; $proxy)=1)

return $proxy

//______________________________________________________
: (Position:C15("#"; $proxy)=1) // Shortcut for Resources folder

return "path:/RESOURCES/"+Delete string:C232($proxy; 1; 1)

//______________________________________________________
: ($proxy="|@")

return "path:/.PRODUCT_RESOURCES/"+Delete string:C232($proxy; 1; 1)

//______________________________________________________
: (Position:C15("/"; $proxy)=1)

return "path:"+$proxy

//______________________________________________________
Else

// Relative to the form.4DForm
return "path:/FORM/"+$proxy

//______________________________________________________
End case

// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Function _getLocalizeString($resname : Text) : Text

var $t : Text

If (Position:C15(":xliff:"; $resname)=1)

$resname:=Delete string:C232($resname; 1; 7)

End if

//%W-533.1
If (Length:C16($resname)>0)\
&& (Length:C16($resname)<=255)\
&& ($resname[[1]]#Char:C90(1))

$t:=Formula from string:C1601("Get localized string:C991($1)"; sk execute in host database:K88:5).call(Null:C1517; $resname)

End if
//%W+533.1

return Length:C16($t)>0 ? $t : $resname // Revert if no localization
119 changes: 101 additions & 18 deletions UI/Project/Sources/Classes/tabControl.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,73 @@ Class extends widget

property data : Object

Class constructor($name : Text; $data : Object)
Class constructor($name : Text; $data; $page)

Super:C1705($name)

This:C1470.dataSource:=$data
/*
💡 The widget "Variable or Expression" property mut be:
"formGetInstance.<name>.dataSource"
*/

This:C1470.data:={}

Case of

//______________________________________________________
: ($data.values=Null:C1517)
: (This:C1470.isChoiceList) // Using a choice list

This:C1470.data.values:=[]

//______________________________________________________
: (Value type:C1509($data.values)=Is collection:K8:32)

This:C1470.data.values:=$data.values
var $i : Integer
For ($i; 1; Count list items:C380($data); 1)

GET LIST ITEM:C378($data; $i; $ref; $label)
This:C1470.data.values.push($label)

End for

//______________________________________________________
: (Value type:C1509($data.values)=Is text:K8:3)
: (This:C1470.isObject) // Using an object

This:C1470.data.values:=[$data.values]
Case of

//______________________________________________________
: ($data.values=Null:C1517)

This:C1470.data.values:=[]

//______________________________________________________
: (Value type:C1509($data.values)=Is collection:K8:32)

This:C1470.data.values:=$data.values

//______________________________________________________
: (Value type:C1509($data.values)=Is text:K8:3)

This:C1470.data.values:=[$data.values]

//______________________________________________________
Else

ASSERT:C1129(False:C215; "Type not allowed for data.values!")

//______________________________________________________
End case

This:C1470.data.index:=Num:C11($data.index)

//______________________________________________________
Else

ASSERT:C1129(False:C215; "Type not allowed for data.values!")
// We don't want manage legacy text array
ASSERT:C1129(False:C215; "⛔️ The data parameter must be an Object or a Choice list")

//______________________________________________________
End case

This:C1470.data.index:=Num:C11($data.index)

This:C1470.data.currentValue:=This:C1470.data.index<=This:C1470.data.values.length\
? This:C1470.data.values[This:C1470.data.index]\
: ""
This:C1470.pageNumber:=$page

// <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <==
Function get pageNumber() : Integer
Expand All @@ -47,20 +78,72 @@ Function get pageNumber() : Integer
// ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==>
Function set pageNumber($page : Integer)

$page-=1 // Map to 0 - collection.length-1

// Map to 0 - collection.length-1
$page-=1
This:C1470.data.index:=$page>=0 ? $page : 0

This:C1470.data.currentValue:=This:C1470.data.index<=This:C1470.data.values.length\
? This:C1470.data.values[This:C1470.data.index]\
: ""

If (Value type:C1509(OBJECT Get subform container value:C1785)=Is undefined:K8:13)
If (This:C1470.isChoiceList)

SELECT LIST ITEMS BY REFERENCE:C630(This:C1470.dataSource; $page+1)

End if

If (Value type:C1509(OBJECT Get subform container value:C1785)#Is undefined:K8:13) // Subform

FORM GOTO PAGE:C247($page+1; *)

Else

FORM GOTO PAGE:C247($page+1)

End if

// === === === === === === === === === === === === === === === === === === === === === === === === === ===
Function goToPage()

var $t : Text
var $page : Integer

If (This:C1470.isChoiceList)

GET LIST ITEM:C378(*; This:C1470.name; *; $page; $t)

Else

FORM GOTO PAGE:C247($page+1; *)
$page:=This:C1470.pageNumber

End if

If (Value type:C1509(OBJECT Get subform container value:C1785)#Is undefined:K8:13)

FORM GOTO PAGE:C247($page; *)

Else

FORM GOTO PAGE:C247($page)

End if

// <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <==
Function get isChoiceList() : Boolean

return ((Value type:C1509(This:C1470.dataSource)=Is longint:K8:6) || (Value type:C1509(This:C1470.dataSource)=Is real:K8:4))\
&& (Is a list:C621(This:C1470.dataSource))

// <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <==
Function get isObject() : Boolean

return (Value type:C1509(This:C1470.dataSource)=Is object:K8:27)

// === === === === === === === === === === === === === === === === === === === === === === === === === ===
Function clearList()

If (This:C1470.isChoiceList)

CLEAR LIST:C377(This:C1470.dataSource; *)

End if
Loading

0 comments on commit ca9d732

Please sign in to comment.