(Created page with "<div style="float:right; clear:both; margin-left:0.5em;">__TOC__</div> <span STYLE="font-size: xx-large"><code>gn:act_forEach</code></span> Category:Action_Library ;Descr...") |
|||
(12 intermediate revisions by 3 users not shown) | |||
Line 3: | Line 3: | ||
[[Category:Action_Library]] | [[Category:Action_Library]] | ||
− | ;Description: Used exclusively with [[Variables]] of [[Datatypes#rows|rows]], [[Datatypes#rowsColumn|rowsColumn]], [[Datatypes#pictures|pictures]], [[Datatypes#email|email]] | + | ;Description: Used exclusively with [[:Category:Variables|variables]] of <code>[[Datatypes#rows|rows]]</code>, <code>[[Datatypes#rowsColumn|rowsColumn]]</code>, <code>[[Datatypes#assignment|assignments]]</code>, <code>[[Datatypes#pictures|pictures]]</code>, <code>[[Datatypes#email|email]]</code> datatypes, to repeat the execution of commands, for each element in the list parameter |
;Action returns: void | ;Action returns: void | ||
+ | |||
+ | ;Controlling action: <code>[[gn:act_break]]</code> is used to stop <code>[[gn:act_forEach]]</code> action execution | ||
+ | |||
+ | #35218 | ||
+ | Using showProgressDialog and changeProgressDialog may lead to unexpected behavior, please use only if absolutely necessary. Currently there is no global solution for showing UI changes during action execution but there is a ticket where this is planned: ##38048. | ||
+ | What was done in scope of this ticket is that we added additional signature to forEach which will internally show progress dialog during iterations. However it comes with some limitations, more information about new signature at wiki. | ||
+ | |||
+ | create zip and attach to ticket | ||
+ | wiki : https://wiki.ginstr.com/index.php?title=gn:act_forEach&action=edit§ion=1 | ||
+ | |||
==Action signatures== | ==Action signatures== | ||
− | === | + | ===Full signature=== |
− | ;<code>[gn:act_forEach]|[source;ACTIONS]</code> | + | :;<code>[gn:act_forEach]|[source,column,progressDialogMessage,progressDialogStyle,callbackWidgetWhenForEachIterated,callbackWidgetActionSet;ACTIONS]</code> |
− | {| class="wikitable sortable" style="font-size: 85%; text-align: left;" | + | :{| class="wikitable sortable" style="font-size: 85%; text-align: left;" |
|- | |- | ||
! scope="col" | Parameter | ! scope="col" | Parameter | ||
! scope="col" | Description | ! scope="col" | Description | ||
|- | |- | ||
− | | [[source]] | + | | <code>[[source]]</code> |
| [[source]] from where the while action is using value as expression parameter | | [[source]] from where the while action is using value as expression parameter | ||
* Valid [[source|sources]]: | * Valid [[source|sources]]: | ||
− | ** [[Datatypes#rows|rows]] | + | ** <code>[[Datatypes#rows|rows]]</code> |
− | ** [[Datatypes#rowsColumn|rowsColumn]] | + | ** <code>[[Datatypes#rowsColumn|rowsColumn]]</code> |
− | ** [[Datatypes#pictures|pictures]] | + | ** <code>[[Datatypes#pictures|pictures]]</code> |
− | ** [[Datatypes#email|email]] | + | ** <code>[[Datatypes#email|email]]</code> |
+ | ** <code>hardcoded</code> - number of times to repeat <code>forEach</code> | ||
|- | |- | ||
− | | [[Action_Library|ACTIONS]] | + | | <code>[[configuration.xml#Column|column]]</code> |
+ | | [[configuration.xml#Column|column]] name which will be internally added as parameter to [[source]] reference names in actions which will be executed in for each action. | ||
+ | :e.g. | ||
+ | :<code>[gn:act_getRow]|[@variable/employee_allowedDivisions, @variable/divisionIndex;;@variable/currentDivisionText]</code> | ||
+ | :to | ||
+ | :<code>[gn:act_getRow]|[@variable/employee_allowedDivisions(divisionName), @variable/divisionIndex;;@variable/currentDivisionText]</code> | ||
+ | |||
+ | * Valid [[source|sources]]: | ||
+ | ** hardcoded | ||
+ | |- | ||
+ | | <code>progressDialogMessage</code>(optional) | ||
+ | | if message is defined then progress bar dialog will appear when for each starts executing. Progress dialog will take <code>source</code> over which for each is iterating. Size of elements in <code>source</code> will represent total number in dialog, while 0 is beginning iteration number. i.e. 4-50 in progress bar would mean 4th element in <code>source</code> is being processed from total of 50 elements | ||
+ | * Valid [[source|sources]]: | ||
+ | :*<code>[[Datatypes#text|text]]</code> | ||
+ | <span style="color: red;">Warning!</span> When using progress dialog <code>forEach</code> must not be called in a trigger which at calling point has more actions that need to be executed after that trigger, those actions will be ignored. In addition, all actions AFTER <code>forEach</code> will be ignored. In order to execute actions after <code>forEach</code> you must define <code>callbackWidgetWhenForEachIterated</code> with <code>callbackWidgetActionSet</code> and put actions that follow there. | ||
+ | |- | ||
+ | | <code>progressDialogStyle</code>(optional) | ||
+ | | defines the progress dialog type. By default it's <code>HORIZONTAL</code> | ||
+ | Can be: | ||
+ | * <code>SPINNER</code> | ||
+ | * <code>HORIZONTAL</code> | ||
+ | |- | ||
+ | | <code>callbackWidgetWhenForEachIterated</code> (optional) | ||
+ | | [[target]] on which is defined <code>callbackWidgetActionSet</code> | ||
+ | * Valid [[source|sources]]: | ||
+ | :*<code>widgetId</code> | ||
+ | |- | ||
+ | | <code>callbackWidgetActionSet</code> (optional) | ||
+ | | [[:Category:Events|event]] action set name which will be fired after all iterations of for each loop have been executed | ||
+ | * Valid [[source|sources]]: | ||
+ | :*<code>hardcoded</code> | ||
+ | |- | ||
+ | | <code>[[Action_Library|ACTIONS]]</code> | ||
| list of actions which will be executed continuously until all rows are iterated | | list of actions which will be executed continuously until all rows are iterated | ||
|- | |- | ||
|} | |} | ||
+ | |||
+ | ===Repeat the execution of commands based on list source=== | ||
+ | :;<code>[gn:act_forEach]|[source;ACTIONS]</code> | ||
+ | |||
+ | ====Example==== | ||
+ | :<code>variable/listId</code> - list used for iteration<br> | ||
+ | :<code>variable/listId(rowColumnName1)</code> - retrieving value from <code>rowColumnName1</code> column of iterated row<br> | ||
+ | :; ⤷ <code>[gn:act_forEach]|[variable/listId;[gn:act_rawWriteValues]|[tableId;column1,column2;variable/listId(rowColumnName1), +id/listRow]]</code> | ||
+ | |||
+ | <hr> | ||
+ | |||
+ | ===Repeat the execution of commands based on list source with defined column name=== | ||
+ | |||
+ | :;<code>[gn:act_forEach]|[source,column;ACTIONS]</code> | ||
+ | |||
+ | ====Example==== | ||
+ | :<code>@variable/employee_allowedDivisions</code> - list used for iteration<br> | ||
+ | :<code>divisionName</code> - column name<br> | ||
+ | :<code>[gn:act_getRow]|[@variable/employee_allowedDivisions,@variable/divisionIndex;;@variable/currentDivisionText]</code> - action<br> | ||
+ | :; ⤷ <code>[gn:act_forEach]|[@variable/employee_allowedDivisions,divisionName;[gn:act_getRow]|[@variable/employee_allowedDivisions, @variable/divisionIndex;;@variable/currentDivisionText]]</code> | ||
+ | <hr> | ||
+ | |||
+ | ===Repeat the execution of commands based on list source with defined column name and progress dialog with actions to post execute=== | ||
+ | |||
+ | :;<code>[gn:act_forEach]|[source,column,progressDialogMessage,progressDialogStyle,callbackWidgetWhenForEachIterated,callbackWidgetActionSet;ACTIONS]</code> | ||
====Example==== | ====Example==== | ||
− | <code>variable/ | + | :<code>@variable/allEmployeesRows</code> - source<br> |
− | <code> | + | :<code>_id</code> - column<br> |
− | <syntaxhighlight lang=" | + | :<code>@string/progressMessage</code> - progressDialogMessage<br> |
− | [gn:act_forEach]|[variable/ | + | :<code>HORIZONTAL</code> - progressDialogStyle<br> |
− | + | :<code>@+id/exampleFrame</code> - callbackWidgetWhenForEachIterated<br> | |
− | ] | + | :<code>gn:act_set1</code> - callbackWidgetActionSet<br> |
+ | |||
+ | <syntaxhighlight lang="xml"> | ||
+ | <FrameLayout | ||
+ | android:id="@+id/exampleFrame" | ||
+ | android:layout_width="wrap_content" | ||
+ | android:layout_height="wrap_content" | ||
+ | android:visibility="gone" | ||
+ | gn:act_set="[gn:act_forEach]|[@variable/allEmployeesRows,_id,@string/progressMessage,HORIZONTAL,@+id/exampleFrame,gn:act_set1; | ||
+ | [gn:act_setVariable]|[@variable/colorIndex,@variable/redIndex] | ||
+ | ];" | ||
+ | gn:act_set1="[gn:act_getVariableToWidget]|[@variable/employeesLastLogins,@+id/employeesLastLogins], | ||
+ | [gn:act_showWidgets]|[@+id/lastLoginEmployeesToday_refresh]," /> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<hr> | <hr> |
Latest revision as of 19:07, 22 October 2020
Contents
- 1 Action signatures
gn:act_forEach
- Description
- Used exclusively with variables of
rows
,rowsColumn
,assignments
,pictures
,email
datatypes, to repeat the execution of commands, for each element in the list parameter
- Action returns
- void
- Controlling action
gn:act_break
is used to stopgn:act_forEach
action execution
- 35218
Using showProgressDialog and changeProgressDialog may lead to unexpected behavior, please use only if absolutely necessary. Currently there is no global solution for showing UI changes during action execution but there is a ticket where this is planned: ##38048. What was done in scope of this ticket is that we added additional signature to forEach which will internally show progress dialog during iterations. However it comes with some limitations, more information about new signature at wiki.
create zip and attach to ticket wiki : https://wiki.ginstr.com/index.php?title=gn:act_forEach&action=edit§ion=1
Action signatures
Full signature
[gn:act_forEach]|[source,column,progressDialogMessage,progressDialogStyle,callbackWidgetWhenForEachIterated,callbackWidgetActionSet;ACTIONS]
Parameter Description source
source from where the while action is using value as expression parameter - Valid sources:
rows
rowsColumn
pictures
email
hardcoded
- number of times to repeatforEach
column
column name which will be internally added as parameter to source reference names in actions which will be executed in for each action. - e.g.
[gn:act_getRow]|[@variable/employee_allowedDivisions, @variable/divisionIndex;;@variable/currentDivisionText]
- to
[gn:act_getRow]|[@variable/employee_allowedDivisions(divisionName), @variable/divisionIndex;;@variable/currentDivisionText]
- Valid sources:
- hardcoded
progressDialogMessage
(optional)if message is defined then progress bar dialog will appear when for each starts executing. Progress dialog will take source
over which for each is iterating. Size of elements insource
will represent total number in dialog, while 0 is beginning iteration number. i.e. 4-50 in progress bar would mean 4th element insource
is being processed from total of 50 elements- Valid sources:
Warning! When using progress dialog
forEach
must not be called in a trigger which at calling point has more actions that need to be executed after that trigger, those actions will be ignored. In addition, all actions AFTERforEach
will be ignored. In order to execute actions afterforEach
you must definecallbackWidgetWhenForEachIterated
withcallbackWidgetActionSet
and put actions that follow there.progressDialogStyle
(optional)defines the progress dialog type. By default it's HORIZONTAL
Can be:
SPINNER
HORIZONTAL
callbackWidgetWhenForEachIterated
(optional)target on which is defined callbackWidgetActionSet
- Valid sources:
widgetId
callbackWidgetActionSet
(optional)event action set name which will be fired after all iterations of for each loop have been executed - Valid sources:
hardcoded
ACTIONS
list of actions which will be executed continuously until all rows are iterated - Valid sources:
Repeat the execution of commands based on list source
[gn:act_forEach]|[source;ACTIONS]
Example
variable/listId
- list used for iterationvariable/listId(rowColumnName1)
- retrieving value fromrowColumnName1
column of iterated row
- ⤷
[gn:act_forEach]|[variable/listId;[gn:act_rawWriteValues]|[tableId;column1,column2;variable/listId(rowColumnName1), +id/listRow]]
- ⤷
Repeat the execution of commands based on list source with defined column name
[gn:act_forEach]|[source,column;ACTIONS]
Example
@variable/employee_allowedDivisions
- list used for iterationdivisionName
- column name[gn:act_getRow]|[@variable/employee_allowedDivisions,@variable/divisionIndex;;@variable/currentDivisionText]
- action
- ⤷
[gn:act_forEach]|[@variable/employee_allowedDivisions,divisionName;[gn:act_getRow]|[@variable/employee_allowedDivisions, @variable/divisionIndex;;@variable/currentDivisionText]]
- ⤷
Repeat the execution of commands based on list source with defined column name and progress dialog with actions to post execute
[gn:act_forEach]|[source,column,progressDialogMessage,progressDialogStyle,callbackWidgetWhenForEachIterated,callbackWidgetActionSet;ACTIONS]
Example
@variable/allEmployeesRows
- source_id
- column@string/progressMessage
- progressDialogMessageHORIZONTAL
- progressDialogStyle@+id/exampleFrame
- callbackWidgetWhenForEachIteratedgn:act_set1
- callbackWidgetActionSet
<FrameLayout android:id="@+id/exampleFrame" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" gn:act_set="[gn:act_forEach]|[@variable/allEmployeesRows,_id,@string/progressMessage,HORIZONTAL,@+id/exampleFrame,gn:act_set1; [gn:act_setVariable]|[@variable/colorIndex,@variable/redIndex] ];" gn:act_set1="[gn:act_getVariableToWidget]|[@variable/employeesLastLogins,@+id/employeesLastLogins], [gn:act_showWidgets]|[@+id/lastLoginEmployeesToday_refresh]," />