Skip to content

Commit

Permalink
feat: add list meta support
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Jul 6, 2024
1 parent 11667d5 commit 8777266
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions packages/tushan/client/api/http/jsonServerProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ export function jsonServerProvider(
getList: (resource, params) => {
const { page, perPage } = params.pagination;
const { field, order } = params.sort;
const meta = params.meta;
const query = {
...flattenObject(params.filter),
_sort: field,
_order: order,
_start: (page - 1) * perPage,
_end: page * perPage,
meta,
};
const url = `${apiUrl}/${resource}?${qs.stringify(query)}`;

Expand Down Expand Up @@ -78,6 +80,7 @@ export function jsonServerProvider(
getMany: (resource, params) => {
const query = {
id: params.ids,
meta: params.meta,
};
const url = `${apiUrl}/${resource}?${qs.stringify(query)}`;
return httpClient(url).then(({ json }) => ({ data: json }));
Expand All @@ -86,13 +89,15 @@ export function jsonServerProvider(
getManyReference: (resource, params) => {
const { page, perPage } = params.pagination;
const { field, order } = params.sort;
const meta = params.meta;
const query = {
...flattenObject(params.filter),
[params.target]: params.id,
_sort: field,
_order: order,
_start: (page - 1) * perPage,
_end: page * perPage,
meta,
};
const url = `${apiUrl}/${resource}?${qs.stringify(query)}`;

Expand Down
4 changes: 2 additions & 2 deletions packages/tushan/client/components/fields/datetime.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { DatePicker, Input, TimePicker } from '@arco-design/web-react';
import { DatePicker } from '@arco-design/web-react';
import React from 'react';
import { createFieldFactory } from './factory';
import type { FieldDetailComponent, FieldEditComponent } from './types';

export type DateTimeFieldValueType = string | number;

export interface DateTimeFieldOptions {
format: 'iso' | 'unix' | 'timestamp';
format?: 'iso' | 'unix' | 'timestamp';
}

export const DateTimeFieldDetail: FieldDetailComponent<
Expand Down
2 changes: 2 additions & 0 deletions packages/tushan/client/components/list/ListTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export interface ListTableProps {
batchAction?: {
delete?: boolean;
};
meta?: any;
}

export const ListTable: React.FC<ListTableProps> = React.memo((props) => {
Expand All @@ -113,6 +114,7 @@ export const ListTable: React.FC<ListTableProps> = React.memo((props) => {
},
filter: lazyFilter,
sort,
meta: props.meta,
};
const {
data: list,
Expand Down
2 changes: 1 addition & 1 deletion packages/tushan/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tushan",
"version": "0.3.7",
"version": "0.3.9",
"description": "",
"main": "./index.ts",
"scripts": {
Expand Down

0 comments on commit 8777266

Please sign in to comment.