Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _data/components/grid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ inheritedAttributes: [{
},{
component: "OServiceComponent",
path: "components/service/service/api",
attributes: ["title", "visible", "enabled", "controls", "detail-mode", "detail-form-route", "recursive-detail", "quick-filter", "quick-filter-placeholder", "quick-filter-appearance", "pagination-controls", "page-size-options"]
attributes: ["title", "visible", "enabled", "controls", "detail-mode", "detail-form-route", "recursive-detail", "quick-filter", "quick-filter-placeholder", "quick-filter-appearance", "pagination-controls", "page-size-options","initial-filter-function"]
}]

attributes: [{
Expand Down
2 changes: 1 addition & 1 deletion _data/components/list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ inheritedAttributes: [{
},{
component: "OServiceComponent",
path: "components/service/service/api",
attributes: ["title", "visible", "enabled", "controls", "detail-mode", "detail-form-route", "recursive-detail", "detail-button-in-row", "detail-button-in-row-icon", "edit-form-route", "recursive-edit", "edit-button-in-row", "edit-button-in-row-icon", "insert-button", "row-height", "insert-form-route", "recursive-insert", "quick-filter", "quick-filter-placeholder", "quick-filter-appearance", "pagination-controls", "page-size-options"]
attributes: ["title", "visible", "enabled", "controls", "detail-mode", "detail-form-route", "recursive-detail", "detail-button-in-row", "detail-button-in-row-icon", "edit-form-route", "recursive-edit", "edit-button-in-row", "edit-button-in-row-icon", "insert-button", "row-height", "insert-form-route", "recursive-insert", "quick-filter", "quick-filter-placeholder", "quick-filter-appearance", "pagination-controls", "page-size-options","initial-filter-function"]
}]

inheritedOutputs: [{
Expand Down
2 changes: 1 addition & 1 deletion _data/components/otableData/00table.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ inheritedAttributes: [{
},{
component: "OServiceComponent",
path: "components/service/service/api",
attributes: ["title", "visible", "enabled", "controls", "detail-mode", "detail-form-route", "recursive-detail", "detail-button-in-row", "detail-button-in-row-icon", "edit-form-route", "recursive-edit", "edit-button-in-row", "edit-button-in-row-icon", "insert-button", "row-height", "insert-form-route", "recursive-insert", "filter-case-sensitive", "quick-filter", "quick-filter-placeholder", "pagination-controls", "page-size-options"]
attributes: ["title", "visible", "enabled", "controls", "detail-mode", "detail-form-route", "recursive-detail", "detail-button-in-row", "detail-button-in-row-icon", "edit-form-route", "recursive-edit", "edit-button-in-row", "edit-button-in-row-icon", "insert-button", "row-height", "insert-form-route", "recursive-insert", "filter-case-sensitive", "quick-filter", "quick-filter-placeholder", "pagination-controls", "page-size-options","initial-filter-function"]
}]

attributes: [{
Expand Down
5 changes: 5 additions & 0 deletions _data/components/service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ attributes: [{
default : "outline",
required : "",
description : "Indicates which of the mat-form-field different except in o-table component[appearance variants](https://v15.material.angular.io/components/form-field/overview#form-field-appearance-variants) will be used. except in the o-table component."
},{
name: "initial-filter-function",
type: "() => Expression | { [key: string]: any }",
since: "15.8.3",
description: "Callback function that returns an initial filter to be applied on every query."
}]


Expand Down
2 changes: 1 addition & 1 deletion _data/components/tree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ apiTitle: "OTreeComponent"
inheritedAttributes: [{
component: "OServiceBaseComponent",
path: "components/service/service-base/api",
attributes: ["attr", "static-data", "service", "service-type","query-fallback-function", "query-method", "entity", "keys", "parent-keys", "columns", "query-on-init", "query-on-bind", "query-rows", "insert-method", "update-method", "paginated-query-method", "delete-method", "pageable", "store-state"]
attributes: ["attr", "static-data", "service", "service-type","query-fallback-function", "query-method", "entity", "keys", "parent-keys", "columns", "query-on-init", "query-on-bind", "query-rows", "insert-method", "update-method", "paginated-query-method", "delete-method", "pageable", "store-state", "initial-filter-function"]
}]

attributes: [{
Expand Down
37 changes: 37 additions & 0 deletions docs/components/o_service_components/01-o-service.component.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,43 @@ export class MyComponent extends OServiceBaseComponent {
row-height
-->

## Initial-filter-function
The `initial-filter-function` input allows you to provide a callback function that returns an initial filter to be applied on every query performed by the component. This filter is merged with any other active filters (quick filter, filter builder) using a logical `AND` operation.

The returned value can be either an OntimizeWeb **Expression** object (for complex, structured filter expressions) or a **plain key-value object** (for simple column-value filters). The component handles both cases automatically:

* If the returned value is an Expression, it is combined with the existing filter expression using FilterExpressionUtils.OP_AND.
* If the returned value is a plain object, its properties are merged directly into the base filter object via object spread.

This input is especially useful when you need to enforce a persistent filter condition regardless of user interactions, such as restricting data to the current user, a specific tenant, or a fixed business rule.

**Examples**
```html
<o-table ... [initial-filter-function]="initialFilterFunction">
...
</o-table>
```

```ts
import { Expression, FilterExpressionUtils } from 'ontimize-web-ngx';

// Returning a Expression (STARTDATE > 01/01/2010 AND < Today)
initialFilterFunction(): Expression {
const exp1 = FilterExpressionUtils.buildExpressionMoreEqual('STARTDATE', 1262304000000);
const exp2 = FilterExpressionUtils.buildExpressionLessEqual('STARTDATE', Date.now());
return FilterExpressionUtils.buildComplexExpression(exp1, exp2, FilterExpressionUtils.OP_AND);
}

//Returning a plain key-value object
initialFilterFunction(): { [key: string]: any } {
return { CUSTOMERTYPEID: 1 };
}
```

**NOTE**:
* **Execution on every query**: The callback is invoked on every request made by the component, including pagination, sorting, and refresh actions. Ensure the function is lightweight and side-effect free.
* **Compatibility**: This input is available on all components that extend OServiceComponent, including o-table, o-grid, o-list, and similar data-bound components.

## Navigation to record detail
In the service components, the default action when user clicks a item is to trigger the navigation to its record detail. For changing this behaviour, the user can change the `detail-mode` input value using one of the following values `none`, `click` or `doubleclick`.

Expand Down