mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-09 15:39:24 +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.
|
||||
*/
|
||||
|
||||
import React, { useState, useMemo, useContext } from 'react';
|
||||
import React from '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 { Helper } from './Helper';
|
||||
const _HelperList = () => {
|
||||
|
@ -8,14 +8,15 @@
|
||||
*/
|
||||
import get from 'lodash/get';
|
||||
import { createJSONTemplateParser } from '../parser';
|
||||
import { extractTemplateVariable } from '../utils';
|
||||
|
||||
const parser = createJSONTemplateParser();
|
||||
|
||||
describe('ctx function', () => {
|
||||
it('should handle basic context function', () => {
|
||||
const template = '{{}}';
|
||||
const variable = parser.engine.fullVariablesSync(template);
|
||||
console.log(variable);
|
||||
const variable = extractTemplateVariable(template);
|
||||
expect(variable).toBe(null);
|
||||
});
|
||||
it('should handle basic context function with state', () => {
|
||||
const template = '{{$user.id}} - {{$user.name}}';
|
||||
|
@ -176,7 +176,7 @@ export const parseFilter = async (filter: any, opts: ParseFilterOptions = {}) =>
|
||||
if (typeof value === 'string') {
|
||||
const match = re.exec(value);
|
||||
if (match) {
|
||||
const { fullVariable: key, filters: helpers } = extractTemplateElements(value);
|
||||
const { fullVariable: key, helpers } = extractTemplateElements(value);
|
||||
const val = getValuesByPath(vars, key, null);
|
||||
const field = getField?.(path);
|
||||
if (key.startsWith('$date') || key.startsWith('$nDate')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user