@webtypen/webframez-core 0.2.16 → 0.2.18

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.
@@ -1,5 +1,5 @@
1
1
  import { Request } from "../Router/Request";
2
- type DatatableAutoApplyMatchModeType = "begin" | "end" | null;
2
+ export type DatatableAutoApplyType = "begin" | "end" | null;
3
3
  export declare class Datatable {
4
4
  collection: string | Function;
5
5
  aggregation: {
@@ -19,8 +19,8 @@ export declare class Datatable {
19
19
  perPage: number;
20
20
  onRow?: Function;
21
21
  onAttributes?: Function;
22
- autoApplyFilter: DatatableAutoApplyMatchModeType;
23
- autoApplySearch: DatatableAutoApplyMatchModeType;
22
+ autoApplyFilter: DatatableAutoApplyType;
23
+ autoApplySearch: DatatableAutoApplyType;
24
24
  getInit(req: Request): Promise<any>;
25
25
  getAggregation(req: Request): Promise<any>;
26
26
  getSubAggregation(req: Request): Promise<any>;
@@ -39,4 +39,3 @@ export declare class Datatable {
39
39
  private formatFilterEntryVal;
40
40
  getFilterMatch(req: Request, searchOrFilter: any): Promise<any>;
41
41
  }
42
- export {};
@@ -67,18 +67,18 @@ class Datatable {
67
67
  const aggr = typeof this.aggregation === "function" ? yield this.aggregation(req) : this.aggregation;
68
68
  if (this.autoApplyFilter && req.body.filter && typeof req.body.filter === "object") {
69
69
  if (this.autoApplyFilter === "begin") {
70
- return [{ $match: Object.assign({}, this.getFilterMatch(req, req.body.filter)) }, ...aggr];
70
+ return [{ $match: Object.assign({}, (yield this.getFilterMatch(req, req.body.filter))) }, ...aggr];
71
71
  }
72
72
  else if (this.autoApplyFilter === "end") {
73
- return [...aggr, { $match: Object.assign({}, this.getFilterMatch(req, req.body.filter)) }];
73
+ return [...aggr, { $match: Object.assign({}, (yield this.getFilterMatch(req, req.body.filter))) }];
74
74
  }
75
75
  }
76
76
  else if (this.autoApplySearch && req.body.search && typeof req.body.search === "object") {
77
77
  if (this.autoApplySearch === "begin") {
78
- return [{ $match: Object.assign({}, this.getFilterMatch(req, req.body.search)) }, ...aggr];
78
+ return [{ $match: Object.assign({}, (yield this.getFilterMatch(req, req.body.search))) }, ...aggr];
79
79
  }
80
80
  else if (this.autoApplySearch === "end") {
81
- return [...aggr, { $match: Object.assign({}, this.getFilterMatch(req, req.body.search)) }];
81
+ return [...aggr, { $match: Object.assign({}, (yield this.getFilterMatch(req, req.body.search))) }];
82
82
  }
83
83
  }
84
84
  return aggr;
@@ -312,7 +312,7 @@ class Datatable {
312
312
  value = { $ne: null };
313
313
  break;
314
314
  case "==":
315
- value = this.formatFilterEntryVal(entry, filterEl);
315
+ value = this.formatFilterEntryVal(entry, filterEl, { regex: filterEl && filterEl.regex ? true : false });
316
316
  break;
317
317
  case "!=":
318
318
  const temp = this.formatFilterEntryVal(entry, filterEl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webtypen/webframez-core",
3
- "version": "0.2.16",
3
+ "version": "0.2.18",
4
4
  "description": "The core package of the typescript based webframez (web-framework) by webtypen.de",
5
5
  "homepage": "https://webtypen.de/",
6
6
  "license": "MIT",
@@ -2,7 +2,7 @@ import { DBConnection } from "../Database/DBConnection";
2
2
  import { NumericFunctions } from "../Functions/NumericFunctions";
3
3
  import { Request } from "../Router/Request";
4
4
 
5
- type DatatableAutoApplyMatchModeType = "begin" | "end" | null;
5
+ export type DatatableAutoApplyType = "begin" | "end" | null;
6
6
 
7
7
  export class Datatable {
8
8
  collection: string | Function = "";
@@ -15,8 +15,8 @@ export class Datatable {
15
15
  perPage: number = 25;
16
16
  onRow?: Function;
17
17
  onAttributes?: Function;
18
- autoApplyFilter: DatatableAutoApplyMatchModeType = "begin";
19
- autoApplySearch: DatatableAutoApplyMatchModeType = null;
18
+ autoApplyFilter: DatatableAutoApplyType = "begin";
19
+ autoApplySearch: DatatableAutoApplyType = null;
20
20
 
21
21
  async getInit(req: Request) {
22
22
  const out: any = { table: req.body._table };
@@ -67,15 +67,15 @@ export class Datatable {
67
67
  const aggr = typeof this.aggregation === "function" ? await this.aggregation(req) : this.aggregation;
68
68
  if (this.autoApplyFilter && req.body.filter && typeof req.body.filter === "object") {
69
69
  if (this.autoApplyFilter === "begin") {
70
- return [{ $match: { ...this.getFilterMatch(req, req.body.filter) } }, ...aggr];
70
+ return [{ $match: { ...(await this.getFilterMatch(req, req.body.filter)) } }, ...aggr];
71
71
  } else if (this.autoApplyFilter === "end") {
72
- return [...aggr, { $match: { ...this.getFilterMatch(req, req.body.filter) } }];
72
+ return [...aggr, { $match: { ...(await this.getFilterMatch(req, req.body.filter)) } }];
73
73
  }
74
74
  } else if (this.autoApplySearch && req.body.search && typeof req.body.search === "object") {
75
75
  if (this.autoApplySearch === "begin") {
76
- return [{ $match: { ...this.getFilterMatch(req, req.body.search) } }, ...aggr];
76
+ return [{ $match: { ...(await this.getFilterMatch(req, req.body.search)) } }, ...aggr];
77
77
  } else if (this.autoApplySearch === "end") {
78
- return [...aggr, { $match: { ...this.getFilterMatch(req, req.body.search) } }];
78
+ return [...aggr, { $match: { ...(await this.getFilterMatch(req, req.body.search)) } }];
79
79
  }
80
80
  }
81
81
  return aggr;
@@ -324,7 +324,7 @@ export class Datatable {
324
324
  value = { $ne: null };
325
325
  break;
326
326
  case "==":
327
- value = this.formatFilterEntryVal(entry, filterEl);
327
+ value = this.formatFilterEntryVal(entry, filterEl, { regex: filterEl && filterEl.regex ? true : false });
328
328
  break;
329
329
  case "!=":
330
330
  const temp = this.formatFilterEntryVal(entry, filterEl);