mobx-lark 2.4.1 → 2.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/module/BITable/index.d.ts +54 -46
- package/dist/module/InstantMessenger/index.d.ts +14 -10
- package/dist/module/Task/index.d.ts +28 -20
- package/dist/module/Wiki/index.d.ts +14 -10
- package/package.json +18 -19
- package/src/module/BITable/index.ts +28 -5
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { observable } from 'mobx';
|
|
1
2
|
import { DataObject, Filter, ListModel, PageData, RESTClient, Stream, toggle } from 'mobx-restful';
|
|
2
3
|
import { buildURLData, Constructor, isEmpty } from 'web-utility';
|
|
3
4
|
|
|
@@ -151,7 +152,11 @@ export function BiDataTable<T extends DataObject, F extends Filter<T> = Filter<T
|
|
|
151
152
|
return BiDataTableModel;
|
|
152
153
|
}
|
|
153
154
|
|
|
154
|
-
export
|
|
155
|
+
export type BiSearchFilter<D extends DataObject> = Filter<D> & {
|
|
156
|
+
keywords?: string;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export function BiSearch<D extends DataObject, F extends BiSearchFilter<D> = BiSearchFilter<D>>(
|
|
155
160
|
Model: Constructor<ListModel<D, F>>
|
|
156
161
|
) {
|
|
157
162
|
abstract class BiSearchModel extends Model {
|
|
@@ -161,19 +166,37 @@ export function BiSearch<D extends DataObject, F extends Filter<D> = Filter<D>>(
|
|
|
161
166
|
|
|
162
167
|
abstract searchKeys: readonly (keyof TableRecordFields)[];
|
|
163
168
|
|
|
169
|
+
@observable
|
|
170
|
+
accessor keywords = '';
|
|
171
|
+
|
|
164
172
|
makeFilter(filter: F) {
|
|
165
173
|
return isEmpty(filter) ? '' : makeSimpleFilter(filter, 'contains', 'OR');
|
|
166
174
|
}
|
|
167
175
|
|
|
176
|
+
async getList(
|
|
177
|
+
{ keywords, ...filter }: F,
|
|
178
|
+
pageIndex = this.pageIndex + 1,
|
|
179
|
+
pageSize = this.pageSize
|
|
180
|
+
) {
|
|
181
|
+
keywords = keywords?.trim();
|
|
182
|
+
|
|
183
|
+
if (keywords) {
|
|
184
|
+
const wordList = (this.keywords = keywords).split(/[\s,]+/);
|
|
185
|
+
|
|
186
|
+
filter = Object.fromEntries(this.searchKeys.map(key => [key, wordList])) as F;
|
|
187
|
+
}
|
|
188
|
+
return super.getList(filter as F, pageIndex, pageSize);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* @deprecated since v2.4.2, use {@link getList} instead
|
|
193
|
+
*/
|
|
168
194
|
async getSearchList(
|
|
169
195
|
keywords: string,
|
|
170
196
|
pageIndex = this.pageIndex + 1,
|
|
171
197
|
pageSize = this.pageSize
|
|
172
198
|
) {
|
|
173
|
-
|
|
174
|
-
const filterList = this.searchKeys.map(key => [key, wordList]);
|
|
175
|
-
|
|
176
|
-
return this.getList(Object.fromEntries(filterList), pageIndex, pageSize);
|
|
199
|
+
return this.getList({ keywords } as F, pageIndex, pageSize);
|
|
177
200
|
}
|
|
178
201
|
}
|
|
179
202
|
return BiSearchModel;
|