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

View File

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

View File

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

View File

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

View File

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