From wiki.ginstr.com
Jump to: navigation, search
(VALIDATIONS)
(ACTION MESSAGES)
 
Line 46: Line 46:
  
 
======ACTION MESSAGES======
 
======ACTION MESSAGES======
* "on no rights", [[GBAMRulesForIDGeneration#STRING_RESOURCE_ID.27S_.40string.2F|<code>${$noReadRightsToast}</code>]]
+
* "message in case of missing read rights", [[GBAMRulesForIDGeneration#STRING_RESOURCE_ID.27S_.40string.2F|<code>${$noReadRightsToast}</code>]]
* "on no result", [[GBAMRulesForIDGeneration#STRING_RESOURCE_ID.27S_.40string.2F|<code>${$noResultToast}</code>]]
+
* "message shown in case the query initiated by an NFC tag scan does not return any result", [[GBAMRulesForIDGeneration#STRING_RESOURCE_ID.27S_.40string.2F|<code>${$noResultToast}</code>]]
  
 
=====DATABASE=====
 
=====DATABASE=====

Latest revision as of 08:44, 6 April 2020

Nfc text read only query

Widget preforms query action to database when nfc is scanned. Widget is represented by input field which is not editable. When nfc is scanned, data is filled to widgets on screen.

Widget id, ${gbamID}:

nfcTextReadOnlyQuery

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
VALIDATIONS
<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
  • "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.
ACTION MESSAGES
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 node android:id=@+id/${widgetID}_input of buttonQuery 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

Common widget code

<!--nfcTextReadOnlyQuery-->
<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/nfcTextReadOnlyQuery_label"/>
   
<com.ginstr.widgets.GnEditText
   android:id="@+id/${widgetID}_input"
   android:layout_height="wrap_content"
   android:layout_width="match_parent"
   gn:dataType="text"
   gn:s_hint="@string/${widgetHint}"
   gn:s_sourceType="nfc"
   gn:act_setOnNfc="
	[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],
	[gn:act_if]|[[gn:act_rawQueryToWidgets]|[${tableName},${widgetID}_input;${listOfDbColumnIds};${listofVariableIds};@variable/${widgetID}_input]--
		${variableToWidgetList}
	::
		[gn:act_toast]|[@string/$noResultToast]],
	[gn:act_hideKeyboard]|[]"
   gn:style="@style/nfcTextReadOnlyQuery_input"/>

strings.xml

Lines to be added for each language.

<string name="${widgetID}">${widgetLabel}</string>

queries.xml

Add to queries.xml :

    <query
        id="${widgetID}_input${tableName}" 
        columns="${listOfDbColumnIds}"
        keys="${keyDbColumn}"/>