From wiki.ginstr.com
Jump to: navigation, search

Calculation

Widget is used to store the result obtained by calculation of several widgets on screen.

Widget id, ${gbamID}

numberCalculationReadOnly

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}
  • "button label", ${widgetButtonLabel}
  • "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}"
VALIDATIONS
  • "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", places the n number of 0 after the "."(dot) in gn:s_decimalFormat="0.00". Default is 2. This can not exceed total allowed size of decimal number of 15, add to configuration.xml:
<columnNumber>
    <decimalPlaces>null|>=0|<=13</decimalPlaces>
</columnNumber>
internal validators

Validators not visible to user.

ACTION
  • "clear all", button on click clears "formula" and removes all blocks from "area for dropping widgets"
  • "write value widget", widget that can be dragged to block area of calculation. User can write into this widget input such as brackets, integer or decimal numbers and it should allow following functions
  • "calculation area for drop widgets from mobile view or value widget", similar to mobile view where we drop widgets, user can drag widgets from mobile view to this formula drop area.
    • drop area will display widget user entered labels.
    • only widget of datatype number and "write value widget" can be dropped into calculating area
    • each dropped element will be in separate line and hover, click, selected events should behave like on standard widgets in mobile view.
    • when user selects certain block it should highlight him the text in "formula" field which is related to this widget.
    • "write value widget" widgets in calculation area will display as input fields with small padding so you can drag them around as well
    • "select operator", dropdown which will appear below each dropped widget from mobile view with basic arithmetic operators +,-,/,*. select operator will not appear after "write value widget"
  • "formula", ${formula} input field with label formula. when user manipulates blocks above formula of calculation will be automatically built in this line. If user changes manually formula in this line blocks will be changed to match the formula
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", 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.

Common widget code

Common widget code

<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/numberCalculationReadOnly_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_NUMBER_FLAG_DECIMAL"
    gn:s_decimalFormat="0.00"
    gn:autoAdjustHeight="true"
    ${initialValue}
    gn:style="@style/numberCalculationReadOnly_input" />

<com.ginstr.widgets.GnButton
  android:id="@+id/${widgetID}_button"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  gn:style="@style/numberCalculationReadOnly_button"
  gn:act_setClick="
      [gn:act_calculate]|[@+id/${widgetID}_input,${formula}],
      [gn:act_hideKeyboard]|[]"
  android:text="@string/${screenLabelGenerated}_${widgetButtonLabelGenerated}"/>

strings.xml

Lines to be added for each language.

<string name="${widgetID}">${widgetLabel}</string>
<string name="${screenLabelGenerated}_${widgetButtonLabelGenerated}">${widgetButtonLabel}</string>