Module: table-utils

A mixin object containing methods for table editing and saving.

Source:

Methods

(function) data()

Method data
Source:

(method) addRow()

Adds a new row to the table for editing.

Source:

(method) clearFilter()

Clears the filter

Source:

(method) createRowForTable(row, columns) → {Array}

Creates a row for a table based on the given row object and columns.

Parameters:
Name Type Description
row Object

The row object.

columns Array.<Object>

The array of column objects.

Source:
Returns:
  • An array representing the row for the table.
Type
Array

(method) deleteRow(row)

Deletes a row from the table.

Parameters:
Name Type Description
row Object

The row to be deleted.

Source:

(method) editRow(row)

Edits a row in the table.

Parameters:
Name Type Description
row Object

The row to be edited.

Source:

(method) findIndexOfColumn(columns, columnName) → {number}

Finds the index of a column in the given array of columns based on the column name.

Parameters:
Name Type Description
columns Array

The array of columns to search.

columnName string

The name of the column to find.

Source:
Returns:
  • The index of the column if found, otherwise -1.
Type
number

(method) frugalJsonToArray(data) → {Array.<Object>}

Converts a frugal JSON object to an array of objects.

Parameters:
Name Type Description
data Object

The frugal JSON object containing data and attributes.

Properties
Name Type Description
data Array

The array of data rows.

attributes Array

The array of attribute names.

Source:
Returns:

An array of objects where each object represents a row of data with attribute names as keys.

Type
Array.<Object>

(method) loadLookups() → {Promise.<void>}

Loads the lookup values for the columns in the table.

Source:
Returns:

A promise that resolves when the lookup values are loaded.

Type
Promise.<void>

(method) reload()

reload (or load) the table data

Source:

(method) rowToObject(row) → {Object}

Converts a row from the table to an object.

Parameters:
Name Type Description
row Array

The row to convert.

Source:
Returns:
  • The converted object.
Type
Object

(method) saveRow()

Method saveRow
Source:

(method) saveRowToDb(editMode, tableAPI, columns, editingRow, editingRowIndex, rows, customAPI, customMethod) → {Promise.<void>}

Saves the edited row to the database.

Parameters:
Name Type Description
editMode string

The edit mode ('add' or 'edit').

tableAPI string

The API endpoint for the table.

columns Array

The columns of the table.

editingRow Object

The edited row.

editingRowIndex number

The index of the edited row.

rows Array

The rows of the table.

customAPI string

The custom API endpoint for the table.

customMethod string

The custom method to use for the API request.

Source:
Returns:
  • A promise that resolves when the row is saved to the database.
Type
Promise.<void>

(method) setupColumns(attributes) → {Array}

Sets up the columns for the table based on the given attributes.

Parameters:
Name Type Description
attributes Array

The array of attributes for the table.

Source:
Returns:
  • An array of column objects for the table.
Type
Array

(function) format()

Method format
Source:

(function) format()

Method format
Source:

(method) updateRow(props)

Updates a row in the table with the provided properties. Invoked from popup.

Parameters:
Name Type Description
props Object

The properties to update in the row.

Source:

(function) format()

Method format
Source:

(function) format()

Method format
Source:

(function) "timestamp with time zone"()

Method "timestamp with time zone"
Source:

(function) date()

Method date
Source:

(function) numeric()

Method numeric
Source:

(async, function) saveRow() → {Promise.<void>}

Saves the edited row to the table.

Source:
Returns:

A Promise that resolves when the row is saved.

Type
Promise.<void>