mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-01 18:52:20 +08:00
fix: block model
This commit is contained in:
parent
881fcd86a3
commit
0f5952a6e1
@ -8,8 +8,21 @@
|
||||
*/
|
||||
|
||||
import { APIResource, BaseRecordResource, Collection, DefaultStructure, FlowModel } from '@nocobase/flow-engine';
|
||||
import { Card } from 'antd';
|
||||
import React from 'react';
|
||||
|
||||
export class BlockModel<T = DefaultStructure> extends FlowModel<T> {}
|
||||
export class BlockModel<T = DefaultStructure> extends FlowModel<T> {
|
||||
decoratorProps: Record<string, any> = {};
|
||||
|
||||
renderComponent() {
|
||||
throw new Error('renderComponent method must be implemented in subclasses of BlockModel');
|
||||
return null;
|
||||
}
|
||||
|
||||
render() {
|
||||
return <Card {...this.decoratorProps}>{this.renderComponent()}</Card>;
|
||||
}
|
||||
}
|
||||
|
||||
export class DataBlockModel<T = DefaultStructure> extends BlockModel<T> {
|
||||
resource: APIResource;
|
||||
|
@ -216,9 +216,8 @@ export class TableModel extends DataBlockModel<TableModelStructure> {
|
||||
},
|
||||
};
|
||||
|
||||
render() {
|
||||
renderComponent() {
|
||||
return (
|
||||
<Card>
|
||||
<Spin spinning={this.resource.loading}>
|
||||
<DndProvider>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>
|
||||
@ -227,10 +226,7 @@ export class TableModel extends DataBlockModel<TableModelStructure> {
|
||||
// @ts-ignore
|
||||
if (action.props.position === 'left') {
|
||||
return (
|
||||
<FlowModelRenderer
|
||||
model={action}
|
||||
showFlowSettings={{ showBackground: false, showBorder: false }}
|
||||
/>
|
||||
<FlowModelRenderer model={action} showFlowSettings={{ showBackground: false, showBorder: false }} />
|
||||
);
|
||||
}
|
||||
|
||||
@ -244,10 +240,7 @@ export class TableModel extends DataBlockModel<TableModelStructure> {
|
||||
// @ts-ignore
|
||||
if (action.props.position !== 'left') {
|
||||
return (
|
||||
<FlowModelRenderer
|
||||
model={action}
|
||||
showFlowSettings={{ showBackground: false, showBorder: false }}
|
||||
/>
|
||||
<FlowModelRenderer model={action} showFlowSettings={{ showBackground: false, showBorder: false }} />
|
||||
);
|
||||
}
|
||||
|
||||
@ -287,7 +280,6 @@ export class TableModel extends DataBlockModel<TableModelStructure> {
|
||||
}}
|
||||
/>
|
||||
</Spin>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -436,6 +436,10 @@ export class CollectionField {
|
||||
return this.options.uiSchema || {};
|
||||
}
|
||||
|
||||
get targetCollection() {
|
||||
return this.collection.collectionManager.getCollection(this.options.target);
|
||||
}
|
||||
|
||||
getComponentProps() {
|
||||
return this.options.uiSchema?.['x-component-props'] || {};
|
||||
}
|
||||
@ -444,11 +448,10 @@ export class CollectionField {
|
||||
if (!this.options.target) {
|
||||
return [];
|
||||
}
|
||||
const targetCollection = this.collection.collectionManager.getCollection(this.options.target);
|
||||
if (!targetCollection) {
|
||||
if (!this.targetCollection) {
|
||||
throw new Error(`Target collection ${this.options.target} not found for field ${this.name}`);
|
||||
}
|
||||
return targetCollection.getFields();
|
||||
return this.targetCollection.getFields();
|
||||
}
|
||||
|
||||
getInterfaceOptions() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user