@frui.ts/data
Advanced tools
Comparing version 1.0.0-alpha.10 to 1.0.0-alpha.11
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./pagerHelper")); | ||
__export(require("./sortingDirection")); | ||
__export(require("./sortingHelper")); | ||
__exportStar(require("./pagerHelper"), exports); | ||
__exportStar(require("./sortingDirection"), exports); | ||
__exportStar(require("./sortingHelper"), exports); | ||
__exportStar(require("./types"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { IPagingFilter, IPagingInfo } from "./types"; | ||
import type { IPagingFilter, IPagingInfo } from "./types"; | ||
declare type onPageChangedHandler = (offset: number, limit: number) => void; | ||
@@ -3,0 +3,0 @@ export interface IPagerProps { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var defaultPageSize = 25; | ||
exports.handlePageSizeChanged = exports.pageChangedHandler = exports.handlePageChanged = exports.handlePagingChanged = void 0; | ||
const defaultPageSize = 25; | ||
function handlePagingChanged(offset, limit, filter, onPageChanged) { | ||
@@ -15,4 +16,4 @@ if (filter) { | ||
function handlePageChanged(newPageNumber, filter, onPageChanged) { | ||
var pageSize = (filter && filter.limit) || defaultPageSize; | ||
var offset = (newPageNumber - 1) * pageSize; | ||
const pageSize = (filter === null || filter === void 0 ? void 0 : filter.limit) || defaultPageSize; | ||
const offset = (newPageNumber - 1) * pageSize; | ||
handlePagingChanged(offset, pageSize, filter, onPageChanged); | ||
@@ -22,3 +23,3 @@ } | ||
function pageChangedHandler(newPageNumber, filter, onPageChanged) { | ||
return function () { return handlePageChanged(newPageNumber, filter, onPageChanged); }; | ||
return () => handlePageChanged(newPageNumber, filter, onPageChanged); | ||
} | ||
@@ -25,0 +26,0 @@ exports.pageChangedHandler = pageChangedHandler; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SortingDirection = void 0; | ||
var SortingDirection; | ||
@@ -4,0 +5,0 @@ (function (SortingDirection) { |
@@ -1,2 +0,5 @@ | ||
import { IPagingFilter } from "./types"; | ||
export declare function applySort(filter: IPagingFilter, columnName: string): void; | ||
import { SortingDirection } from "./sortingDirection"; | ||
import type { IPagingFilter } from "./types"; | ||
export declare function getSortingDirection(filter: IPagingFilter, columnName: string): SortingDirection | undefined; | ||
export declare function setSort(filter: IPagingFilter, columnName: string, direction?: SortingDirection): void; | ||
export declare function addSort(filter: IPagingFilter, columnName: string, direction?: SortingDirection): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var sortingDirection_1 = require("./sortingDirection"); | ||
function applySort(filter, columnName) { | ||
if (filter.sortColumn === columnName) { | ||
filter.sortDirection = | ||
filter.sortDirection === sortingDirection_1.SortingDirection.Ascending ? sortingDirection_1.SortingDirection.Descending : sortingDirection_1.SortingDirection.Ascending; | ||
exports.addSort = exports.setSort = exports.getSortingDirection = void 0; | ||
const sortingDirection_1 = require("./sortingDirection"); | ||
function getSortingDirection(filter, columnName) { | ||
var _a, _b; | ||
const existingIndex = (_a = filter.sorting) === null || _a === void 0 ? void 0 : _a.findIndex(x => x.column === columnName); | ||
if (existingIndex === undefined || existingIndex < 0) { | ||
return undefined; | ||
} | ||
return (_b = filter.sorting) === null || _b === void 0 ? void 0 : _b[existingIndex].direction; | ||
} | ||
exports.getSortingDirection = getSortingDirection; | ||
function setSort(filter, columnName, direction) { | ||
var _a; | ||
const existingSort = ((_a = filter.sorting) === null || _a === void 0 ? void 0 : _a.length) ? filter.sorting[0] : undefined; | ||
const sortDirection = direction !== null && direction !== void 0 ? direction : ((existingSort === null || existingSort === void 0 ? void 0 : existingSort.column) === columnName && existingSort.direction === sortingDirection_1.SortingDirection.Ascending | ||
? sortingDirection_1.SortingDirection.Descending | ||
: sortingDirection_1.SortingDirection.Ascending); | ||
if (filter.sorting) { | ||
filter.sorting[0] = { column: columnName, direction: sortDirection }; | ||
filter.sorting.length = 1; | ||
} | ||
else { | ||
filter.sortColumn = columnName; | ||
filter.sortDirection = sortingDirection_1.SortingDirection.Ascending; | ||
filter.sorting = [{ column: columnName, direction: sortDirection }]; | ||
} | ||
} | ||
exports.applySort = applySort; | ||
exports.setSort = setSort; | ||
function addSort(filter, columnName, direction) { | ||
if (!filter.sorting) { | ||
filter.sorting = [{ column: columnName, direction: direction !== null && direction !== void 0 ? direction : sortingDirection_1.SortingDirection.Ascending }]; | ||
return; | ||
} | ||
const existingIndex = filter.sorting.findIndex(x => x.column === columnName); | ||
if (existingIndex === -1) { | ||
filter.sorting.push({ column: columnName, direction: direction !== null && direction !== void 0 ? direction : sortingDirection_1.SortingDirection.Ascending }); | ||
} | ||
else { | ||
filter.sorting[existingIndex].direction = | ||
direction !== null && direction !== void 0 ? direction : (filter.sorting[existingIndex].direction === sortingDirection_1.SortingDirection.Ascending | ||
? sortingDirection_1.SortingDirection.Descending | ||
: sortingDirection_1.SortingDirection.Ascending); | ||
} | ||
} | ||
exports.addSort = addSort; | ||
//# sourceMappingURL=sortingHelper.js.map |
@@ -1,6 +0,6 @@ | ||
import { SortingDirection } from "./sortingDirection"; | ||
import type { SortingDirection } from "./sortingDirection"; | ||
export interface IPagingInfo { | ||
totalItems: number; | ||
offset: number; | ||
limit: number; | ||
readonly totalItems: number; | ||
readonly offset: number; | ||
readonly limit: number; | ||
} | ||
@@ -10,5 +10,7 @@ export interface IPagingFilter { | ||
limit: number; | ||
sortColumn?: string; | ||
sortDirection?: SortingDirection; | ||
sorting?: { | ||
column: string; | ||
direction: SortingDirection; | ||
}[]; | ||
} | ||
export declare type PagedQueryResult<TEntity> = [TEntity[], IPagingInfo]; |
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "1.0.0-alpha.10", | ||
"version": "1.0.0-alpha.11", | ||
"description": "Helpers and interfaces for handling paged and sorted data sets", | ||
@@ -37,3 +37,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "5454d007244bb9cdd28be5207a9f125f04a9ac43" | ||
"gitHead": "f9f70e1d4bcbe45b8b37f11f5dcdfd2ed9a523c7" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16714
139