Skip to content

Commit

Permalink
Merge pull request #5612 from StrangelyTyped/gridconstants-docs
Browse files Browse the repository at this point in the history
docs(core): documented core uiGridConstants entries
  • Loading branch information
mportuga committed Sep 9, 2016
2 parents 7c11c95 + d9f1c31 commit a08a3e3
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 17 deletions.
113 changes: 112 additions & 1 deletion src/js/core/constants.js
@@ -1,5 +1,14 @@
(function () {
'use strict';

/**
* @ngdoc object
* @name ui.grid.service:uiGridConstants
* @description Constants for use across many grid features
*
*/


angular.module('ui.grid').constant('uiGridConstants', {
LOG_DEBUG_MESSAGES: true,
LOG_WARN_MESSAGES: true,
Expand Down Expand Up @@ -62,8 +71,52 @@
F11: 122,
F12: 123
},
/**
* @ngdoc object
* @name ASC
* @propertyOf ui.grid.service:uiGridConstants
* @description Used in {@link ui.grid.class:GridOptions.columnDef#properties_sort columnDef.sort} and
* {@link ui.grid.class:GridOptions.columnDef#properties_sortDirectionCycle columnDef.sortDirectionCycle}
* to configure the sorting direction of the column
*/
ASC: 'asc',
/**
* @ngdoc object
* @name DESC
* @propertyOf ui.grid.service:uiGridConstants
* @description Used in {@link ui.grid.class:GridOptions.columnDef#properties_sort columnDef.sort} and
* {@link ui.grid.class:GridOptions.columnDef#properties_sortDirectionCycle columnDef.sortDirectionCycle}
* to configure the sorting direction of the column
*/
DESC: 'desc',


/**
* @ngdoc object
* @name filter
* @propertyOf ui.grid.service:uiGridConstants
* @description Used in {@link ui.grid.class:GridOptions.columnDef#properties_filter columnDef.filter}
* to configure filtering on the column
*
* `SELECT` and `INPUT` are used with the `type` property of the filter, the rest are used to specify
* one of the built-in conditions.
*
* Available `condition` options are:
* - `uiGridConstants.filter.STARTS_WITH`
* - `uiGridConstants.filter.ENDS_WITH`
* - `uiGridConstants.filter.CONTAINS`
* - `uiGridConstants.filter.GREATER_THAN`
* - `uiGridConstants.filter.GREATER_THAN_OR_EQUAL`
* - `uiGridConstants.filter.LESS_THAN`
* - `uiGridConstants.filter.LESS_THAN_OR_EQUAL`
* - `uiGridConstants.filter.NOT_EQUAL`
* - `uiGridConstants.filter.STARTS_WITH`
*
*
* Available `type` options are:
* - `uiGridConstants.filter.SELECT` - use a dropdown box for the cell header filter field
* - `uiGridConstants.filter.INPUT` - use a text box for the cell header filter field
*/
filter: {
STARTS_WITH: 2,
ENDS_WITH: 4,
Expand All @@ -78,6 +131,20 @@
INPUT: 'input'
},

/**
* @ngdoc object
* @name aggregationTypes
* @propertyOf ui.grid.service:uiGridConstants
* @description Used in {@link ui.grid.class:GridOptions.columnDef#properties_aggregationType columnDef.aggregationType}
* to specify the type of built-in aggregation the column should use.
*
* Available options are:
* - `uiGridConstants.aggregationTypes.sum` - add the values in this column to produce the aggregated value
* - `uiGridConstants.aggregationTypes.count` - count the number of rows to produce the aggregated value
* - `uiGridConstants.aggregationTypes.avg` - average the values in this column to produce the aggregated value
* - `uiGridConstants.aggregationTypes.min` - use the minimum value in this column as the aggregated value
* - `uiGridConstants.aggregationTypes.max` - use the maximum value in this column as the aggregated value
*/
aggregationTypes: {
sum: 2,
count: 4,
Expand All @@ -89,6 +156,20 @@
// TODO(c0bra): Create full list of these somehow. NOTE: do any allow a space before or after them?
CURRENCY_SYMBOLS: ['ƒ', '$', '£', '$', '¤', '¥', '៛', '₩', '₱', '฿', '₫'],

/**
* @ngdoc object
* @name scrollDirection
* @propertyOf ui.grid.service:uiGridConstants
* @description Set on {@link ui.grid.class:Grid#properties_scrollDirection Grid.scrollDirection},
* to indicate the direction the grid is currently scrolling in
*
* Available options are:
* - `uiGridConstants.scrollDirection.UP` - set when the grid is scrolling up
* - `uiGridConstants.scrollDirection.DOWN` - set when the grid is scrolling down
* - `uiGridConstants.scrollDirection.LEFT` - set when the grid is scrolling left
* - `uiGridConstants.scrollDirection.RIGHT` - set when the grid is scrolling right
* - `uiGridConstants.scrollDirection.NONE` - set when the grid is not scrolling, this is the default
*/
scrollDirection: {
UP: 'up',
DOWN: 'down',
Expand All @@ -98,18 +179,48 @@

},

/**
* @ngdoc object
* @name dataChange
* @propertyOf ui.grid.service:uiGridConstants
* @description Used with {@link ui.grid.core.api:PublicApi#methods_notifyDataChange PublicApi.notifyDataChange},
* {@link ui.grid.class:Grid#methods_callDataChangeCallbacks Grid.callDataChangeCallbacks},
* and {@link ui.grid.class:Grid#methods_registerDataChangeCallback Grid.registerDataChangeCallback}
* to specify the type of the event(s).
*
* Available options are:
* - `uiGridConstants.dataChange.ALL` - listeners fired on any of these events, fires listeners on all events.
* - `uiGridConstants.dataChange.EDIT` - fired when the data in a cell is edited
* - `uiGridConstants.dataChange.ROW` - fired when a row is added or removed
* - `uiGridConstants.dataChange.COLUMN` - fired when the column definitions are modified
* - `uiGridConstants.dataChange.OPTIONS` - fired when the grid options are modified
*/
dataChange: {
ALL: 'all',
EDIT: 'edit',
ROW: 'row',
COLUMN: 'column',
OPTIONS: 'options'
},

/**
* @ngdoc object
* @name scrollbars
* @propertyOf ui.grid.service:uiGridConstants
* @description Used with {@link ui.grid.class:GridOptions#properties_enableHorizontalScrollbar GridOptions.enableHorizontalScrollbar}
* and {@link ui.grid.class:GridOptions#properties_enableVerticalScrollbar GridOptions.enableVerticalScrollbar}
* to specify the scrollbar policy for that direction.
*
* Available options are:
* - `uiGridConstants.scrollbars.NEVER` - never show scrollbars in this direction
* - `uiGridConstants.scrollbars.ALWAYS` - always show scrollbars in this direction
*/

scrollbars: {
NEVER: 0,
ALWAYS: 1
//WHEN_NEEDED: 2
}
});

})();
})();
18 changes: 10 additions & 8 deletions src/js/core/factories/Grid.js
Expand Up @@ -121,8 +121,9 @@ angular.module('ui.grid')
* @ngdoc property
* @name scrollDirection
* @propertyOf ui.grid.class:Grid
* @description set one of the uiGridConstants.scrollDirection values (UP, DOWN, LEFT, RIGHT, NONE), which tells
* us which direction we are scrolling. Set to NONE via debounced method
* @description set one of the {@link ui.grid.service:uiGridConstants#properties_scrollDirection uiGridConstants.scrollDirection}
* values (UP, DOWN, LEFT, RIGHT, NONE), which tells us which direction we are scrolling.
* Set to NONE via debounced method
*/
self.scrollDirection = uiGridConstants.scrollDirection.NONE;

Expand Down Expand Up @@ -423,8 +424,8 @@ angular.module('ui.grid')
* and you'd like cell classes to be re-evaluated, or changed config within
* the columnDef and you'd like headerCellClasses to be re-evaluated.
* @param {string} type one of the
* uiGridConstants.dataChange values (ALL, ROW, EDIT, COLUMN), which tells
* us which refreshes to fire.
* {@link ui.grid.service:uiGridConstants#properties_dataChange uiGridConstants.dataChange}
* values (ALL, ROW, EDIT, COLUMN), which tells us which refreshes to fire.
*
*/
self.api.registerMethod( 'core', 'notifyDataChange', this.notifyDataChange );
Expand Down Expand Up @@ -556,8 +557,8 @@ angular.module('ui.grid')
*
* @param {function(grid)} callback function to be called
* @param {array} types the types of data change you want to be informed of. Values from
* the uiGridConstants.dataChange values ( ALL, EDIT, ROW, COLUMN, OPTIONS ). Optional and defaults to
* ALL
* the {@link ui.grid.service:uiGridConstants#properties_dataChange uiGridConstants.dataChange}
* values ( ALL, EDIT, ROW, COLUMN, OPTIONS ). Optional and defaults to ALL
* @returns {function} deregister function - a function that can be called to deregister this callback
*/
Grid.prototype.registerDataChangeCallback = function registerDataChangeCallback(callback, types, _this) {
Expand All @@ -584,8 +585,9 @@ angular.module('ui.grid')
* @description Calls the callbacks based on the type of data change that
* has occurred. Always calls the ALL callbacks, calls the ROW, EDIT, COLUMN and OPTIONS callbacks if the
* event type is matching, or if the type is ALL.
* @param {number} type the type of event that occurred - one of the
* uiGridConstants.dataChange values (ALL, ROW, EDIT, COLUMN, OPTIONS)
* @param {string} type the type of event that occurred - one of the
* {@link ui.grid.service:uiGridConstants#properties_dataChange uiGridConstants.dataChange}
* values (ALL, ROW, EDIT, COLUMN, OPTIONS)
*/
Grid.prototype.callDataChangeCallbacks = function callDataChangeCallbacks(type, options) {
angular.forEach( this.dataChangeCallbacks, function( callback, uid ){
Expand Down
19 changes: 13 additions & 6 deletions src/js/core/factories/GridColumn.js
Expand Up @@ -75,6 +75,8 @@ angular.module('ui.grid')
* @name filter
* @propertyOf ui.grid.class:GridColumn
* @description Filter on this column.
*
* Available built-in conditions and types are listed under {@link jui.grid.service:uiGridConstants#properties_filter uiGridOptions.filter}
* @example
* <pre>{ term: 'text', condition: uiGridConstants.filter.STARTS_WITH, placeholder: 'type to filter...', ariaLabel: 'Filter for text', flags: { caseSensitive: false }, type: uiGridConstants.filter.SELECT, [ { value: 1, label: 'male' }, { value: 2, label: 'female' } ] }</pre>
*
Expand Down Expand Up @@ -110,7 +112,9 @@ angular.module('ui.grid')
* @name aggregationType
* @propertyOf ui.grid.class:GridOptions.columnDef
* @description The aggregation that you'd like to show in the columnFooter for this
* column. Valid values are in uiGridConstants, and currently include `uiGridConstants.aggregationTypes.count`,
* column. Valid values are in
* {@link ui.grid.service:uiGridConstants#properties_aggregationTypes uiGridConstants.aggregationTypes},
* and currently include `uiGridConstants.aggregationTypes.count`,
* `uiGridConstants.aggregationTypes.sum`, `uiGridConstants.aggregationTypes.avg`, `uiGridConstants.aggregationTypes.min`,
* `uiGridConstants.aggregationTypes.max`.
*
Expand Down Expand Up @@ -278,7 +282,8 @@ angular.module('ui.grid')
* @propertyOf ui.grid.class:GridOptions.columnDef
* @description An object of sort information, attributes are:
*
* - direction: values are uiGridConstants.ASC or uiGridConstants.DESC
* - direction: values are {@link ui.grid.service:uiGridConstants#properties_ASC uiGridConstants.ASC}
* or {@link ui.grid.service:uiGridConstants#properties_DESC uiGridConstants.DESC}
* - ignoreSort: if set to true this sort is ignored (used by tree to manipulate the sort functionality)
* - priority: says what order to sort the columns in (lower priority gets sorted first).
* @example
Expand Down Expand Up @@ -647,8 +652,8 @@ angular.module('ui.grid')
* @ngdoc property
* @name sortDirectionCycle
* @propertyOf ui.grid.class:GridOptions.columnDef
* @description (optional) An array of sort directions, specifying the order that they
* should cycle through as the user repeatedly clicks on the column heading.
* @description (optional) An array of {@link ui.grid.service:uiGridConstants#properties_ASC sort directions},
* specifying the order that they should cycle through as the user repeatedly clicks on the column heading.
* The default is `[null, uiGridConstants.ASC, uiGridConstants.DESC]`. Null
* refers to the unsorted state. This does not affect the initial sort
* direction; use the {@link ui.grid.class:GridOptions.columnDef#sort sort}
Expand Down Expand Up @@ -726,7 +731,8 @@ angular.module('ui.grid')
* A filter consists of a condition, a term, and a placeholder:
*
* - condition defines how rows are chosen as matching the filter term. This can be set to
* one of the constants in uiGridConstants.filter, or you can supply a custom filter function
* one of the constants in {@link ui.grid.service:uiGridConstants#properties_filter uiGridConstants.filter},
* or you can supply a custom filter function
* that gets passed the following arguments: [searchTerm, cellValue, row, column].
* - term: If set, the filter field will be pre-populated
* with this value.
Expand All @@ -736,7 +742,8 @@ angular.module('ui.grid')
* your custom function doesn't require a term (so it can run even when the term is null)
* - flags: only flag currently available is `caseSensitive`, set to false if you don't want
* case sensitive matching
* - type: defaults to uiGridConstants.filter.INPUT, which gives a text box. If set to uiGridConstants.filter.SELECT
* - type: defaults to {@link ui.grid.service:uiGridConstants#properties_filter uiGridConstants.filter.INPUT},
* which gives a text box. If set to {@link ui.grid.service:uiGridConstants#properties_filter uiGridConstants.filter.SELECT}
* then a select box will be shown with options selectOptions
* - selectOptions: options in the format `[ { value: 1, label: 'male' }]`. No i18n filter is provided, you need
* to perform the i18n on the values before you provide them
Expand Down
6 changes: 4 additions & 2 deletions src/js/core/factories/GridOptions.js
Expand Up @@ -383,7 +383,8 @@ angular.module('ui.grid')
* @ngdoc boolean
* @name enableVerticalScrollbar
* @propertyOf ui.grid.class:GridOptions
* @description uiGridConstants.scrollbars.ALWAYS by default. This settings controls the vertical scrollbar for the grid.
* @description {@link ui.grid.service:uiGridConstants#properties_scrollbars uiGridConstants.scrollbars.ALWAYS} by default.
* This settings controls the vertical scrollbar for the grid.
* Supported values: uiGridConstants.scrollbars.ALWAYS, uiGridConstants.scrollbars.NEVER
*/
baseOptions.enableVerticalScrollbar = typeof(baseOptions.enableVerticalScrollbar) !== "undefined" ? baseOptions.enableVerticalScrollbar : uiGridConstants.scrollbars.ALWAYS;
Expand All @@ -392,7 +393,8 @@ angular.module('ui.grid')
* @ngdoc boolean
* @name enableHorizontalScrollbar
* @propertyOf ui.grid.class:GridOptions
* @description uiGridConstants.scrollbars.ALWAYS by default. This settings controls the horizontal scrollbar for the grid.
* @description {@link ui.grid.service:uiGridConstants#properties_scrollbars uiGridConstants.scrollbars.ALWAYS} by default.
* This settings controls the horizontal scrollbar for the grid.
* Supported values: uiGridConstants.scrollbars.ALWAYS, uiGridConstants.scrollbars.NEVER
*/
baseOptions.enableHorizontalScrollbar = typeof(baseOptions.enableHorizontalScrollbar) !== "undefined" ? baseOptions.enableHorizontalScrollbar : uiGridConstants.scrollbars.ALWAYS;
Expand Down

0 comments on commit a08a3e3

Please sign in to comment.