Number decimal
Widget is used for numerical input of data by user. Value will be stored in couchdb as datatype NUMBER.
Widget id, ${gbamID}
:
see alignment
Back to GBAM widgets table
Datatypes
Value is stored from widget to database as number
datatype.
Predefined user data
PreLoaded
Properties panel
User will configure this data in properties panels of selected widget:
GENERAL
- "label",
${widgetLabel}
- "hint",
${widgetHint}
- "initial value" value which is set into widget on screen load. Attribute is added only if user types initial value and the input can be only valid integer or decimal number. ${initialValue}=
gn:s_text="${userValue}"
- "alignment", represented by dropdown with two options
- "vertical",
${gbamID}
:numberDecimal
when selected UI should show label above the input field,vertical
xml should be used - "horizontal",
${gbamID}
:numberDecimalHorizontal
when selected UI should show label to right of input field in same line,horizontal
xml should be used
- "vertical",
- "is masked" checkbox if selected, the value in input field is masked, by default it's unchecked. If checkbox is selected following code is added to widget. ${isMasked}=
gn:isMasked="true"
VALIDATIONS
- "required", RequiredValidator, add to configuration.xml:
<columnNumber required="true|false"></columnNumber>
- "unique", check uniqueness when widget gets saved into db, having "is part of database" checked, add to configuration.xml:
<columnNumber unique="true|false"></columnNumber>
- "decimal format", TextValidator#REGEX set to
@string/$decimalPattern
not changeable by user, only error message. - "decimal places",
${decimalPlaces}
= input field which defines number of "0" digits to add, default is 2. Add to configuration.xml:
<columnNumber> <decimalPlaces>null|>=0|<=13</decimalPlaces> </columnNumber>
- "maximal number of decimals",
${maxNumberOfDecimalsAllowed}
= defines maximal number of decimals. Use same value as defined for${decimalPlaces}
.
Add validator:
gn:act_validate="[name:TextValidator],[inputType=REGEX],[REGEXErrMsg=@string/maxNumberOfDecimalsNumber],[pattern=@string/decimalPatternMaxDecimals]"
Add string:
<string name="$maxNumberOfDecimalsNumber">maximum number of decimals allowed is ${maxNumberOfDecimalsAllowed}</string>
- "compare with", compares current widget with target selected in the validator. Validator has a dropdown to select widget which will be target and also has dropdown to select comparison type
${comparator}
. Validated target has to be of same datatype as current widget, in this casenumber
- allowed comparison types are described here ComparatorValidator#Comparator_types
- only comparator types that are allowed for certain datatype should be shown in dropdown selection where user chooses comparison type
- comparison types should need to have user friendly translations
- Following line should be added to widget:
gn:act_validate="[name:ComparatorValidator],[message=@string/$comparatorValidatorMessage],[targetWidget=@+id/${widgetID}_suffix],[comparator=${comparator}]" gn:act_setOnFocusLost="[gn:act_validateScreen]|[@+id/${widgetID}_suffix]" gn:actionSetOnFocusLost="true"
internal validators
Validators not visible to user.
- "max length", TextValidator#maxLength set to 15
ACTION
- -
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":
- "percentage %", add to configuration.xml:
<columnNumber> <percentage>true|false</percentage> </columnNumber>
- "horizontal alignment", add to configuration.xml:
<columnNumber> <horizontalAlignment>left|center|right</horizontalAlignment> </columnNumber>
- "list of allowed values", add to configuration.xml:
<columnNumber> <valuesList> <value>1</value> <value>2</value> </valuesList> </columnNumber>
- "related unique columns", add to configuration.xml:
<columnNumber> <uniqueInsideList> <reference> <table>refTableId1</table> <column>refColumnField1</column> </reference> <reference> <table>refTableId2</table> <column>refColumnField2</column> </reference> </uniqueInsideList> </columnNumber>
- "hidden ginstr web column settings":
- "number signs", for positive number add: "equalToZero" and "greaterThanZero", add to configuration.xml:
<numberSigns> <numberSign>lessThanZero</numberSign> <numberSign>equalToZero</numberSign> <numberSign>greaterThanZero</numberSign> </numberSigns>
Code snippets
GBAM Code Variables
Variables which are used in code snippet below but not defined in user modifiable inputs.
Available layouts
vertical layout
<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/numberDecimal_label"/> <com.ginstr.widgets.GnEditText android:id="@+id/${widgetID}_input" android:layout_width="match_parent" android:layout_height="wrap_content" gn:s_hint="@string/${widgetID}Hint" gn:s_sourceType="input" gn:dataType="number" gn:inputType="TYPE_CLASS_NUMBER|TYPE_NUMBER_FLAG_SIGNED|TYPE_NUMBER_FLAG_DECIMAL" gn:s_decimalFormat="0.${decimalPlaces}" gn:autoAdjustHeight="true" ${initialValue} ${isMasked} gn:style="@style/numberDecimal_input" />
horizonal layout
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:weightSum="100" android:orientation="horizontal"> <com.ginstr.widgets.GnTextView android:id="@+id/${widgetID}_label" android:layout_width="0dp" android:layout_weight="66" android:layout_height="wrap_content" android:text="@string/${widgetID}" gn:style="@style/numberDecimalHorizontal_label"/> <com.ginstr.widgets.GnEditText android:id="@+id/${widgetID}_input" android:layout_width="0dp" android:layout_weight="34" android:layout_height="wrap_content" gn:s_hint="@string/${widgetID}Hint" gn:s_sourceType="input" gn:dataType="number" gn:inputType="TYPE_CLASS_NUMBER|TYPE_NUMBER_FLAG_SIGNED|TYPE_NUMBER_FLAG_DECIMAL" gn:s_decimalFormat="0.${decimalPlaces}" gn:autoAdjustHeight="true" ${initialValue} ${isMasked} gn:style="@style/numberDecimalHorizontal_input" /> </LinearLayout>
strings.xml
Lines to be added for each language.
<string name="${widgetID}">${widgetLabel}</string> <string name="${widgetID}Hint">${widgetHint}</string>