mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-09 07:29: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 }) => {
|
||||
const app = useApp();
|
||||
const { value, helperObservables } = useCurrentVariable();
|
||||
|
||||
const { helpersObs, rawHelpersObs, removeHelper } = helperObservables;
|
||||
const helper = helpersObs.value[index];
|
||||
const rawHelper = rawHelpersObs.value[index];
|
||||
@ -77,11 +78,11 @@ const Configurator = observer(
|
||||
}, value);
|
||||
|
||||
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 = () => {
|
||||
return <Tag color="green">{JSON.stringify(outputValue).slice(1, -1)}</Tag>;
|
||||
return <Tag color="green">{outputValue.toDate().toLocaleString()}</Tag>;
|
||||
};
|
||||
|
||||
const useFormBlockProps = () => {
|
||||
|
@ -13,6 +13,7 @@ import { isArray } from 'lodash';
|
||||
import minimatch from 'minimatch';
|
||||
import React, { createContext, useContext, useEffect, useState } from 'react';
|
||||
import { useLocalVariables, useVariables } from '../../../variables';
|
||||
import { useVariablesContext } from '../../../variables/context';
|
||||
import { useHelperObservables } from './Helpers/hooks/useHelperObservables';
|
||||
interface VariableContextValue {
|
||||
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) => {
|
||||
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) => {
|
||||
return dayjs.isDayjs(value) ? value.subtract(number, unit) : dayjs(value).subtract(number, unit);
|
||||
};
|
||||
|
@ -39,13 +39,6 @@ export const helpers = [
|
||||
group: 'date',
|
||||
sort: 2,
|
||||
uiSchema: [
|
||||
{
|
||||
name: 'number',
|
||||
title: tval('Amount'),
|
||||
type: 'number',
|
||||
'x-component': 'InputNumber',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: 'unit',
|
||||
title: tval('Unit'),
|
||||
@ -62,6 +55,13 @@ export const helpers = [
|
||||
{ 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',
|
||||
sort: 3,
|
||||
uiSchema: [
|
||||
{
|
||||
name: 'number',
|
||||
title: tval('Amount'),
|
||||
type: 'number',
|
||||
'x-component': 'InputNumber',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: 'unit',
|
||||
title: tval('Unit'),
|
||||
@ -94,6 +87,13 @@ export const helpers = [
|
||||
{ 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