@itrocks/list 0.2.1 → 0.2.2
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/cjs/sort.d.ts +2 -0
- package/cjs/sort.js +10 -1
- package/package.json +1 -1
package/cjs/sort.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Type } from '@itrocks/class-type';
|
|
2
2
|
import { Request } from '@itrocks/request-response';
|
|
3
3
|
import { Option } from '@itrocks/storage';
|
|
4
|
+
import { Sort as SortOption } from '@itrocks/storage';
|
|
4
5
|
import { Columns } from './columns';
|
|
5
6
|
import { Parameter } from './parameter';
|
|
6
7
|
interface Serialized {
|
|
@@ -17,6 +18,7 @@ export declare class Sort<T extends object> extends Parameter {
|
|
|
17
18
|
getParams(request: Request, type: Type<T>): void;
|
|
18
19
|
readOptions(options?: Option[]): Option[];
|
|
19
20
|
serialize(): Serialized | undefined;
|
|
21
|
+
sortOption(): SortOption | Type<SortOption>;
|
|
20
22
|
unserialize(data: Serialized): void;
|
|
21
23
|
}
|
|
22
24
|
export {};
|
package/cjs/sort.js
CHANGED
|
@@ -56,12 +56,21 @@ class Sort extends parameter_1.Parameter {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
readOptions(options = new Array) {
|
|
59
|
-
options.push(
|
|
59
|
+
options.push(this.sortOption());
|
|
60
60
|
return options;
|
|
61
61
|
}
|
|
62
62
|
serialize() {
|
|
63
63
|
return this.sorted;
|
|
64
64
|
}
|
|
65
|
+
sortOption() {
|
|
66
|
+
if (!this.sorted)
|
|
67
|
+
return storage_1.Sort;
|
|
68
|
+
const properties = new Array;
|
|
69
|
+
for (const [propertyName, reverse] of Object.entries(this.sorted)) {
|
|
70
|
+
properties.push(reverse ? new sort_1.Reverse(propertyName) : propertyName);
|
|
71
|
+
}
|
|
72
|
+
return new storage_1.Sort(properties);
|
|
73
|
+
}
|
|
65
74
|
unserialize(data) {
|
|
66
75
|
this.sorted = data;
|
|
67
76
|
}
|
package/package.json
CHANGED