mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-09 23:49:27 +08:00
feat: simplify imports in HelperList and update ctx-func test to use extractTemplateVariable
This commit is contained in:
parent
d385c2b325
commit
4c92a8a788
@ -7,14 +7,8 @@
|
|||||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { useState, useMemo, useContext } from 'react';
|
import React from 'react';
|
||||||
import { observer } from '@formily/reactive-react';
|
import { observer } from '@formily/reactive-react';
|
||||||
import type { MenuProps } from 'antd';
|
|
||||||
import { Dropdown, Popover } from 'antd';
|
|
||||||
import { FilterOutlined } from '@ant-design/icons';
|
|
||||||
import { useCompile } from '../../../hooks';
|
|
||||||
import { useApp } from '../../../../application';
|
|
||||||
import { addHelper } from './observables';
|
|
||||||
import { helpersObs } from './observables';
|
import { helpersObs } from './observables';
|
||||||
import { Helper } from './Helper';
|
import { Helper } from './Helper';
|
||||||
const _HelperList = () => {
|
const _HelperList = () => {
|
||||||
|
@ -8,14 +8,15 @@
|
|||||||
*/
|
*/
|
||||||
import get from 'lodash/get';
|
import get from 'lodash/get';
|
||||||
import { createJSONTemplateParser } from '../parser';
|
import { createJSONTemplateParser } from '../parser';
|
||||||
|
import { extractTemplateVariable } from '../utils';
|
||||||
|
|
||||||
const parser = createJSONTemplateParser();
|
const parser = createJSONTemplateParser();
|
||||||
|
|
||||||
describe('ctx function', () => {
|
describe('ctx function', () => {
|
||||||
it('should handle basic context function', () => {
|
it('should handle basic context function', () => {
|
||||||
const template = '{{}}';
|
const template = '{{}}';
|
||||||
const variable = parser.engine.fullVariablesSync(template);
|
const variable = extractTemplateVariable(template);
|
||||||
console.log(variable);
|
expect(variable).toBe(null);
|
||||||
});
|
});
|
||||||
it('should handle basic context function with state', () => {
|
it('should handle basic context function with state', () => {
|
||||||
const template = '{{$user.id}} - {{$user.name}}';
|
const template = '{{$user.id}} - {{$user.name}}';
|
||||||
|
@ -176,7 +176,7 @@ export const parseFilter = async (filter: any, opts: ParseFilterOptions = {}) =>
|
|||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
const match = re.exec(value);
|
const match = re.exec(value);
|
||||||
if (match) {
|
if (match) {
|
||||||
const { fullVariable: key, filters: helpers } = extractTemplateElements(value);
|
const { fullVariable: key, helpers } = extractTemplateElements(value);
|
||||||
const val = getValuesByPath(vars, key, null);
|
const val = getValuesByPath(vars, key, null);
|
||||||
const field = getField?.(path);
|
const field = getField?.(path);
|
||||||
if (key.startsWith('$date') || key.startsWith('$nDate')) {
|
if (key.startsWith('$date') || key.startsWith('$nDate')) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user