@galadrim/galadmin 0.1.141 → 0.1.142

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.
@@ -63,6 +63,7 @@ export type ForeignSelectColumn = {
63
63
  selectExpression?: string;
64
64
  join?: string;
65
65
  filters?: Filter[];
66
+ filtersFromUser?: (userId: number) => string;
66
67
  orderBy?: string;
67
68
  optional?: boolean;
68
69
  formatForeignValue?: (record: any) => string;
@@ -77,6 +78,7 @@ export type ForeignDatalistColumn = {
77
78
  selectExpression?: string;
78
79
  join?: string;
79
80
  filters?: Filter[];
81
+ filtersFromUser?: (userId: number) => string;
80
82
  orderBy?: string;
81
83
  optional?: boolean;
82
84
  formatForeignValue?: (record: any) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galadrim/galadmin",
3
- "version": "0.1.141",
3
+ "version": "0.1.142",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
package/src/api.ts CHANGED
@@ -176,7 +176,11 @@ export default (db, config, user) => {
176
176
  const { rows: records, error } = await getRecords({
177
177
  table: column.table,
178
178
  page: 1,
179
- filters: sqlAnd([column.filters, req.body.query ? `${column.searchableName} LIKE '${column.wholeSearch ? '%' : ''}${req.body.query}%'` : null]),
179
+ filters: sqlAnd([
180
+ column.filters,
181
+ req.body.query ? `${column.searchableName} LIKE '${column.wholeSearch ? '%' : ''}${req.body.query}%'` : null,
182
+ column.filtersFromUser ? column.filtersFromUser(user.userId) : null
183
+ ]),
180
184
  join: column.join,
181
185
  selectExpression: column.selectExpression,
182
186
  orderBy: column.orderBy,