refactor(plugin-workflow-dc): move collection template to plugin and remove sort field (#4682)

* refactor(plugin-workflow-dc): move collection template to plugin and remove sort field

* fix(client): fix variable component style
This commit is contained in:
Junyi 2024-06-17 18:21:11 +08:00 committed by GitHub
parent 2b7544bdc4
commit 9bef416d51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 22 additions and 18 deletions

View File

@ -55,7 +55,6 @@ import {
} from './interfaces';
import {
GeneralCollectionTemplate,
ExpressionCollectionTemplate,
SqlCollectionTemplate,
TreeCollectionTemplate,
ViewCollectionTemplate,
@ -180,7 +179,6 @@ export class CollectionPlugin extends Plugin {
addCollectionTemplates() {
this.dataSourceManager.addCollectionTemplates([
GeneralCollectionTemplate,
ExpressionCollectionTemplate,
SqlCollectionTemplate,
TreeCollectionTemplate,
ViewCollectionTemplate,

View File

@ -9,6 +9,5 @@
export * from './general';
export * from './tree';
export * from './expression';
export * from './view';
export * from './sql';

View File

@ -486,6 +486,7 @@ async function preloadOptions(scope, value: string) {
TextArea.ReadPretty = function ReadPretty(props): JSX.Element {
const { value } = props;
const scope = typeof props.scope === 'function' ? props.scope() : props.scope;
const { wrapSSR, hashId, componentCls } = useStyles();
const [options, setOptions] = useState([]);
const keyLabelMap = useMemo(() => createOptionsValueLabelMap(options), [options]);
@ -499,10 +500,13 @@ TextArea.ReadPretty = function ReadPretty(props): JSX.Element {
}, [scope, value]);
const html = renderHTML(value ?? '', keyLabelMap);
const content = (
const content = wrapSSR(
<span
dangerouslySetInnerHTML={{ __html: html }}
className={css`
className={cx(
componentCls,
hashId,
css`
overflow: auto;
.ant-tag {
@ -512,8 +516,9 @@ TextArea.ReadPretty = function ReadPretty(props): JSX.Element {
padding: 2px 7px;
border-radius: 10px;
}
`}
/>
`,
)}
/>,
);
return (

View File

@ -8,8 +8,7 @@
*/
import { getOptions } from '@nocobase/evaluators/client';
import { getConfigurableProperties } from './properties';
import { CollectionTemplate } from '../../data-source/collection-template/CollectionTemplate';
import { getConfigurableProperties, CollectionTemplate } from '@nocobase/client';
export class ExpressionCollectionTemplate extends CollectionTemplate {
name = 'expression';
@ -21,7 +20,6 @@ export class ExpressionCollectionTemplate extends CollectionTemplate {
updatedBy: true,
createdAt: true,
updatedAt: true,
sortable: true,
fields: [
{
name: 'engine',

View File

@ -13,6 +13,7 @@ import WorkflowPlugin from '@nocobase/plugin-workflow/client';
import DynamicCalculation from './DynamicCalculation';
import { DynamicExpression } from './DynamicExpression';
import { ExpressionFieldInterface } from './expression';
import { ExpressionCollectionTemplate } from './ExpressionCollectionTemplate';
export default class extends Plugin {
async afterAdd() {
@ -27,6 +28,9 @@ export default class extends Plugin {
this.app.addComponents({
DynamicExpression,
});
this.dataSourceManager.addCollectionTemplates([ExpressionCollectionTemplate]);
const workflow = this.app.pm.get('workflow') as WorkflowPlugin;
const dynamicCalculation = new DynamicCalculation();
workflow.instructions.register(dynamicCalculation.type, dynamicCalculation);