1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | import * as ng1 from 'angular';
|
11 | import { IPromise } from 'angular';
|
12 | import { IDefaults } from './ngTableDefaults';
|
13 | import { NgTableEventsChannel } from './ngTableEventsChannel';
|
14 | import { NgTableSettings, ISettings } from './ngTableSettings';
|
15 | import { DataResult } from './data';
|
16 | import { IFilterValues } from './filtering';
|
17 | import { Grouping, IGroupingFunc, GroupSort, IGroupValues } from './grouping';
|
18 | import { ISortingValues } from './sorting';
|
19 | import { IPageButton } from './paging';
|
20 |
|
21 |
|
22 |
|
23 | export interface InternalTableParams<T> extends NgTableParams<T> {
|
24 | isNullInstance: boolean;
|
25 | }
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | export interface IParamValues<T> {
|
31 | |
32 |
|
33 |
|
34 | page?: number;
|
35 | |
36 |
|
37 |
|
38 | count?: number;
|
39 | |
40 |
|
41 |
|
42 | filter?: IFilterValues;
|
43 | |
44 |
|
45 |
|
46 | sorting?: ISortingValues;
|
47 | |
48 |
|
49 |
|
50 | group?: string | Grouping<T>;
|
51 | }
|
52 |
|
53 |
|
54 |
|
55 | export declare class NgTableParams<T> {
|
56 | |
57 |
|
58 |
|
59 | data: T[];
|
60 | reloadPages: () => void;
|
61 | private defaultSettings;
|
62 | private errParamsMemento;
|
63 | private isCommittedDataset;
|
64 | isNullInstance: boolean;
|
65 | private initialEvents;
|
66 | private prevParamsMemento;
|
67 | private _params;
|
68 | private _settings;
|
69 | constructor(baseParameters?: IParamValues<T> | boolean, baseSettings?: ISettings<T>);
|
70 | /**
|
71 | * Returns the number of data rows per page
|
72 | */
|
73 | count(): number;
|
74 | /**
|
75 | * Sets the number of data rows per page.
|
76 | * Changes to count will cause `isDataReloadRequired` to return true
|
77 | */
|
78 | count(count: number): this;
|
79 | /**
|
80 | * Returns the current filter values used to restrict the set of data rows.
|
81 | * @param trim supply true to return the current filter minus any insignificant values
|
82 | * (null, undefined and empty string)
|
83 | */
|
84 | filter(trim?: boolean): IFilterValues;
|
85 | /**
|
86 | * Sets filter values to the `filter` supplied; any existing filter will be removed
|
87 | * Changes to filter will cause `isDataReloadRequired` to return true and the current `page` to be set to 1
|
88 | */
|
89 | filter(filter: IFilterValues): this;
|
90 | /**
|
91 | * Generate array of pages.
|
92 | * When no arguments supplied, the current parameter state of this `NgTableParams` instance will be used
|
93 | * @param currentPage Which page must be active
|
94 | * @param totalItems Total quantity of items
|
95 | * @param pageSize Quantity of items on page
|
96 | * @param maxBlocks Quantity of blocks for pagination
|
97 | * @returns Array of pages
|
98 | */
|
99 | generatePagesArray(currentPage?: number, totalItems?: number, pageSize?: number, maxBlocks?: number): IPageButton[];
|
100 | /**
|
101 | * Returns the current grouping used to group the data rows
|
102 | */
|
103 | group(): Grouping<T>;
|
104 | /**
|
105 | * Sets grouping to the `group` supplied; any existing grouping will be removed.
|
106 | * Changes to group will cause `isDataReloadRequired` to return true and the current `page` to be set to 1
|
107 | */
|
108 | group(group: IGroupValues): this;
|
109 | /**
|
110 | * Sets grouping to the `field` and `sortDirection` supplied; any existing grouping will be removed
|
111 | * Changes to group will cause `isDataReloadRequired` to return true and the current `page` to be set to 1
|
112 | */
|
113 | group(field: string, sortDirection?: GroupSort): this;
|
114 | /**
|
115 | * Sets grouping to the `group` supplied; any existing grouping will be removed.
|
116 | * If `sortDirection` is supplied, this will be assigned to the sortDirection property of `group`
|
117 | * Changes to group will cause `isDataReloadRequired` to return true and the current `page` to be set to 1
|
118 | */
|
119 | group(group: IGroupingFunc<T> | string, sortDirection?: GroupSort): this;
|
120 | /**
|
121 | * Returns true when an attempt to `reload` the current `parameter` values have resulted in a failure.
|
122 | * This method will continue to return true until the `reload` is successfully called or when the
|
123 | * `parameter` values have changed
|
124 | */
|
125 | hasErrorState(): boolean;
|
126 | /**
|
127 | * Returns true if `filter` has significant filter value(s) (any value except null, undefined, or empty string),
|
128 | * otherwise false
|
129 | */
|
130 | hasFilter(): boolean;
|
131 | /**
|
132 | * Return true when a change to `filters` require the `reload` method
|
133 | * to be run so as to ensure the data presented to the user reflects these filters
|
134 | */
|
135 | hasFilterChanges(): boolean;
|
136 | /**
|
137 | * Returns true when at least one group has been set
|
138 | */
|
139 | hasGroup(): boolean;
|
140 | /**
|
141 | * Returns true when the `group` and when supplied, the `sortDirection` matches an existing group
|
142 | */
|
143 | hasGroup(group: string | IGroupingFunc<T>, sortDirection?: string): boolean;
|
144 | /**
|
145 | * Return true when a change to this instance should require the `reload` method
|
146 | * to be run so as to ensure the data rows presented to the user reflects the current state.
|
147 | *
|
148 | * Note that this method will return false when the `reload` method has run but fails. In this case
|
149 | * `hasErrorState` will return true.
|
150 | *
|
151 | * The built-in `ngTable` directives will watch for when this function returns true and will then call
|
152 | * the `reload` method to load its data rows
|
153 | */
|
154 | isDataReloadRequired(): boolean;
|
155 | /**
|
156 | * Returns true if sorting by the field supplied. Where direction supplied
|
157 | * the field must also be sorted by that direction to return true
|
158 | */
|
159 | isSortBy(field: string, direction?: string): boolean;
|
160 | /**
|
161 | * Returns sorting values in a format that can be consumed by the angular `$orderBy` filter service
|
162 | */
|
163 | orderBy(): string[];
|
164 | /**
|
165 | * Returns the index of the current "slice" of data rows
|
166 | */
|
167 | page(): number;
|
168 | /**
|
169 | * Sets the index of the current "slice" of data rows. The index starts at 1.
|
170 | * Changing the page number will cause `isDataReloadRequired` to return true
|
171 | */
|
172 | page(page: number): this;
|
173 | parameters(): IParamValues<T>;
|
174 | /**
|
175 | * Set new parameters
|
176 | */
|
177 | parameters(newParameters?: IParamValues<T> | {
|
178 | [name: string]: string;
|
179 | }, parseParamsFromUrl?: boolean): this;
|
180 | /**
|
181 | * Trigger a reload of the data rows
|
182 | */
|
183 | reload<TResult extends DataResult<T>>(): IPromise<TResult[]>;
|
184 | /**
|
185 | * Returns the settings for the table.
|
186 | */
|
187 | settings(): ISettings<T>;
|
188 | /**
|
189 | * Sets the settings for the table; new setting values will be merged with the existing settings.
|
190 | * Supplying a new `dataset` will cause `isDataReloadRequired` to return true and the `ngTableEventsChannel`
|
191 | * to fire its `datasetChanged` event
|
192 | */
|
193 | settings(newSettings: ISettings<T>): this;
|
194 | /**
|
195 | * Returns the current sorting used to order the data rows.
|
196 | * Changes to sorting will cause `isDataReloadRequired` to return true
|
197 | */
|
198 | sorting(): ISortingValues;
|
199 | /**
|
200 | * Sets sorting values to the `sorting` supplied; any existing sorting will be removed.
|
201 | * Changes to sorting will cause `isDataReloadRequired` to return true
|
202 | */
|
203 | sorting(sorting: ISortingValues): this;
|
204 | /**
|
205 | * Sets sorting to the `field` and `direction` supplied; any existing sorting will be removed
|
206 | */
|
207 | sorting(field: string, direction: string): this;
|
208 | /**
|
209 | * Returns the count of the data rows that match the current `filter`
|
210 | */
|
211 | total(): number;
|
212 | /**
|
213 | * Sets `settings().total` to the value supplied.
|
214 | * Typically you will need to set a `total` in the body of any custom `getData` function
|
215 | * you supply as a setting value to this instance.
|
216 | * @example
|
217 | * ```js
|
218 | * const tp = new NgTableParams({}, { getData: customGetData })
|
219 | * function customGetData(params) {
|
220 | * const queryResult =
|
221 | * params.total(queryResult.total);
|
222 | * return queryResult.dataRowsPage;
|
223 | * }
|
224 | * ```
|
225 | */
|
226 | total(total: number): this;
|
227 | /**
|
228 | * Returns the current parameter values uri-encoded. Set `asString` to
|
229 | * true for the parameters to be returned as an array of strings of the form 'paramName=value'
|
230 | * otherwise parameters returned as a key-value object
|
231 | */
|
232 | url(asString?: boolean): {
|
233 | [name: string]: string;
|
234 | };
|
235 | private createComparableParams();
|
236 | private hasGlobalSearchFieldChanges();
|
237 | private log(...args);
|
238 | private parseGroup(group);
|
239 | private runInterceptorPipeline(fetchedData);
|
240 | private static $q;
|
241 | private static $log;
|
242 | private static ngTableDefaults;
|
243 | private static ngTableEventsChannel;
|
244 | private static ngTableSettings;
|
245 | static init($q: ng1.IQService, $log: ng1.ILogService, ngTableDefaults: IDefaults, ngTableEventsChannel: NgTableEventsChannel, ngTableSettings: NgTableSettings): void;
|
246 | }
|
247 |
|
\ | No newline at end of file |