ListFormRoute Class
addon/routes/list-form.js:22
Base route for the List Forms.
This class re-exports to the application as /routes/list-form
.
So, you can inherit from ./list-form
, even if file app/routes/list-form.js
is not presented in the application.
Item Index
Methods
- _attributesForFilter
- _filtersPredicate
- _getFilterPredicate
- _invalidSorting
- _normalizeNeqPredicate
- actions.objectListViewRowClick
- actions.refreshList
- model
- objectListViewLimitPredicate
- onModelLoadingAlways.
- onModelLoadingFulfilled.
- onModelLoadingRejected.
- onModelLoadingStarted.
- predicateForAttribute
- predicateForFilter
- reloadList
- setupController
Methods
_attributesForFilter
-
projection
-
store
Generates array attributes for filter.
Returns:
Array objects format: { name, type }
, where name
- attribute name, type
- attribute type.
_filtersPredicate
()
BasePredicate | Undefined
private
Return predicate for QueryBuilder
or undefined
.
Returns:
Predicate for QueryBuilder
or undefined
.
_getFilterPredicate
-
modelProjection
-
params
It forms the filter predicate for data loading.
Parameters:
Returns:
Filter predicate for data loading.
_normalizeNeqPredicate
-
predicate
Generates new predicate for neq value predicate.
Parameters:
-
predicate
Object
Returns:
Normalized predicate.
actions.objectListViewRowClick
-
record
Table row click handler.
Parameters:
-
record
EmberObjectRecord related to clicked table row
actions.refreshList
()
public
This action is called when user click on refresh button.
model
-
params
-
transition
A hook you can implement to convert the URL into the model for this route. More info.
objectListViewLimitPredicate
-
options
It forms the limit predicate for loaded data.
By default it returns undefined
.
In order to set specific limit predicate, this method have to be overriden on applied-specific route.
Parameters:
Returns:
The predicate to limit loaded data
Example:
// app/routes/limit-function-example.js
import ListFormRoute from 'ember-flexberry/routes/list-form';
import { StringPredicate } from 'ember-flexberry-data/query/predicate';
export default ListFormRoute.extend({
modelProjection: 'FolvWithLimitFunctionExampleView',
modelName: 'ember-flexberry-dummy-suggestion',
objectListViewLimitPredicate: function(options) {
let methodOptions = merge({
modelName: undefined,
projectionName: undefined,
params: undefined
}, options);
if (methodOptions.modelName === this.get('modelName') &&
methodOptions.projectionName === this.get('modelProjection')) {
let currentPerPageValue = methodOptions.params ? methodOptions.params.perPage : undefined;
let limitFunction = (currentPerPageValue && currentPerPageValue % 2 === 0) ?
new StringPredicate('address').contains('S') :
new StringPredicate('address').contains('п');
return limitFunction;
}
return undefined;
}
});
onModelLoadingAlways.
-
data
-
transition
This method will be invoked always when model loading operation completed, regardless of model loading promise's state (was it fulfilled or rejected). Override this method to add some custom logic on model loading operation completion.
Parameters:
-
data
ObjectData about completed model loading operation.
-
transition
TransitionCurrent transition object.
Example:
onModelLoadingAlways(data, transition) {
alert('Model loading operation completed!');
}
onModelLoadingFulfilled.
-
model
-
transition
This method will be invoked when model loading operation successfully completed. Override this method to add some custom logic on model loading operation success.
Parameters:
-
model
ObjectLoaded model data.
-
transition
TransitionCurrent transition object.
Example:
onModelLoadingFulfilled(model, transition) {
alert('Model loading operation succeed!');
}
onModelLoadingRejected.
-
errorData
-
transition
This method will be invoked when model loading operation completed, but failed. Override this method to add some custom logic on model loading operation fail. By default showing error form.
Parameters:
-
errorData
ObjectData about model loading operation fail.
-
transition
TransitionCurrent transition object.
Example:
onModelLoadingRejected(errorData, transition) {
alert('Model loading operation failed!');
}
onModelLoadingStarted.
-
queryParameters
-
transition
This method will be invoked before model loading operation will be called. Override this method to add some custom logic on model loading operation start.
Parameters:
-
queryParameters
ObjectQuery parameters used for model loading operation.
-
transition
TransitionCurrent transition object.
Example:
onModelLoadingStarted(queryParameters, transition) {
alert('Model loading operation started!');
}
predicateForAttribute
-
attribute
-
filter
-
filterCondition
Create predicate for attribute. Can you overload this function for extended logic.
Default supported attribute types:
string
number
Parameters:
-
attribute
ObjectObject contains attribute info.
-
filter
StringPattern for search.
-
filterCondition
StringCondition for predicate, can be
or
orand
.
Returns:
Object class of BasePredicate
or null
, if not need filter.
Example:
// app/routes/example.js
...
// Add support for logical attribute
predicateForAttribute(attribute, filter) {
switch (attribute.type) {
case 'boolean':
let yes = ['TRUE', 'True', 'true', 'YES', 'Yes', 'yes', 'ДА', 'Да', 'да', '1', '+'];
let no = ['False', 'False', 'false', 'NO', 'No', 'no', 'НЕТ', 'Нет', 'нет', '0', '-'];
if (yes.indexOf(filter) > 0) {
return new SimplePredicate(attribute.name, 'eq', 'true');
}
if (no.indexOf(filter) > 0) {
return new SimplePredicate(attribute.name, 'eq', 'false');
}
return null;
default:
return this._super(...arguments);
}
},
...
predicateForFilter
-
filter
Builds predicate for filter.
Parameters:
-
filter
ObjectObject (
{ name, condition, pattern }
) with parameters for filter.
Returns:
Predicate to filter through.
Example:
// app/routes/example.js
...
predicateForFilter(filter) {
if (filter.type === 'string' && filter.condition === 'like') {
return new StringPredicate(filter.name).contains(filter.pattern);
}
return this._super(...arguments);
},
...
reloadList
-
options
It reloads data by parameters.
This method is called to get data for flexberry-objectlistview
(both on list-form and lookup modal window).
Parameters:
-
options
ObjectMethod options.
-
[modelName]
String optionalType of records to load.
-
[projectionName]
String optionalProjection name to load data by.
-
[perPage]
String optionalPage size.
-
[page]
String optionalCurrent page.
-
[sorting]
String optionalCurrent sorting.
-
[filter]
String optionalCurrent filter.
-
[filterProjectionName]
String optionalName of model projection which should be used for filtering throught search-element on toolbar. Filtering is processed only by properties defined in this projection.
-
[predicate]
String optionalPredicate to limit records.
-
Returns:
A promise, which is resolved with a set of loaded records once the server returns.
setupController
-
controller
-
model
A hook you can use to setup the controller for the current route. More info.
Parameters:
-
controller
Controller -
model
Object
Properties
colsConfigMenu
Service
filterPredicate
BasePredicate
Result predicate with filters restrictions for olv.
Default: null
objectlistviewEvents
Class
Service that triggers objectlistview events.
Default: inject()
resultPredicate
BasePredicate
Result predicate with all restrictions for olv.
Default: null