Qr text editable query / horizontal
Widget is used for scanning and querying barcode values. Value will be stored as datatype TEXT.
Widget id, ${gbamID}
see alignment
Back to GBAM widgets table
Datatypes
Value is stored from widget to database as text
datatype.
Predefined user data
PreLoaded
Properties panel
User will configure this data in properties panels of selected widget:
GENERAL
- "label",
${widgetLabel}
- "hint",
${widgetHint}
- "button label",
${widgetButtonLabel}
- "alignment", represented by dropdown with two options
- "vertical",
${gbamID}
:qrTextEditableQuery
when selected UI should show label above the input field,vertical
xml should be used and control widget_en_qrcode.xml should be used - "horizontal",
${gbamID}
:qrTextEditableQueryHorizontal
when selected UI should show label to right of input field in same line,horizontal
xml and control widget_en_qrcode_horizontal.xml should be used
- "vertical",
VALIDATIONS
- "required", RequiredValidator, add to configuration.xml:
<columnText required="true|false"></columnText>
- "min length", TextValidator#minLength
- "max length", TextValidator#maxLength, add to configuration.xml:
<columnText> <len>null|>=0|<=10000</len> </columnText>
- "unique", check uniqueness when widget gets saved into db, having "is part of database" checked, add to configuration.xml:
<columnText unique="true|false"></columnText>
ACTION
- "choose query type",
${queryType}
based on query type different queries will be activated. current query types:- query single result
singleResult
- query sorted result
sortedResult
- query single result
- "widgets to load",
${listOfDbWidgets}
, list of comma separated${widgetID}
widget id's. All widgets on screen which have checkbox "is part of database", user can change selection. - "sort key", visible only if
query sorted result
is selected ${sortByWidgetId} by default it's equal to GnEditTextandroid:id
value of current widget . User can change it to any widget which have checkbox "is part of database". - "clean widgets on no result", cleans widgets that receive result if nothing is returned ${cleanWidgetsOnNoResult}, only if checkbox selected. By default is selected
ACTION MESSAGES
- "message in case of missing read rights",
${$noReadRightsToast}
- "message shown in case the query initiated by a QR-code scan does not return any result",
${$noResultToast}
DATABASE
- "is part of database", checkbox option by default is set as checked. When checked database column is created for this widget.
- "additional ginstr web column settings":
- "align text", radio button options with values: "left", "middle", "right", add to configuration.xml:
<columnText> <horizontalAlignment>left|center|right</horizontalAlignment> </columnText>
- "list of allowed values" array with list of allowed values, add to configuration.xml:
<columnText> <valuesList> <value>val1</value> <value>val2</value> </valuesList> </columnText>
- "pattern", add to configuration.xml:
<columnText> <pattern errorMessage="invalidTextTableValue">[0-9A-Z]{3}</pattern> </columnText>
- "related unique columns", add to configuration.xml:
<columnText> <uniqueInsideList> <reference> <table>refTableId1</table> <column>refColumnField1</column> </reference> <reference> <table>refTableId2</table> <column>refColumnField2</column> </reference> </uniqueInsideList> </columnText>
Code snippets
GBAM Code Variables
Variables which are used in code snippet below but not defined in user modifiable inputs.
${widgetID}
${tableName}
${variableToWidgetList}
=${[gn:act_getVariableToWidget]|@variable/${widgetID},@+id/${widgetID}];}
- repeats as many times as is the number of widgets with "is part of database" checked, last repetition does not have ";" , except widget@+id/${widgetID}_input
${reloadAutoFilledWidgetsIfDateTimeWidgetsPresent}
=${[gn:act_reloadAutoFilledWidgets]|[@+id/${dateTimeWidgetAsSortKey}];}
- it should only exist if Timestamp widget is added to screen${listOfWidgetIdsExceptQueryKey}
- all widgets on screen which have checkbox "is part of database", except GnEditText nodeandroid:id=@+id/${widgetID}_input
ofbuttonQuery
widget which is used as key.${listofVariableIds}
- comma separated list of@variable/${widgetID}
. Represents all variables (related to widgets) which have checkbox "is part of database", except@variable/${widgetID}_input
${listOfDbColumnIds}
- comma separated list of${columnName}
column names. Represents all widgets/variables which have checkbox "is part of database", except@+id/${widgetID}_input
${keyDbColumn}
- column name of GnEditText node widget which used as key${sortByWidgetId}
is only added if${queryType}
=sortedResult
[gn:act_setVariable]|[@variable/${sortByWidgetId},@+id/${sortByWidgetId}],
${queryType}
=singleResult
[gn:act_rawQueryToWidgets]|[${tableName},${widgetID}_input;${listOfDbColumnIds};${listofVariableIds};@variable/${widgetID}_input]
in queries.xml, ${queriesXml}=
<query id="${widgetID}_input${tableName}" columns="${listOfDbColumnIds}" keys="${keyDbColumn}"/>
${queryType}
=sortedResult
[gn:act_rawQueryToWidgets]|[${tableName},${widgetID}_input${tableName},,,sortreversetop;${listOfDbColumnIds};${listofVariableIds};@variable/${widgetID}_input,@variable/${sortByWidgetId}]
in queries.xml, ${queriesXml}=
<query id="${widgetID}_input${tableName}" columns="${listOfDbColumnIds}" keys="${keyDbColumn},${sortDbColumn}"/>
${cleanWidgetsOnNoResult}
following code for clean is added if checkbox is selected:
[gn:act_cleanWidgets]|[@+id/${listOfWidgetIdsExceptQueryKey}], [gn:act_resetVariables]|[@variable/${listOfDbWidgets}]
Available layouts
vertical layout
Common widget code
<!--qrTextEditableQuery--> <com.ginstr.widgets.GnTextView android:id="@+id/${widgetID}_label" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/${widgetID}" gn:style="@style/qrTextEditableQuery_label"/> <com.ginstr.widgets.GnEditText android:id="@+id/${widgetID}_input" android:layout_height="wrap_content" android:layout_width="match_parent" gn:s_customLayoutXml="widget_en_qrcode.xml" gn:dataType="text" gn:s_hint="@string/${widgetID}Hint" gn:s_sourceType="qr" gn:autoAdjustHeight="true" gn:act_setOnQr=" [gn:act_if]|[[gn:act_hasTableRights]|[${tableName}!=R]-- [gn:act_toast]|[@string/${$noReadRightsToast}]; [gn:act_break]|[]], [gn:act_if]|[[gn:act_validateScreen]|[@+id/${widgetID}_input]--::[gn:act_break]|[]], [gn:act_cleanWidgets]|[@+id/${listOfWidgetIdsExceptQueryKey}], [gn:act_resetVariables]|[@variable/${listOfDbWidgets}], ${reloadAutoFilledWidgetsIfDateTimeWidgetsPresent}, [gn:act_setVariable]|[@variable/${widgetID}_input,@+id/${widgetID}_input], ${sortByWidgetId}, [gn:act_if]|[${queryType}-- ${variableToWidgetList} :: ${cleanWidgetsOnNoResult}, [gn:act_toast]|[@string/$noResultToast]], [gn:act_hideKeyboard]|[]"/>
horizonal layout
<!--qrTextEditableQueryHorizontal--> <com.ginstr.widgets.GnTextView android:id="@+id/${widgetID}_label" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/${widgetID}" gn:style="@style/qrTextEditableQueryHorizontal_label"/> <com.ginstr.widgets.GnEditText android:id="@+id/${widgetID}_input" android:layout_height="wrap_content" android:layout_width="match_parent" gn:s_customLayoutXml="widget_en_qrcode_horizontal.xml" gn:dataType="text" gn:s_hint="@string/${widgetID}Hint" gn:s_sourceType="qr" gn:autoAdjustHeight="true" gn:act_setOnQr=" [gn:act_if]|[[gn:act_hasTableRights]|[${tableName}!=R]-- [gn:act_toast]|[@string/${$noReadRightsToast}]; [gn:act_break]|[]], [gn:act_if]|[[gn:act_validateScreen]|[@+id/${widgetID}_input]--::[gn:act_break]|[]], [gn:act_cleanWidgets]|[@+id/${listOfWidgetIdsExceptQueryKey}], [gn:act_resetVariables]|[@variable/${listOfDbWidgets}], ${reloadAutoFilledWidgetsIfDateTimeWidgetsPresent}, [gn:act_setVariable]|[@variable/${widgetID}_input,@+id/${widgetID}_input], ${sortByWidgetId}, [gn:act_if]|[${queryType}-- ${variableToWidgetList} :: ${cleanWidgetsOnNoResult}, [gn:act_toast]|[@string/$noResultToast]], [gn:act_hideKeyboard]|[]"/>
strings.xml
Lines to be added for each language.
<string name="${widgetID}">${widgetLabel}</string>
queries.xml
Add to queries.xml : ${queriesXml}
Internal controls layout for widget (vertical)
- widget_en_qrcode.xml is added to Controls folder
Internal controls layout for widget (horizontal)
- widget_en_qrcode_horizontal.xml is added to Controls folder