Contents |
Button save
Widget preforms save action to database. Before saving all widgets get validated that have validators. If content is valid save will proceed otherwise validation warnings will popup. Before save also all timestamp widgets update the timestamp to match the exact date and time when save button is pressed by user.
Widget id, ${gbamID}
:
buttonSave
Back to GBAM widgets table
Predefined user data
PreLoaded
Properties panel
User will configure this data in properties panels of selected widget:
GENERAL
- "label",
${widgetLabel}
VALIDATIONS
- -
ACTION
- "clean widgets on save",
${listofWidgetIds1}
,${listofVariableIds1}
only widgets that are selected in "widgets to save" list will appear in "clean widgets on save" list will be selected and that have flag "is part of database". User can deselect widgets that he does not want to clean during save procedure. Only selected widgets in this list are part of${listofWidgetIds1}
,${listofVariableIds1}
. - "widgets to save",
${listOfDbColumnIds},${listofVariableIds},${listWidgetToVariable}
by default all widgets that have flag "is part of database" and are added to this list. User can additionally deselect the ones that should not be saved.- at least one widget in list should be selected
- if list contains
questionnaires
in list then for each add${questionnairesSave}
=
${listWidgetToVariableFromQuestionnaire}, [gn:act_saveQuestionnaire]|[@+id/${questionnaireWidgetID}], [gn:act_loadQuestionnaire]|[@+id/${questionnaireWidgetID}]
- if only questionnaires are selected then use:
[gn:act_if]|[[gn:act_validateScreen]|[${listofWidgetIds}]-- ${reloadAutoFilledWidgetsIfDateTimeWidgetsPresent} ${eventBefore} ${questionnairesSave} [gn:act_toast]|[@string/${$dataSavedToast}]; [gn:act_resetVariables]|[${listofVariableIds1}]; ${eventAfter} [gn:act_hideKeyboard]|[] :: [gn:act_toast]|[@string/${$validateAllRequiredFieldsToast}]]
ACTION MESSAGES
- "on no rights",
${$noWriteRightsToast}
- "on save",
${$dataSavedToast}
- "on all fields required",
${$validateAllRequiredFieldsToast}
Code snippets
GBAM Code Variables
Variables which are used in code snippet below but not defined in user modifiable inputs.
-
${widgetID}
-
${tableName}
-
${listofVariableIds}
- comma separated list of@variable/${widgetID}
. Represents all variables (related to widgets) which have checkbox "is part of database" and are in list "widgets to save" -
${listofWidgetIds}
- comma separated list of@+id/${widgetID}
. Represents all widgets which have checkbox "is part of database", including Questionnaire which is special case. -
${listofVariableIds1}
- comma separated list of@variable/${widgetID}
. Represents all variables (related to widgets) which are selected in list "clean widgets on save" -
${listofWidgetIds1}
- comma separated list of@+id/${widgetID}
. Represents all widgets which are selected in list "clean widgets on save" -
${listOfDbColumnIds}
- comma separated list of${columnName}
column names. Represents all widgets/variables which have checkbox "is part of database" and are in list "widgets to save" -
${reloadAutoFilledWidgetsIfDateTimeWidgetsPresent}
=${[gn:act_reloadAutoFilledWidgets]|[${listOfTimestampWidgets}],}
- it should only exist if Timestamp widget is added to screen. -
${listOfTimestampWidgets}
comma separated list of@+id/${listOfTimestampWidgets}
. Represents all widgets which have checkbox "is part of database" -
${listWidgetToVariable}
=${[gn:act_setVariable]|[@variable/${widgetID},@+id/${widgetID}];}
- repeats as many times as is the number of widgets with "is part of database" checked and are in list "widgets to save" -
${listWidgetToVariableFromQuestionnaire}
=${[gn:act_setVariable]|[@variable/${widgetID},@+id/${widgetID}];}
- repeats as many times as is the number of "external widgets to save" in questionnaires combined
GBAM Code Events
${eventBefore}
${eventAfter}
Common widget code
<com.ginstr.widgets.GnButton android:id="@+id/${widgetID}_button" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/${widgetID}" gn:style="@style/buttonSave_button" gn:act_setClick=" [gn:act_if]|[[gn:act_hasTableRights]|[${tableName}!=C]-- [gn:act_toast]|[@string/${$noWriteRightsToast}]; [gn:act_break]|[]], [gn:act_if]|[[gn:act_validateScreen]|[${listofWidgetIds}]-- ${eventBefore} ${reloadAutoFilledWidgetsIfDateTimeWidgetsPresent} ${listWidgetToVariable} ${questionnairesSave} [gn:act_if]|[[gn:act_rawWriteValues]|[${tableName};${listOfDbColumnIds};${listofVariableIds}]-- [gn:act_toast]|[@string/${$dataSavedToast}]; [gn:act_cleanWidgets]|[${listofWidgetIds1}]; [gn:act_resetVariables]|[${listofVariableIds1}]; ${eventAfter} ::]; [gn:act_hideKeyboard]|[] ::] "/>
strings.xml
Lines to be added for each language.
<string name="${widgetID}">${widgetLabel}</string>