mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-09 15:39:24 +08:00
feat: update date helper functions and improve variable configuration UI
This commit is contained in:
parent
c8ecdb7c2c
commit
cbcc2a944d
@ -63,6 +63,7 @@ const Configurator = observer(
|
|||||||
({ index, close }: { index: number; close: () => void }) => {
|
({ index, close }: { index: number; close: () => void }) => {
|
||||||
const app = useApp();
|
const app = useApp();
|
||||||
const { value, helperObservables } = useCurrentVariable();
|
const { value, helperObservables } = useCurrentVariable();
|
||||||
|
|
||||||
const { helpersObs, rawHelpersObs, removeHelper } = helperObservables;
|
const { helpersObs, rawHelpersObs, removeHelper } = helperObservables;
|
||||||
const helper = helpersObs.value[index];
|
const helper = helpersObs.value[index];
|
||||||
const rawHelper = rawHelpersObs.value[index];
|
const rawHelper = rawHelpersObs.value[index];
|
||||||
@ -77,11 +78,11 @@ const Configurator = observer(
|
|||||||
}, value);
|
}, value);
|
||||||
|
|
||||||
const InputValue = () => {
|
const InputValue = () => {
|
||||||
return <Tag color="red">{JSON.stringify(inputValue).slice(1, -1)}</Tag>;
|
return <Tag color="red">{JSON.stringify(typeof inputValue).slice(1, -1)}</Tag>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const OuputValue = () => {
|
const OuputValue = () => {
|
||||||
return <Tag color="green">{JSON.stringify(outputValue).slice(1, -1)}</Tag>;
|
return <Tag color="green">{outputValue.toDate().toLocaleString()}</Tag>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const useFormBlockProps = () => {
|
const useFormBlockProps = () => {
|
||||||
|
@ -13,6 +13,7 @@ import { isArray } from 'lodash';
|
|||||||
import minimatch from 'minimatch';
|
import minimatch from 'minimatch';
|
||||||
import React, { createContext, useContext, useEffect, useState } from 'react';
|
import React, { createContext, useContext, useEffect, useState } from 'react';
|
||||||
import { useLocalVariables, useVariables } from '../../../variables';
|
import { useLocalVariables, useVariables } from '../../../variables';
|
||||||
|
import { useVariablesContext } from '../../../variables/context';
|
||||||
import { useHelperObservables } from './Helpers/hooks/useHelperObservables';
|
import { useHelperObservables } from './Helpers/hooks/useHelperObservables';
|
||||||
interface VariableContextValue {
|
interface VariableContextValue {
|
||||||
value: any;
|
value: any;
|
||||||
|
@ -47,7 +47,7 @@ export function dateFormat(initialValue: any, format: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function dateAdd(initialValue: any, number: number, unit: any) {
|
export function dateAdd(initialValue: any, unit: any, number: number) {
|
||||||
const handler = (value: any) => {
|
const handler = (value: any) => {
|
||||||
return dayjs.isDayjs(value) ? value.add(number, unit) : dayjs(value).add(number, unit);
|
return dayjs.isDayjs(value) ? value.add(number, unit) : dayjs(value).add(number, unit);
|
||||||
};
|
};
|
||||||
@ -58,7 +58,7 @@ export function dateAdd(initialValue: any, number: number, unit: any) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function dateSubtract(initialValue: any, number: number, unit: any) {
|
export function dateSubtract(initialValue: any, unit: any, number: number) {
|
||||||
const handler = (value: any) => {
|
const handler = (value: any) => {
|
||||||
return dayjs.isDayjs(value) ? value.subtract(number, unit) : dayjs(value).subtract(number, unit);
|
return dayjs.isDayjs(value) ? value.subtract(number, unit) : dayjs(value).subtract(number, unit);
|
||||||
};
|
};
|
||||||
|
@ -39,13 +39,6 @@ export const helpers = [
|
|||||||
group: 'date',
|
group: 'date',
|
||||||
sort: 2,
|
sort: 2,
|
||||||
uiSchema: [
|
uiSchema: [
|
||||||
{
|
|
||||||
name: 'number',
|
|
||||||
title: tval('Amount'),
|
|
||||||
type: 'number',
|
|
||||||
'x-component': 'InputNumber',
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'unit',
|
name: 'unit',
|
||||||
title: tval('Unit'),
|
title: tval('Unit'),
|
||||||
@ -62,6 +55,13 @@ export const helpers = [
|
|||||||
{ label: tval('Second'), value: 'second' },
|
{ label: tval('Second'), value: 'second' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'number',
|
||||||
|
title: tval('Amount'),
|
||||||
|
type: 'number',
|
||||||
|
'x-component': 'InputNumber',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -71,13 +71,6 @@ export const helpers = [
|
|||||||
group: 'date',
|
group: 'date',
|
||||||
sort: 3,
|
sort: 3,
|
||||||
uiSchema: [
|
uiSchema: [
|
||||||
{
|
|
||||||
name: 'number',
|
|
||||||
title: tval('Amount'),
|
|
||||||
type: 'number',
|
|
||||||
'x-component': 'InputNumber',
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'unit',
|
name: 'unit',
|
||||||
title: tval('Unit'),
|
title: tval('Unit'),
|
||||||
@ -94,6 +87,13 @@ export const helpers = [
|
|||||||
{ label: tval('Second'), value: 'second' },
|
{ label: tval('Second'), value: 'second' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'number',
|
||||||
|
title: tval('Amount'),
|
||||||
|
type: 'number',
|
||||||
|
'x-component': 'InputNumber',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user