UNPKG

@egalteam/framework

Version:

Egal

67 lines (66 loc) 2.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GetItemsActionParams = void 0; var GetItemsSortingParams_1 = require("./GetItemsSortingParams"); var GetItemsFilterParams_1 = require("./GetItemsFilterParams"); var GetItemsActionParams = /** @class */ (function () { function GetItemsActionParams() { this.withs = []; this.filter = []; this.order = []; this.pagination = null; this.id = ''; } /** * Функция формирует массив с выбранными пользователем with * @param withObj */ GetItemsActionParams.prototype.with = function (withObj) { if (withObj) { Array.isArray(withObj) ? (this.withs = withObj) : this.withs.push(withObj); } else return undefined; }; /** * Функция для передачи id в параметры, применяется при запросах getItem, update, delete * @param setId */ GetItemsActionParams.prototype.setId = function (setId) { this.id = setId; }; /** * Функция формирования фильтров * @param filterObj */ GetItemsActionParams.prototype.filters = function (filterObj) { var newFilterObj = new GetItemsFilterParams_1.GetItemsFilterParams(filterObj); newFilterObj.checkFilterType(); this.filter = newFilterObj.formFilterObject(); }; /** * Функция формирования массива сортировок * @param orderObj */ GetItemsActionParams.prototype.orders = function (orderObj) { this.order = new GetItemsSortingParams_1.GetItemsSortingParams().createOrderObj(orderObj); }; GetItemsActionParams.prototype.setPagination = function (perPage, page) { // @ts-ignore this.pagination = { per_page: perPage, page: page }; }; /** * Функция, формирующая конечный объект параметров запроса */ GetItemsActionParams.prototype.toObject = function () { return { pagination: this.pagination, filter: this.filter, withs: this.withs, order: this.order, id: this.id }; }; return GetItemsActionParams; }()); exports.GetItemsActionParams = GetItemsActionParams;