new ActionTableController()
The Angular controller for managing the Action Table
- Source:
Members
-
corpus :Array
-
Each element contained here is an element that is valid after the rows have been filtered by search and sort criteria.
Type:
- Array
- Source:
-
error :Object
-
Handles displaying an error to the widget.
Generally set by calling the private function
fault
.Type:
- Object
- Source:
-
filter_icon :String
-
The displayed icon in the filter to give feedback to the user.
Type:
- String
- Source:
-
pages :Array
-
Doubles as a page count and rendering array for ng-repeat.
Type:
- Array
- Source:
-
reload_icon :String
-
The displayed icon for reloading data to give feedback to the user.
Type:
- String
- Source:
-
render :Array
-
Each element contained here is a row to render on the page. This is pared down to only the rows that should render based on the current page and sourced from the corpus array to follow search and sort criteria and drive a faster rendering.
Type:
- Array
- Source:
-
state :State
-
Holds the stateful data for the widget that should be tracked and reloaded on refresh. This is specifically accomplished by calls to
saveState
in combination with a$watch
specification.Type:
- State
- Source:
Methods
-
actionVisible(row, action)
-
Check if an action is visible based on its
condition
object.No condition object indicates it is always visible.
Condition checking is managed with the
checkConditions
function.Parameters:
Name Type Description row
Object action
Object - Source:
Returns:
- Type
- Boolean
-
checkCondition(row, condition)
-
Every field in the condition that is defined must match the corresponding field value in the row, or the check fails.
Parameters:
Name Type Description row
Object condition
Object - Source:
Returns:
- Type
- Boolean
-
<private> clearFault()
-
Internal method for clearing an error that had been encountered if one such error exists.
- Source:
-
completeTemplate(row, template)
-
Performs basic token replacement in a string based on the values in the row object using "{{...}}" for replacement indicators.
Due to service-now template processing, using "${...}" fails without oerly complicated syntax, for example an option value of "My name is ${name}" simply displays as "My name is name" and looking at the option value received to the widget, the value of that option will also be "My name is name" because Sevice-Now's templating has already altered the value.
Additionally note that the replacement handling is managed with cached regular expressions generated at the start of this controller.
Parameters:
Name Type Description row
Object template
String - Source:
Returns:
- Type
- String
-
<private> endReload()
-
Waits 1 second to reset the reload icon to give the visual impact time.
- Source:
-
<private> fault(error)
-
Internal method for displaying an error that was encountered.
Parameters:
Name Type Description error
Error That occurred and should be displayed
- Source:
-
fillin(fill, row)
-
Use template filling to create a new object whose values mimic the fill object but with templates completed based on the row. Due to the regular expressions in volved and the number of search/replacements that can be triggered here, this method should be used sparingly.
Parameters:
Name Type Description fill
Object Object whose values are to be completed
row
Object Source for values
- Source:
-
<private> filtering()
-
Timed function used to balance user typing with when to fire updating the results.
- Source:
-
getLastUpdateDisplay()
-
- Source:
Returns:
0
- Type
- String
-
getPageClasses(page)
-
Parameters:
Name Type Description page
Number - Source:
Returns:
- Type
- String
-
loadCorpus()
-
Filter and sort the general data received from the server.
This serves as our cache for paging through the data set.
- Source:
-
loadData()
-
Retrieves data from the server if necessary.
This is essesntially a stepping method for AJAX sourced data as the other 2 sources (server script, and table) would already be populated here by the server initialization.
The SPGlideAjax is heavily favored for the ability to create new configurable data sources without modifying the widget or its supporting pieces while also keeping the creating of the data in a more traditionally understood form, Script Includes, instead of passing the data through a more web traditional method such as an API, where Scripted APIs may get heavier. Though support for such a process should be added and would also be handled here.
- Source:
-
loadRender()
-
Load data from the
corpus
to therender
array for the current page being viewed.- Source:
-
mapDataFields()
-
Updates the fieldTracking & fieldList properties.
- Source:
-
mapFields(row)
-
Checks the object keys to ensure that all fields have a RegExp mapping in the
fieldTracking
object.Parameters:
Name Type Description row
Object - Source:
-
prepareData()
-
Essentially prepares the data received from the server.
This primarily involves setting the
$search
property for easy lower cased string index checks for filtering based on the columns andoptions.filterable
.Additionally, the data objectis emitted on the root scope for other widgets to consume if needed under the event "ststable:data:[ID]" where "[ID]" is the table's ID specified in options. This allows another widget on the same page as the table to implement something akin to
$scope.$on("ststable:data:[ID]", $scope.processAPIData)
to receive the data and perform any needed actions.- Source:
-
processAction(row, action)
-
Process an action object for a row.
Parameters:
Name Type Description row
Object action
Object - Source:
-
receiveData(response)
-
Called for receiving the text portion of a request for data. All text is assumed to be a JSON object with the general format:
{ "rows": [{ Object 1 Data... }, { Object 2 Data... }, { ... {, Object N Data... }] }
An object is used to allow for other information to be present on the API call for use later.
Parameters:
Name Type Description response
String - Source:
-
<private> refresh()
-
Used to keep the data up to date if a refresh interval has been specified.
- Source:
-
reloadData()
-
Get a new array of data from the server and apply it to the current state and render.
- Source:
-
renderValue(row, column)
-
Get the string to display for the value in row under the column's field value.
Parameters:
Name Type Description row
Object Of data from which to get the value to render.
column
Object Describing what data should be rendered.
- Source:
Returns:
To place in the table
- Type
- String
-
reorder(column)
-
Change the direction of sorting or the column to sort by.
Calling on the currently sorted column toggles the sort direction.
Changing to a new column does NOT change the sort direction.
Parameters:
Name Type Description column
Column - Source:
-
<private> saveState()
-
Save an encoded value of the scope's state value to give persistence to the table's rendering.
- Source:
-
setIcons()
-
Updates the icons for various objects for cached rendering purposes
- Source:
-
sortData(a, b)
-
Sorting function used to sort the data.rows array based on the current state values.
Parameters:
Name Type Description a
b
- Source:
-
toPage(page)
-
Sets the page and updates the
render
array for display via theloadRender
method.Parameters:
Name Type Description page
Number - Source:
-
update()
-
Forces a re-rendering of AngularJS bindings
- Source:
-
viewStatusWarning(row)
-
Using a Modal, show the status text for the row.
Parameters:
Name Type Description row
Object - Source:
-
visible(row)
-
Parameters:
Name Type Description row
Object - Source: