change-rule
Description
Fires each time a change is made to the filtering rule
Usage
"change-rule": ({
id: string | string,
rule: {
id?: string,
parent?: string,
data?: rule[],
glue?: "and" | "or",
field?: string,
$temp?: boolean,
type?: string,
predicate?: "month" | "year",
filter?: string,
includes?: any[],
value?: any,
};
}) => void;
Parameters
The callback of the action takes an object with the following parameters:
id
- (required) the id of a field for which the rule is updatedrule
- (required) a filtering rule with the following parameters:id
- (optional) the rule idparent
- (optional) parent id if anydata
- (optional) an array with therule
object parameters for each item$temp
- (optional) set to true by default, which means that a group is added only temporarily before changes are savedglue
- (optional) "and" | "or"field
- (optional) the id of a fieldtype
- (optional) the type of a value: "text" (default, for string values), "number", "date", "tuple"filter
- (optional) the filter operatorincludes
- (optional) an array of the included values (strings, numbers or dates)value
- (optional) the value passed to the field
Example
<script>
import { getData } from "./common/data";
import { FilterBuilder } from "@svar-ui/svelte-filter";
const { fields, options } = getData();
const init = (api) => {
api.on("change-rule", ev => {
console.log("The id of the field for which the rule was changed:" (ev.id));
});
}
</script>
<FilterBuilder {options} {fields} {init} />
Related articles: