Dataset

Edit me

Redux pattern: https://medium.com/code-cartoons/a-cartoon-intro-to-redux-3afb775501a6

Dataset

getName()

Return the name of the dataset.

toJson(aIdEntries, bAddExtra = true)

Return a json of the dataset with all entries asked. If no id entries are passed, the entiere dataset will be serialized. bAddExtra add variables for the internal storage. (example: “_shouldBeSaved” = true if the entry has changed).

toSms(aIdEntries)

Return a string of the dataset with all entries asked. If no id entries are passed, the entiere dataset will be serialized.

reset() async

Remove all row datas (entries).

addVariableDefinition(oDetails = {}) async

Add a variable to the dataset using it’s definition.

{
	type: 'textfield',
	isMandatory: false,
	defaultValue: ''
}

getVariableDefinition(sVariableName)

Return the definition of the variable.

updateValue(sIdEntry, sVariableName, mValue) async

Alter value of a variable.

getValue(sIdEntry, sVariableName)

Return the value of a variable.

setValidation(sVariableName, fValidator)

Add a function to validate value of a variable.

getValidationStatus(sIdEntry, sVariableName)

Return the status of a variable.

isValid(sIdEntry, sVariableName, bHardCheck = false)

Return the validation status, if it’s not available yet, it will validate at the same time. CAUTION: if bHardCheck = true, the validation status will be manually updated and store for later use. It’s costly for the device and can slow down all the interface. It’s better to not force the check unless you really need to be sure everything is good (usually needed when adding a validation after the value has been entered by the user, or if the value is manually updated).

hardValidationRowData(sIdEntry, sVariableName) async

Force validation of a variable. Doesn’t return the status.

getRowData(sIdEntry)

Return a json of the row data (entry).

getRowDatas(aRowsIds)

Return a json of all the row datas.

deleteEntry(sIdEntry) async

Delete a row data (entry).

isRowDataExist(sIdEntry)

Return if the row data exist with this id.

getVersion(sIdEntry, sVariableName)

Each time a variable of a row data is modified, the “version” is changed too. It’s a easy way to know if something has changed and if we need to render a component to update the view. If no arguments are passed, return the version of the dataset. The version of the dataset is linked to the structure used to create it. It’s a way to know if the data sent to the server are using a recent version or not of the project.

isMandatory(sVariableName)

Return true if the variable is mandatory.

getDefaultValue(sVariableName)

Return the default value of a variable.

getIndex(sVariableName)

Return the position of the variable in the page (not quite trustable because there can be several page, some conditionalDisplay and such…)

getVariablesNames()

Return an array of names of all variables in the dataset.

getType(sVariableName)

Return the type of a variable.

getVariableAttribute(sVariableName, sAttributeName)

Return a single attribute of the definition of a variable.

oDataset.getVariableAttribute('pat_name', 'type');

deleteVariable(sVariableName) async

Delete the variable in the dataset (will remove the value in all row datas too).

hasRowDatasNotSaved()

Return true if some row datas have been modified.

getRowDatasNotSaved()

Return a json of the row datas that have been modified.

getCursorPosition()

Return the current position of the cursor.

setCursorPosition(sCursor) async

Set the cursor on an entry.

saveToDb()

Save current state of the dataset in the local database.

Draft

Draft

createNewDraft(sIdEntry)

validateDraft(sIdEntry)

deleteDraft(sIdEntry)

hasDraftChanged(sIdEntry)