@sdflc/backend-helpers 1.0.42 → 1.0.43
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/build/BaseGateway.js
CHANGED
|
@@ -84,10 +84,10 @@ var BaseGateway = /** @class */ (function () {
|
|
|
84
84
|
};
|
|
85
85
|
BaseGateway.prototype.onListFilter = function (query, filterParams) {
|
|
86
86
|
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
-
var _a, hasStatus, hasRemovedAt, hasSpace, activeStatuses, hasLang, fieldForKeyword;
|
|
88
|
-
var _b;
|
|
89
|
-
return __generator(this, function (
|
|
90
|
-
_a = this.config || {}, hasStatus = _a.hasStatus, hasRemovedAt = _a.hasRemovedAt, hasSpace = _a.hasSpace, activeStatuses = _a.activeStatuses, hasLang = _a.hasLang, fieldForKeyword = _a.fieldForKeyword;
|
|
87
|
+
var _a, hasStatus, hasRemovedAt, hasSpace, activeStatuses, hasLang, fieldForKeyword, filterByUserField;
|
|
88
|
+
var _b, _c;
|
|
89
|
+
return __generator(this, function (_d) {
|
|
90
|
+
_a = this.config || {}, hasStatus = _a.hasStatus, hasRemovedAt = _a.hasRemovedAt, hasSpace = _a.hasSpace, activeStatuses = _a.activeStatuses, hasLang = _a.hasLang, fieldForKeyword = _a.fieldForKeyword, filterByUserField = _a.filterByUserField;
|
|
91
91
|
// This function should be overriden
|
|
92
92
|
if (hasStatus) {
|
|
93
93
|
query.whereIn(constants_1.FIELDS.STATUS, Array.isArray(filterParams === null || filterParams === void 0 ? void 0 : filterParams[constants_1.FIELDS.STATUS]) ? filterParams === null || filterParams === void 0 ? void 0 : filterParams[constants_1.FIELDS.STATUS] : (0, lodash_1.castArray)(activeStatuses));
|
|
@@ -109,6 +109,9 @@ var BaseGateway = /** @class */ (function () {
|
|
|
109
109
|
if (fieldForKeyword && filterParams.keyword) {
|
|
110
110
|
query.whereRaw("".concat(fieldForKeyword, " ILIKE ?"), "%".concat(filterParams.keyword, "%"));
|
|
111
111
|
}
|
|
112
|
+
if (filterByUserField) {
|
|
113
|
+
query.where((_c = {}, _c[filterByUserField] = this.getContext().userId, _c));
|
|
114
|
+
}
|
|
112
115
|
return [2 /*return*/];
|
|
113
116
|
});
|
|
114
117
|
});
|
|
@@ -21,6 +21,7 @@ export interface BaseGatewayPropsInterface extends CacheInterface {
|
|
|
21
21
|
localizationForField?: string;
|
|
22
22
|
defaultSorting?: SortItemInterface[];
|
|
23
23
|
fieldForKeyword?: string;
|
|
24
|
+
filterByUserField?: string;
|
|
24
25
|
insertChunkSize?: number;
|
|
25
26
|
hardRemove?: boolean;
|
|
26
27
|
loader?: LoaderInterface;
|
package/package.json
CHANGED