fix: sorting
This commit is contained in:
@@ -8,6 +8,9 @@ import {Call as $Call, Create as $Create} from "@wailsio/runtime";
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: Unused imports
|
||||
import * as models$0 from "../models/models.js";
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: Unused imports
|
||||
import * as utils$0 from "../utils/models.js";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: Unused imports
|
||||
@@ -50,8 +53,8 @@ export function GetById(id: number): Promise<$models.Author | null> & { cancel()
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
export function SortedByOrder(fieldsSortOrder: { [_: string]: string }): Promise<($models.Author | null)[]> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(3046628691, fieldsSortOrder) as any;
|
||||
export function SortedByOrder(fieldsSortingOrder: utils$0.SortField[]): Promise<($models.Author | null)[]> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(3046628691, fieldsSortingOrder) as any;
|
||||
let $typingPromise = $resultPromise.then(($result: any) => {
|
||||
return $$createType2($result);
|
||||
}) as any;
|
||||
|
||||
@@ -8,6 +8,9 @@ import {Call as $Call, Create as $Create} from "@wailsio/runtime";
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: Unused imports
|
||||
import * as models$0 from "../models/models.js";
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: Unused imports
|
||||
import * as utils$0 from "../utils/models.js";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: Unused imports
|
||||
@@ -50,7 +53,7 @@ export function GetById(id: number): Promise<$models.Comment | null> & { cancel(
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
export function SortedByOrder(fieldsSortOrder: { [_: string]: string }): Promise<($models.Comment | null)[]> & { cancel(): void } {
|
||||
export function SortedByOrder(fieldsSortOrder: utils$0.SortField[]): Promise<($models.Comment | null)[]> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(4244533291, fieldsSortOrder) as any;
|
||||
let $typingPromise = $resultPromise.then(($result: any) => {
|
||||
return $$createType2($result);
|
||||
|
||||
@@ -8,6 +8,9 @@ import {Call as $Call, Create as $Create} from "@wailsio/runtime";
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: Unused imports
|
||||
import * as models$0 from "../models/models.js";
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: Unused imports
|
||||
import * as utils$0 from "../utils/models.js";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: Unused imports
|
||||
@@ -50,7 +53,7 @@ export function GetById(id: number): Promise<$models.Post | null> & { cancel():
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
export function SortedByOrder(fieldsSortOrder: { [_: string]: string }): Promise<($models.Post | null)[]> & { cancel(): void } {
|
||||
export function SortedByOrder(fieldsSortOrder: utils$0.SortField[]): Promise<($models.Post | null)[]> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(471862744, fieldsSortOrder) as any;
|
||||
let $typingPromise = $resultPromise.then(($result: any) => {
|
||||
return $$createType2($result);
|
||||
|
||||
@@ -8,6 +8,9 @@ import {Call as $Call, Create as $Create} from "@wailsio/runtime";
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: Unused imports
|
||||
import * as models$0 from "../models/models.js";
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: Unused imports
|
||||
import * as utils$0 from "../utils/models.js";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: Unused imports
|
||||
@@ -50,7 +53,7 @@ export function GetById(id: number): Promise<$models.PostType | null> & { cancel
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
export function SortedByOrder(fieldsSortOrder: { [_: string]: string }): Promise<($models.PostType | null)[]> & { cancel(): void } {
|
||||
export function SortedByOrder(fieldsSortOrder: utils$0.SortField[]): Promise<($models.PostType | null)[]> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(1097313920, fieldsSortOrder) as any;
|
||||
let $typingPromise = $resultPromise.then(($result: any) => {
|
||||
return $$createType2($result);
|
||||
|
||||
4
frontend/bindings/app/internal/utils/index.ts
Normal file
4
frontend/bindings/app/internal/utils/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
export * from "./models.js";
|
||||
31
frontend/bindings/app/internal/utils/models.ts
Normal file
31
frontend/bindings/app/internal/utils/models.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: Unused imports
|
||||
import {Create as $Create} from "@wailsio/runtime";
|
||||
|
||||
export class SortField {
|
||||
"Name": string;
|
||||
"Order": string;
|
||||
|
||||
/** Creates a new SortField instance. */
|
||||
constructor($$source: Partial<SortField> = {}) {
|
||||
if (!("Name" in $$source)) {
|
||||
this["Name"] = "";
|
||||
}
|
||||
if (!("Order" in $$source)) {
|
||||
this["Order"] = "";
|
||||
}
|
||||
|
||||
Object.assign(this, $$source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new SortField instance from a string or object.
|
||||
*/
|
||||
static createFrom($$source: any = {}): SortField {
|
||||
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
|
||||
return new SortField($$parsedSource as Partial<SortField>);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
import type { Post } from "../../bindings/app/internal/services";
|
||||
import type { IService } from "../types/service.type.ts";
|
||||
import type {SortOptions} from "../types/sort-options.type.ts";
|
||||
import {SortField} from "../../bindings/app/internal/utils";
|
||||
|
||||
export default class PostService implements IService<Post> {
|
||||
async read(id: number) {
|
||||
@@ -36,6 +37,6 @@ export default class PostService implements IService<Post> {
|
||||
}
|
||||
|
||||
async sort(options: SortOptions<Post>) {
|
||||
return await SortedByOrder(options) as Post[]
|
||||
return await SortedByOrder(Object.entries(options).map(item => ({Name: item[0], Order: item[1]}))) as Post[]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user