Replace sortingExpression with sortingPreset in all files
Signed-off-by: trivernis <trivernis@protonmail.com>pull/12/head
parent
c0dca663b0
commit
ece096fb86
@ -1,20 +1,39 @@
|
|||||||
import {SortKey} from "./SortKey";
|
import {SortKey} from "./SortKey";
|
||||||
import {SortingPresetData} from "../api-types/presets";
|
import {SortingPresetData} from "../api-types/presets";
|
||||||
|
import {mapNew} from "./adaptors";
|
||||||
|
|
||||||
export class SortingPreset {
|
export class SortingPreset {
|
||||||
private readonly _id: number;
|
|
||||||
private keys: SortKey[];
|
private keys: SortKey[];
|
||||||
|
|
||||||
constructor(presetData: SortingPresetData) {
|
constructor(presetData: SortingPresetData) {
|
||||||
this._id = presetData.id;
|
this._id = presetData.id;
|
||||||
this.keys = presetData.keys.map(SortKey.fromRawData);
|
this.keys = presetData.keys.map(mapNew(SortKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _id: number;
|
||||||
|
|
||||||
public get id(): number {
|
public get id(): number {
|
||||||
return this._id;
|
return this._id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public set id(value: number) {
|
||||||
|
this._id = value;
|
||||||
|
}
|
||||||
|
|
||||||
public get sortKeys(): SortKey[] {
|
public get sortKeys(): SortKey[] {
|
||||||
return this.sortKeys;
|
return this.keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get rawData(): SortingPresetData {
|
||||||
|
return {
|
||||||
|
id: this._id,
|
||||||
|
keys: this.keys.map(k => k.rawData),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static fromValues(id: number, keys: SortKey[]) {
|
||||||
|
let preset = new SortingPreset({ id, keys: [] });
|
||||||
|
preset.keys = keys;
|
||||||
|
return preset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue